// JavaScript Document
function checacategoria() {
  if ((document.frmInicio.categoria[0].checked == false) && 
      (document.frmInicio.categoria[1].checked == false) &&
	  (document.frmInicio.categoria[2].checked == false) &&
	  (document.frmInicio.categoria[3].checked == false) &&
	  (document.frmInicio.categoria[4].checked == false)) {
       alert("Selecione uma categoria");
   }
   else {
	   goPagina('/default.asp?menu=6&opcao=6&acao=0&novocli=1');
   }
}

function hidestatus(){
var statusmsg=""
window.status=statusmsg
return true
}


function IsPopupBlocker(){
var oWin = window.open ("","testpopupblocker","width=100,height=50,top=5000,left=5000");
if (oWin==null || typeof(oWin)=="undefined") {
alert("Favor desbloquear o uso do Pop-up para este site!");
return true;
} else {
oWin.close();
return false;
}
}

function ShowMessage(missinginfo) {
    alert(missinginfo);
}

function SetFocus() {
    var oField;
    if (document.forms.length > 0) {
       for (var i=0; i < document.forms[0].elements.length; ++i) {
           oField = document.forms[0].elements[i];
           if ((oField.type != "hidden") && (oField.type != "select-one") && 
		       (oField.type != "button") && (oField.type != "submit")) {
              if ((oField.disabled != true) && (oField.value == "")) {
                 oField.focus();
                 break;
              } 
           }
       }
    }
}


function MascaraCNPJ(cnpj){
    if(mascaraInteiro(cnpj)==false){
        event.returnValue = false;
    }    
    return formataCampo(cnpj, '00.000.000/0000-00', event);
}

//adiciona mascara de cep
function MascaraCep(cep){
        if(mascaraInteiro(cep)==false){
        event.returnValue = false;
    }    
    return formataCampo(cep, '00000-000', event);
}

//adiciona mascara de data
function MascaraData(data){
    if(mascaraInteiro(data)==false){
        event.returnValue = false;
    }    
    return formataCampo(data, '00/00/0000', event);
}

//adiciona mascara ao telefone
function MascaraTelefone(tel){    
    if(mascaraInteiro(tel)==false){
        event.returnValue = false;
    }    
    return formataCampo(tel, '(000) 0000-0000', event);
}

//adiciona mascara ao CPF
function MascaraCPF(cpf){
    if(mascaraInteiro(cpf)==false){
        event.returnValue = false;
    }    
    return formataCampo(cpf, '000.000.000-00', event);
}

//valida telefone
function ValidaTelefone(tel) {
    if (tel.value != "") {
       exp = /\(\d{3}\)\ \d{4}\-\d{4}/
       if (!exp.test(tel.value)) {
          alert('Formato de Telefone Inválido!');
	   	  tel.value = "";
		  tel.focus();
		  return false;
	   }
	}
	return true;
}

//valida CEP
function ValidaCep(cep){
    if (cep.value != "") {
       exp = /\d{5}\-\d{3}/
       if(!exp.test(cep.value)) {
          alert('Formato de Cep Inválido!');        
	  	  cep.value = "";
		  cep.focus();
		  return false;
	   }
	}
	return true;
}

//valida data
function ValidaData(obj){
  date=obj.value
  if (/[^\d/]|(\/\/)/g.test(date)) {
     obj.value=obj.value.replace(/[^\d/]/g,'');obj.value=obj.value.replace(/\/{2}/g,'/'); 
	 return;
  }
  if (/^\d{2}$/.test(date)) {
     obj.value=obj.value+'/'; 
	 return;
  }
  if (/^\d{2}\/\d{2}$/.test(date)) {
     obj.value=obj.value+'/'; 
	 return;
  }
  if (!/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(date)) return;

  test1=(/^\d{1,2}\/?\d{1,2}\/\d{4}$/.test(date));
  date=date.split('/');
  d=new Date(date[2],date[1]-1,date[0]);
  test2=(1*date[0]==d.getDate() && 1*date[1]==(d.getMonth()+1) && 1*date[2]==d.getFullYear());
  if (test1 && test2) return true;
  alert("Data Inválida");
  obj.value="";
  obj.focus();
  return false;
}

