//----------------------Incio da consistência das EMPRESA---------------------------//
//Verificação de todos os campos do cadastre_empresa do empregador.
function Verificacadastre_empresa(cadastre_empresa) {
   nome           = cadastre_empresa.nome.value;
   cnpj      	  = cadastre_empresa.cnpj.value;
   fantasia       = cadastre_empresa.fantasia.value;
   endereco 	  = cadastre_empresa.endereco.value;
   bairro         = cadastre_empresa.bairro.value;
   municipio 	  = cadastre_empresa.municipio.value;
   cep            = cadastre_empresa.cep.value;
   uf          	  = cadastre_empresa.uf.value;
   telefone       = cadastre_empresa.telefone.value;
   fax            = cadastre_empresa.fax.value;
   email          = cadastre_empresa.email.value;
   responsavel    = cadastre_empresa.responsavel.value;
   senha 		  = cadastre_empresa.senha.value;
   confirmarSenha = cadastre_empresa.confirmarSenha.value;
   if(nome == ""){
      alert ("NOME não pode ser vazio!");
      document.cadastre_empresa.nome.focus();
      document.cadastre_empresa.nome.select();
      return false;
   }
   if(fantasia == "") {
      alert ("NOME FANTASIA não pode ser vazio!");
      document.cadastre_empresa.fantasia.focus();
      document.cadastre_empresa.fantasia.select();
      return false;
   }
   if(endereco == "") {
      alert("ENDEREÇO não pode ser vazio!");
      document.cadastre_empresa.endereco.focus();
      document.cadastre_empresa.endereco.select();
      return false;
   }
   if(bairro == "") {
      alert("BAIRRO não pode ser vazio!");
      document.cadastre_empresa.bairro.focus();
      document.cadastre_empresa.bairro.select();
      return false;
   }
   if(municipio == "") {
      alert("MUNICÍPIO não pode ser vazio!");
      document.cadastre_empresa.municipio.focus();
      document.cadastre_empresa.municipio.select();
      return false;
   }
   if(cep == "") {
      alert("CEP não pode ser vazio!");
      document.cadastre_empresa.cep.focus();
      document.cadastre_empresa.cep.select();
      return false;
   }
   if(uf == ""){
      alert("Selecione seu \"ESTADO!\"");
	  document.cadastre_empresa.uf.focus();
      return false;
   }
   if(telefone == "") {
      alert("TELEFONE não pode ser vazio!");
      document.cadastre_empresa.telefone.focus();
      document.cadastre_empresa.telefone.select();
      return false;
   }
   if(fax == "") {
      alert("FAX não pode ser vazio!");
      document.cadastre_empresa.fax.focus();
      document.cadastre_empresa.fax.select();
      return false;
   }
   if(email == "") {
      alert("E-MAIL não pode ser vazio!");
      document.cadastre_empresa.email.focus();
      document.cadastre_empresa.email.select();
      return false;
   }
   if(responsavel == "") {
      alert ("RESPONSÁVEL não pode ser vazio!");
      document.cadastre_empresa.responsavel.focus();
      document.cadastre_empresa.responsavel.select();
      return false;
   }
   if(senha == "") {
      alert ("SENHA não pode ser vazio!");
      document.cadastre_empresa.senha.focus();
      document.cadastre_empresa.senha.select()
      return false;
   }
   if(confirmarSenha == "") {
      alert ("CONFIRMAÇÃO DE SENHA não pode ser vazio!");
      document.cadastre_empresa.confirmarSenha.focus();
      document.cadastre_empresa.confirmarSenha.select()
      return false;
   }
   if(confirmarSenha != senha){
      alert ("As SENHAS informadas são diferentes!")
      document.cadastre_empresa.confirmarSenha.focus();
      document.cadastre_empresa.confirmarSenha.select()
      return false;
   }
}

