
function disableEnterKey(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13)
          return false;
     else
          return true;
}


function fcnAjuda(sHelpId) {

	fcnNovaTela('ajuda.asp?ac=' + sHelpId, 'no', 'yes', '560', '600')

}

function fcnVerFoto(sFotoId) {

	fcnNovaTela('ver_fotos_carros.asp?f_id=' + sFotoId, 'no', 'yes', '710', '590')

}

function fcnVerFotoCarro(sFotoId,sCarroId) {

	fcnNovaTela('ver_fotos_carros.asp?f_id=' + sFotoId+'&c_id=' + sCarroId, 'no', 'yes', '710', '590')

}

function fcnVerGraficoCarro(sGraficoId,sCarroId) {

	fcnNovaTela('ver_graficos_carros.asp?f_id=' + sGraficoId+'&c_id=' + sCarroId, 'no', 'yes', '710', '590')

}

function fcnVerFotoGaleria(sFotoId,sGaleriaId) {

	fcnNovaTela('ver_fotos_galerias.asp?f_id=' + sFotoId+'&g_id=' + sGaleriaId, 'no', 'yes', '710', '590')

}

function fcnVerFotoGeral(sFoto,sDiretorio) {
	fcnNovaTela('ver_fotos_gerais.asp?foto=' + sFoto +'&dir=' + sDiretorio, 'no', 'yes', '710', '590')

}


function fcnVerPeca(sPecaId) {

	fcnNovaTela('ver_pecas.asp?p_id=' + sPecaId, 'no', 'yes', '710', '700')

}

function fcnVerMapa(sMapaId) {

	fcnNovaTela('ver_mapa.asp?mapa=' + sMapaId, 'no', 'yes', '710', '700')

}

function fcnVerCurriculo(sCurriculoId) {

	fcnNovaTela('ver_curriculo.asp?curriculo=' + sCurriculoId, 'no', 'yes', '710', '700')

}

function fcnVerMateria(jMatId, jMateriaId) {

	fcnNovaTela('ver_materias.asp?m_id=' + jMatId + '&mat_id='+jMateriaId, 'no', 'yes', '800', '1200')

}



function fcnSubmit(sPagina, sFormulario) {

    sFormulario.method='post';
    sFormulario.action=sPagina;
    sFormulario.submit();    

}

function fcnChangeLanguage(idioma)
{
if (idioma == 'P')
   {
      if (!confirm('Mudar idioma para português?')) return;
      fcnSubmit('change_language.asp?lg=P', formulario)
      return false;
   }
if (idioma == 'I')
   {
      if (!confirm('Change language to english?')) return;
      fcnSubmit('change_language.asp?lg=I', formulario)
      return false;
    }
}


function fcnNovaTela(url, bExibeFerramentas, bExibeRolagem, sWidth, sHeight)
{ 
  newwindow=window.open(url, '_blank', 'width=' + sWidth + ',height=' + sHeight + ',left=' + (screen.width - sWidth) / 2 + ',top=' + ((screen.height - sHeight) / 2.0) + ',toolbar=no,location=no,status=no,menubar=' + bExibeFerramentas + ',scrollbars=' + bExibeRolagem + ',resizable=no')
}

function fcnNovaTelaCheia(url, bExibeFerramentas)
{
  newwindow=window.open(url, '_blank', 'width=' + (screen.width - 10) + ',height=' + (screen.height - 57) + ',left=0,top=0,toolbar=no,location=no,status=no,menubar=' + bExibeFerramentas + ',scrollbars=yes,resizable=no,left=0,top=0')
}

function fcnChecaHora(dt)
{

  if (dt.value == '')
    return true;

  if (dt.value.length != 5)
  {
    alert('Hora inválida');
    dt.select();
    return false;
  }

  var hora   = dt.value.substring(0, 2)
  var minuto = dt.value.substring(3, 5)
  var barra1 = dt.value.substring(2, 3)

  if (isNaN(hora))
  {
    alert('Hora inválida');
    dt.select();
    return false;
  }

  if (isNaN(minuto))
  {
    alert('Hora inválida');
    dt.select();
    return false;
  }
  
  if (barra1 != ':')
  {
    alert('Hora inválida');
    dt.select();
    return false;
  }

  if (hora < 0 || hora > 23)
  {
    alert('Hora inválida');
    dt.select();
    return false;
  }

  if (minuto < 0 || minuto > 59)
  {
    alert('Hora inválida');
    dt.select();
    return false;
  }

}

