	function Buscar()
	{
		if (document.FrmBuscaSimples.str_Palavra.value == "")
		{
			alert("Digite a Palavra-Chave");
			document.FrmBuscaSimples.str_Palavra.focus();
			return false;
		}
		else
		document.FrmBuscaSimples.submit();
	}
	
	function Newsletter()
	{
	if (document.frmNews.str_Nome.value == "")
	{
		alert("Preencha o Campo NOME");
		document.frmNews.str_Nome.focus();
		return false;
	}
	if (document.frmNews.str_Email.value == "")
	{
		alert("Preencha o Campo E-MAIL");
		document.frmNews.str_Email.focus();
		return false;
	}
	if (document.frmNews.str_Email.value.indexOf ('@',0) == -1 || document.frmNews.str_Email.value.indexOf ('.',0) == -1)
	{
		alert("Digite um endereço de e-mail válido.")
		document.frmNews.str_Email.value = "";
		document.frmNews.str_Email.focus();
		return false;   
	}  
	document.frmNews.submit();
	}
	

	function critica(frm)
	{
	var texto, msgaux, erro;
	 
	msgaux = 'Os campos listados abaixo são de preenchimento obrigatório:\n' 
	erro=false;
	
	//Campo Nome
	
		texto = frm.str_Nome.value; 
	    if (texto.length == 0)    
	    { 
	        msgaux+='\n. Nome';      
	        erro=true;
	    } 
	
	//Campo email
	
		texto = frm.str_Email.value; 
	    if (texto.length == 0)    
	    { 
	        msgaux+='\n. E-mail';      
	        erro=true;
	    } 
		
	//Campo Sexo
	
		texto = frm.str_Sexo.value; 
	    if (texto.length == 0)    
	    { 
	        msgaux+='\n. Sexo';      
	        erro=true;
	    }
		
	//Campo Endereco
	
		texto = frm.str_Endereco.value; 
	    if (texto.length == 0)    
	    { 
	        msgaux+='\n. Endere&ccedil;o';      
	        erro=true;
	    } 
	
	//Campo Bairro
	
		texto = frm.str_Bairro.value; 
	    if (texto.length == 0)    
	    { 
	        msgaux+='\n. Bairro';      
	        erro=true;
	    } 
		
	//Campo Cidade
	
		texto = frm.str_Cidade.value; 
	    if (texto.length == 0)    
	    { 
	        msgaux+='\n. Cidade';      
	        erro=true;
	    } 
		
	//Campo Nascimento
	
		texto = frm.str_DataNascimento.value; 
	    if (texto.length == 0)    
	    { 
	        msgaux+='\n. Nascimento';      
	        erro=true;
	    }
		
	//Campo CEP
	
		texto = frm.str_CEP.value; 
	    if (texto.length == 0 || texto.length < 8)    
	    { 
	        msgaux+='\n. CEP';      
	        erro=true;
	    } 
 
	//Campo CPF
	
	texto = frm.str_CPF.value; 
	if (texto.length == 0)    
		{ 
		msgaux+='\n. CPF';      
		erro=true;
	} 
		
		if (erro) alert(msgaux);
	
	      return !(erro);
	}
	function ValidaDataNascimento(valor,campo)
{
    var texto, i, t, c, erro, dd, mm, aaaa, Dia, Mes, Ano;
    erro=false;
	texto=valor.value;
 
    t = texto.length;
 
    if (t == 10) 
       {  
          for (i=0;i<t;i++) {
		      c=texto.charAt(i);
		      if ((i==0) || (i==1) || (i==3) || (i==4) || (i==6) || (i==7) || (i==8) || (i==9)) {
			     if (!(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' ||
					   c == '5' || c == '6' || c == '7' || c == '8' || c == '9'))
					   {
					   
					     msgaux='Digite a data no formato dd/mm/aaaa\n';
						
					     erro=true;
					   }
			  }
			  if ((i==2) || (i==5))
			     {
		 	        if (!(c=='/'))
			           {
			             erro=true;
						 
			             msgaux='Digite a data no formato dd/mm/aaaa\n';
						 
			           }
				 }
           }  
 
		   dd=texto.charAt(0) + texto.charAt(1);
		   mm=texto.charAt(3) + texto.charAt(4);
		   aaaa=texto.charAt(6) + texto.charAt(7) + texto.charAt(8) + texto.charAt(9);
		   
		   Dia=parseInt(dd,10);
		   Mes=parseInt(mm,10);
		   Ano=parseInt(aaaa,10);
 
   		   if ((Dia<1) || (Dia>31))
		   {//FAIXA DO DIA INVALIDO
               erro=true;
               msgaux='Digite dias de 1 a 31!\n';
		   }//if
		   if ((Mes<1) || (Mes>12))
		   {//FAIXA DO MES INVALIDA
               erro=true;
               msgaux='Digite meses de 1 a 12!\n';
		   }//if
		   if ((Dia>=31) && ((Mes==4) || (Mes==6) || (Mes==9) || (Mes==11)))
		   {//DIA INVALIDO PARA ESTE MES
               erro=true;
			   	
	               msgaux='Dia inválido para este mês!\n';
				  
		   }//if
		   if (Mes==2)
		   {//MES DE FEVEREIRO
			   if (Dia>=30)
			   {//DIA INVALIDO PARA FEVEREIRO
                  erro=true;
                  msgaux='Dia inválido para o mês de Fevereiro!\n';
			   }//if
			   if ((Dia==29) && (((Ano % 4) != 0) || (((Ano % 100) == 0) && ((Ano % 400) != 0))))
			   {//NAO E' BISSEXTO
                  erro=true;
				  
                  	msgaux='Dia inválido para este mês!\n';
				
			   }//if
		   }//if  
		   if (Ano<1900) {
              erro=true;
			  
	              msgaux='Ano inválido!\n';
			
		   }
	   }
	else 
       {
	     if (!(t == 0))
		 {
 	        erro=true;
            
			             msgaux='Digite a data no formato dd/mm/aaaa\n';
						 
		 }
       }
   
	if (erro) {
	   document.frm.str_DataNascimento.focus();
	   alert(msgaux);
	}
 
    return !(erro);  
}

