function validaDadosPessoais() {

     
    if (document.getElementById("txtNome").value == "")   {
        alert(" Campo nome é obrigatório");
        document.getElementById("txtNome").focus();
        return;
    }

    if (document.getElementById("txtNomeFantasia").value == "")   {
        alert(" Campo apelido é obrigatório");
        document.getElementById("txtNomeFantasia").focus();
        return;
    }
    
    if (document.getElementById("txtNacionalidade").value == "")   {
        alert(" Campo nacionalidade é obrigatório");
        document.getElementById("txtNacionalidade").focus();
        return;
    }

    if (document.getElementById("cmbCidadeNaturalidade").value == "-1")   {
        alert(" Campo naturalidade é obrigatório");
        document.getElementById("cmbCidadeNaturalidade").focus();
        return;
    }

    if (document.getElementById("txtNomePai").value == "")   {
        alert(" Campo nome pai é obrigatório");
        document.getElementById("txtNomePai").focus();
        return;
    }
    
    if (document.getElementById("txtNomeMae").value == "")   {
        alert(" Campo nome mãe é obrigatório");
        document.getElementById("txtNomeMae").focus();
        return; 
    }
    
    
    if (document.getElementById("txtRg").value == "")   {
        alert(" Campo RG é obrigatório");
        document.getElementById("txtRg").focus();
        return;
    }
    
    if (document.getElementById("cmbUfRg").value == "-1")   {
        alert(" Campo UF é obrigatório");
        document.getElementById("cmbUfRg").focus();
        return;
    }
    
    if (document.getElementById("txtOrgaoEmissor").value == "")   {
        alert(" Campo orgão emissor é obrigatório");
        document.getElementById("txtOrgaoEmissor").focus();
        return;
    }
    
    if (document.getElementById("txtDataEmissao").value == "") {
        alert(" Campo data emissão é obrigatório");
        document.getElementById("txtDataEmissao").focus();
        return;
    }

    if ( converteData(document.getElementById("txtDataNascimento").value) >
             converteData(document.getElementById("txtDataEmissao").value) ) {
        alert("A data de Emissão do RG está menor que a data de nascimento.");
        document.getElementById("txtDataEmissao").focus();
        return;
    }

    if (document.getElementById("txtDataNascimento").value == "") {
        alert(" Campo data nascimento é obrigatório");
        document.getElementById("txtDataNascimento").focus();
        return;

    }

    if (document.getElementById("cmbSexo").value == "-1")   {
        alert(" Campo Sexo é obrigatório");
        document.getElementById("cmbSexo").focus();
        return;
    }

    if (document.getElementById("cmbEstadoCivil").value == "-1")   {
        alert(" Campo estado civil é obrigatório");
        document.getElementById("cmbEstadoCivil").focus();
        return;
    }
    
    if (document.getElementById("cmbLogradouro").value == "-1")   {
        alert(" Campo logradouro é obrigatório");
        document.getElementById("cmbLogradouro").focus();
        return;
    }
    
    if (document.getElementById("txtEndereco").value == "")   {
        alert(" Campo endereço é obrigatório");
        document.getElementById("txtEndereco").focus();
        return;
    }
    
    if (document.getElementById("txtNumero").value == "")   {
        alert(" Campo número é obrigatório");
        document.getElementById("txtNumero").focus();
        return;
    }
    
    
    if (document.getElementById("txtBairro").value == "")   {
        alert(" Campo bairro é obrigatório");
        document.getElementById("txtBairro").focus();
        return;
    } 
    
    if (document.getElementById("cmbUfCidade").value == "-1")   {
        alert(" Campo UF é obrigatório");
        document.getElementById("cmbUf").focus();
        return;
    }
    
    if (document.getElementById("cmbCidade").value == "-1")   {
        alert(" Campo cidade é obrigatório");
        document.getElementById("cmbCidade").focus();
        return;
    }
    
    if (document.getElementById("txtCep").value == "")   {
        alert(" Campo cep é obrigatório");
        document.getElementById("txtCep").focus();
        return;
    }
    
    if (document.getElementById("txtSenha").value == "")   {
        alert(" Campo confirmar senha é obrigatório");
        document.getElementById("txtSenha").focus();
        return;
    }
    
    if (document.getElementById("txtConfirmarSenha").value == "")   {
        alert(" Campo confirmar senha é obrigatório");
        document.getElementById("txtConfirmarSenha").focus();
        return;
    }
    
    if (document.getElementById("txtSenha").value != document.getElementById("txtConfirmarSenha").value) {
        alert(" os campos Senha e confirmar senha estão diferentes");
        document.getElementById("txtSenha").focus();
        return;
    }
    
    if (document.getElementById("txtSenhaLembrete").value == "") {
        alert(" campo lembrete senha é obrigatório");
        document.getElementById("txtSenhaLembrete").focus();
        return;
    }

    if (checkFillFone()) {
        return;
    } else if (verificaCheckTelefone()) {
        return;
    } else if (checkFillEmail()) {
        return;
    } else if (verificaCheckEmail()) {
        return;
    }

    if (document.getElementById("txtEmail_0").value == "")   {
        alert(" Campo email é obrigatório");
        document.getElementById("txtEmail_0").focus();
        return;
    }

    if (document.getElementById("cmbTipoCnh").selectedIndex == 0) {
        alert("Campo tipo da CNH é obrigatório");
        document.getElementById("cmbTipoCnh").focus();
        return;
    }

    if (document.getElementById("cmbTipoCnh").value > 0 ) {
        if (document.getElementById("txtNumeroCnh").value == "") {
            alert("Campo número da CNH é obrigatório.");
            document.getElementById("txtNumeroCnh").focus();
            return;
        }

        if (document.getElementById("cmbCategoriaCnh").selectedIndex == 0) {
            alert("Campo categoria da CNH é obrigatório");
            document.getElementById("cmbCategoriaCnh").focus();
            return;
        }

        if (document.getElementById("txtPrimeiraCnh").value != "") {
          if ( converteData(document.getElementById("txtDataNascimento").value) > converteData(document.getElementById("txtPrimeiraCnh").value) ) {
              alert("A Primeira data da CNH está menor que a data de nascimento.");
              document.getElementById("txtPrimeiraCnh").focus();
              return false;
          }
        }

        if ( converteData(document.getElementById("txtDataNascimento").value) >
             converteData(document.getElementById("txtEmissaoCnh").value) ) {
            alert("A data de Emissão do CNH está menor que a data de nascimento.");
            document.getElementById("txtEmissaoCnh").focus();
            return;
        }

        if ( converteData(document.getElementById("txtVencimentoCnh").value) <
             converteData(document.getElementById("txtEmissaoCnh").value) ) {
            alert("A data de Vencimento da CNH está menor que a data de Emissão.");
            document.getElementById("txtEmissaoCnh").focus();
            return;
        }

        if (document.getElementById("txtPrimeiraCnh").value != "") {
          if ( converteData(document.getElementById("txtEmissaoCnh").value) <
                   converteData(document.getElementById("txtPrimeiraCnh").value) ) {
                  alert("A data da Primeira CNH está maior que a data de Emissão.");
                  document.getElementById("txtEmissaoCnh").focus();
                  return;
              }
          }
    }

    if (document.getElementById("txtAltura").value == "") {
        alert("Campo altura é obrigatório");
        document.getElementById("txtAltura").focus();
        return;
    } else {
        var altura = document.getElementById("txtAltura").value.replace(',','.');
        if (parseFloat(altura) < 1.0 ) {
            alert("Altura deve ser maior do que 1 m!");
            document.getElementById("txtAltura").focus();
            return;
        } else if (parseFloat(altura) > 3.5) {
            alert("Altura deve ser menor do que 3.50 m!");
            document.getElementById("txtAltura").focus();
            return;
        }

    }

    if (document.getElementById("txtPeso").value == "") {
        alert("Campo peso é obrigatório");
        document.getElementById("txtPeso").focus();
        return;
    } else {
        
        if (parseInt(document.getElementById("txtPeso").value) < 20 ) {
            alert("Peso deve ser maior do que 20 kg!");
            document.getElementById("txtPeso").focus();
            return;
        } else if (parseInt(document.getElementById("txtPeso").value) > 450) {
            alert("Peso deve ser menor do que 450 kg!");
            document.getElementById("txtPeso").focus();
            return;
        }

    }

    if (document.getElementById("cmbNumeroCalcado").selectedIndex == 0) {
        alert("Campo número do calçado é obrigatório");
        document.getElementById("cmbNumeroCalcado").focus();
        return;
    }

    if (document.getElementById("cmbTamCamisa").selectedIndex == 0) {
        alert("Campo tamanho da camisa é obrigatório");
        document.getElementById("cmbTamCamisa").focus();
        return;
    }

    if (document.getElementById("cmbTamCalca").selectedIndex == 0) {
        alert("Campo tamanho da calça é obrigatório");
        document.getElementById("cmbTamCalca").focus();
        return;
    } 

    document.getElementById("txtNome").disabled = false;
    this.document.forms[0].submit();
     
}