//Verificação de todos os campos do Alterar_empresa do empregador.
function AlterarDadosEmpresa(alterar_empresa){
   nome           = alterar_empresa.nome.value;
   cnpj      	  = alterar_empresa.cnpj.value;
   fantasia       = alterar_empresa.fantasia.value;
   endereco 	  = alterar_empresa.endereco.value;
   bairro         = alterar_empresa.bairro.value;
   municipio 	  = alterar_empresa.municipio.value;
   cep            = alterar_empresa.cep.value;
   uf          	  = alterar_empresa.uf.value;
   telefone       = alterar_empresa.telefone.value;
   responsavel    = alterar_empresa.responsavel.value;
   alteraSenha    = alterar_empresa.alteraSenha.value;
   calteraSenha   = alterar_empresa.calteraSenha.value;
   if(nome == ""){
      alert ("NOME não pode ser vazio!");
      document.alterar_empresa.nome.focus();
      return false;
   }
   if(fantasia == "") {
      alert ("NOME FANTASIA não pode ser vazio!");
      document.alterar_empresa.fantasia.focus();
      return false;
   }
   if(endereco == "") {
      alert("ENDEREÇO não pode ser vazio!");
      document.alterar_empresa.endereco.focus();
      return false;
   }
   if(bairro == "") {
      alert("BAIRRO não pode ser vazio!");
      document.alterar_empresa.bairro.focus();
      return false;
   }
   if(municipio == "") {
      alert("MUNICÍPIO não pode ser vazio!");
      document.alterar_empresa.municipio.focus();
      return false;
   }
   if(cep == "") {
      alert("CEP não pode ser vazio!");
      document.alterar_empresa.cep.focus();
      return false;
   }
   if(uf == ""){
      alert("Selecione seu \"ESTADO!\"");
	  document.alterar_empresa.uf.focus();
      return false;
   }
   if(telefone == "") {
      alert("TELEFONE não pode ser vazio!");
      document.alterar_empresa.telefone.focus();
      return false;
   }

   if(responsavel == "") {
      alert ("RESPONSÁVEL não pode ser vazio!");
      document.alterar_empresa.responsavel.focus();
      return false;
   }

	if(calteraSenha != alteraSenha){
      alert ("As SENHAS informadas são diferentes!")
      document.cadastre_empresa.calteraSenha.focus();
      document.cadastre_empresa.calteraSenha.select()
      return false;
   }
}

//Transforma o CNPJ na mascara 99.999.999/9999-99
function TransformaCNPJ(cnpj){
   var mydata = '';
   mydata = mydata + cnpj.value;
   if(mydata.length == 2){
      mydata = mydata + '.';
      cnpj.value = mydata;
   }
   if(mydata.length == 6){
      mydata = mydata + '.';
      cnpj.value = mydata;
   }
   if(mydata.length == 10){
      mydata = mydata + '/';
      cnpj.value = mydata;
   }
   if(mydata.length == 15){
      mydata = mydata + '-';
      cnpj.value = mydata;
   }
}

//Valida o CNPJ
function analisa_cnpj(campo,nome){
   // verifica o tamanho
   var CNPJ = campo.value
   var valor = CNPJ.substr(0,2)+CNPJ.substr(3,3)+CNPJ.substr(7,3)+CNPJ.substr(11,4)+CNPJ.substr(16,2);
/*
   if(valor.length == 0){
      alert("CNPJ não pode ser fazio!");
      campo.focus();
	  return false;
   }
*/
   if(valor.length != 14) {
	  sim = false
	  alert("Tamanho Inválido de CNPJ");
      campo.focus();
      return false;
   } else{
		sim = true
     }
   if((sim) && (!isNaN(valor))){ // se for numero continua
      var digito = valor.toString()
	  // DIGITO 1
	  var soma1 = 0
	  soma1 = soma1 + 5 * digito.charAt(0)
	  soma1 = soma1 + 4 * digito.charAt(1)
	  soma1 = soma1 + 3 * digito.charAt(2)
	  soma1 = soma1 + 2 * digito.charAt(3)
	  soma1 = soma1 + 9 * digito.charAt(4)
	  soma1 = soma1 + 8 * digito.charAt(5)
	  soma1 = soma1 + 7 * digito.charAt(6)
	  soma1 = soma1 + 6 * digito.charAt(7)
	  soma1 = soma1 + 5 * digito.charAt(8)
	  soma1 = soma1 + 4 * digito.charAt(9)
	  soma1 = soma1 + 3 * digito.charAt(10)
	  soma1 = soma1 + 2 * digito.charAt(11)
	  var divisao1 = soma1 / 11
      var multiplica1 = parseInt(divisao1,10) * 11
	  var resto1 = soma1 - multiplica1
	  if(resto1 <= 1){
         var digi1 = 0
      } else{
           var digi1 = 11 - resto1
        }
	  // DIGITO 2
	  var soma2 = 0
	  soma2 = soma2 + 6 * digito.charAt(0)
	  soma2 = soma2 + 5 * digito.charAt(1)
	  soma2 = soma2 + 4 * digito.charAt(2)
	  soma2 = soma2 + 3 * digito.charAt(3)
	  soma2 = soma2 + 2 * digito.charAt(4)
	  soma2 = soma2 + 9 * digito.charAt(5)
	  soma2 = soma2 + 8 * digito.charAt(6)
	  soma2 = soma2 + 7 * digito.charAt(7)
	  soma2 = soma2 + 6 * digito.charAt(8)
	  soma2 = soma2 + 5 * digito.charAt(9)
	  soma2 = soma2 + 4 * digito.charAt(10)
	  soma2 = soma2 + 3 * digito.charAt(11)
	  soma2 = soma2 + 2 * digi1
	  var divisao2 = soma2 / 11
	  var multiplica2 = parseInt(divisao2,10) * 11
	  var resto2 = soma2 - multiplica2
	  if(resto2 <= 1){
         var digi2 = 0
      } else{
           var digi2 = 11 - resto2
        }
	  if(digito.charAt(12) == digi1.toString() & digito.charAt(13) == digi2.toString()){
		 return(true)
	  } else{
		   window.alert(nome+" Inválido!");
		   campo.focus()
		   return(false)
		}
   } else{
		window.alert(nome+" Inválido!");
		campo.focus()
		return false
	 }
}