function fcnChecaData(dt)
{

  if (dt.value == '')
    return true;

  if (dt.value.length != 10)
  {
    alert('Data inválida');
    dt.select();
    return false;
  }

  var dia    = dt.value.substring(0, 2)
  var mes    = dt.value.substring(3, 5)
  var ano    = dt.value.substring(6, 10)
  var barra1 = dt.value.substring(2, 3)
  var barra2 = dt.value.substring(5, 6)

  if (barra1 != '/')
  {
    alert('Data inválida');
    dt.select();
    return false;
  }

  if (barra2 != '/')
  {
    alert('Data inválida');
    dt.select();
    return false;
  }

  if (dia < 1 || dia > 31)
  {
    alert('Data inválida');
    dt.select();
    return false;
  }

  if (mes < 1 || mes > 12)
  {
    alert('Data inválida');
    dt.select();
    return false;
  }

  if (ano < 1900 || ano > 2050)
  {
    alert('Data inválida');
    dt.select();
    return false;
  }

}

function fcnChecaAno(dt)
{

  if (dt.value == '')
    return true;

  if (dt.value.length != 4)
  {
    alert('Ano inválido');
    dt.select();
    return false;
  }

  if (dt.value < 2000 || dt.value > 2050)
  {
    alert('Ano inválido');
    dt.select();
    return false;
  }

}

function fcnChecaMes(dt)
{

  if (dt.value == '')
    return true;

  if (dt.value < 1 || dt.value > 12)
  {
    alert('Mês inválido');
    dt.select();
    return false;
  }

}






function fcnMostra(qual) 
{
   if (qual.style.display=='none') {
   qual.style.display='block'
   } else {
   qual.style.display='none'
   }
}


function popUp(URL, w , h) 
{
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=175,left = '+winl+',top = '+wint+'');");
}

function finalizar_sessao(sLogin)
{
  if (confirm('Tem certeza que deseja finalizar a sessao?')) 
    window.location=sLogin;
}

function cancelar(sLink)
{
  if (confirm('Tem certeza que deseja cancelar?')) 
    window.location=sLink;
}

function isNUMB(c) 
 { 
 if((cx=c.indexOf(","))!=-1) 
  { 
  c = c.substring(0,cx)+"."+c.substring(cx+1); 
  } 
 if((parseFloat(c) / c != 1)) 
  { 
  if(parseFloat(c) * c == 0) 
   { 
   return(1); 
   } 
  else 
   { 
   return(0); 
   } 
  } 
 else 
  { 
  return(1); 
  } 
 } 

function LIMP(c) 
 { 
 while((cx=c.indexOf("-"))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf("/"))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf(","))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf("."))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf("("))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf(")"))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf(" "))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 return(c); 
 } 

function VerifyCNPJ(CNPJ) 
 { 
 CNPJ = LIMP(CNPJ); 
 if(isNUMB(CNPJ) != 1) 
  { 
  return(0); 
  } 
 else 
  { 
  if(CNPJ == 0) 
   { 
   return(0); 
   } 
  else 
   { 
   g=CNPJ.length-2; 
   if(RealTestaCNPJ(CNPJ,g) == 1) 
    { 
    g=CNPJ.length-1; 
    if(RealTestaCNPJ(CNPJ,g) == 1) 
     { 
     return(1); 
     } 
    else 
     { 
     return(0); 
     } 
    } 
   else 
    { 
    return(0); 
    } 
   } 
  } 
 } 