function encaminharPasso(destino) {
    var proximo = document.getElementById("proximoPasso").value;
    var passoAtual = (parseInt(proximo) - 1); 

    /*if (destino == 2 && proximo == 2) {
        if (validarPasso1()) return;
    } else if ((destino == 1 || destino == 3) && proximo == 3) {
        if (validarPasso2()) return;
    } else if ( (destino == 5 || destino == 3) && proximo == 5) {
        if( validarPasso4()) return;
    } else if ( (destino == 4 || destino == 2) && proximo == 4) {
        if (validarPasso3()) return;
    }*/
 
    if ((passoAtual) == 1) {
        if (validarPasso1()) return;
    } else if ((passoAtual) == 2) {
        if (validarPasso2()) return;
    } else if ((passoAtual) == 3) {
        if (validarPasso3()) return;
    } else if ((passoAtual) == 4) {
        if (validarPasso4()) return;
    }

    document.getElementById("proximoPasso").value = destino;
    document.forms[0].submit();

}

function validarPasso1() {
    
    if (document.getElementById("cmbExperiencia").value == "-1") {
        alert(" campo experiência em agroquímica é obrigatório") ;
        document.getElementById("cmbExperiencia").focus();
        return true;
         
    }            
    
    if (document.getElementById("cmbAreaInteresse1").value == "-1" && document.getElementById("cmbAreaInteresse2").value == "-1" && document.getElementById("cmbAreaInteresse3").value == "-1") {
        alert("Selecione ao menos uma área de interesse") ;
        document.getElementById("cmbAreaInteresse1").focus();
        return true;
        
    }    
    
    if (!document.getElementById("ckbTodoPais").checked) {    
        
        if (document.getElementById("cmbUF1").value == "-1" && document.getElementById("cmbUF2").value == "-1" && document.getElementById("cmbUF3").value == "-1") {
            alert("Selecione ao menos um estado") ;
            document.getElementById("cmbUF1").focus();
            return true;
            
         } 
        
        if (document.getElementById("cmbRegiaoEstado1").value == "-1" && document.getElementById("cmbRegiaoEstado2").value == "-1" && document.getElementById("cmbRegiaoEstado3").value == "-1") {
            alert("Selecione ao menos uma região do estado") ;
            document.getElementById("cmbRegiaoEstado1").focus();
            return true; 
        }


        if (document.getElementById("cmbRegiaoPais1").value == "-1" && document.getElementById("cmbRegiaoPais2").value == "-1" && document.getElementById("cmbRegiaoPais3").value == "-1") {
            alert("Selecione ao menos uma região do país") ;
            document.getElementById("cmbRegiaoPais1").focus();
            return true;

        }

        
    }
    
}