//----------------------Incio da consistência das VAGAS---------------------------//
//Verificação de todos os campos do cadastre_vaga.php
function Verificacadastro_vaga(cadastro_vaga) {
   data_validade    = cadastro_vaga.data_vaga.value;
   nome_funcao      = cadastro_vaga.nome_funcao.value;
   vagas_oferecidas = cadastro_vaga.vagas_oferecidas.value;
   idade_menor_     = cadastro_vaga.idade_menor_.value;
   idade_maior_     = cadastro_vaga.idade_maior_.value;
   idade_menor_h    = cadastro_vaga.idade_menor_h.value;
   idade_maior_h    = cadastro_vaga.idade_maior_h.value;
   vagash           = cadastro_vaga.vagash.value;
   idade_menor_f    = cadastro_vaga.idade_menor_f.value;
   idade_maior_f    = cadastro_vaga.idade_maior_f.value;
   vagasf           = cadastro_vaga.vagasf.value;
   local            = cadastro_vaga.local.value;
   horario          = cadastro_vaga.horario.value;
   salario          = cadastro_vaga.salario.value;
   atribuicoes      = cadastro_vaga.atribuicoes.value;
   if(data_validade == ""){
      alert ("DATA DE VALIDADE não pode ser vazio!");
      document.cadastro_vaga.data_vaga.focus();
      return false;
   }
   if(nome_funcao == "0"){
      alert("Selecione uma Função pesquisada!");
      document.cadastro_vaga.nome_funcao.focus();
      Atualiza(nome_funcao);
      return false;
   }
   if(vagas_oferecidas == ""){
      alert("VAGAS OFERECIDAS não pode ser vazio!");
      document.cadastro_vaga.vagas_oferecidas.focus();
      return false;
   }
   if(document.cadastro_vaga.especificar1.checked == false) {
      if(document.cadastro_vaga.especificar0.checked == false){
	     alert("Marque uma opção para ESPECIFICAR A DISTRIBUIÇÃO DE VAGAS!");
 		 return false;
      }
   }
   if(document.cadastro_vaga.especificar1.checked == true){
      if(idade_menor_h == ""){
	     alert("IDADE inicial HOMEM não pode ser vazio!");
	     document.cadastro_vaga.idade_menor_h.focus();
 		 return false;
      }
      if(idade_maior_h == ""){
	     alert("IDADE final HOMEM não pode ser vazio!");
	     document.cadastro_vaga.idade_maior_h.focus();
 		 return false;
      }
      if(vagash == ""){
	     alert("VAGAS OFERECIDAS HOMEM não pode ser vazio!");
	     document.cadastro_vaga.vagash.focus();
 		 return false;
      }
      if(idade_menor_f == ""){
	     alert("IDADE inicial MULHER não pode ser vazio!");
	     document.cadastro_vaga.idade_menor_f.focus();
 		 return false;
      }
      if(idade_maior_f == ""){
	     alert("IDADE final MULHER não pode ser vazio!");
	     document.cadastro_vaga.idade_maior_f.focus();
 		 return false;
      }
      if(vagasf == ""){
	     alert("VAGAS OFERECIDAS MULHERES não pode ser vazio!");
	     document.cadastro_vaga.vagasf.focus();
 		 return false;
      }
      if((parseInt(vagash,10) + parseInt(vagasf,10)) != parseInt(vagas_oferecidas,10)){
         alert("O total das VAGAS dos homens mais daS mulheres esta diferente do total de VAGAS OFERECIDAS!");
	     document.cadastro_vaga.vagash.focus();
 		 return false;
      }
   }
   if(document.cadastro_vaga.especificar0.checked == true){
      if(idade_menor_ == ""){
	     alert("IDADE inicial não pode ser vazio!");
	     document.cadastro_vaga.idade_menor_.focus();
 		 return false;
      }
      if(idade_maior_ == ""){
	     alert("IDADE final não pode ser vazio!");
	     document.cadastro_vaga.idade_maior_.focus();
 		 return false;
      }
   }
   if(local == ""){
      alert ("LOCAL DE TRABALHO \"Bairro/Município\" não pode ser vazio!");
      document.cadastro_vaga.local.focus();
      return false;
   }
   if(horario == ""){
      alert("HORÁRIO não pode ser vazio!");
      document.cadastro_vaga.salario.focus();
      return false;
   }
   if(salario == ""){
      alert("SALÁRIO não pode ser vazio!");
      document.cadastro_vaga.salario.focus();
      return false;
   }
   if(atribuicoes == ""){
      alert("ATRIBUIÇÕES não pode ser vazio!");
      document.cadastro_vaga.atribuicoes.focus();
      return false;
   }

   else
      //alert ("CADASTRO EFETUADO COM SUCESSO!");
      return true;
}

