<!--
	// See KB article about changing this dynamic HTML
	dynamicanimAttr = "dynamicanimation"

function verificarEmail(txtemail)
{
	var arroba = false;
	var ponto = false;
	for (var i = 0; i < txtemail.length; i++)
	{
		if (txtemail.substring(i-1,i) == "@")
		{ 
			arroba = true;
		}
		if (txtemail.substring(i-1,i) == ".")
		{ 
			ponto = true;
		}
	}
	if ((arroba == false) || (ponto == false))
	{
		return false;
	}
	else
    {	    
        return true;
	}
}

function validarData(txtdia, txtmes, txtano)
{
	var data = txtano + "/" + txtmes + "/" + txtdia;
	var bissexto = false; 
    var ret = false;

	var dia = data.substr(8,2);
    var mes = data.substr(5,2);
    var ano = data.substr(0,4);
    
    switch (mes)
    {
      case "01":
      case "03":
      case "05":
      case "07":
      case "08":
      case "10":
      case "12":
        if  (dia <= 31) 
        {
          ret = true;
        }
        break;
      case "04":        
      case "06":
      case "09":
      case "11":
        if  (dia <= 30) 
        {
          ret = true;
        }
        break;
      case "02":
        /* Validando ano Bissexto / fevereiro / dia */ 
        if ((ano % 4 == 0) || (ano % 100 == 0) || (ano % 400 == 0)) 
        { 
          bissexto = true;
        } 
        if ((bissexto) && (dia <= 29)) 
        { 
          ret = true;                 
        } 
        if ((!bissexto) && (dia <= 28)) 
        { 
          ret = true; 
        }            
        break;
    }
	
	if (!ret)
	{
      alert("DATA DE NASCIMENTO inválida!");
	  return "";
	}
	else
	{		
	  return data;
	}
}

function validarSenha(txtsenha, txtsenhaconf)
{
   if (txtsenha == "")
   {
      alert ("Favor preencher o campo SENHA.");
      return false;
   }
   else if (txtsenhaconf == "")
   {
      alert ("Favor preencher o campo CONFIRMAR SENHA.");
      return false;
   }
   else if (txtsenha != txtsenhaconf)
   {
      alert ("As senhas não conferem, favor verificar.");
      return false;
   }
   else if (txtsenha.length < 8)
   {
      alert ("A senha deve ter no mínimo 8 caracteres.");
      return false;
   }
   else
   {
      return true;
   }

}

function validarNumeros(txt)
{
	var ret = true;
	
	//Valida se tem apenas números
	for (var i = 0; i < txt.length; i++)
	{
		if (
		    (txt.substr(i,1) != "0") & (txt.substr(i,1) != "1") &
		    (txt.substr(i,1) != "2") & (txt.substr(i,1) != "3") &
		    (txt.substr(i,1) != "4") & (txt.substr(i,1) != "5") &
		    (txt.substr(i,1) != "6") & (txt.substr(i,1) != "7") &
		    (txt.substr(i,1) != "8") & (txt.substr(i,1) != "9")
		   )
		{
		  ret = false;
		  break;
		}
	}
	return ret;	
}

function validarCep(txtcep)
{
	var ret = true;
	
	if (txtcep.substr(5,1) != "-" )
	{
	  ret = false;
	}
	else if ( !validarNumeros( txtcep.substr(0,5) + txtcep.substr(6,3) ) )
	{
	  ret = false;
	}
	
	return ret;
}

function validarNome(txtnome)
{
	if (txtnome == "")
	{
	  alert ("Favor preencher o campo NOME COMPLETO.");
	  return false;
	}
	
	var ret = false;
	
	//Valida se tem apenas números
	for (var i = 0; i < txtnome.length; i++)
	{
		if (txtnome.substr(i,1) == " ")
		{
		  ret = true;
		  break;
		}
	}

	if (! ret)
	{
	  alert ("Informe nome e sobrenome no campo NOME COMPLETO.");
	}
	
	return ret;	
}