function validarPasso2() {    
      
    if (document.getElementById("cmbEscolaridade1").value == "-1" )  {
        alert(" campo escolaridade é obrigatório");
        document.getElementById("cmbEscolaridade1").focus();
        return true;
        
    }   
       

    if (document.getElementById("cmbStatus1").value == "-1" )  {   
        alert(" campo status é obrigatório");
        document.getElementById("cmbStatus1").focus();
        return true;
        
    }
 
 
    
    if (document.getElementById("cmbCurso1").value == "-1" && document.getElementById("txtOutroCurso1").value == "")  {   
        alert(" selecione um curso ou preencha o campo outro curso");
        document.getElementById("cmbCurso1").focus();
        return true;
        
    } 
    
    
    if (document.getElementById("cmbAno1").value == "-1")  {   
        alert(" campo ano é obrigatório");
        document.getElementById("cmbAno1").focus();
        return true;
        
    }
    
    if (document.getElementById("cmbInstituicao1").value == "-1" && document.getElementById("txtOutraInstituicao1").value == "")  {   
        alert(" selecione uma instituição ou preencha o campo outra instituição");
        document.getElementById("cmbInstituicao1").focus();
        return true;
        
    }    
    
    if (document.getElementById("cmbExterior1").value == "-1")  {   
        alert(" campo exterior é obrigatório");
        document.getElementById("cmbExterior1").focus();
        return true;
        
    }
    
    
    if (document.getElementById("cmbEscolaridade2").value != "-1" )  {   
        
        if (document.getElementById("cmbStatus2").value == "-1" )  {   
            alert(" campo status é obrigatório");
            document.getElementById("cmbStatus2").focus();
            return true;
            
        }
        
        if (document.getElementById("cmbCurso2").value == "-1" && document.getElementById("txtOutroCurso2").value == "")  {   
            alert(" selecione um curso ou preencha o campo outro curso");
            document.getElementById("cmbCurso2").focus();
            return true;
            
        }
        
        
        if (document.getElementById("cmbAno2").value == "-1")  {   
            alert(" campo ano é obrigatório");
            document.getElementById("cmbAno2").focus();
            return true;
            
        }
        
        if (document.getElementById("cmbInstituicao2").value == "-1" && document.getElementById("txtOutraInstituicao2").value == "")  {   
            alert(" selecione uma instituição ou preencha o campo outra instituição");
            document.getElementById("cmbInstituicao2").focus();
            return true;
            
        }    
        
        if (document.getElementById("cmbExterior2").value == "-1")  {   
            alert(" campo exterior é obrigatório");
            document.getElementById("cmbExterior2").focus();
            return true;
            
        }
        
    } 
    
    if (document.getElementById("cmbEscolaridade3").value != "-1" )  {   
        
        if (document.getElementById("cmbStatus3").value == "-1" )  {   
            alert(" campo status é obrigatório");
            document.getElementById("cmbStatus3").focus();
            return true;
            
        }
        
        if (document.getElementById("cmbCurso3").value == "-1" && document.getElementById("txtOutroCurso3").value == "")  {   
            alert(" selecione um curso ou preencha o campo outro curso");
            document.getElementById("cmbCurso3").focus();
            return true;
            
        }
        
        
        if (document.getElementById("cmbAno3").value == "-1")  {   
            alert(" campo ano é obrigatório");
            document.getElementById("cmbAno3").focus();
            return true;
            
        }
        
        if (document.getElementById("cmbInstituicao3").value == "-1" && document.getElementById("txtOutraInstituicao3").value == "")  {   
            alert(" selecione uma instituição ou preencha o campo outra instituição");
            document.getElementById("cmbInstituicao3").focus();
            return true;
            
        }
 
 
        
        if (document.getElementById("cmbExterior3").value == "-1")  {   
            alert(" campo exterior é obrigatório");
            document.getElementById("cmbExterior3").focus();
            return true;
            
        }        
    }
    
    
    
    
}

