// dadosAjax

function loadAcoes(){
	
	if(eLementos('btEnviar')){
		eLementos('btEnviar').onclick = function(){
			//conta palavras
			var texto = eLementos('texto').value;
			var myArr = new Array();
			var myString = new String();
			myString = texto; 			
			myArr = myString.split(" "); 			
			for(var i=0;i<myArr.length;i++)
			{
				//document.write("Array Index " + i + " = " + myArr[i] + "<br />");
			} 
			if (i > 20 ){
				alert("Este campo texto esta limitado em 20 palavras!")
				document.all.texto.focus();
				return false;
			}
			if(valCampo('texto',1,'um texto!')==false) return false;
			if(valCampo('nome',1,'o nome!')==false) return false;
			if(valCampo('cpf',14,'o cpf!')==false) return false;
			if(valCampo('endereco',1,'o endereço!')==false) return false;
			if(valCampo('bairro',1,'o bairro!')==false) return false;
			if(valCampo('cidade',1,'a cidade!')==false) return false;
			if(valCampo('uf',2,'o estado!')==false) return false;
			if(valCampo('cep',9,'o cep!')==false) return false;
			if(valCampo('tel_residencial',12,'o tel. residencial com DDD!')==false) return false;
			if(valCampo('tel_comercial',12,'o tel. comercial com DDD!')==false) return false;
			if (document.all.sexo[0].checked==false && document.all.sexo[1].checked==false ){
				alert("Favor informar o sexo!")
				document.all.tel_residencial.focus();
				return false;
			}
			if(valCampo('nascimento_dia',1,'o dia do nascimento!')==false) return false;
			if(valCampo('nascimento_mes',1,'o mês do nascimento!')==false) return false;
			if(valCampo('nascimento_ano',1,'o ano do nascimento!')==false) return false;
			//validarData('nascimento_dia')
			//if(valCampo('data_casamento_dia',1,'o dia do casamento!')==false) return false;
			//if(valCampo('data_casamento_mes',1,'o mês do casamento!')==false) return false;
			//if(valCampo('data_casamento_ano',1,'o ano do casamento!')==false) return false;
			//if(valCampo('data_aniv_conjugue_dia',1,'o dia do aniv. do cônjugue!')==false) return false;
			//if(valCampo('data_aniv_conjugue_mes',1,'o mês do aniv. do cônjugue!')==false) return false;
			//if(valCampo('data_aniv_conjugue_ano',1,'o ano do aniv. do cônjugue!')==false) return false;
			//if(valCampo('nome_conjugue',1,'o nome do cônjugue!')==false) return false;
			if(valCampo('profissao_cargo',1,'a sua profissão/cargo!')==false) return false;
			if(valCampo('email',1,'o seu e-mail!')==false) return false;
			if(valMail('email')==false) return false;
		
			eLementos('frm_concursoculturalkurotel').submit();
		}		
	}
	
		
}






//---------------------funções--------------------//
function valCampo(campo,qtd,desc){
	if(qtd==0)qtd=1;
	var objCampo = document.getElementById(campo);
		if (objCampo.value.length < qtd) {
			alert("Favor digitar " + desc );
			objCampo.focus();
			return false;
		}		
}


function eLementos(recebeId){
		return document.getElementById(recebeId);
}

function exibeObj(linha) {
	if (eLementos(linha).style.display=='none') {
   		eLementos(linha).style.display='';
  	} else {
   		eLementos(linha).style.display='none';
  	}
}

	
function isEmail(str){
	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
  	if (!supported)
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		return (!r1.test(str) && r2.test(str));
}

function valMail(email){
	var objMail = document.getElementById(email);
	var invalid, s;		
	if (objMail.value == '' ) {
		alert('Favor digitar o e-mail.');
		objMail.focus();
		return false;
	}else{
		if (isEmail(objMail.value)==false ) {
			alert('Favor digitar o e-mail corretamente.');
			objMail.focus();
			return false;
		}
	}			
}


function Mascara(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 validarData(campo){alert(campo)
	var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
	var msgErro = 'Formato inválido de data.';
	if ((document.getElementById(campo).value.match(expReg)) && (document.getElementById(campo).value!='')){
	var dia = document.getElementById(campo).value.substring(0,2);
	var mes = document.getElementById(campo).value.substring(3,5);
	var ano = document.getElementById(campo).value.substring(6,10);
	if(mes==4 || mes==6 || mes==9 || mes==11 && dia > 30){
	alert("Dia incorreto !!! O mês especificado contém no máximo 30 dias.");
	return false;
	} else{
	if(ano%4!=0 && mes==2 && dia>28){
	alert("Data incorreta!! O mês especificado contém no máximo 28 dias.");
	return false;
	} else{
	if(ano%4==0 && mes==2 && dia>29){
	alert("Data incorreta!! O mês especificado contém no máximo 29 dias.");
	return false;
	} else{ 
	alert ("Data correta!");
	return true;
	}}}} else {
	alert(msgErro);
	document.getElementById(campo).focus();
	return false;
	}
}
