﻿function checkEmail(val) {
	//expressão regular para validar o formato do email
	expreg = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	
	if (expreg.test(val)) {
		return true;
	} else {
		return false;
	}
}


function float2moeda(num) {
   x = 0;
   if(num<0) {
      num = Math.abs(num);
      x = 1;
   }
   
   if(isNaN(num)) num = "0";
      cents = Math.floor((num*100+0.5)%100);

   num = Math.floor((num*100+0.5)/100).toString();

   if(cents < 10) cents = "0" + cents;
      for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
         num = num.substring(0,num.length-(4*i+3))+'.'+num.substring(num.length-(4*i+3));
	
	ret = num + ',' + cents;
	if (x == 1) ret = ' - ' + ret;return ret;
}


function completeDate(objtxt) {
	txt = objtxt.name;
	val = objtxt.value;
	if (val != "/") {
		if (val.length == 2) {
			val += "/";
		}
		if (val.length == 5) {
			val += "/";
		}
		objtxt.value = val;
	} 
	else {
		objtxt.value = "";
	}
}

/* Javascript do arquivo inscricao.php */

function verifica() {



//Validações dos campos

	if (document.form2.nome.value=="") { 

		alert("O Campo NOME deve ser preenchido.");

		document.form2.nome.focus();

		return false;

		}

	if (document.form2.nascimento.value==""){

		alert("O Campo NASCIMENTO deve ser preenchido.");

		document.form2.nascimento.focus();

		return false;

	}

	if (document.form2.endereco.value==""){

		alert("O Campo ENDEREÇO deve ser preenchido.");

		document.form2.endereco.focus();

		return false;

	}

	if (document.form2.bairro.value==""){

		alert("O Campo BAIRRO deve ser preenchido.");

		document.form2.bairro.focus();

		return false;

	}

	if (document.form2.cidade.value==""){

		alert("O Campo CIDADE deve ser preenchido.");

		document.form2.cidade.focus();

		return false;

	}

	if (document.form2.cep.value==""){

		alert("O Campo CEP deve ser preenchido.");

		document.form2.cep.focus();

		return false;

	}

	if (document.form2.salario.value==""){

		alert("O Campo RENDA FAMILIAR deve ser preenchido.");

		document.form2.salario.focus();

		return false;

	}

	if (document.form2.num_dep.value==""){

		alert("O Campo DEPENDENTES DA RENDA FAMILIAR deve ser preenchido.");

		document.form2.num_dep.focus();

		return false;

	}

	if (document.form2.vest_radio.checked==false && document.form2.vest_tv.checked==false && document.form2.outros_vest.checked==false){

		alert("Informe como ficou sabendo do PROCESSO SELETIVO.");

		document.form2.vest_radio.focus();

		return false;

	}

	if (document.form2.particular.checked==false && document.form2.estadual_urbana.checked==false && document.form2.estadual_rural.checked==false

		&& document.form2.federal_urbana.checked==false && document.form2.federal_rural.checked==false

		&& document.form2.municipal_urbana.checked==false && document.form2.municipal_rural.checked==false && 

		document.form2.escola_outra.checked==false){

		alert("Informe onde você obteve seu GRAU DE INSTRUÇÃO.");

		document.form2.particular.focus();

		return false;

	}

}