function validarPasso3() {
    var i = 0;
  
    for (i=1; i<=3; i++) {
         
        if ( (document.getElementById("txtEmpresa" + i).value != "")  && (document.getElementById("txtDataInicio" + i).value == "") )
        {
            alert("Campo Data Início é obrigatório");
            document.getElementById("txtDataInicio" + i).focus();
            return true;
        } 
        if (document.getElementById("txtDataFim" + i).value != "") {
            if ( converteData(document.getElementById("txtDataFim" + i).value) <
                   converteData(document.getElementById("txtDataInicio" + i).value)) {
                alert("A data início está maior que a data fim.");
                document.getElementById("txtDataFim"+ i).focus();
                return true;
            }
        }
    }
    
} 

function validarPasso4(){  
    for( i = 1; i <= 4; i++ ){
    
        // Pega os campos da tela e verifica
        if((document.getElementById("txtInstituicao" + i).value != "") ||
           (document.getElementById("txtCidade" + i).value != "") ||
           (document.getElementById("txtAtividades" + i).value != "")) {
               
               // Verifica se o txtCursoEstagio é nulo
               if(document.getElementById("txtCursoEstagio" + i).value == ""){
                   alert("Não é possível salvar um Curso/Estágio sem o nome do mesmo");
                   document.getElementById("txtCursoEstagio" + i).focus();
                   return true;
               }

               var dataInicioEst = "01/" + document.getElementById("cmbMesInicio" + i).value + "/" + document.getElementById("cmbAnoInicio" + i).value;
               var dataFimEst = "01/" + document.getElementById("cmbMesFim" + i).value + "/" + document.getElementById("cmbAnoFim" + i).value;

               if (converteData(dataInicioEst) > converteData(dataFimEst)) {
                    alert("Data Inicial Maior que Data Final");
                    document.getElementById("cmbMesFim" + i).focus(); 
                    return true;
              }
        }
    }
}