//Verificação de todos os campos do altera_vaga.php
function Verificaalterar_vaga(alterar_vaga){
   data_validade    = alterar_vaga.data_vaga.value;
   vagas_oferecidas = alterar_vaga.vagas_oferecidas.value;
   idade_menor_     = alterar_vaga.idade_menor_.value;
   idade_maior_     = alterar_vaga.idade_maior_.value;
   idade_menor_h    = alterar_vaga.idade_menor_h.value;
   idade_maior_h    = alterar_vaga.idade_maior_h.value;
   vagash           = alterar_vaga.vagash.value;
   idade_menor_f    = alterar_vaga.idade_menor_f.value;
   idade_maior_f    = alterar_vaga.idade_maior_f.value;
   vagasf           = alterar_vaga.vagasf.value;
   local            = alterar_vaga.local.value;
   horario          = alterar_vaga.horario.value;
   salario          = alterar_vaga.salario.value;
   atribuicoes      = alterar_vaga.atribuicoes.value;
   if(data_validade == ""){
      alert ("DATA DE VALIDADE não pode ser vazio!");
      document.alterar_vaga.data_vaga.focus();
      return false;
   }
   if(vagas_oferecidas == ""){
      alert("VAGAS OFERECIDAS não pode ser vazio!");
      document.alterar_vaga.vagas_oferecidas.focus();
      return false;
   }
   if(document.alterar_vaga.especificar1.checked == false) {
      if(document.alterar_vaga.especificar0.checked == false){
	     alert("Marque uma opção para ESPECIFICAR A DISTRIBUIÇÃO DE VAGAS!");
 		 return false;
      }
   }
   if(document.alterar_vaga.especificar1.checked == true){
      if(idade_menor_h == ""){
	     alert("IDADE inicial HOMEM não pode ser vazio!");
	     document.alterar_vaga.idade_menor_h.focus();
 		 return false;
      }
      if(idade_maior_h == ""){
	     alert("IDADE final HOMEM não pode ser vazio!");
	     document.alterar_vaga.idade_maior_h.focus();
 		 return false;
      }
      if(vagash == ""){
	     alert("VAGAS OFERECIDAS HOMEM não pode ser vazio!");
	     document.alterar_vaga.vagash.focus();
 		 return false;
      }
      if(idade_menor_f == ""){
	     alert("IDADE inicial MULHER não pode ser vazio!");
	     document.alterar_vaga.idade_menor_f.focus();
 		 return false;
      }
      if(idade_maior_f == ""){
	     alert("IDADE final MULHER não pode ser vazio!");
	     document.alterar_vaga.idade_maior_f.focus();
 		 return false;
      }
      if(vagasf == ""){
	     alert("VAGAS OFERECIDAS MULHERES não pode ser vazio!");
	     document.alterar_vaga.vagasf.focus();
 		 return false;
      }
      if((parseInt(vagash,10) + parseInt(vagasf,10)) != parseInt(vagas_oferecidas,10)){
         alert("O total das VAGAS dos homens mais daS mulheres esta diferente do total de VAGAS OFERECIDAS!");
	     document.alterar_vaga.vagash.focus();
 		 return false;
      }
   }
   if(document.alterar_vaga.especificar0.checked == true){
      if(idade_menor_ == ""){
	     alert("IDADE inicial não pode ser vazio!");
	     document.alterar_vaga.idade_menor_.focus();
 		 return false;
      }
      if(idade_maior_ == ""){
	     alert("IDADE final não pode ser vazio!");
	     document.alterar_vaga.idade_maior_.focus();
 		 return false;
      }
   }
   if(local == ""){
      alert ("LOCAL DE TRABALHO \"Bairro/Município\" não pode ser vazio!");
      document.alterar_vaga.local.focus();
      return false;
   }
   if(horario == ""){
      alert("HORÁRIO não pode ser vazio!");
      document.alterar_vaga.salario.focus();
      return false;
   }
   if(salario == ""){
      alert("SALÁRIO não pode ser vazio!");
      document.alterar_vaga.salario.focus();
      return false;
   }
   if(atribuicoes == ""){
      alert("ATRIBUIÇÕES não pode ser vazio!");
      document.alterar_vaga.atribuicoes.focus();
      return false;
   }
   else
      //alert ("CADASTRO EFETUADO COM SUCESSO!");
      return true;
}