//valida o CPF digitado
function ValidarCPF(Objcpf){
    var cpf = Objcpf.value;
    exp = /\.|\-/g
    cpf = cpf.toString().replace( exp, "" ); 
    if ((cpf=='00000000000') || (cpf=='11111111111') || 
	    (cpf=='22222222222') || (cpf=='33333333333') || 
	    (cpf=='44444444444') || (cpf=='55555555555') || 
		(cpf=='66666666666') || (cpf=='77777777777') || 
		(cpf=='88888888888') || (cpf=='99999999999')) {
        alert('CPF Inválido');       
		Objcpf.value = "";
		Objcpf.focus();
		return false;
	}
		
    var digitoDigitado = eval(cpf.charAt(9)+cpf.charAt(10));
    var dig1=0, dig2=0;
    var var1 = 10;
    var var2 = 11;
    for (i=0 ; i < 9 ; i++) {
        dig1 = dig1 + parseInt(cpf.substring(i, i+1) * var1);
        var1 = var1 - 1;
    }

    resto = dig1 % 11;
    dig1 = 11 - resto;
    if ((resto == 0) || (resto == 1)) dig1 = 0;
	
    for ( i=0 ; i < 9 ; i++) {
        dig2 = dig2 + parseInt(cpf.substring(i, i + 1) * var2);
        var2 = var2 - 1;
    }
	
    dig2 = dig2 + 2 * dig1;
    resto = dig2 % 11;
    dig2 = 11 - resto;

    if ((resto == 0) || (resto == 1)) dig2 = 0;
    digitoGerado = (dig1 * 10) + dig2;
	
    if (digitoGerado!=digitoDigitado) {
        alert('CPF Inválido');       
		Objcpf.value = "";
		Objcpf.focus();
		return false;
	}
	return true;
}

//valida numero inteiro com mascara
function mascaraInteiro(){
    if (event.keyCode < 48 || event.keyCode > 57){
        event.returnValue = false;
        return false;
    }
    return true;
}

//formata de forma generica os campos
function formataCampo(campo, Mascara, evento) { 
    var boleanoMascara; 
    
    var Digitato = evento.keyCode;
    exp = /\-|\.|\/|\(|\)| /g
    campoSoNumeros = campo.value.toString().replace( exp, "" ); 
   
    var posicaoCampo = 0;     
    var NovoValorCampo="";
    var TamanhoMascara = campoSoNumeros.length;; 
    
    if (Digitato != 8) { // backspace 
        for(i=0; i<= TamanhoMascara; i++) { 
            boleanoMascara  = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".")
                                || (Mascara.charAt(i) == "/")) 
            boleanoMascara  = boleanoMascara || ((Mascara.charAt(i) == "(") 
                                || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " ")) 
            if (boleanoMascara) { 
                NovoValorCampo += Mascara.charAt(i); 
                  TamanhoMascara++;
            }else { 
                NovoValorCampo += campoSoNumeros.charAt(posicaoCampo); 
                posicaoCampo++; 
              }            
          }     
        campo.value = NovoValorCampo;
          return true; 
    }else { 
        return true; 
    }
}


function autoTab(origem,destino) { 
    if (origem.getAttribute&&origem.value.length == origem.getAttribute("maxlength")) {
       destino.focus();
	}
} 


//valida o CPF digitado
function ValidarCPF(Objcpf){
    var cpf = Objcpf.value;
    exp = /\.|\-/g
    cpf = cpf.toString().replace( exp, "" ); 
    if ((cpf=='00000000000') || (cpf=='11111111111') || 
	    (cpf=='22222222222') || (cpf=='33333333333') || 
	    (cpf=='44444444444') || (cpf=='55555555555') || 
		(cpf=='66666666666') || (cpf=='77777777777') || 
		(cpf=='88888888888') || (cpf=='99999999999')) {
        alert('CPF Inválido');       
		Objcpf.value = "";
		Objcpf.focus();
		return false;
	}
		
    var digitoDigitado = eval(cpf.charAt(9)+cpf.charAt(10));
    var dig1=0, dig2=0;
    var var1 = 10;
    var var2 = 11;
    for (i=0 ; i < 9 ; i++) {
        dig1 = dig1 + parseInt(cpf.substring(i, i+1) * var1);
        var1 = var1 - 1;
    }

    resto = dig1 % 11;
    dig1 = 11 - resto;
    if ((resto == 0) || (resto == 1)) dig1 = 0;
	
    for ( i=0 ; i < 9 ; i++) {
        dig2 = dig2 + parseInt(cpf.substring(i, i + 1) * var2);
        var2 = var2 - 1;
    }
	
    dig2 = dig2 + 2 * dig1;
    resto = dig2 % 11;
    dig2 = 11 - resto;

    if ((resto == 0) || (resto == 1)) dig2 = 0;
    digitoGerado = (dig1 * 10) + dig2;
	
    if (digitoGerado!=digitoDigitado) {
        alert('CPF Inválido');       
		Objcpf.value = "";
		Objcpf.focus();
		return false;
	}
	return true;
}

