// JavaScript Document

//FUNÇÃO QUE PERMITE APENAS A ENTRADE DE NÚMEROS
function Tecla(e){
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		if (tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else{
			if (tecla != 8) // backspace
				event.keyCode = 0;
				//return false;
			else
				return true;
		}
}
//=========================================================================================================

//FUNÇÃO PARA VERIFICAÇÃO DA PRIMEIRA ETAPA
function verifica_cad01() {
	with(document.form1) {
		if (nome.value == "") {
			alert("Preencha o campo Nome");
			nome.focus();
			return false; 
		}
		if (sexo.value == "") {
			alert("Preencha o campo Sexo");
			sexo.focus();
			return false; 
		}
		if (nasc_dia.value == "") {
			alert("Preencha o campo Data de Nascimento");
			nasc_dia.focus();
			return false; 
		}
		if (nasc_mes.value == "") {
			alert("Preencha o campo Data de Nascimento");
			nasc_mes.focus();
			return false; 
		}
		if (nasc_ano.value == "") {
			alert("Preencha o campo Data de Nascimento");
			nasc_ano.focus();
			return false; 
		}
		if (cidade_nat.value == "") {
			alert("Preencha o campo Cidade Natal");
			cidade_nat.focus();
			return false; 
		}
		if (estado_nat.value == "") {
			alert("Preencha o campo Estado Natal");
			estado_nat.focus();
			return false; 
		}
		if (est_civil.value == "") {
			alert("Preencha o campo Estado Civil");
			est_civil.focus();
			return false; 
		}
		if (cpf.value == "") {
			alert("Preencha o campo CPF");
			cpf.focus();
			return false; 
		}
		if (rg.value == "") {
			alert("Preencha o campo RG");
			rg.focus();
			return false; 
		}
		if (rg_uf.value == "") {
			alert("Preencha o campo UF de seu RG");
			rg_uf.focus();
			return false; 
		}
		if (rua.value == "") {
			alert("Preencha o campo Rua / Avenida");
			rua.focus();
			return false; 
		}
		if (numero.value == "") {
			alert("Preencha o campo Número");
			numero.focus();
			return false; 
		}
		if (bairro.value == "") {
			alert("Preencha o campo Bairro");
			bairro.focus();
			return false; 
		}
		if (cidade.value == "") {
			alert("Preencha o campo Cidade");
			cidade.focus();
			return false; 
		}
		if (estado.value == "") {
			alert("Preencha o campo Estado");
			estado.focus();
			return false; 
		}
		if (cep.value == "") {
			alert("Preencha o campo CEP");
			cep.focus();
			return false; 
		}
		if (ddd1.value == "") {
			alert("Preencha o campo DDD");
			ddd1.focus();
			return false; 
		}
		if (ddd1.value.lemgth <=1) {
			alert("O campo DDD está incorreto");
			ddd1.focus();
			return false; 
		}
		if (ddd1.value.lemgth <=8) {
			alert("O campo Telefone está incorreto");
			ddd1.focus();
			return false; 
		}
		if (fone1.value == "") {
			alert("Preencha o campo Telefone");
			fone1.focus();
			return false; 
		}
		if (email.value == "") {
			alert("Informe seu e-mail");
			email.focus();
			return false;
		}
		else {
			prim = email.value.indexOf("@")
			if(prim < 2) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("@",prim + 1) != -1) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf(".") < 1) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf(" ") != -1) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("zipmeil.com") > 0) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("hotmeil.com") > 0) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf(".@") > 0) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("@.") > 0) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf(".com.br.") > 0) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("/") > 0) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("[") > 0) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("]") > 0) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("(") > 0) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf(")") > 0) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("..") > 0) {
				alert("O e-mail informado parece não estar correto");
				email.focus();
				email.select();
				return false;
			}
		//return true;
		}
		if( (nece_especiais == "Não") && (qual_nece_especiais != "") ){
			alert("O campo Necesidades Especiais está Incorreto");
			qual_nece_especiais.focus();
			return false;
		}
		if((nece_especiais == "Sim") && (qual_nece_especiais == "") ){
			alert("Selecione o campo Necesidades Especiais está Incorreto");
			qual_nece_especiais.focus();
			return false;
		}
	}	
	var i = 0;
	var n_checked = 0;
	var error = 0;
	var error_message = "";
	var cpf = document.form1.cpf.value;
	
	if (cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999") {
		error_message = "Por favor digite um CPF válido!\n";
		error = 1;
	}
	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))) {
		error_message = "Por favor digite um CPF válido!\n";
		error = 1;
	}
	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))) {
		error_message = "Por favor digite um CPF válido!\n";
		error = 1;
	}
	if (error == 1) {
		alert(error_message);
		return false;
	} else {
		return true;
	}
}
//=========================================================================================================
function verifica_cad02() {
	with(document.form2) {
		if (interesse1.value == "") {
			alert("Preencha o campo: interesse");
			interesse1.focus();
			return false;				
		}
		if (salario1.value == "") {
			alert("Preencha o campo: salário");
			salario1.focus();
			return false;				
		}
		if (horames1.value == "") {
			alert("Preencha o campo: Hora/Mês");
			horames1.focus();
			return false;				
		}
		if (horames1.value == "M" && salario1.value.length <= 2) {
			alert("O campo salário está incorreto");
			salario1.focus();
			return false;				
		}
		if (horames1.value == "H" && salario1.value.length >= 2) {
			alert("O campo salário está incorreto");
			salario1.focus();
			return false;				
		}
		if (horames2.value == "M" && salario2.value.length <= 2) {
			alert("O campo salário está incorreto");
			salario2.focus();
			return false;				
		}
		if (horames2.value == "H" && salario2.value.length >= 2) {
			alert("O campo salário está incorreto");
			salario2.focus();
			return false;				
		}
		if (horames3.value == "M" && salario3.value.length <= 2) {
			alert("O campo salário está incorreto");
			salario3.focus();
			return false;				
		}
		if (horames3.value == "H" && salario3.value.length >= 2) {
			alert("O campo salário está incorreto");
			salario3.focus();
			return false;				
		}
	}
}
//========================================================================================================
//FUNÇÃO PARA VERIFICAÇÃO DA 3ª ETAPA
function verifica_cad03() {
	with(document.form3) {
		//formulario 1
		if (funcao.value != "") {
			if(instituicao.value == ""){	
				alert("Preencha o campo instituição");
				instituicao.focus();
				return false;				
			}
			if(adm_mes.value == "" ){	
				alert("Preencha o mês de admissão");
				adm_mes.focus();
				return false;				
			} 
			if(adm_ano.value == "" ){	
				alert("Preencha o ano de admissão");
				adm_ano.focus();
				return false;				
			} 
			if (saida_ano.value != "" && saida_mes.value != "") {
				if(saida_ano.value.concat(saida_mes.value) < adm_ano.value.concat(adm_mes.value) ) {
					alert('Verifique as Datas de Admissão e Saída');
					saida_mes.focus();
					return false;
				}	
			}	
		}	
	}
}
//=========================================================================================================