//Transforma o valor do campo em Data com a máscara dd/mm/aaaa
function mascara_data(data_validade){
   var mydata = '';
   mydata = mydata + data_validade.value;
   if (mydata.length == 2){
      mydata = mydata + '/';
      data_validade.value = mydata;
   }
   if (mydata.length == 5){
      mydata = mydata + '/';
      data_validade.value = mydata;
   }
}

//Validade a Data de Validade
function TestaData3(objdata){
  strnasc = objdata.value;
  if ((FG_ValData(strnasc))&&(strnasc.substring(2,3)=='/')&&(strnasc.substring(5,6)=='/')) {
	  dd = parseInt(strnasc.substring(0,2),10);
	  mm = parseInt(strnasc.substring(3,5),10);
	  aa = parseInt(strnasc.substring(6,strnasc.length),10);
	  nasc  = new Data(dd,mm,aa);
	  auxi  = new Date();
	  if(auxi.getYear()==99){
         anocerto = 1999;
	  } else{
           anocerto = 0000 + auxi.getYear();
        }
      hoje  = new Data(auxi.getDate(),auxi.getMonth()+1,anocerto);
	  idade_ano = nasc.ano - hoje.ano ;
	  if(idade_ano < 0) {
		 alert ('A data de validade da vaga deve ser maior do que hoje');
      } else
           if(idade_ano == 0){
              difmes = hoje.mes - nasc.mes;
	          if(difmes > 0){
                 alert('Mês inválido. A data de validade da vaga deve ser maior do que hoje');
				 //objdata.value  = '';
				 //objidade.value = '';
				 objdata.focus();
              } else
                   if(difmes == 0){
				      difdia = hoje.dia - nasc.dia;
				      if(difdia >= 0){
                         alert('Dia inválido. A data de validade da vaga deve ser maior do que hoje');
					     //objdata.value  = '';
					     //objidade.value = '';
					     objdata.focus();
				      }
				   }
     	        }
   } else{
	    if(strnasc.length != 0){
           alert('Data inválida ou formato incorreto.\nFormato: dd/mm/aaaa.');
		   //objdata.value  = '';
		   //objidade.value = '';
		   objdata.focus();
		}
	 }
}
function FG_TiraBrancosData(Texto){
   i=0;
   auxiliar="";
   while(i < Texto.length){
      if(Texto.charAt(i) == " "){
	       auxiliar = auxiliar + "";
	  } else{
		   auxiliar = auxiliar + Texto.charAt(i);
		}
	  i++;
   }
   return auxiliar;
}
function FG_ValData(SData){
   var Sano;
   var Smes;
   var Sdia;
   SData = FG_TiraBrancosData(SData);
   if( !(SData.length==10) ){
      return (false);
   };
   Sdia = SData.substring(0,2);
   if(isNaN(Sdia)) {
      return(false);
   };
   Sdia = parseInt(Sdia,10);
   Smes = SData.substring(3,5);
   if(isNaN(Smes)) {
      return(false);
   };
   Smes = parseInt(Smes,10);
   Sano = SData.substring(6,10);
   if(isNaN(Sano)) {
      return(false);
   };
   Sano = parseInt(Sano,10);
   if( Sano<0 ) {
      return (false);
   };
   if(Sano>2079) {
      return (false);
   };
   if(Sano<1900) {
      return (false);
   };
   if((Sdia<1) || (Sdia>31)) {
      return (false);
   };
   if((Smes<1) || (Smes>12)) {
      return (false);
   };
   if( ((Smes==4) || (Smes==6) || (Smes==9) || (Smes==11)) && (Sdia > 30) ) {
      return (false);
   };
   if( (Smes == 2) &&(Sdia > 29)) {
      return (false);
   };
   if( (Smes == 2) && (Sdia == 29) && !(FG_Bissexto(Sano))) {
      return (false);
   };
   return (true);
}
function FG_Bissexto(ano){
   var resto;
   if(ano == 0) {
      return(true);
   }
   resto = (ano % 400);
   if(resto == 0) {
      return (true);
   }
   resto = (ano % 100);
   if(resto == 0) {
      return (false);
   }
   resto = (ano % 4);
   if(resto == 0) {
      return (true);
   }
   return (false);
}
function Data(dd,mm,aa){
   this.dia = dd;
   this.mes = mm;
   this.ano = aa;
   return this;
}
//Fim de validação da data de validade//