//Redireciona a URL
function goPagina(url) {
  if (url.indexOf('?') > 0) {
     url = url + '&uUrl=' + new Date();
  } else { 
     url = url + '?uUrl=' + new Date();
	 }
 window.location = url;
//  window.location = 'principal.asp'; 
//  window.open(url, 'Principal');
}

//Redireciona a URL
function Abrir(url)
{
if (url.indexOf('?') > 0) {
    url = url + '&uUrl=' + new Date();
} else { 
    url = url + '?uUrl=' + new Date();
}
window.open(url, "_blank");
}

function checkCPFSnh() {
 missinginfo = "";
 if (document.frmInicio.cpfsnh.value == "") {
    missinginfo += "\n     -  CPF não Informado";
	}

 if (missinginfo != "") {
    missinginfo = "Campo de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o campo indicado";
    alert(missinginfo);
    document.frmInicio.cpfsnh.focus();
    return false;
    }
 else {
       return true;
      }
}


function checkLogin() {
 missinginfo = "";
 if (document.frmInicio.cpf.value == "") {
    missinginfo += "\n     -  CPF não Informado";
	}
 if (document.frmInicio.senha.value == "") {
    missinginfo += "\n     -  Senha não Informada";
 }

 if (missinginfo != "") {
    missinginfo = "Campo de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o campo indicado";
    alert(missinginfo);
	if (document.frmInicio.cpf.value == "") {
        document.frmInicio.cpf.focus();
		}
	else {
	if (document.frmInicio.senha.value == "") {
        document.frmInicio.senha.focus();
		}
	  }
    return false;
    }
 else {
       return true;
      }
}

//Verifica os campos CPF e senha
function checkLoginInicio() {
 missinginfo = "";
 if (document.frmLoginPrincipal.cpf.value == "") {
    missinginfo += "\n     -  CPF não Informado";
	}
 if (document.frmLoginPrincipal.senha.value == "") {
    missinginfo += "\n     -  Senha não Informada";
 }

 if (missinginfo != "") {
    missinginfo = "Campo de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o campo indicado";
    alert(missinginfo);
	if (document.frmLoginPrincipal.cpf.value == "") {
        document.frmLoginPrincipal.cpf.focus();
		}
	else {
	if (document.frmLoginPrincipal.senha.value == "") {
        document.frmLoginPrincipal.senha.focus();
		}
	  }
    return false;
    }
 else {
       return true;
      }
}


// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function openCurso(x, y, codcurso, dtinicio) {
   result = window.open('../cursos/detalhe_cursos.asp?codcurso=' + codcurso + '&dtinicio=' + dtinicio + '&uUrl=' + new Date(), 'popup', 'height=480, width=600, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, copyhistory=no, directories=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web");
   }
}


