﻿


function valida_time() {
    nome                = $("#nome");
    rg                  = $("#rg");
    cpf                 = $("#cpf");
    nascimento          = $("#nascimento");
    localnascimento     = $("#localnascimento");
    filiacao            = $("#filiacao");
    email               = $("#email");
    telefone            = $("#telefone");
    celular             = $("#celular");
    estado              = $("#estado");
    cidade              = $("#cidade");
    endereco            = $("#endereco");
    bairro              = $("#bairro");
    nacionalidade       = $("#nacionalidade");
    curriculo           =$("#file");

    if(nome.val() == "") {
        alert("Preencha seu nome.");
        nome.focus();
        return false;
    }
    if(rg.val() == "") {
        alert("Preencha seu RG.");
        rg.focus();
        return false;
    }
    if(cpf.val() == "") {
        alert("Preencha seu CPF.");
        cpf.focus();
        return false;
    }
    if(nascimento.val() == "") {
        alert("Preencha sua data de nascimento.");
        nascimento.focus();
        return false;
    }
    if(localnascimento.val() == "") {
        alert("Preencha o Local do seu nascimento.");
        localnascimento.focus();
        return false;
    }
    if(filiacao.val() == "") {
        alert("Preencha a Filiação");
        filiacao.focus();
        return false;
    }
    if(email.val() == "") {
        alert("Preencha seu email.");
        email.focus();
        return false;
    }
    if(!checkMail(email.val())) {
        alert("Preencha seu email corretamente.");
        email.focus();
        return false;
    }
    if(telefone.val() == "") {
        alert("Preencha seu Telefone com DDD.");
        telefone.focus();
        return false;
    }
    if(estado.val() == "") {
        alert("Selecione um estado.");
        estado.focus();
        return false;
    }
    if(cidade.val() == "") {
        alert("Selecione uma cidade.");
        cidade.focus();
        return false;
    }
    if(endereco.val() == "") {
        alert("Preencha seu endereço.");
        endereco.focus();
        return false;
    }
    if(bairro.val() == "") {
        alert("Preencha seu bairro.");
        bairro.focus();
        return false;
    }
	
	
    if ($('input[type=checkbox][name=interesse[]]:checked').length == 0){
        alert("Escolha seu[s] Interesse[s].");
        return false;
    }else if($('input[type=checkbox][name=cargo[]]:checked').length == 0){
        alert("Escolha o[s] Cargo[s].");
        return false
    }
	
	
	if(curriculo.val() == "") {
        alert("Selecione o arquivo");
        curriculo.focus();
        return false;
    }
	

   return true
}


  
function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){
            return true;
        }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
            return true;
        }
    }else{
        return false;
    }
}