//Carregar a tabela CBO com o que foi digitado na pesquisa
function loadXMLDoc(url,valor){
   req = null;
   if (window.XMLHttpRequest) {
       req = new XMLHttpRequest();
       req.onreadystatechange = processReqChange;
       req.open("GET", url+'?categoria='+valor, true);
       req.send(null);
   } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url+'?categoria='+valor, true);
            req.send();
        }
     }
}

//Verifica quando o estado esta completado
function processReqChange(){
   if (req.readyState == 4) {
       if (req.status == 200) {
           document.getElementById('atualiza').innerHTML = req.responseText;
       } else {
            alert("Houve um problema ao obter os dados:\n" + req.statusText);
         }
   }
}

//Recebe o valor digitado na pesquisa da tabela CBO
function Atualiza(valor){
    loadXMLDoc("atualiza.php",valor);
}

//Exibe ou Não Exibe o campo da Especificar em Cadastro de Vaga
function ExibirEspecificar(){
   if(document.cadastro_vaga.especificar1.checked == true) {
      document.getElementById('especificar_sim').style.display='block';
      document.getElementById('especificar_sim1').style.display='block';
      document.getElementById('especificar_sim2').style.display='block';
      document.getElementById('especificar_sim3').style.display='block';
      document.getElementById('especificar_sim4').style.display='block';
      document.getElementById('especificar_sim5').style.display='block';
      document.getElementById('especificar_sim6').style.display='block';
      document.getElementById('especificar_sim7').style.display='block';
      document.getElementById('especificar_sim8').style.display='block';
      document.getElementById('especificar_sim9').style.display='block';
      document.getElementById('especificar_sim10').style.display='block';
      document.getElementById('especificar_sim11').style.display='block';
      document.getElementById('especificar_nao').style.display='none';
      document.getElementById('especificar_nao1').style.display='none';
      document.getElementById('especificar_nao2').style.display='none';
      document.getElementById('especificar_nao3').style.display='none';
   } else{
      document.getElementById('especificar_sim').style.display='none';
      document.getElementById('especificar_sim1').style.display='none';
      document.getElementById('especificar_sim2').style.display='none';
      document.getElementById('especificar_sim3').style.display='none';
      document.getElementById('especificar_sim4').style.display='none';
      document.getElementById('especificar_sim5').style.display='none';
      document.getElementById('especificar_sim6').style.display='none';
      document.getElementById('especificar_sim7').style.display='none';
      document.getElementById('especificar_sim8').style.display='none';
      document.getElementById('especificar_sim9').style.display='none';
      document.getElementById('especificar_sim10').style.display='none';
      document.getElementById('especificar_sim11').style.display='none';
      document.getElementById('especificar_nao').style.display='block';
      document.getElementById('especificar_nao1').style.display='block';
      document.getElementById('especificar_nao2').style.display='block';
      document.getElementById('especificar_nao3').style.display='block';
     }
}