function CriticaCadastro() {
    missinginfo = "";
	document.getElementById("c01").style.color = "#666";
	document.getElementById("c02").style.color = "#666";
	document.getElementById("c03").style.color = "#666";
	document.getElementById("c04").style.color = "#666";
	document.getElementById("c05").style.color = "#666";
	document.getElementById("c06").style.color = "#666";
	document.getElementById("c07").style.color = "#666";
	document.getElementById("c08").style.color = "#666";
	document.getElementById("c09").style.color = "#666";
	document.getElementById("c10").style.color = "#666";
	document.getElementById("c11").style.color = "#666";
	document.getElementById("c12").style.color = "#666";
	document.getElementById("c13").style.color = "#666";
	document.getElementById("c14").style.color = "#666";
	document.getElementById("c15").style.color = "#666";
	document.getElementById("c16").style.color = "#666";
	document.getElementById("c17").style.color = "#666";
	document.getElementById("c18").style.color = "#666";
	document.getElementById("c19").style.color = "#666";
    if (document.frmCadastro.cpf.value == "") {
	   document.getElementById("c01").style.color = "red";
       missinginfo += "\n     -  CPF";
	   }
    if (document.frmCadastro.nasc.value == "") {
	   document.getElementById("c02").style.color = "red";
       missinginfo += "\n     -  Nascimento";
    }
    if (document.frmCadastro.nome.value == "") {
	   document.getElementById("c03").style.color = "red";
       missinginfo += "\n     -  Nome";
    }
    if ((document.frmCadastro.rdsexo[0].checked == false) && 
	    (document.frmCadastro.rdsexo[1].checked == false)) {
	   document.getElementById("c04").style.color = "red";
       missinginfo += "\n     -  Sexo";
    }
    if (document.frmCadastro.ecivil.value == "") {
	   document.getElementById("c05").style.color = "red";
       missinginfo += "\n     -  Estado Civil";
    }
    if (document.frmCadastro.cep.value == "") {
	   document.getElementById("c06").style.color = "red";
       missinginfo += "\n     -  CEP";
    }
    if (document.frmCadastro.uf.value == "") {
	   document.getElementById("c07").style.color = "red";
       missinginfo += "\n     -  UF";
    }
    if (document.frmCadastro.tpend.value == "") {
	   document.getElementById("c08").style.color = "red";
       missinginfo += "\n     -  Tipo de Endereço";
    }
    if (document.frmCadastro.tplog.value == "") {
	   document.getElementById("c09").style.color = "red";
       missinginfo += "\n     -  Tipo de Logradouro";
    }
    if (document.frmCadastro.logradouro.value == "") {
	   document.getElementById("c10").style.color = "red";
       missinginfo += "\n     -  Logradouro";
    }
    if (document.frmCadastro.numero.value == "") {
	   document.getElementById("c11").style.color = "red";
       missinginfo += "\n     -  Número do Logradouro";
    }
    if (document.frmCadastro.bairro.value == "") {
	   document.getElementById("c12").style.color = "red";
       missinginfo += "\n     -  Bairro";
    }
    if (document.frmCadastro.cidade.value == "") {
	   document.getElementById("c13").style.color = "red";
       missinginfo += "\n     -  Cidade";
    }
    if ((document.frmCadastro.telcom.value == "") && (document.frmCadastro.telres.value == "") &&
	    (document.frmCadastro.telcel.value == "") && (document.frmCadastro.telfax.value == "") &&
	    (document.frmCadastro.email.value  == "")) {
	   document.getElementById("c14").style.color = "red";
	   document.getElementById("c15").style.color = "red";
	   document.getElementById("c16").style.color = "red";
	   document.getElementById("c17").style.color = "red";
       missinginfo += "\n     -  Pelo menos um Telefone ou E-Mail";
    }

    if (document.frmCadastro.senha.value != "jácadastrado") {
	   if (document.frmCadastro.senha.value == "") {
	      document.getElementById("c18").style.color = "red";
          missinginfo += "\n     -  Senha";
		  }
    }
    if (document.frmCadastro.confsnh.value != "jácadastrado") {
	   if (document.frmCadastro.confsnh.value == "") {
	      document.getElementById("c19").style.color = "red";
          missinginfo += "\n     -  Confirmação da Senha";
		  }
    }
    if (document.frmCadastro.senha.value != "jácadastrado") {
	   if (document.frmCadastro.senha.value != document.frmCadastro.confsnh.value) {
          missinginfo += "\n     -  Senhas não Conferem";
		  }
    }

 if (missinginfo != "") {
    missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
    "___________________________________          \n" +
    missinginfo + "\n___________________________________" +
    "\nFavor preencher o(s) campo(s) indicado(s)";
    alert(missinginfo);
    return false;
    }
 else {
       return true;
      }
}


function SetIndex(txt,cbo) { 
  var achou=false; 
  if (txt.value != "") { 
     for (x = 0; x < cbo.length; x++) { 
         if (cbo[x].value == txt.value) { 
            achou=true; 
            pos=x; 
            x=cbo.length; 
         } 
     } 
  } 

  if (achou == true) { 
     cbo.selectedIndex = pos; 
     return true; 
  } 
   else 
  { 
   cbo.selectedIndex = -1; 
   return false; 
  } 
} 


