// JavaScript Document


//VALIDAR FORMULARIO DO FALE CONOSCO
function validaFormFale(){
	//validar nome
	d = document.form_fale;
	if (d.nome.value == ""){
		alert("O campo nome deve ser preenchido!");
		d.nome.focus();
		return false;
	}
	//validar email
	if (d.email_remetente.value == ""){
		alert("O campo e-mail deve ser preenchido!");
		d.email_remetente.focus();
		return false;
	}
	//validar email(verificao de endereco eletronico)
	parte1 = d.email_remetente.value.indexOf("@");
	parte2 = d.email_remetente.value.length;
	if (!(parte1 >= 2 && parte2 >= 5)) {
		alert("O campo e-mail deve conter um endereco eletrônico!");
		d.email_remetente.focus();
		return false;
	}
	//validar mensagem
	if (d.mensagem.value == ""){
		alert("O campo mensagem deve ser preenchido!");
		d.mensagem.focus();
		return false;
	}
	return true;
}


//VALIDAR FORMULARIO DO FALE CONOSCO
function validaFormInscricao(){
	d = document.inscricao;
	cpf = d.strParCpf.value;
	erro = new String;
	if (cpf.length < 11) erro += "São necesários 11 digitos para verificação do CPF! \n\n";
	var nonNumbers = /\D/;
	if (nonNumbers.test(cpf)) erro += "A verificação do CPF suporta apenas números! \n\n";
	if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
		 erro += "CPF inválido!"
	}
	var a = [];
	var b = new Number;
	var c = 11;
	for (i=0; i<11; i++){
		   a[i] = cpf.charAt(i);
		   if (i < 9) b += (a[i] * --c);
	}
	if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	b = 0;
	c = 11;
	for (y=0; y<10; y++) b += (a[y] * c--);
	if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
		   erro +="CPF Inválido!";
	}
	if (erro.length > 0){
		   alert(erro);
		   d.cpf.focus();
		   return false;
	}
	return true;
}


function showHide(valor) {
	var objEstudante = document.getElementById("estudante");
	var objProfissional = document.getElementById("profissional");
	var objInstituicao = document.getElementById("strParInstituicao");
	var objPeriodo = document.getElementById("strParPeriodo");
	if((valor == "estudante_fasete") || (valor == "estudante_fasete_uniasselvi") || (valor == "egresso_fasete") || (valor == "estudante_externo")) {
		objEstudante.className = "";
		objProfissional.className = "ocultaObj";
	}else{
		objEstudante.className = "ocultaObj";
		objProfissional.className = "";
		objInstituicao.value = "";
		objPeriodo.value = "";
	}
	if(valor == "estudante_fasete"){
		objPeriodo.value = "";
		objInstituicao.value = "FASETE";
	}
	if(valor == "estudante_fasete_uniasselvi"){
		objPeriodo.value = "";
		objInstituicao.value = "FASETE EAD/UNIASSELVI";
	}
	if(valor == "egresso_fasete"){
		objPeriodo.value = "-";
		objInstituicao.value = "FASETE";
	}
	if(valor == "estudante_externo"){
		objPeriodo.value = "";
		objInstituicao.value = "";
	}
}