//Exibe ou Não Exibe o campo da Especificar em Alterar Vaga
function ExibirEspecificar2(){
   if(document.alterar_vaga.especificar1.checked == true) {
      document.getElementById('especificar_sim').style.display='block';
      document.getElementById('especificar_sim1').style.display='block';
      document.getElementById('especificar_sim2').style.display='block';
      document.getElementById('especificar_sim3').style.display='block';
      document.getElementById('especificar_sim4').style.display='block';
      document.getElementById('especificar_sim5').style.display='block';
      document.getElementById('especificar_sim6').style.display='block';
      document.getElementById('especificar_sim7').style.display='block';
      document.getElementById('especificar_sim8').style.display='block';
      document.getElementById('especificar_sim9').style.display='block';
      document.getElementById('especificar_sim10').style.display='block';
      document.getElementById('especificar_sim11').style.display='block';
      document.getElementById('especificar_nao').style.display='none';
      document.getElementById('especificar_nao1').style.display='none';
      document.getElementById('especificar_nao2').style.display='none';
      document.getElementById('especificar_nao3').style.display='none';
   } else{
      document.getElementById('especificar_sim').style.display='none';
      document.getElementById('especificar_sim1').style.display='none';
      document.getElementById('especificar_sim2').style.display='none';
      document.getElementById('especificar_sim3').style.display='none';
      document.getElementById('especificar_sim4').style.display='none';
      document.getElementById('especificar_sim5').style.display='none';
      document.getElementById('especificar_sim6').style.display='none';
      document.getElementById('especificar_sim7').style.display='none';
      document.getElementById('especificar_sim8').style.display='none';
      document.getElementById('especificar_sim9').style.display='none';
      document.getElementById('especificar_sim10').style.display='none';
      document.getElementById('especificar_sim11').style.display='none';
      document.getElementById('especificar_nao').style.display='block';
      document.getElementById('especificar_nao1').style.display='block';
      document.getElementById('especificar_nao2').style.display='block';
      document.getElementById('especificar_nao3').style.display='block';
     }
}

//Exibir ou não Exibir o campo Descrição da Deficiência
function camadaSelect(idCamada, Campo, Foco, Valor, Tipo){
   if(Tipo == "!=") {
      if(d.getElementById(Campo).value != Valor) {
		 Ativo = true;
		 d.getElementById(idCamada).style.display = "block"
	  } else {
		   Ativo = false;
		   d.getElementById(idCamada).style.display = "none"
		}
   } else {
	    if(d.getElementById(Campo).value == Valor) {
		   Ativo = true;
		   d.getElementById(idCamada).style.display = "block"
		} else {
		     Ativo = false;
			 d.getElementById(idCamada).style.display = "none"
		  }
	 }
   if(Foco && Ativo) {
      d.getElementById(Foco).focus();
   }
   return;
}

//Conta a quantidade de caracteres e ao mesmo tempo não permite ser digitado mais nenhum acima do Limite
function contador(Campo, idContador, Limite){
   var Maximo = Limite ? Limite : 500;
   var field = d.getElementById(Campo);
   var txtField = d.getElementById(idContador);
   if(field && field.value.length > Maximo){
      field.value = field.value.substring(0, Maximo);
      alert("O limite é de "+Maximo+" letras.");
   }
   if(txtField){
      document.getElementById('mens').style.display='block';
      document.getElementById('mens1').style.display='none';
      document.getElementById('mens2').style.display='block';
      document.getElementById('mens3').style.display='none';
      document.getElementById('mens4').style.display='block';
      document.getElementById('mens5').style.display='none';
      document.getElementById('mens6').style.display='block';
      document.getElementById('mens7').style.display='none';
      document.getElementById('mens8').style.display='block';
      document.getElementById('mens9').style.display='none';
      txtField.innerHTML = Maximo - field.value.length;
   }
}