function masc_Cpf(objeto, ev) {
    campo = eval(objeto);
    
     var e= ev;

    if (browserIE()) {
      if (((e.keyCode < 48)  || (e.keyCode > 57)) && (e.keyCode != 8) && (e.keyCode != 0))
          e.returnValue = false;
    }
     else {
      if (((e.which < 48)  || (e.which > 57)) && (e.which != 8) && (e.which != 0))
         e.preventDefault();
     }
    
    /*if ( (event.keyCode<48 || event.keyCode>57) )
        event.returnValue = false;  */
    
    if (campo.value.length == 3) 
        campo.value = campo.value + '.';
    else if (campo.value.length == 7) 
        campo.value = campo.value + '.';
    else if (campo.value.length == 11) 
        campo.value = campo.value + '-';   
    
    
}

function verifica_checkbox() {     
    var novo;
    var velho; 
    novo = document.forms[0].rdbTipo[0];
    velho = document.forms[0].rdbTipo[1];
    
    if (novo.checked){ 
        document.forms[0].elements['senha'].disabled = true;
        document.getElementById('LayerSenha').style.visibility = 'hidden';
    }else if( velho.checked){
        document.forms[0].elements['senha'].disabled = false;
        document.getElementById('LayerSenha').style.visibility = 'visible';
    }
}

function valida_Cpf(texto){
    var cpf = texto.value;
    var filtro = /^\d{3}.\d{3}.\d{3}-\d{2}$/i;
    if(!filtro.test(cpf)){     
        return false;
    }
    
    cpf = remove(cpf, ".");
    cpf = remove(cpf, "-");
    
    if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||
    cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
    cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
    cpf == "88888888888" || cpf == "99999999999"){	  
        return false;
    }
    
    soma = 0;
    for(i = 0; i < 9; i++)
        soma += parseInt(cpf.charAt(i)) * (10 - i);
    resto = 11 - (soma % 11);
    if(resto == 10 || resto == 11)
        resto = 0;
    if(resto != parseInt(cpf.charAt(9))){	 
        return false;
    }
    soma = 0;
    for(i = 0; i < 10; i ++)
        soma += parseInt(cpf.charAt(i)) * (11 - i);
    resto = 11 - (soma % 11);
    if(resto == 10 || resto == 11)
        resto = 0;
    if(resto != parseInt(cpf.charAt(10))){     
        return false;
    }
    return true;
}

function remove(str, sub) {
    i = str.indexOf(sub);
    r = "";
    if (i == -1) return str;
    r += str.substring(0,i) + remove(str.substring(i + sub.length), sub);
    return r;
}

function msg(texto) {
    if (texto != null) {
        alert("Este CPF já está cadastrado fazer o login!!!");
        document.forms[0].rdbTipo[1].checked = true;
        verifica_checkbox();    
    }
}

function goStandard() {  
    location.href("standard.jsp");
}

function enviar(id) {               
    document.getElementById("idmensagem").value = id;    
    document.forms[0].submit();  
}

function mensagemSaida(id) {               
    document.getElementById("idmensagem").value = id;    
    document.getElementById("op").value = "retrieveSaida";
    document.forms[0].submit();  
}

function enviaMensagemMarcada() {
    document.getElementById("op").value = "update";
    document.forms[0].submit();
}

function irHome() {
    alert("Seu cadastro foi enviado com sucesso!!!\nA UNICAMPO agradece seu interesse em prestar serviços conosco!");
    //location.href = "../index.jsp";
    
    document.forms[0].submit();
}

function irMensagem() {  
    location.href("../pages/mainMensagem.jsp");
}

