Date.dayNames = ['Domingo', 'Segunda-feira', 'Terça-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'Sábado'];
//Date.abbrDayNames = ['dom', 'seg', 'ter', 'qua', 'qui', 'sex', 's?b'];
Date.monthNames = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'];
Date.abbrMonthNames = ['jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dec'];
Date.firstDayOfWeek = 1;
Date.format = 'dd/mm/yyyy';
Date.fullYearStart = '20';
function WebMethodExec(pagePath, fn, paramArray, successFn, errorFn) {
var paramList = '';
if (paramArray.length > 0) {
for (var i = 0; i < paramArray.length; i += 2) {
if (paramList.length > 0) paramList += ',';
paramList += '"' + paramArray[i] + '":"' + paramArray[i + 1] + '"';
}
}
paramList = '{' + paramList + '}';
$.ajax({
type: "POST",
url: pagePath + "/" + fn,
contentType: "application/json; charset=utf-8",
data: paramList,
success: successFn,
error: errorFn,
async: false
})
;
}
function stripHTML(html) {
var BodyContents = /([\s\S]*\
]*\>)([\s\S]*)(\<\/body\>[\s\S]*)/i;
var h = html.match(BodyContents);
if (h != null && h[2]) {
html = h[2];
}
html = html.replace(/\/\/--\>/gi, "");
html = html.replace(/
/gi, "\n");
html = html.replace(/(<\/h.>|<\/p>|<\/div>)/gi, "$1\n\n");
html = html.replace(/<[^>]+>/g, "");
html = html.replace(/</g, "<");
html = html.replace(/>/g, ">");
html = html.replace(/ /g, "");
html = html.replace(/ /g, "");
return html;
}
function HtmlToTextArea(html) {
var BodyContents = /([\s\S]*\]*\>)([\s\S]*)(\<\/body\>[\s\S]*)/i;
var h = html.match(BodyContents);
if (h != null && h[2]) {
html = h[2];
}
html = html.replace(/
/gi, "\n");
return html;
}
function stripHTMLOnSubmit() {
var re = /<\S[^><]*>/g
for (i = 0; i < arguments.length; i++)
arguments[i].value = arguments[i].value.replace(re, "")
}
/**
* Extensoes do JQuery
*/
//Valida email
jQuery.fn.isValidEmail = function() {
var str = $(this).val();
if (str.indexOf('@') > -1 && str.indexOf('.') > -1) {
return true;
}
return false;
}
function isValidEmail(email) {
if (email.indexOf('@') > -1 && email.indexOf('.') > -1)
return true;
return false;
}
//Pega valor de uma CheckBox
jQuery.fn.isChecked = function() {
this.each(function() {
isChecked = this.checked;
});
return isChecked;
}
var datetime = {
convert: function(d) {
return (
d.constructor === Date ? d :
d.constructor === Array ? new Date(d[0], d[1], d[2]) :
d.constructor === Number ? new Date(d) :
d.constructor === String ? new Date(d) :
typeof d === "object" ? new Date(d.year, d.month, d.date) :
NaN
);
},
compare: function(a, b) {
return (
isFinite(a = this.convert(a).valueOf()) &&
isFinite(b = this.convert(b).valueOf()) ?
(a > b) - (a < b) :
NaN
);
},
inRange: function(d, start, end) {
return (
isFinite(d = this.convert(d).valueOf()) &&
isFinite(start = this.convert(start).valueOf()) &&
isFinite(end = this.convert(end).valueOf()) ?
start <= d && d <= end :
NaN
);
},
validate: function(d) {
return new Date(d);
}
}
function getDate(date) {
//var d = new Date(date)
// alert(d);
//return d.getTime();
date = date.split('/');
if (date[0] < 10) date[0] = '0' + date[0];
return date[2] + date[1] + date[0];
}
function ValidateDate(date) {
date = date.split('/');
if (date[0] < 10) date[0] = '0' + date[0];
return (date[2] + date[1] + date[0]) >= 19000101;
}
function eventStartEndDate(input, start, end, msg) {
if (getDate(input.value) < getDate(start) || getDate(input.value) > getDate(start)) {
alert(msg + ' (' + start + ' - ' + end + ')');
input.value = "";
return false;
}
return true;
}
function ticketStartDate(input, ed) {
if (getDate(input.value) > getDate(ed))
return false;
return true;
}
function ticketEndDate(input, sd) {
if (getDate(input.value) < getDate(sd))
return false;
return true;
}
function ticketPromotion(input, start, end) {
if (getDate(input.value) < getDate(start) || getDate(input.value) > getDate(end))
return false;
return true;
}
function compareLowDate(start, end) {
if (getDate(end) > getDate(start))
return false;
return true;
}
function compareHour(input, nextInput, msg) {
hrs = input.value.substring(0, 2);
min = input.value.substring(3, 5);
nextHrs = nextInput.substring(0, 2);
nextMin = nextInput.substring(3, 5);
if ((hrs < nextHrs) || (min < nextMin) || ((hrs == nextHrs) && (min == nextMin))) {
input.focus();
}
}
function compareHour2(start, end) {
hrs = start.substring(0, 2);
min = start.substring(3, 5);
nextHrs = end.substring(0, 2);
nextMin = end.substring(3, 5);
if ((hrs < nextHrs) || (min < nextMin) || ((hrs == nextHrs) && (min == nextMin))) {
return false;
}
return true;
}
function validateHour(txt) {
hrs = txt.substring(0, 2);
min = txt.substring(3, 5);
if (txt == "")
return false;
if (((hrs >= 00) && (hrs <= 23)) && ((min >= 00) && (min <= 59)))
return true;
return false;
}
function onlyNum(e) {
var key = new Number();
if (window.event) {
key = e.keyCode;
}
else if (e.which) {
key = e.which;
}
else {
return true;
}
if (key == 8)
return true;
if ((key < 48) || (key > 63) && (key != 8)) {
return false;
}
}
function eventPreview(eventId) {
window.open("Website.aspx?eventId=" + eventId, "_preview", "");
}
function setMaxLength() {
var x = document.getElementsByTagName('textarea');
var counter = document.createElement('div');
counter.className = 'counter';
for (var i = 0; i < x.length; i++) {
if (x[i].getAttribute('MaxLen')) {
x[i].onkeyup = x[i].onchange = checkMaxLength;
x[i].onkeyup();
}
}
}
function checkMaxLength() {
var maxLength = this.getAttribute('MaxLen');
var currentLength = this.value.length;
if (currentLength > maxLength) {
this.value = this.value.substring(0, maxLength)
}
}
window.onload = function() {
$("input, textarea").change(function() {
this.value = $.trim(this.value);
this.value = stripHTML(this.value);
});
setMaxLength();
}
//***************////REGISTER.ASPX
function validateRegister(txtName, txtEmail, txtPassword, txtRepeatPassword, cboSubject, chkterms, esp) {
var log = "";
if (txtName == "")
log = log + "\nSeu nome não pode ficar em branco.";
if (txtEmail == "")
log = log + "\nSeu e-mail não pode ficar em branco";
else
if (!isValidEmail(txtEmail))
log = log + "\nE-mail inválido";
if (txtPassword.length < 6)
log = log + "\nSua senha precisa ter no mínimo 6 caracteres.";
if (txtPassword != txtRepeatPassword)
log = log + "\nSenha e confirmação de senha estão diferentes";
if (cboSubject == "Outros")
if(esp == "")
log = log + "\nO campo Especifique não foi preenchido corretamente.";
if (log == "") {
if (chkterms)
return true;
else {
alert("Para prosseguir é necessário aceitar os termos de uso.");
return false;
}
}
else {
alert("Os campos listados abaixo não foram preenchidos corretamente:\n" + log);
return false;
}
}
//**************////LOGIN.ASPX
function validateLogin(txtemail, txtsenha) {
if (!isValidEmail(txtemail) || txtsenha == "") {
alert("Os campos e-mail e senha não foram preenchidos corretamente.");
return false;
}
else
return true;
}
//**************////MASTERPAGE.ASPX
function userLogin(email, password) {
if (!isValidEmail(email) || password == "")
alert("E-mail e/ou senha inválidos");
else
WebMethodExec("/Default.aspx", "UserAuthorize", ["email", email, "password", password], LoginOK, OpenModalLogin);
}
function OpenModalLogin() {
$('#txtEmail').val("");
$('#txtPass').val("");
var newA = document.createElement("A");
newA.rel = "thickbox";
newA.href = "/Login.aspx?login=true&TB_iframe=true&height=240&width=542";
newA.title = "";
tb_show(newA.title, newA.href, newA.rel);
newA = null;
}
function OpenModalLogin2() {
$('#txtEmail').val("");
$('#txtPass').val("");
var newA = document.createElement("A");
newA.rel = "thickbox";
newA.href = "/Login.aspx?TB_iframe=true&height=240&width=542";
newA.title = "";
tb_show(newA.title, newA.href, newA.rel);
newA = null;
}
function LoginOK(response) {
var data = eval('(' + response + ')');
if (data.d != '')
window.location = data.d;
else
OpenModalLogin();
}
//**************////TOOLS.ASPX
function validateSelectTool(websiteTool, ticketTool) {
if (websiteTool == false && ticketTool == false) {
alert("Translate(TOOLS_MANDATORY_SELECTION)");
return false;
}
return true;
}
function validaFeb(date) {
date = date.split('/');
year = date[2];
test = false;
if (date[1] == 2) {
if (year % 100 == 0) {
if (year % 400 == 0)
test = true;
}
else
if ((year % 4) == 0)
test = true;
else
test = false;
if (test == true)
if (date[0] > 29) return false;
else
return true;
if (test == false)
if (date[0] > 28) return false;
else
return true;
} else return true;
}
//***************PRESENTATION.ASPX
/*
*/
function validatePresentation(name, description, date, starthour, endhour, speakername, eventStartDate, eventEndDate) {
var log = "";
if (name == "") log = log + "\nNome";
if (description == "") log = log + "\nDescrição";
if (date == "" || !datetime.validate(date))
log = log + "\nData";
else
if (getDate(eventStartDate) > getDate(date))
log = log + "\nA data da sua atividade não pode ser antes do início do evento.";
else {
if (!validateHour(starthour))
log = log + "\nHorário inicial";
else
if (!validateHour(endhour))
log = log + "\nHorário final";
else
if (compareHour2(starthour, endhour))
log = log + "\nHorário de término menor que o horário de início";
else
if (!validaFeb(date))
log = log + "\nData inválida";
else
if (getDate(eventEndDate) < getDate(date))
log = log + "\nA data da sua atividade não pode ser depois do término do evento.";
}
if (log == "")
return true;
else {
alert("Os campos listados abaixo não foram preenchidos corretamente:" + log);
return false;
}
}
//***************PHOTOSPEAKER.ASPX
var maxWidth = 500;
var maxHeight = 500;
var fileTypes = ["bmp", "gif", "png", "jpg", "jpeg", "tif"];
var globalPic;
function imgVerify() {
__doPostBack('lbtnSendPhoto', '');
}
function InValidDateInterval(startDate, endDate) {
return datetime.compare(startDate, endDate) == 1;
}
//***************WEBSITEINFO.ASPX
function websiteInfoVerify(name, compareLowDate, startDate, endDate, enableEndDate, locationName, locationAddress, locationCity, locationState, organizerName, startHour, endHour, OrganizerEmail, PublicationName, PublicationNameMessage) {
var log = "";
if ($.trim(name) == "") log = log + "\nNome do evento";
if (!validateHour(startHour)) log = log + "\nHorário inicial";
if (enableEndDate) {
if (!validateHour(endHour)) log = log + "\nHorário final";
if (parseInt(endDate.split("/")[2].toString() + endDate.split("/")[1].toString() + endDate.split("/")[0].toString()) < parseInt(startDate.split("/")[2].toString() + startDate.split("/")[1].toString() + startDate.split("/")[0].toString()))
//if (InValidDateInterval(startDate + " " + startHour, endDate + " " + endHour))
log = log + "\nA data final não pode ser menor que a data inicial";
}
if (locationName == "") log = log + "\nLocal";
if (locationAddress == "") log = log + "\nEndereço";
if (locationCity == "") log = log + "\nCidade";
if (locationState == "") log = log + "\nEstado";
if (organizerName == "") log = log + "\nOrganização";
if (!PublicationName) log = log + "\n" + PublicationNameMessage;
if (!isValidEmail(OrganizerEmail)) log = log + "\nEmail";
if (log == "") {
return true;
}
else {
alert("Os campos listados abaixo não foram preenchidos corretamente:" + log);
return false;
}
}
function saveErro() {
alert('Não foi possível salvar o formulário.');
}
jQuery.fn.enter2tab = function() {
this.keyup(function(e) {
var key = e.charCode ? e.charCode : (e.keyCode ? e.keyCode : 0);
if ((key == 13) && /^(input|select)$/i.test(this.nodeName)) {
var next = this.tabIndex + 1;
} else if ((key == 38) && /^(input|select)$/i.test(this.nodeName)) {
var next = this.tabIndex - 1;
}
if (next == 0) {
return false;
}
var keytop = 0;
if (key == 38 && this.nodeName == "SELECT") {
keytop = 0;
var indx = this.selectedIndex;
if (indx - 1 < 0) {
keytop = 1;
}
} else if (key == 38) {
keytop = 1;
}
if ((key == 13 || (keytop == 1)) && /^(input|select)$/i.test(this.nodeName)) {
var list;
list = $("input[@tabIndex='" + next + "']");
list2 = $("textarea[@tabIndex='" + next + "']");
if (list.size() > 0) {
list.get(0).focus();
//return false;
} else if (list2.size() > 0) {
list2.get(0).focus();
}
}
});
return this;
}
//
function strReplaceChr(texto) {
texto = texto.replace(/[^a-zA-Z 0-9]+/g, '');
texto = texto.replace(/\s * | * \s+/g, '');
//
return $.trim(texto);
}