function RealTestaCNPJ(CNPJ,g) 
 { 
 var VerCNPJ=0; 
 var ind=2; 
 var tam; 
 for(f=g;f>0;f--) 
  { 
  VerCNPJ+=parseInt(CNPJ.charAt(f-1))*ind; 
  if(ind>8) 
   { 
   ind=2; 
   } 
  else 
   { 
   ind++; 
   } 
  } 
  VerCNPJ%=11; 
  if(VerCNPJ==0 || VerCNPJ==1) 
   { 
   VerCNPJ=0; 
   } 
  else 
   { 
   VerCNPJ=11-VerCNPJ; 
   } 
 if(VerCNPJ!=parseInt(CNPJ.charAt(g))) 
  { 
  return(0); 
  } 
 else 
  { 
  return(1); 
  } 
 } 

function fcnChecaCnpj(s) 
 { 
 if(VerifyCNPJ(s.value) == 1) 
  { 
  } 
 else 
  { 
  alert("CNPJ não é válido!"); 
  s.focus(); 
  return false;
  } 
 return true; 
 } 

function fcnFormataCnpj(Campo, teclapres){

	var tecla = teclapres.keyCode;

	var vr = new String(Campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");

	tam = vr.length + 1 ;

	
	if (tecla != 9 && tecla != 8){
		if (tam > 2 && tam < 6)
			Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
		if (tam >= 6 && tam < 9)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
		if (tam >= 9 && tam < 13)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
		if (tam >= 13 && tam < 15)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
		}
}

function fcnValidaCpf(sCpf)
{

var iInicia;

iInicia = 0;

sCpf = sCpf.replace("-","");
sCpf = sCpf.replace(".","");
sCpf = sCpf.replace(".","");

if (sCpf == 11111111111) iInicia = 1;
if (sCpf == 22222222222) iInicia = 1;
if (sCpf == 33333333333) iInicia = 1;
if (sCpf == 44444444444) iInicia = 1;
if (sCpf == 55555555555) iInicia = 1;
if (sCpf == 66666666666) iInicia = 1;
if (sCpf == 77777777777) iInicia = 1;
if (sCpf == 88888888888) iInicia = 1;
if (sCpf == 99999999999) iInicia = 1;
if (sCpf == 00000000000) iInicia = 1;
if (sCpf == 10987654321) return true;

if (iInicia == 0)
   {
   // Aqui começa a checagem do CPF
   var POSICAO, I, SOMA, DV, DV_INFORMADO;
   var DIGITO = new Array(10);
   DV_INFORMADO = sCpf.substr(9, 2); // Retira os dois últimos dígitos do número informado

   // Desemembra o número do CPF na array DIGITO
   for (I=0; I<=8; I++) {
     DIGITO[I] = sCpf.substr( I, 1);
   }

   // Calcula o valor do 10º dígito da verificação
   POSICAO = 10;
   SOMA = 0;
      for (I=0; I<=8; I++) {
         SOMA = SOMA + DIGITO[I] * POSICAO;
         POSICAO = POSICAO - 1;
      }
   DIGITO[9] = SOMA % 11;
   if (DIGITO[9] < 2) {
        DIGITO[9] = 0;
   }
   else{
       DIGITO[9] = 11 - DIGITO[9];
   }

   // Calcula o valor do 11º dígito da verificação
   POSICAO = 11;
   SOMA = 0;
      for (I=0; I<=9; I++) {
         SOMA = SOMA + DIGITO[I] * POSICAO;
         POSICAO = POSICAO - 1;
      }
   DIGITO[10] = SOMA % 11;
      if (DIGITO[10] < 2) {
           DIGITO[10] = 0;
      }
      else {
           DIGITO[10] = 11 - DIGITO[10];
      }

   // Verifica se os valores dos dígitos verificadores conferem
   DV = DIGITO[9] * 10 + DIGITO[10];
      if (DV != DV_INFORMADO) {
         return false;
      }
      else {
         return true;
      } 
   }
}


function fcnMascara(valor, id, mascara, evento) 
{
	/*
		Diego Hellas
		diegohellas@gmail.com
		
		Esse script foi desenvolvido com a finalidade de suprir qualquer necessidade
		com máscaras em formulários HTML.
		Para funcionar corretamente o campo tem que ter obrigatóriamente a propriedade
		id no campo input <input name="teste" id="teste" type="text" />, o script so foi
		testado com o evento onkeyup, não sei do comportamento do script com outros eventos
		Uma outra caracteristica dele é a verificação do tipo de dado que entra por posição
		na máscara comforme a tabelinha a seguir:
		***************************
		*       números      *  # *
		***************************
		* qualuqer caratcter *  @ *
		***************************
	*/  
	
	
	/////////////////////////////////////////////////////////////////////////////////
	//                                 MODELO                                      //
	//onkeyup="mascaraHellas(this.value, this.id, '####.##.##.#######-#/#', event)"//
	/////////////////////////////////////////////////////////////////////////////////
	
	
	//inicializa a variavel que vai conter o valor final
	var valorFinal = "";
	
	//verifica o que foi digitada para que seja verificado se é somente números ou não
	var tecla = evento.keyCode;	
	
	//manetem o tamanho original do campo sem retirar a máscara
	var valorOriginal = valor;
	
	//inicializa um array com todos os caracteres que serão retirado
	var arrNaoPermitidos = new Array("-", ".", "/", "\\", "|", "(", ")", ":", " ");
	
	//retira qualquer máscatra que já tenho sido colocada
	for(i1=0;i1<valor.length;i1++)
	{
		for(i2=0;i2<arrNaoPermitidos.length;i2++)
		{
			if(valor.charAt(i1) == arrNaoPermitidos[i2])
			{
				valor = valor.toString().replace( arrNaoPermitidos[i2], "" );
			}	
		}	
	}	
	
		
	//verifica se foi precionado o backspae
	if(tecla != 8)
	{			
		//verifica se já não ultrapassou o tamanha máximo da máscara
		if(mascara.length >= valorOriginal.length)
		{			
			//loop em cima do valor do campo sem a máscara
			jaTemMascara = false;
			for(i=0;i<valor.length;i++)
			{			
				//verifica se a string já recebeu alguma máscara ou não
				if(jaTemMascara == false)
				{
					//verifica se o tipo da entrada de dados tem que ser némerica
					if(mascara.charAt(i) == "#")
					{
						//verifica se foi digitado somente números
						if(((tecla > 95) && (tecla < 106)) || ((tecla > 47) && (tecla < 58)) || tecla == 9 || tecla == 16)
						{
							//0 = 96 ou 48
							//1 = 97 ou 49
							//2 = 98 ou 50
							//3 = 99 ou 51
							//4 = 100 ou 52
							//5 = 101 ou 53
							//6 = 102 ou 54
							//7 = 103 ou 55
							//8 = 104 ou 56
							//9 = 105 ou 57
							//tecla == 9 = tab
							valorFinal = valorFinal  + valor.charAt(i);
						}
						else//se não foi digitado um número é retirado o caracter da string
						{
							valorFinal = valorOriginal.substring(0, valorOriginal.length -1);
						}					
					}
					else if(mascara.charAt(i) == "@")//verifica se o tipo da entrada é qualquer caracter
					{
						valorFinal = valorFinal  + valor.charAt(i);
					}
					else//se não for quelaquer caracter é algum elemento da máscara
					{
						//verifica se o próxima depois da máscara é númerica 
						if(mascara.charAt(i + 1) == "#")
						{
							//verifica se foi digitado somente números
							if(((tecla > 95) && (tecla < 106)) || ((tecla > 47) && (tecla < 58)) || tecla == 9 || tecla == 16)
							{
								//0 = 96 ou 48
								//1 = 97 ou 49
								//2 = 98 ou 50
								//3 = 99 ou 51
								//4 = 100 ou 52
								//5 = 101 ou 53
								//6 = 102 ou 54
								//7 = 103 ou 55
								//8 = 104 ou 56
								//9 = 105 ou 57
								//tecla == 9 = tab
								valorFinal = valorFinal + mascara.charAt(i + jaTemMascara)  + valor.charAt(i);			
								jaTemMascara = jaTemMascara + 1;	
							}
							else//se não foi digitado um número é retirado o caracter da string
							{
								valorFinal = valorOriginal.substring(0, valorOriginal.length -1);
							}
						}
						else// se não é númerico então pode ser qualuqer caracter
						{
							valorFinal = valorFinal + mascara.charAt(i + jaTemMascara)  + valor.charAt(i);			
							jaTemMascara = jaTemMascara + 1;
						}					
					}
				}
				else//else da verificação da máscara
				{
					//verifica se foi digitado somente números
					if(mascara.charAt(i + jaTemMascara) == "#")
					{
						//verifica se foi digitado somente números
						if(((tecla > 95) && (tecla < 106)) || ((tecla > 47) && (tecla < 58)) || tecla == 9 || tecla == 16)
						{
							//0 = 96 ou 48
							//1 = 97 ou 49
							//2 = 98 ou 50
							//3 = 99 ou 51
							//4 = 100 ou 52
							//5 = 101 ou 53
							//6 = 102 ou 54
							//7 = 103 ou 55
							//8 = 104 ou 56
							//9 = 105 ou 57
							//tecla == 9 = tab
							valorFinal = valorFinal  + valor.charAt(i);
						}
						else//se não foi digitado um número é retirado o caracter da string
						{
							valorFinal = valorOriginal.substring(0, valorOriginal.length -1);
						}
					}
					else if(mascara.charAt(i + jaTemMascara) == "@")//verifica se o tipo da entrada é qualquer caracter
					{
						valorFinal = valorFinal  + valor.charAt(i);
					}
					else
					{
						//verifica se foi digitado somente números
						if(mascara.charAt(i + jaTemMascara +1) == "#")
						{
							//verifica se foi digitado somente números
							if(((tecla > 95) && (tecla < 106)) || ((tecla > 47) && (tecla < 58)) || tecla == 9 || tecla == 16)
							{
								//0 = 96 ou 48
								//1 = 97 ou 49
								//2 = 98 ou 50
								//3 = 99 ou 51
								//4 = 100 ou 52
								//5 = 101 ou 53
								//6 = 102 ou 54
								//7 = 103 ou 55
								//8 = 104 ou 56
								//9 = 105 ou 57
								//tecla == 9 = tab
								valorFinal = valorFinal + mascara.charAt(i + jaTemMascara)  + valor.charAt(i);			
								jaTemMascara = jaTemMascara + 1;	
							}
							else//se não foi digitado um número é retirado o caracter da string
							{
								valorFinal = valorOriginal.substring(0, valorOriginal.length -1);
							}
						}
						else// se não é númerico então pode ser qualuqer caracter
						{
							valorFinal = valorFinal + mascara.charAt(i + jaTemMascara)  + valor.charAt(i);			
							jaTemMascara = jaTemMascara + 1;
						}							
					}	
				}//fim da verificação da máscara	
			}	
		}
		else
		{
			valorFinal = valorOriginal.substring(0, mascara.length);	
		}//final da verificação do tamanha máximo da string
	}
	else
	{
		//valorFinal = valorOriginal.substring(0, valorOriginal.length -1)
		valorFinal = valorOriginal.substring(0, valorOriginal.length);		
	}//final da verificação do backspace
	document.getElementById(id).value = valorFinal;
}

function VerificaEmail (email_campo)
{

var emailStr = document.formulario_newsletter.txtEmail.value;

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|br|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@',;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("O endereço de email parece incorreto. Por favor cheque a localização da @ e dos pontos.");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("O email contém caracteres inválidos (antes da arroba).");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("O email contém caracteres inválidos (depois da arroba).");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("O email é inválido.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("O endereço de IP é inválido.");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;

if ((domArr == 'grupofoco,com,br') || (domArr == 'focorh,com,br') || (domArr == 'stantonchaseinternational,com,br') || (domArr == 'yaho,com') || (domArr == 'yaho,com,br') || (domArr == 'globo,com,br') || (domArr == 'zipmail,com') || (domArr == 'hotmail,com,br') || (domArr == 'gmail,com,br')) {
domArr_disp = domArr;
for (i=0;i<len;i++) {
   domArr_disp = domArr_disp.toString().replace( ",", "." );
}
alert("Seu email é inválido (não pode ser @" + domArr_disp + ")");
return false;}

for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("O nome do domínio é inválido.");
return false;
   }

}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("O endereço de email deve terminar com as letras correspondentes ao país de origem do mesmo.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("O endereço de email está sem domínio válido.");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