function ValidaCPF(oCampo)
{
	var i = 0;
	var n_checked = 0;
	var error = 0;
	var error_message = "";
	var cpf = oCampo.value;
	
	if (cpf.length != 0)
	{
		if (cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999") {
		
			error_message = "Por favor digite um CPF válido.\n";
		
			error = 1;
		}
		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)))
		{
			
				error_message = "Por favor digite um CPF válido.\n";
			
			error = 1;
		}
		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)))
		{
			
				error_message = "CPF inválido.\n";
			
			error = 1;
		}
		if (error == 1)
		{
			alert(error_message);
			oCampo.focus();
			return false;
		}
		else
		{
			return true;
		}
	}
}

var MudarCampo = true;
document.onkeypress = HabilitarTABAutom;

function HabilitarTABAutom(evt) {
    var codTecla;
    var e = evt ? evt : window.event; 

    if(e.keyCode) { // IE
        codTecla = e.keyCode;
    }
    else { // Netscape/Firefox/Opera
        codTecla = e.which;
    }

    if ( (codTecla < 48) || (codTecla >  255) )
        MudarCampo = false;
    else
        MudarCampo = true;
}
function tabAutom(quem, e) {
    if ( ( quem.value.length == quem.maxLength ) && ( MudarCampo ) ){
        var i=0,j=0, indice=-1;
        // Localiza em qual form está o input no documento
        for (i=0; i<document.forms.length; i++) {
            for (j=0; j<document.forms[i].elements.length; j++) {
                if (document.forms[i].elements[j].name == quem.name) {
                    indice=i;
                    break;
                }
            }
            if (indice != -1)
                 break;
        }

        // Localiza o input no documento e verifica se existe outro input para receber o foco
        for (i=0; i<document.forms[indice].elements.length; i++) {
            if (document.forms[indice].elements[i].name == quem.name) {
                while ( ((i+1) < document.forms[indice].elements.length) && 
                        ( (document.forms[indice].elements[(i+1)].type == "hidden") || 
                      (document.forms[indice].elements[(i+1)].name == "Lim") ) )
                {
                            i++;
                }
                if ( (i+1) < document.forms[indice].elements.length )
                {
                    document.forms[indice].elements[(i+1)].focus();
					MudarCampo = false;
                }
                break;
            } 
        }
    } 
}

function inteiro(campo)
{
	x=navigator
	if (x.appName!="Netscape")
	{
		  if(document.all) // Internet Explorer
			var tecla = event.keyCode;
		  else if(document.layers) // Nestcape
			var tecla = campo.which;
		
		  if(tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		  else
			{
			  if (tecla != 8) // backspace
				return false;
			  else
				return true;
			}
	}
}
function fale()
	{
		window.open('indique.asp','email', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=350,height=310');
}