//Exibe ou Não Exibe o campo da Categoria de Habilitação Cadastro de Vaga
function AbreHabilitacao(){
   if(document.cadastro_vaga.hsim.checked == true) {
      document.getElementById('htexto').style.display='block';
      document.getElementById('htexto1').style.display='block';
   } else{
        document.getElementById('htexto').style.display='none';
        document.getElementById('htexto1').style.display='none';
     }
}

//Exibe ou Não Exibe o campo da Categoria de Habilitação Alterar de Vaga
function AbreHabilitacao2(){
   if(document.alterar_vaga.hsim.checked == true) {
      document.getElementById('htexto').style.display='block';
      document.getElementById('htexto1').style.display='block';
   } else{
        document.getElementById('htexto').style.display='none';
        document.getElementById('htexto1').style.display='none';
     }
}

//Não permite incluir letras somente Números
function SomenteNumero(objeto){
   if(event.keyCode < 48 || event.keyCode > 57){
      alert("Este campo só aceita números");
      event.keyCode = 0;
   }
}

//Altera o valor digita para uma valor em moeda ex: 450 para 450,00
function AcertaMoeda(controle){
  x = '';
  for (i=0; i<controle.value.length; i++) {
    if ((controle.value.substring(i,i+1)==',')||(controle.value.substring(i,i+1)=='.')) {
		  break;
		}
		else {
		  if ((controle.value.substring(i,i+1)=='1')||(controle.value.substring(i,i+1)=='2')||(controle.value.substring(i,i+1)=='3')||(controle.value.substring(i,i+1)=='4')||(controle.value.substring(i,i+1)=='5')||(controle.value.substring(i,i+1)=='6')||(controle.value.substring(i,i+1)=='7')||(controle.value.substring(i,i+1)=='8')||(controle.value.substring(i,i+1)=='9')||(controle.value.substring(i,i+1)=='0')) {
		    x = x + controle.value.substring(i,i+1);
		  }
		}
  }
  if (x.length > 0) x += ',00';
  controle.value = x;
}

//Exclui Vaga
function ExcluirVaga(url,confirma){
   if(confirma){
      var pergunta = confirm(confirma)
	  if(pergunta == true){
		 variavel = 1;
	  } else{
	       variavel = 0;
	    }
   }
   if(variavel == 1){
      var req2 = null;
      if(window.XMLHttpRequest){
         req2 = new XMLHttpRequest();
         //req2.onreadystatechange = processReqChange;
         req2.open('GET',url,true);
         req2.send(null);
      } else if(window.ActiveXObject){
           req2 = new ActiveXObject('Microsoft.XMLHTTP');
           if(req2){
              //req2.onreadystatechange = processReqChange;
              req2.open('GET',url,true);
              req2.send();
           }
        }
      alert("A VAGA foi EXCLUÍDA.");
      location.href='gerenciar_vaga.php';
   }
}

//Suspende Vaga
function SuspendeVaga(url,confirma){
  if(confirma){
	 var pergunta = confirm(confirma)
	 if(pergunta == true){
		variavel = 1;
	 } else{
	      variavel = 0;
	   }
  }
  if(variavel == 1){
     var req2 = null;
     if(window.XMLHttpRequest){
        req2 = new XMLHttpRequest();
        //req2.onreadystatechange = processReqChange;
        req2.open('GET',url,true);
        req2.send(null);
     } else if(window.ActiveXObject){
          req2 = new ActiveXObject('Microsoft.XMLHTTP');
          if(req2){
             //req2.onreadystatechange = processReqChange;
             req2.open('GET',url,true);
             req2.send();
          }
       }
     alert("A VAGA foi SUSPENSA.");
     location.href='gerenciar_vaga.php';
  }
}

//Consistência dos campos de RECUPERAR SENHA.
function Verificacarecuperasenha(recuperasenha) {
   cnpj  = recuperasenha.cnpj.value;
   email = recuperasenha.email.value;
   if(cnpj == ""){
      alert ("CNPJ não pode ser vazio!");
      document.recuperasenha.cnpj.focus();
      return false;
   }
   if(email == ""){
      alert ("E-MAIL não pode ser vazio!");
      document.recuperasenha.email.focus();
      return false;
   }
}
   
//Valida E-MAIL.
function ValidaEmail()
{
  var obj = eval("document.forms[0].email");
  var txt = obj.value;
  if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7)))
  {
    alert('E-mail incorreto!');
	document.forms[0].email.focus();
	document.forms[0].email.select();
  }
}