//FUNÇÃO PARA VERIFICAÇÃO DA 4ª ETAPA
function verifica_cad04() {
	with(document.form4) {
		if (formacao.value != "Selecione"){
			if(instituicao.value == "") {	
				alert("Preencha os Campos: Instituição");
				instituicao.focus();
				return false;					
			}
		}
	}
}				
//=========================================================================================================
//FUNÇÃO PARA VERIFICAÇÃO DA 5ª ETAPA
function verifica_cad05() {
	with(document.form5) {
		//especializações, mestrados e doutorados
		//formulario 1
		if (tipo.value != "Selecione") {
			if(nome.value == ""){	
				alert("Preencha o campo: nome");
				nome.focus();
				return false;				
			}
			if(instituicao.value == ""){
				alert("Preencha o campo: instituição");
				instituicao.focus();
				return false;
			}	
		}
	}
}

//=========================================================================================================
//FUNÇÃO PARA VERIFICAÇÃO DA 6ª ETAPA
function verifica_cad06() {
	with(document.form6) {		
		if (curso.value != "") {
			if(local.value == "") {	
				alert("Preencha o campo: local");
				local.focus();
				return false;				
			}
			if(comentario.value == "") {	
				alert("Preencha o campo: comentário");
				comentario.focus();
				return false;				
			}				
		}
	}
}	
//=========================================================================================================