function validarCpf(txtcpf)
{
	txtcpf = txtcpf.replace( /[.-]/g, "" );
    //Valida se é um cpf válido
	if (
		(txtcpf == "00000000000") || (txtcpf == "11111111111") ||
		(txtcpf == "22222222222") || (txtcpf == "33333333333") ||
		(txtcpf == "44444444444") || (txtcpf == "55555555555") ||
		(txtcpf == "66666666666") || (txtcpf == "77777777777") ||
		(txtcpf == "88888888888") || (txtcpf == "99999999999")
	   )
	{
	  return false;
	}

	var n1, n2, n3, n4, n5, n6, n7, n8, n9, d1, d2 = 0;
	var digitado, calculado = "";
	
	n1 = txtcpf.substr(0,1);
	n2 = txtcpf.substr(1,1);
	n3 = txtcpf.substr(2,1);
	n4 = txtcpf.substr(3,1);
	n5 = txtcpf.substr(4,1);
	n6 = txtcpf.substr(5,1);
	n7 = txtcpf.substr(6,1);
	n8 = txtcpf.substr(7,1);
	n9 = txtcpf.substr(8,1);
	
	d1=n9*2+n8*3+n7*4+n6*5+n5*6+n4*7+n3*8+n2*9+n1*10;
	d1=11-(d1 % 11);
	
	if (d1>=10)
	{
		d1=0;
	}
	  
	d2=d1*2+n9*3+n8*4+n7*5+n6*6+n5*7+n4*8+n3*9+n2*10+n1*11;
	d2=11-(d2 % 11);
	
	if (d2>=10) 
	{
		d2=0;
	}
	
	calculado = d1.toString()+d2.toString();	
	digitado = txtcpf.substr(9,1)+txtcpf.substr(10,1);

	return (calculado == digitado);
}

function trim(txt)
{
	//> Retira espacos do inicio
	while (txt.substr(0,1) == " ")
	{
	  txt = txt.substr(1, txt.length-1);	
	}
	
	//> Retira espacos do fim
	while (txt.substr(txt.length-1,1) == " ")
	{
	  txt = txt.substr(0, txt.length-1);	
	}

	return txt;
}

//adiciona mascara de cep
function MascaraCep(cep){
	if(mascaraInteiro(cep)==false){
		event.returnValue = false;
	}
	return formataCampo(cep, '00000-000', event);
}

//adiciona mascara ao CPF
function MascaraCPF(cpf){
	if(mascaraInteiro(cpf)==false){
		event.returnValue = false;
	}
	
	return formataCampo(cpf, '000.000.000-00', event);
}

//adiciona mascara ao CNPJ
function MascaraCNPJ(CNPJ){
	if(mascaraInteiro(CNPJ)==false){
		event.returnValue = false;
	}
	
	return formataCampo(CNPJ, '00.000.000/0000-00', event);
}

//valida numero inteiro com mascara
function mascaraInteiro(){
	if (event.keyCode < 48 || event.keyCode > 57){
		event.returnValue = false;
		return false;
	}
	return true;
}

//formata de forma generica os campos
function formataCampo(campo, Mascara, evento) {
	var boleanoMascara;
	var Digitato = evento.keyCode;
	exp = /\-|\.|\/|\(|\)| /g
	campoSoNumeros = campo.value.toString().replace( exp, "" );
	var posicaoCampo = 0;
	var NovoValorCampo="";
	var TamanhoMascara = campoSoNumeros.length;;
	if (Digitato != 8) { // backspace
		for(i=0; i<= TamanhoMascara; i++) {
			boleanoMascara  = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".") || (Mascara.charAt(i) == "/"));
			boleanoMascara  = boleanoMascara || ((Mascara.charAt(i) == "(") || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " "));
			if (boleanoMascara) {
				NovoValorCampo += Mascara.charAt(i);
				TamanhoMascara++;
			}else{
					NovoValorCampo += campoSoNumeros.charAt(posicaoCampo);
				posicaoCampo++;
			}
		}
		campo.value = NovoValorCampo;
		return true;
	}else{
		return true;
	}
}

//adiciona mascara de data
function MascaraData(data){
	if(mascaraInteiro(data)==false){
		event.returnValue = false;
	}
	
	return formataCampo(data, '00/00/0000', event);
}

function valida_cnpj(cnpj)
      {
	  if (cnpj==""){
		  return true;
	  }
      cnpj = cnpj.replace( /[./-]/g, "" );
      var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
      digitos_iguais = 1;
      if (cnpj.length < 14 && cnpj.length < 15)
            return false;
      for (i = 0; i < cnpj.length - 1; i++)
            if (cnpj.charAt(i) != cnpj.charAt(i + 1))
                  {
                  digitos_iguais = 0;
                  break;
                  }
      if (!digitos_iguais)
            {
            tamanho = cnpj.length - 2
            numeros = cnpj.substring(0,tamanho);
            digitos = cnpj.substring(tamanho);
            soma = 0;
            pos = tamanho - 7;
            for (i = tamanho; i >= 1; i--)
                  {
                  soma += numeros.charAt(tamanho - i) * pos--;
                  if (pos < 2)
                        pos = 9;
                  }
            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
            if (resultado != digitos.charAt(0))
                  return false;
            tamanho = tamanho + 1;
            numeros = cnpj.substring(0,tamanho);
            soma = 0;
            pos = tamanho - 7;
            for (i = tamanho; i >= 1; i--)
                  {
                  soma += numeros.charAt(tamanho - i) * pos--;
                  if (pos < 2)
                        pos = 9;
                  }
            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
            if (resultado != digitos.charAt(1))
                  return false;
            return true;
            }
      else
            return false;
      } 

//-->