function Desabilita() {
    var oField;
    if (document.forms.length > 0) {
       for (var i=0; i < document.forms[0].elements.length; ++i) {
           oField = document.forms[0].elements[i];
           if ((oField.type != "hidden") && (oField.type != "select-one") && 
		       (oField.type != "button") && (oField.type != "submit")) {
              if (oField.disabled != true) {
				 oField.style.border = 0;
                 oField.disabled     = true;
              }
           }
       }
    }
}


function Mascara(objeto, evt, mask) {
  var LetrasU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  var LetrasL = 'abcdefghijklmnopqrstuvwxyz';
  var Letras  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  var Numeros = '0123456789';
  var Fixos  = '().-:/ '; 
  var Charset = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_/`abcdefghijklmnopqrstuvwxyz{|}~";

  evt = (evt) ? evt : (window.event) ? window.event : "";
  var value = objeto.value;
  if (evt) {
     var ntecla = (evt.which) ? evt.which : evt.keyCode;
     tecla = Charset.substr(ntecla - 32, 1);
     if (ntecla < 32) return true;

     var tamanho = value.length;
     if (tamanho >= mask.length) return false;

     var pos = mask.substr(tamanho,1); 
     while (Fixos.indexOf(pos) != -1) {
           value += pos;
           tamanho = value.length;
           if (tamanho >= mask.length) return false;
           pos = mask.substr(tamanho,1);
     }

     switch (pos) {
            case '#' : if (Numeros.indexOf(tecla) == -1) return false; break;
            case 'A' : if (LetrasU.indexOf(tecla) == -1) return false; break;
            case 'a' : if (LetrasL.indexOf(tecla) == -1) return false; break;
            case 'Z' : if (Letras.indexOf(tecla) == -1) return false; break;
            case '*' : objeto.value = value; return true; break;
     default : return false; break;
     }
  }
objeto.value = value; 
return true;
}


//Valida o cpf formatado com os pontos e traços
function valida_cpf(objeto,CPF) {
dig_1 = 0;
dig_2 = 0;
controle_1 = 10;
controle_2 = 11;
lsucesso = 1;
MaskCPF = CPF;

if (CPF.length == 11) {
   mascara_cpf(objeto,CPF);
}

if ((CPF.length != 14) || (CPF.substring(11, 12) != "-")) 
   return false
else
{
CPF = CPF.substring(0,3) + CPF.substring(4,7) + CPF.substring(8,14);
for (i=0 ; i < 9 ; i++)
{
dig_1 = dig_1 + parseInt(CPF.substring(i, i+1) * controle_1);
controle_1 = controle_1 - 1;
}

resto = dig_1 % 11;
dig_1 = 11 - resto;

if ((resto == 0) || (resto == 1)) dig_1 = 0;
for ( i=0 ; i < 9 ; i++)
{
dig_2 = dig_2 + parseInt(CPF.substring(i, i + 1) * controle_2);
controle_2 = controle_2 - 1;
}
dig_2 = dig_2 + 2 * dig_1;
resto = dig_2 % 11;
dig_2 = 11 - resto;

if ((resto == 0) || (resto == 1)) dig_2 = 0;
dig_ver = (dig_1 * 10) + dig_2;

if ((MaskCPF == "111.111.111-11") || (MaskCPF == "222.222.222-22") || (MaskCPF == "333.333.333-33") || 
    (MaskCPF == "444.444.444-44") || (MaskCPF == "555.555.555-55") || (MaskCPF == "666.666.666-66") ||
    (MaskCPF == "777.777.777-77") || (MaskCPF == "888.888.888-88") || (MaskCPF == "000.000.000-00") || 
	(MaskCPF == "999.999.999-99") || (dig_ver != parseFloat(CPF.substring(CPF.length-2,CPF.length)))) {
   missinginfo = "CPF Inválido.\n";
   alert(missinginfo);
   objeto.value = "";
   objeto.focus();
   return false;
   }
}
return true;
} 


function check(objeto,msg) {
  if (objeto.value == "") {
     objeto.focus();
     alert(msg);
	 return false;
  }
  return true;
}

function SubForm(Form) {
  Form.submit();
}

function validarjornal(form) { //nome,email,endereco,bairro,cidade,cep,titulo
	if (document.classificados.nome.value == "") {
		alert("Escreva algo no campo antes de enviar");
		classificados.nome.focus();
		return false;
	}
	if (document.classificados.email.value == "") {
		alert("Escreva algo no campo antes de enviar");
		classificados.email.focus();
		return false;
	}
	if (document.classificados.endereco.value == "") {
		alert("Escreva algo no campo antes de enviar");
		classificados.endereco.focus();
		return false;
	}
	if (document.classificados.bairro.value == "") {
		alert("Escreva algo no campo antes de enviar");
		classificados.bairro.focus();
		return false;
	}
	if (document.classificados.cidade.value == "") {
		alert("Escreva algo no campo antes de enviar");
		classificados.cidade.focus();
		return false;
	}
	if (document.classificados.cep.value == "") {
		alert("Escreva algo no campo antes de enviar");
		classificados.cep.focus();
		return false;
	}
	if (document.classificados.titulo.value == "") {
		alert("Escreva algo no campo antes de enviar");
		classificados.titulo.focus();
		return false;
	}						
	return true;
	
}

//Para rodar flash sem ter que clicar na tela
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function formatar(src, mask) 
{
  var i = src.value.length;
  var saida = mask.substring(0,1);
  var texto = mask.substring(i)
if (texto.substring(0,1) != saida) 
  {
	src.value += texto.substring(0,1);
  }
}


function validDate(obj){
  date=obj.value
  if (/[^\d/]|(\/\/)/g.test(date)) {
     obj.value=obj.value.replace(/[^\d/]/g,'');obj.value=obj.value.replace(/\/{2}/g,'/'); 
	 return;
  }
  if (/^\d{2}$/.test(date)) {
     obj.value=obj.value+'/'; 
	 return;
  }
  if (/^\d{2}\/\d{2}$/.test(date)) {
     obj.value=obj.value+'/'; 
	 return;
  }
  if (!/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(date)) return;

  test1=(/^\d{1,2}\/?\d{1,2}\/\d{4}$/.test(date));
  date=date.split('/');
  d=new Date(date[2],date[1]-1,date[0]);
  test2=(1*date[0]==d.getDate() && 1*date[1]==(d.getMonth()+1) && 1*date[2]==d.getFullYear());
  if (test1 && test2) return true;
  alert("Data Invalida");
  obj.value="";
  obj.focus();
  return false;
}


function checkDados() {
         missinginfo = "";
		 if (document.frmsenha.old_senha.value != "") {
		    if (document.frmsenha.new_senha.value == "") {
               missinginfo += "\n     -  Nova Senha";
			   document.frmsenha.new_senha.focus();
			}
		    if (document.frmsenha.new_senha.value != document.frmsenha.rep_senha.value) {
               missinginfo += "\n     -  Senhas não Conferem";
			   document.frmsenha.rep_senha.focus();
			}
		 }
			   
         if (document.frmsenha.rep_senha.value == "") {
            missinginfo += "\n     -  Confirmação de Senha";
			document.frmsenha.rep_senha.focus();
         }  
	
         if (document.frmsenha.nome.value != "") {
            if (document.frmsenha.dt_nasc.value == "") {
               missinginfo += "\n     -  Nascimento";
			   document.frmsenha.dt_nasc.focus();
            } 
		 }

         if (missinginfo != "") {
            missinginfo = "Campo(s) de preenchimento obrigatório:\n" +
            "___________________________________          \n" +
            missinginfo + "\n___________________________________" +
            "\nFavor preencher o(s) campo(s) indicado(s)!";
            alert(missinginfo);
            return false;
         }

         if (document.frmsenha.rep_senha.value != "") {
            if (document.frmsenha.new_senha.value != document.frmsenha.rep_senha.value) {
               alert("Senhas não Conferem");
	           document.frmsenha.rep_senha.value = "";
	           document.frmsenha.rep_senha.focus();
	           return false;
            }  
         }

         if (document.frmsenha.nome.value != "") {
            if (document.frmsenha.nascimento.value != document.frmsenha.dt_nasc.value) {
               alert("Nascimento não Confere");
	           document.frmsenha.dt_nasc.value = "";
        	   document.frmsenha.dt_nasc.focus();
	           return false;
            }
         }
		 
 return true;
}

function openNoticia(x, y, cod) {
   result = window.open('/noticias/detalhe_noticia.asp?cod=' + cod + '&uUrl=' + new Date(), 'popup', 'height=600, width=800, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, copyhistory=no, directories=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web");
   }
}


function openNotBiblio(x, y, cod) {
   result = window.open('/biblioteca/detalhe_noticia.asp?cod=' + cod + '&uUrl=' + new Date(), 'popup', 'height=600, width=800, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, copyhistory=no, directories=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web");
   }
}


function openCurso(x, y, codcurso, dtinicio) {
   result = window.open('/cursos/detalhe_cursos.asp?codcurso=' + codcurso + '&dtinicio=' + dtinicio + '&uUrl=' + new Date(), 'popup', 'height=480, width=600, left=' + x + ', top=' + y + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, copyhistory=no, directories=no');
   if (result != null) {
   }
   else {
         window.close();
         alert("Favor Desabiltar o Bloqueador de Popup do seu Navegador Web");
   }
}

<!--

function validar(form) {
	if (this.nome.value == "") {
		alert("Escreva algo no campo antes de enviar");
		faleconosco.nome.focus();
		return false;
	}
	if (document.faleconosco.email.value == "") {
		alert("Escreva algo no campo antes de enviar");
		faleconosco.email.focus();
		return false;
	}
	if (document.faleconosco.telefone.value == "") {
		alert("Escreva algo no campo antes de enviar");
		faleconosco.telefone.focus();
		return false;
	}
	if (document.faleconosco.mensagem.value == "") {
		alert("Escreva algo no campo antes de enviar");
		faleconosco.mensagem.focus();
		return false;
	}				
	return true;
	
}

function GetIndex(Objeto) { 
  var indice=-1;
  for ( i=0; i < Objeto.length; i++ ) {   
      if (Objeto[i].checked) {
         indice = i;
	  }
  }
  return indice;
}  


//-->

function checkform(form) {
	var numElement = eval(document.getElementById(form).length);
	var i;
	var Obj = document.getElementById(form);
	var erro = "";
	var fistind = 0;

	for (i = 0; i < numElement; i++) {
		//valor do select
		var index = Obj.elements[i].selectedIndex;

		//Campo de Texto
		if ((Obj.elements[i].type == "text") && (Obj.elements[i].title != "") && (Obj.elements[i].value == "")) {
			erro += "- " +Obj.elements[i].title+".\n";
		}
		
		if ((Obj.elements[i].type == "textarea") && (Obj.elements[i].title != "") && (Obj.elements[i].value == "")) {
			erro += "- " +Obj.elements[i].title+".\n";
		}

		//Campo de select
		if ((Obj.elements[i].type == "select-one") && (Obj.elements[i].title != "") && (Obj.elements[i].options[index].index == 0)) {
			erro += "- " +Obj.elements[i].title+"\n";
		}
		
		//Campo password
		if ((Obj.elements[i].type == "password") && (Obj.elements[i].title != "") && (Obj.elements[i].value == "")) {
			erro += "- " +Obj.elements[i].title+".\n";
		}


		if ((erro != "") && (fistind == 0)) {
			fistind = i;
		}
	
	}

	if (erro != "") {
		alert("Por favor verifique o(s) Campo(s):\n\n"+erro);
		Obj.elements[fistind].focus();
		return false;
	} else {
		return true;
	}
}


function fireOnclick(objID) {
var target=document.getElementById(objID);
if(document.dispatchEvent) { // W3C
    var oEvent = document.createEvent( "MouseEvents" );
    oEvent.initMouseEvent("click", true, true,window, 1, 1, 1, 1, 1, false, false, false, false, 0, target);
    target.dispatchEvent( oEvent );
    }
else if(document.fireEvent) { // IE
    target.fireEvent("onclick");
    }    
}



function criticapesquisa() {
	if (document.frmPesquisa.ler_jornal[0].checked == true) {
		document.frmPesquisa.nao_ler_jornal.disabled = true;
		document.frmPesquisa.sim_ler_jornal.disabled = false;
		document.frmPesquisa.sim_ler_jornal.focus();
	}
	else if (document.frmPesquisa.ler_jornal[1].checked == true) {
		document.frmPesquisa.sim_ler_jornal.disabled = true;
		document.frmPesquisa.nao_ler_jornal.disabled = false;
		document.frmPesquisa.nao_ler_jornal.focus();
	}
	else {
		document.frmPesquisa.sim_ler_jornal.disabled = true;
		document.frmPesquisa.nao_ler_jornal.disabled = true;
	}
	if 	((document.frmPesquisa.ler_jornal[1].checked == true) || 
		 (document.frmPesquisa.ler_jornal[2].checked == true)) {
		if (document.frmPesquisa.ler_jornal[1].checked == true) {
			document.frmPesquisa.nao_ler_jornal.focus();
		}
		else {
			document.frmPesquisa.gostaria_aborj.focus();
		}
		document.frmPesquisa.frequencia[0].checked = false;
		document.frmPesquisa.frequencia[0].disabled = true;
		document.frmPesquisa.frequencia[1].checked = false;
		document.frmPesquisa.frequencia[1].disabled = true;
		document.frmPesquisa.frequencia[2].checked = false;
		document.frmPesquisa.frequencia[2].disabled = true;
		document.frmPesquisa.frequencia[3].checked = false;
		document.frmPesquisa.frequencia[3].disabled = true;
		document.frmPesquisa.gosta_aborj.disabled = true;
	}
	else {
		document.frmPesquisa.frequencia[0].disabled = false;
		document.frmPesquisa.frequencia[1].disabled = false;
		document.frmPesquisa.frequencia[2].disabled = false;
		document.frmPesquisa.frequencia[3].disabled = false;
		document.frmPesquisa.gosta_aborj.disabled = false;
	}

		
}


function vpesquisa() {
	if (document.frmPesquisa.nome.value == "") {
		alert("Preencha o campo nome");
		document.frmPesquisa.nome.focus();
		return false;
	}
	else if (document.frmPesquisa.telefone.value == "") {
		alert("Preencha o campo telefone");
		document.frmPesquisa.telefone.focus();
		return false;
	}

    if ((document.frmPesquisa.ler_jornal[0].checked == false) && 
	    (document.frmPesquisa.ler_jornal[1].checked == false) && 
		(document.frmPesquisa.ler_jornal[2].checked == false)) {
         alert("Selecione uma categoria na pergunta 1");
		 return false;
	}
	else if ((document.frmPesquisa.ler_jornal[0].checked == true) && (document.frmPesquisa.sim_ler_jornal.value == "") || 
        	 (document.frmPesquisa.ler_jornal[1].checked == true) && (document.frmPesquisa.nao_ler_jornal.value == "")) {
			  alert("Preencha o campo de justificativa");
			  return false;
	}
	if ((document.frmPesquisa.ler_jornal[0].checked == true) &&
		(document.frmPesquisa.frequencia[0].checked == false) && 
	   	(document.frmPesquisa.frequencia[1].checked == false) && 
	    (document.frmPesquisa.frequencia[2].checked == false) && 
		(document.frmPesquisa.frequencia[3].checked == false)) {
	     alert("Selecione uma categoria na pergunta 2");
		 return false;
	}
	if ((document.frmPesquisa.ler_jornal[0].checked == true) &&
	    ((document.frmPesquisa.frequencia[0].checked == true) || (document.frmPesquisa.frequencia[1].checked == true) ||
	     (document.frmPesquisa.frequencia[2].checked == true) || (document.frmPesquisa.frequencia[3].checked == true)) &&
		(document.frmPesquisa.gosta_aborj.value == "")) {
	     alert("Preencha o campo da pergunta 3");
		 return false;
	}
	if (document.frmPesquisa.gostaria_aborj.value == "") {
		 alert("Preencha o campo da pergunta 4");
		 return false;
	}
	return true;
}

<!--

function validar(form) {
	if (document.faleconosco.nome.value == "") {
		alert("Escreva algo no campo antes de enviar");
		faleconosco.nome.focus();
		return false;
	}
	if (document.faleconosco.email.value == "") {
		alert("Escreva algo no campo antes de enviar");
		faleconosco.email.focus();
		return false;
	}
	if (document.faleconosco.telefone.value == "") {
		alert("Escreva algo no campo antes de enviar");
		faleconosco.telefone.focus();
		return false;
	}
	if (document.faleconosco.mensagem.value == "") {
		alert("Escreva algo no campo antes de enviar");
		faleconosco.mensagem.focus();
		return false;
	}				
	return true;
	
}
//-->