//CADASTRO DE ESCOLA
function verifica_escola(){
	with(document.f_escola) {
		if (instituicao.value == "") {
			alert("Preencha o campo Instituicao!");
			instituicao.focus();
			return false; 
		}
		if (endereco.value == "") {
			alert("Preencha o campo Endereço");
			endereco.focus();
			return false; 
		}
		if (numero.value == "") {
			alert("Preencha o campo Número");
			numero.focus();
			return false; 
		}
		if (cep.value == "") {
			alert("Preencha o campo CEP");
			cep.focus();
			return false; 
		}
		if (bairro.value == "") {
			alert("Preencha o campo Bairro");
			bairro.focus();
			return false; 
		}
		if (cidade.value == "") {
			alert("Preencha o campo Cidade");
			cidade.focus();
			return false; 
		}
		if (estado.value == "") {
			alert("Preencha o campo Estado");
			estado.focus();
			return false; 
		}
		if (ddd1.value == "") {
			alert("Preencha o campo DDD");
			ddd1.focus();
			return false; 
		}
		if (ddd1.value.length <= 1) {
			alert("O campo DDD está incorreto");
			ddd1.focus();
			return false; 
		}
		if (fone1.value == "") {
			alert("Preencha o campo Telefone");
			fone1.focus();
			return false; 
		}
		if (fone1.value.length <= 7) {
			alert("O campo telefone está incorreto");
			fone1.focus();
			return false; 
		}
		if (ddd2.value != "" || fone2.value != "") {
			if (ddd2.value.length <= 1) {
				alert("O campo DDD está incorreto");
				ddd2.focus();
				return false; 
			}
			if (fone2.value.length <= 7) {
				alert("O campo telefone está incorreto");
				fone2.focus();
				return false; 
			}
		}
		if (email.value == "") {
			alert("Informe seu e-mail.");
			email.focus();
			return false;
		}
		else {
			prim = email.value.indexOf("@")
			if(prim < 2) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("@",prim + 1) != -1) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf(".") < 1) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf(" ") != -1) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("zipmeil.com") > 0) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("hotmeil.com") > 0) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf(".@") > 0) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("@.") > 0) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf(".com.br.") > 0) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("/") > 0) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("[") > 0) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("]") > 0) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("(") > 0) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf(")") > 0) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
			if(email.value.indexOf("..") > 0) {
				alert("O e-mail informado parece não estar correto.");
				email.focus();
				email.select();
				return false;
			}
		//return true;
		}
		if (contato.value == "") {
			alert("Preencha o campo Contato");
			contato.focus();
			return false; 
		}
		if (prof_contato.value == "") {
			alert("Preencha o campo Função do contato");
			prof_contato.focus();
			return false; 
		}
	}		
}

//=========================================================================================================
function verifica_contato() {
	with(document.f_contato) {
	if (nome.value == "") {
		alert("Preencha o campo nome!");
		nome.focus();
		return false; 
	}
	if (email.value == "") {
		alert("Informe seu e-mail.");
		email.focus();
		return false;
	}
	else {
		prim = email.value.indexOf("@")
		if(prim < 2) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf("@",prim + 1) != -1) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf(".") < 1) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf(" ") != -1) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf("zipmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf("hotmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf(".@") > 0) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf("@.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf(".com.br.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf("/") > 0) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf("[") > 0) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf("]") > 0) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf("(") > 0) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf(")") > 0) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		if(email.value.indexOf("..") > 0) {
			alert("O e-mail informado parece não estar correto.");
			email.focus();
			email.select();
			return false;
		}
		return true;
	}
	if (assunto.value == "") {
		alert("Preencha o campo assunto!");
		assunto.focus();
		return false; 
	}
	if (mensagem.value == "") {
		alert("Preencha o campo Mensagem!");
		mensagem.focus();
		return false; 
	}
	submit();
	}
}
//========================================================================================================

function verifica_vaga() {
	with(document.f_vaga) {
		if (nome.value == "") {
			alert("Preencha o campo nome!");
			nome.focus();
			return false; 
		}
		if (cod_can.value == "") {
			alert("Preencha o campo cod_can!");
			cod_can.focus();
			return false; 
		}
		if (cod_vaga.value == "") {
			alert("Informe o código da vaga.");
			cod_vaga.focus();
			return false;
		}
		if (nome_vaga.value == "") {
			alert("Preencha o campo nome vaga!");
			nome_vaga.focus();
			return false; 
		}
		if (comentario.value == "") {
			alert("Preencha o campo comentário!");
			comentario_vaga.focus();
			return false; 
		}
	}
}
//========================================================================================================

function MM_formtCep(e,src,mask) {
if(window.event) { _TXT = e.keyCode; } 
else if(e.which) { _TXT = e.which; }
if(_TXT > 47 && _TXT < 58) { 
 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); } 
    return true; } else { if (_TXT != 8) { return false; } 
 else { return true; }
}
}
//========================================================================================================
function confirma() {
	if(confirm('Deseja mesmo excluir?')){
		janela();
		return true;
	}	 
	else { 
	  	return false;
	}
}
//========================================================================================================
function procuraEnter(evt) { 
evt = (evt) ? evt : event 
var c = (evt.which) ? evt.which : evt.keyCode 
if (c == 13) { 
documents.forms[0].submit() 
return false 
} 
return true 
}

function validar()
{
	if (document.forms[0].login.value == "") {
			alert("O campo Login deve ser preenchido");
			this.document.forms[0].login.focus();
			return false; 
	}
	
	if (document.forms[0].senha.value == "") {
			alert("O campo Senha deve ser preenchido");
			document.forms[0].senha.focus();
			return false; 
	}
}
