// VALIDACAO DOS CAMPOS DE EMAIL
function IsEmail(Expression)
{
	if (Expression == null)
		return (false);

	var supported = 0;
	if (window.RegExp)
	{
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if (!supported) 
		return (Expression.indexOf(".") > 2) && (Expression.indexOf("@") > 0);
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.[a-zA-Z0-9\\-_\\.]+\\@(\\[?)[a-zA-Z0-9\\-_\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(Expression) && r2.test(Expression));
}

// CAMPOS OBRIGATORIOS E ALERTAS 
function valida(){

// NOME
if (document.contato.From.value.length < 3 ) 
{ 	alert("ATENÇÃO!\n\n- Preencha o campo \"NOME\" com pelo menos 3 caracteres.");
    contato.From.focus();
	return false; }

// EMAIL
if (!IsEmail(document.contato.FromEmail.value)) 
{	alert("Verifique o campo \"E-MAIL\"!\n\n- Não use acentuação gráfica ou espaços.\n- Não use caracteres especiais além do \"@\".");
    contato.FromEmail.focus();
	return false; }

// ASSUNTO
if (document.contato.Subject.value.length < 5 ) 
{ 	alert("ATENÇÃO!\n\n- Preencha o campo \"ASSUNTO\" com pelo menos 5 caracteres.");
    contato.Subject.focus();
	return false; }

// MENSAGEM
{
  if (contato.Body.value == "")
  {
    alert("Digite um valor para o campo \"MENSAGEM\".");
    contato.Body.focus();
    return (false);
  }

  if (contato.Body.value.length < 20)
  {
    alert("Digite pelo menos 20 caracteres no campo \"MENSAGEM\".");
    contato.Body.focus();
    return (false);
  }

  if (contato.Body.value.length > 200)
  {
    alert("Digite no máximo 200 caracteres no campo \"MENSAGEM\".");
    contato.Body.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-\" '¹²³£|!@#$%&*()_-+=[]?/\\ªº°;:., \t\r\n\f";
  var checkStr = contato.Body.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("ATENÇÃO!\n\n- Não são permitidos os caracteres \"<\" e \">\" no campo \"MENSAGEM\".");
    contato.Body.focus();
    return (false);
  }
  return (true); }
}
//-->