// #############################   FUNÇÕES BÁSICAS Do LeCiOnAr   ############################



function FormataCpf(campo, teclapres){
	var tecla = teclapres.keyCode;
	var vr = new String(campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");
	tam = vr.length + 1;
	if (tecla != 14)
	{
		if (tam == 4)
			campo.value = vr.substr(0, 3) + '.';
		if (tam == 7)
			campo.value = vr.substr(0, 3) + '.' + vr.substr(3, 6) + '.';
		if (tam == 11)
			campo.value = vr.substr(0, 3) + '.' + vr.substr(3, 3) + '.' + vr.substr(7, 3) + '-' + vr.substr(11, 2);
	}
}

function FormataCep(campo, teclapres){
	var tecla = teclapres.keyCode;
	var vr = new String(campo.value);
	vr = vr.replace("-", "");
	tam = vr.length + 1;
	if (tecla != 14)
	{
		if (tam == 6)
			campo.value = vr.substr(0, 5) + '-';
	}
}

function Formatadata(Campo, teclapres)
{
	var tecla = teclapres.keyCode;
	var vr = new String(Campo.value);
	vr = vr.replace("/", "");
	vr = vr.replace("/", "");
	vr = vr.replace("/", "");
	tam = vr.length + 1;
	if (tecla != 8 && tecla != 8)
	{	
		if(tecla >= '48' && tecla <= '57' || tecla >= '96' && tecla <= '105'){
			
			if (tam > 0 && tam < 2)
				Campo.value = vr.substr(0, 2) ;
			if (tam > 2 && tam < 4)
				Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, 2);
			if (tam > 4 && tam < 7)
				Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, 2) + '/' + vr.substr(4, 7);
		}else Campo.value = Campo.value.substr(0, Campo.value.length-1);
	}
}




function validacao(){
	nome = document.getElementById('nome').value;
	endereco = document.getElementById('endereco').value;
	cpf = document.getElementById('cpf').value;
	email = document.getElementById('email').value;
	telefone = document.getElementById('telefone').value;
	evento_id = document.getElementById('evento_id').value;
	
	var erro = new Array();
	num=0;
	if(nome == ''){
		erro[num] = "<div style='color:red;'>* Preencha o campo Nome!</div>";
		num++;
		$('#erro0').html("<div style='color:red;'>* Preencha o campo Nome!</div").show().fadeOut(5000);
	}
	
	if(endereco == ''){
		erro[num] = "<div style='color:red;'>* Preencha o campo endereco!</div>";
		num++;
		$('#erro1').html("<div style='color:red;'>* Preencha o campo endereco!</div>").show().fadeOut(5000);
	}
	
	if(cpf == ''){
		erro[num] = "<div style='color:red;'>* Preencha o campo cpf!</div>";
		num++;
		$('#erro2').html("<div style='color:red;'>* Preencha o campo cpf!</div>").show().fadeOut(5000);
	}
	
	if(email == ''){
		erro[num] = "<div style='color:red;'>* Preencha o campo email!</div>";
		num++;
		$('#erro3').html("<div style='color:red;'>* Preencha o campo email!</div>").show().fadeOut(5000);
	}
	
	if(telefone == ''){
		erro[num] = "<div style='color:red;'>* Preencha o campo telefone!</div>";
		num++;
		$('#erro4').html("<div style='color:red;'>* Preencha o campo telefone!</div>").show().fadeOut(5000);
	}
	
	if(evento_id == ''){
		erro[num] = "<div style='color:red;'>* Escolha o Evento!</div>";
		num++;
		$('#erro5').html("<div style='color:red;'>* Escolha o Evento!</div>").show().fadeOut(5000);
	}
	
	
	if(num == 0)
		document.cadastroParticipantes.submit();
	
}

function latteson(){
	document.getElementById('curriculo_lates').value = "";
	
}