function marcarTodas(){           
    var qtd = document.getElementById("txtQtdMensagem").value;
    
    for (i=1;  i <= qtd ; i++) {
        
        if (document.getElementById("ckbMarcarTodas").checked)                 
            document.getElementById("ckbMarcarMensagem"  + escape(i) ).checked = true;                    
        else 
            document.getElementById("ckbMarcarMensagem"  + escape(i) ).checked = false;                                 
    }    
}

function logUsuario(texto) {
    
    if (!valida_Cpf(texto)) {
        window.alert("CPF inválido. Tente novamente.");
        texto.focus();
        return;
    }
    
    document.forms[0].submit();  
}

function enviarSenha(texto) {

    if (!valida_Cpf(texto)) {
        window.alert("CPF inválido. Tente novamente.");
        texto.focus();
        return;
    }
    document.forms[0].op.value = "enviarSenha";
    document.forms[0].submit();
}

function reload(obj) {    
    if (obj.name == "cmbUfCidade") 
        this.document.getElementById("ancora").value = "cid";                
    else
        this.document.getElementById("ancora").value = "nat";        
    
    this.document.getElementById("op").value = "retrieveCityOfState";
    
    this.document.forms[0].submit();
}

function voltarMensagem() { 
    var usuario = document.getElementById("usuario").value;
    
    if (document.getElementById("tipo").value == "retrieveEntrada")  
        location.href("../servlet/Controller?op=retrieveGroupEntrada&key=" + usuario +"&nomeClasse=unicampo.base.mensagem.MensagemBase");
    else 
        history.go(-1);
    
}

function checkTodoPais() {
    
    if (document.getElementById("ckbTodoPais").checked) {
        
        document.getElementById("trEstado").disabled = true;
        document.getElementById("trRegiaoEstado").disabled = true;
        document.getElementById("trRegiaoPais").disabled = true;
        document.getElementById("cmbUF1").value = -1;
        document.getElementById("cmbUF2").value = -1;
        document.getElementById("cmbUF3").value = -1;        
        document.getElementById("cmbRegiaoEstado1").value = -1;
        document.getElementById("cmbRegiaoEstado2").value = -1;
        document.getElementById("cmbRegiaoEstado3").value = -1;
        document.getElementById("cmbRegiaoPais1").value = -1;
        document.getElementById("cmbRegiaoPais2").value = -1;
        document.getElementById("cmbRegiaoPais3").value = -1;
    } else {
        
        document.getElementById("trEstado").disabled = false;
        document.getElementById("trRegiaoEstado").disabled = false;
        document.getElementById("trRegiaoPais").disabled = false;
        
    }
}

function habilitaCmbEmpresa() {
    var lblEmpresa = document.getElementById("lblTdEmpresa");
    var tdEmpresa = document.getElementById("tdEmpresa");    
    var lblProjeto = document.getElementById("lblTdProjeto");
    var tdProjeto = document.getElementById("tdProjeto");    
    
    if ( document.getElementById("cmbNivel").value != "4" ) {        
        lblEmpresa.style.display = "none";
        tdEmpresa.style.display = "none";          
        lblProjeto.style.display = "none";
        tdProjeto.style.display = "none";
    } else {
        lblEmpresa.style.display = "";                
        tdEmpresa.style.display = "";     
        lblProjeto.style.display = "";
        tdProjeto.style.display = "";          
    }
    
}

function loadProjeto() {    
    
    document.getElementById("op").value = "loadProjeto";
    document.forms[0].submit();
}

function enviarMensagemDestino() {    
    if (document.getElementById("txtAssunto").value == "") {
        alert("campo assunto é obrigatório");
        document.getElementById("txtAssunto").focus();
        return;
    }
    
    if (document.getElementById("cmbNivel").value == "-1") {
        alert("campo nível é obrigatório");
        document.getElementById("cmbNivel").focus();
        return;
    }
    
    if (document.getElementById("txtMensagem").value == "") {
        alert("campo mensagem é obrigatório");
        document.getElementById("txtMensagem").focus();
        return;
    } 
    
    if (document.getElementById("cmbNivel").value == "4"  && document.getElementById("cmbEmpresa").value == "-1") {
        alert("campo empresa é obrigatório");
        document.getElementById("cmbEmpresa").focus();
        return;
    }
    
    document.forms[0].submit();
    
    
}

function destinatarioMensagem(id) {
    document.getElementById("idmensagem").value = id;
    document.getElementById("op").value = "retrieveGroupDestinatario";
    document.forms[0].submit();  
}

