 // JavaScript Document
 
 var form_alterado = 0;



 //VALIDA E-MAIL

 function validar_email(elemento,valor) {



	 var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

     if(valor=='') { 

	     return true; 

	 } else if(!regex.test(valor)) {

		 return false;

	 }

	 return true;

 }

 //*************************************************************************************************





 //VALIDA CPF

 function validar_cpf(elemento,valor) {



	 if(valor=='') { 

		 return true;

	 }

	 cpf = valor;

	 var caracteres = '1234567890'

 	 for (x = 0; x < cpf.length; x ++) {

	 	 if (caracteres.indexOf(cpf.charAt(x), 0) == -1 ) {			

			 cpf = cpf.replace(cpf.charAt(x),'')

			 x --;

		 }

	 }

	

	 if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||

	    cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||

	    cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||

	    cpf == "88888888888" || cpf == "99999999999") {

		 return false;

	 }

	

	 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))) {

		 return false;

	 }

	 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))){

		 return false;

	 }

	 return true;

 }

 //*************************************************************************************************





 //VALIDA CNPJ

 function validar_cnpj(elemento,valor) {

		return true;


    if(!(valor = /^\d?(\d{2})\.?(\d{3})\.?(\d{3})\/?(\d{4})\-?(\d{2})/.exec(valor)))

		return false;

		

	var sum1 = 0, sum2 = 0, sum3 = 0, calc1 = 5, calc2 = 6;

	

	valor.shift();

	valor = valor.join("");

	

	for (var i=0; i <= 12; i++) {

		calc1 = (calc1 < 2) ? 9 : calc1;

		calc2 = (calc2 < 2) ? 9 : calc2;



		if (i <= 11)

			sum1 += valor[i] * calc1;



		sum2 += valor[i] * calc2;

		sum3 += valor[i];

		calc1--;

		calc2--;

	}

	

	sum1 %= 11;

	sum2 %= 11;



	return (sum3 && valor[12] == (sum1 < 2 ? 0 : 11 - sum1) && valor[13] == (sum2 < 2 ? 0 : 11 - sum2)) ? true : false; 

 }

 //*************************************************************************************************





 //VALIDA IE

 function validar_ie(elemento,valor) {



     var regex = /\d{3}\.\d{3}\.\d{3}\.\d{3}/

	 

	 if(valor=='') { 

	     return true; 

	 } else if(!regex.test(valor)) {

		 return false;

	 }

	 return true;

 }

 //*************************************************************************************************





 //VALIDA IM

 function validar_im(elemento,valor) {



	 return true;

 }

 //*************************************************************************************************





 //VALIDA CEP

 function validar_cep(elemento,valor) {



     var regex = /\d{5}\-\d{3}/

	 

	 if(valor=='') { 

	     return true; 

	 } else if(!regex.test(valor)) {

		 return false;

	 }

	 return true;

 }

 //*************************************************************************************************





 //VALIDA TELEFONE

 function validar_telefone(elemento,valor) {

	 

	 //9999-9999

	 if(/^[0-9]{4}-[0-9]{4}$/.exec(valor)) { 

	     return true; 

	 //999-9999

	 } else if(/^[0-9]{3}-[0-9]{4}$/.exec(valor)) { 

	     return true; 

	 //0800 999 9999

	 } else if(/^[0-9]{4} [0-9]{3} [0-9]{4}$/.exec(valor)) { 

         return true; 

	 //0800 99 9999

	 } else if(/^[0-9]{4} [0-9]{2} [0-9]{4}$/.exec(valor)) { 

	     return true; 

	 //vazio

	 } else if(valor=='') { 

	     return true; 

	 }

	 return false;

 }

 //*************************************************************************************************





 //VALIDA DATA

 function validar_data(elemento,valor) {



     if(valor=='') { 

	     return true;

	 }

     var expReg  = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;

	 if((valor.match(expReg)) && (valor!='')) {

		 var dia = valor.substring(0,2);

		 var mes = valor.substring(3,5);

		 var ano = valor.substring(6,10);

		 if((mes==4 || mes==6 || mes==8 || mes==10 || mes==12) && (dia > 30)) {

		     //alert("Dia incorreto!! O mês especificado contém no máximo 30 dias.");

		     return false;

		 } 

		 if((mes==1 || mes==3 || mes==5 || mes==7 || mes==9 || mes==11) && (dia > 31)) {

		     //alert("Dia incorreto!! O mês especificado contém no máximo 31 dias.");

		     return false;

		 } 

		 if(ano%4!=0 && mes==2 && dia>28) {

		     //alert("Data incorreta!! O mês especificado contém no máximo 28 dias.");

		     return false;

		 }

		 if(ano%4==0 && mes==2 && dia>29) {

		     //alert("Data incorreta!! O mês especificado contém no máximo 29 dias.");

		     return false;

		 }

		 return true;

	 } else {

	     return false;

     }

 }

 //*************************************************************************************************





 //VALIDA HORA

 function validar_hora(elemento,valor) {



	 var regex = /^([0-1][0-9]|[2][0-3]):[0-5][0-9]$/;

     if(valor=='') { 

	     return true; 

	 } else if(!regex.test(valor)) {

		 return false;

	 }

	 return true;

 }

 //*************************************************************************************************

 //VALIDA MOEDA
 function validar_moeda_2(elemento,valor) {
	 if(valor=='') { 
	     return true;
	 }
	 var regex = /^[0-9]{1,3}(\.[0-9]{3})*\,[0-9]{2}$/;
	 if(!regex.test(valor)) {
		 return false;
	 }
	 return true;
 }
 function validar_moeda_3(elemento,valor) {
	 if(valor=='') { 
	     return true;
	 }
	 var regex = /^[0-9]{1,3}(\.[0-9]{3})*\,[0-9]{3}$/;
	 if(!regex.test(valor)) {
		 return false;
	 }
	 return true;
 }
 function validar_moeda_4(elemento,valor) {
	 if(valor=='') { 
	     return true;
	 }
	 var regex = /^[0-9]{1,3}(\.[0-9]{3})*\,[0-9]{4}$/;
	 if(!regex.test(valor)) {
		 return false;
	 }
	 return true;
 }
 function validar_moeda_5(elemento,valor) {
	 if(valor=='') { 
	     return true;
	 }
	 var regex = /^[0-9]{1,3}(\.[0-9]{3})*\,[0-9]{5}$/;
	 if(!regex.test(valor)) {
		 return false;
	 }
	 return true;
 }
 function validar_moeda_6(elemento,valor) {
	 if(valor=='') { 
	     return true;
	 }
	 var regex = /^[0-9]{1,3}(\.[0-9]{3})*\,[0-9]{6}$/;
	 if(!regex.test(valor)) {
		 return false;
	 }
	 return true;
 }
 //*************************************************************************************************

 //VALIDA LOGIN

 function validar_login(elemento,valor) {



     if(valor=='') { 

	     return true;

	 }

     if(valor=='Login') { 

	     return false;

	 }

	 var regex = /^[a-zA-Z0-9]*$/;

	 if(!regex.test(valor)) {

		 return false;

	 }

	 return true;

 }

 //*************************************************************************************************





 //VALIDA SENHA

 function validar_senha(elemento,valor) {

     if(valor=='Senha') { 

	     return false;

	 }

	 return true;

 }

 //*************************************************************************************************





 //VALIDA NUMERO

 function validar_numero(elemento,valor) {

	 

	 if(valor=='') { 

	     return true;

	 }

	 var regex = /^\d+$/;

	 if(!regex.test(valor)) {

		 return false;

	 }

	 return true;

 }

 //*************************************************************************************************





 //VALIDA DECIMAL

 function validar_decimal(elemento,valor) {



     if(valor=='') { 

	     return true;

	 }

	 var regex = /^[+-]?((\d+|\d{1,3}(\.\d{3})+)(\,\d*)?|\,\d+)$/;

	 if(!regex.test(valor)) {

		 return false;

	 }

	 return true;

 }

 //*************************************************************************************************





 //VALIDA DECIMAL INGLES

 function validar_decimal_ingles(elemento,valor) {



     if(valor=='') { 

	     return true;

	 }

	 var regex = /^[+-]?((\d+|\d{1,3}(\,\d{3})+)(\.\d*)?|\.\d+)$/;

	 if(!regex.test(valor)) {

		 return false;

	 }

	 return true;

 }

 //*************************************************************************************************





 //VALIDA LETRAS

 function validar_letras(elemento,valor) {



     if(valor=='') { 

	     return true;

	 }

	 var regex = /^[a-zA-Z]*$/;

	 if(!regex.test(valor)) {

		 return false;

	 }

	 return true;

 }

 //*************************************************************************************************





 //VALIDA URL

 function validar_site(elemento,valor) {



	 return true;

 }

 //************************************************************************************************* 





 //COMPARA CAMPO 

 var aba = '';

 function compare_campo(elemento,valor,elemento_2) {



	 if(valor == eval('document.codo'+aba.replace('#cont', '')+'.'+elemento_2+'.value')) {

	     return true;

	 } else {

		 return false;

	 } 

 }

 //************************************************************************************************* 