/**
* DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*/
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
function ValidaEmail(mail)
{
var ret = false;
if (typeof(mail) != "undefined"){
mail = mail.match(/(\w+)@(.+)\.(\w+)$/);
if (mail != null){
if ((mail[3].length==2) || (mail[3].length==3))
ret = true;
}
}
return ret;
}
function toggleLayer(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}
function DataValida(data)
{
var err=0
if (data.length != 8) return false;
day = data.substring(0,2);
month = data.substring(3,2);
year = data.substring(5,2);
if (month<1 || month>12) err = 1;
if (day<1 || day>31) err = 1;
if (day==31 && (month==4 || month==6 || month==9 || month==11)) err=1;
if (month==2)
{
if ((year%4==0) && (year%100!=0 || year%400==0))
{
if (day>29) err=1;
}
else
{
if (day>28) err=1;
}
}
if (day == "" || month == "" || year == "") err=1;
if (err==1)
{
return false;
}
return true;
}
function isInteger(s)
{
var i;
for (i = 0; i < s.length; i++){
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}
function Login_OnClick()
{
var strCampo = document.frmLogin.txtEmail_b.value;
if (strCampo == "")
{
alert("Informe o e-mail !");
return false;
exit;
}
if (ValidaEmail(document.frmLogin.txtEmail_b.value) == false)
{
alert("E-mail inválido !");
return false;
exit;
}
var strCampo = document.frmLogin.txtSenha_b.value
if (strCampo == "")
{
alert("Informe a senha!");
return false;
exit;
}
document.frmLogin.action = '../release/r_verifica_login.php';
document.frmLogin.submit();
return true;
}
function Esqueci_OnClick()
{
var strCampo = document.frmEsqueci.txtEmail_c.value;
if (strCampo == "")
{
alert("Informe o e-mail !");
return false;
exit;
}
if (ValidaEmail(document.frmEsqueci.txtEmail_c.value) == false)
{
alert("E-mail inválido !");
return false;
exit;
}
document.frmEsqueci.action = '../release/g_esqueci.php?tipo=RELEASE';
document.frmEsqueci.submit();
return true;
}
function EnviaTeste_OnClick()
{
var strCampo = document.frmTeste.txtEmail_teste.value;
if (strCampo == "")
{
alert("Informe o e-mail para ser avisado!");
return false;
exit;
}
if (ValidaEmail(document.frmTeste.txtEmail_teste.value) == false)
{
alert("E-mail inválido !");
return false;
exit;
}
document.frmTeste.action = '/release/g_site_em_teste.php';
document.frmTeste.submit();
return true;
}
function stripCharsInBag(s, bag)
{
var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++){
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
function daysInFebruary (year)
{
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n)
{
for (var i = 1; i <= n; i++) {
this[i] = 31
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
if (i==2) {this[i] = 29}
}
return this
}
function isDate(dtStr)
{
if (dtStr.length == 0) return true;
if (dtStr.length != 8) return false;
// transforma: 'dd/mm/yy' em 'dd/mm/yyyy' ----01/34/67
dtStr = dtStr.substr(0,6)+'20'+dtStr.substr(6,2)
var daysInMonth = DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strDay=dtStr.substring(0,pos1)
var strMonth=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if (pos1==-1 || pos2==-1) return false;
if (strMonth.length<1 || month<1 || month>12) return false;
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]) return false;
if (strYear.length != 4 || year==0 || yearmaxYear) return false;
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false) return false;
return true
}
function ComparaDatas(dtStr1,dtStr2)
{
//returna false de dt_1 > dt_2
//transforma em string no formato yymmdd para poder comparar diretamente
dt_1 = dtStr1.substr(6,2)+ dtStr1.substr(3,2) + dtStr1.substr(0,2);
dt_2 = dtStr2.substr(6,2)+ dtStr2.substr(3,2) + dtStr2.substr(0,2);
if (dt_1>dt_2)
return false;
else
return true;
}
function isCPFCNPJ(campo,pType)
{
// if( isEmpty( campo ) ){return false;}
var campo_filtrado = "", valor_1 = " ", valor_2 = " ", ch = "";
var valido = false;
for (i = 0; i < campo.length; i++){
ch = campo.substring(i, i + 1);
if (ch >= "0" && ch <= "9"){
campo_filtrado = campo_filtrado.toString() + ch.toString()
valor_1 = valor_2;
valor_2 = ch;
}
if ((valor_1 != " ") && (!valido)) valido = !(valor_1 == valor_2);
}
if (!valido) campo_filtrado = "12345678912";
if (campo_filtrado.length < 11){
for (i = 1; i <= (11 - campo_filtrado.length); i++){campo_filtrado = "0" + campo_filtrado;}
}
if(pType <= 1){
if ( ( campo_filtrado.substring(9,11) == checkCPF( campo_filtrado.substring(0,9) ) ) && ( campo_filtrado.substring(11,12)=="") ){return true;}
}
if((pType == 2) || (pType == 0)){
if (campo_filtrado.length >= 14){
if ( campo_filtrado.substring(12,14) == checkCNPJ( campo_filtrado.substring(0,12) ) ){ return true;}
}
}
return false;
}
function checkCNPJ(vCNPJ)
{
var mControle = "";
var aTabCNPJ = new Array(5,4,3,2,9,8,7,6,5,4,3,2);
for (i = 1 ; i <= 2 ; i++){
mSoma = 0;
for (j = 0 ; j < vCNPJ.length ; j++)
mSoma = mSoma + (vCNPJ.substring(j,j+1) * aTabCNPJ[j]);
if (i == 2 ) mSoma = mSoma + ( 2 * mDigito );
mDigito = ( mSoma * 10 ) % 11;
if (mDigito == 10 ) mDigito = 0;
mControle1 = mControle ;
mControle = mDigito;
aTabCNPJ = new Array(6,5,4,3,2,9,8,7,6,5,4,3);
}
return( (mControle1 * 10) + mControle );
}
function checkCPF(vCPF)
{
var mControle = ""
var mContIni = 2, mContFim = 10, mDigito = 0;
for (j = 1 ; j <= 2 ; j++){
mSoma = 0;
for (i = mContIni ; i <= mContFim ; i++)
mSoma = mSoma + (vCPF.substring((i-j-1),(i-j)) * (mContFim + 1 + j - i));
if (j == 2 ) mSoma = mSoma + ( 2 * mDigito );
mDigito = ( mSoma * 10 ) % 11;
if (mDigito == 10) mDigito = 0;
mControle1 = mControle;
mControle = mDigito;
mContIni = 3;
mContFim = 11;
}
return( (mControle1 * 10) + mControle );
}
function Vai_para_Editoria(cmb)
{
window.location.assign('../site/c_mostra_releases.php?editoria=' + cmb.selectedIndex);
// frmDados.cmbQtde4.selectedIndex
// frmDados.action = 'c_mostra_releases_editoria.asp';
// frmDados.submit();
}
function isDate2(dtStr) {
//Funçao identica a isDate() mas checa também se data é no máximo ano que vem.
//Serve para bloquear datas muito no futuro
//Checa se data é valida
if (!isDate(dtStr)) {
return false
}
//Checa se ano não ultrapassa ano que vem
var curdate = new Date()
var ano_atual = curdate.getFullYear()
ano_informado = parseInt('20'+dtStr.substr(6,2))
if (ano_informado>ano_atual+1) {
return false
}
return true
}
function toggle_fechar(whichLayer)
{
if (document.getElementById)
{
var style2 = document.getElementById(whichLayer).style;
}
else if (document.all)
{
var style2 = document.all[whichLayer].style;
}
else if (document.layers)
{
var style2 = document.layers[whichLayer].style;
}
style2.display = "none";
}
function toggle_abrir(whichLayer)
{
if (document.getElementById)
{
var style2 = document.getElementById(whichLayer).style;
}
else if (document.all)
{
var style2 = document.all[whichLayer].style;
}
else if (document.layers)
{
var style2 = document.layers[whichLayer].style;
}
style2.display = "block";
}
function OnClick_Cadastro_Evento(pag)
{
var strCampo = document.frmEvento.txtTitulo.value
if (strCampo == "")
{
alert("Informe o título do evento.");
return false;
}
var strCampo = document.frmEvento.cmbTipoEvento.value
if (strCampo == "")
{
alert("Informe o tipo do evento.");
return false;
}
var strCampo = document.frmEvento.txtTexto.value
if (strCampo == "")
{
alert("Informe o texto do evento.");
return false;
}
var strCampo = document.frmEvento.txtEventoLocal.value
if (strCampo == "")
{
alert("Informe o local do evento.");
return false;
}
var strCampo = document.frmEvento.cmbUf.value
if (strCampo == "")
{
alert("Informe o estado do evento.");
return false;
}
var strCampo = document.frmEvento.txtEventoData.value
if (strCampo == "")
{
alert("Informe a data do evento.");
return false;
}
var strCampo = document.frmEvento.txtEventoData.value;
if ((strCampo != "dd/mm/aa") && (strCampo != ""))
{
if (!isDate(strCampo))
{
alert("Data inválida - informe no formato dd/mm/aa !");
document.frmEvento.txtEventoData.focus();
return false;
}
}
if (pag == 1)
{
var txtTitulo = document.frmEvento.txtTitulo.value
var cmbTipoEvento = document.frmEvento.cmbTipoEvento.value
var cmbCaderno = document.frmEvento.cmbCaderno.value
var txtTexto = document.frmEvento.txtTexto.value;
var txtEventoLocal = document.frmEvento.txtEventoLocal.value;
var cmbUf = document.frmEvento.cmbUf.value;
var txtEventoData = document.frmEvento.txtEventoData.value;
var txtOper = "I1";
Mostra_quadro_Mensagem();
new Ajax.Updater('servicos_mensagem','http://www.labia.com.br', {asynchronous:true, parameters:'txtTitulo='+txtTitulo + '&cmbCaderno='+cmbCaderno + '&cmbTipoEvento='+cmbTipoEvento + '&txtTexto='+txtTexto + '&txtEventoLocal='+txtEventoLocal + '&cmbUf='+cmbUf + '&txtEventoData='+txtEventoData + '&txtOper='+txtOper});
return true;
}
else
{
s = 'l_altera_evento.php'
document.frmEvento.action = s;
document.frmEvento.submit();
}
}
function OnClick_Cadastro_Usu(pag)
{
if (pag == 1)
{
var strCampo = document.frmUsuario.txtNovoComoConheceu.value
if (strCampo == "")
{
alert("Por favor informe como conheceu o LABIA.");
return false;
}
}
var strCampo = document.frmUsuario.txtNovoNome.value
if (strCampo == "")
{
alert("Informe o nome !");
return false;
}
var strCampo = document.frmUsuario.txtNovoEmailCadastro.value
if (strCampo == "")
{
alert("Informe o e-mail !");
return false;
}
if (ValidaEmail(document.frmUsuario.txtNovoEmailCadastro.value) == false)
{
alert("E-mail inválido !");
return false;
}
var strCampo = document.frmUsuario.txtNovoSenha.value
if ((strCampo == ""))
{
alert("Informe a senha !");
return false;
}
var strCampo2 = document.frmUsuario.txtNovoSenha2.value
if (strCampo2 == "")
{
alert("Informe a confirmação da senha !");
return false;
}
if (strCampo != strCampo2)
{
alert("A senha difere da confirmação da senha !");
return false;
}
if (pag == 1)
{
var como = document.frmUsuario.txtNovoComoConheceu.value
var nome = document.frmUsuario.txtNovoNome.value
var email = document.frmUsuario.txtNovoEmailCadastro.value;
var senha = document.frmUsuario.txtNovoSenha.value;
Mostra_quadro_Mensagem();
new Ajax.Updater('servicos_mensagem','http://www.labia.com.br/', {asynchronous:true, parameters:'como='+como + '&nome='+nome + '&email='+email + '&senha='+senha});
return true;
}
else
{
s = 'l_altera_usuario.php'
document.frmUsuario.action = s;
document.frmUsuario.submit();
}
}