function addOptionCidadeCurriculo(codigoCidade, descricaoCidade, componente, selecionada){
    //newOption = addOptionText( document.getElementById("cmbCidadeEndereco_" + i ), codigoCidade, descricaoCidade);
    newOption = addOptionText(document.getElementById(escape(componente)), codigoCidade, descricaoCidade);
    if(selecionada == 1){
        newOption.setAttribute("selected", "selected");
    }
}

var vlrCidadeCurriculo = "";
function carregaComboCidadeCurriculo(obj, valor) {
    vlrCidadeCurriculo = valor;
    DWRUtil.removeAllOptions("cmbCidade");
    obj.disabled = true;
    DadosCadastraisRemote.carregarCidades(obj.value, carregarCidadesCurriculo_Back);
}

function carregarCidadesCurriculo_Back(lista) {
    DWRUtil.addOptions("cmbCidade", lista, "handle", "nomeCidade");
    DWRUtil.setValue("cmbCidade", vlrCidadeCurriculo);
    document.getElementById("cmbUfCidade").disabled = false;
}

var vlrCidadeNaturalidadeCurriculo = "";
function carregaComboCidadeNaturalidadeCurriculo(obj, valor) {
    vlrCidadeNaturalidadeCurriculo = valor;
    DWRUtil.removeAllOptions("cmbCidadeNaturalidade");
    obj.disabled = true;
    DadosCadastraisRemote.carregarCidades(obj.value, carregarCidadesNaturalidadeCurriculo_Back);
}
 
function carregarCidadesNaturalidadeCurriculo_Back(lista) {
    DWRUtil.addOptions("cmbCidadeNaturalidade", lista, "handle", "nomeCidade");
    DWRUtil.setValue("cmbCidadeNaturalidade", vlrCidadeNaturalidadeCurriculo);
    document.getElementById("cmbUfNaturalidade").disabled = false;
}

function limparOutrosCurso(obj,item) {  
    
    if (obj.value !=  -1 ) {
        document.getElementById("txtOutroCurso" + item).value = "";
        document.getElementById("txtOutroCurso" + item).disabled = true;
    } else {
        document.getElementById("txtOutroCurso" + item).disabled = false;
    }

}

function limparOutrosInstituicao(obj,item) {
    
    if (obj.value !=  -1 ) {
        document.getElementById("txtOutraInstituicao" + item).value = "";
        document.getElementById("txtOutraInstituicao" + item).disabled = true;
    } else {
        document.getElementById("txtOutraInstituicao" + item).disabled = false;
    }

}

var posCurso; 
function carregarCursoByTipo(obj) {    
    posCurso = obj.name.substring(obj.name.length -1, obj.name.length);    
    DWRUtil.removeAllOptions("cmbCurso" + posCurso);    
    CursoRemote.carregarCursos(obj.value, carregarCursoByTipo_Back);
}   
  
function carregarCursoByTipo_Back(lista) {    
    DWRUtil.addOptions("cmbCurso" + posCurso, lista, "handle", "nomeCurso");
    DWRUtil.setValue("cmbCurso" + posCurso, document.getElementById("hidVlrCurso" + posCurso).value);
}

var posCursoCurriculoAjax; 
function carregarCursoCurriculoAjax(obj) {
    posCursoCurriculoAjax = obj.name.substring(obj.name.length -1, obj.name.length);
    DWRUtil.removeAllOptions("cmbCurso" + posCursoCurriculoAjax);
    CursoRemote.carregarCursos(obj.value, carregarCursoCurriculoAjax_Back);    
}

function carregarCursoCurriculoAjax_Back(lista) {
   DWRUtil.addOptions("cmbCurso" + posCursoCurriculoAjax, lista, "handle", "nomeCurso");
   DWRUtil.setValue("cmbCurso" + posCursoCurriculoAjax, document.getElementById("hidVlrCurso" + posCursoCurriculoAjax).value);

   var incr = parseInt(posCursoCurriculoAjax) + 1;
   

   if (incr != 5) {
       carregarCursoCurriculoAjax(document.getElementById("cmbEscolaridade" + incr));
   }
}

function cancelarCurriculo() {
    window.location = "../pages/loginCurriculo.jsp";
}
