
function valida(theForm){
   if (theForm.Nome.value == "")
	{
		alert("Por favor, informe um valor para o campo \"Nome\".");
		theForm.Nome.focus();
		return (false);
	}

	if (theForm.Cidade.value == "")
	{
		alert("Por favor, informe um valor para o campo \"Cidade\".");
		theForm.Cidade.focus();
		return (false);
	}
	if (theForm.Endereco.value == "")
	{
		alert("Por favor, informe um valor para o campo \"Endereço\".");
		theForm.Endereco.focus();
		return (false);
	}
	if (theForm.DDD_Fone.value == "")
	{
		alert("Por favor, informe um valor para o campo \"DDD\".");
		theForm.DDD_Fone.focus();
		return (false);
	}

		if (theForm.Fone.value == "")
	{
		alert("Por favor, informe um valor para o campo \"Número\".");
		theForm.Fone.focus();
		return (false);
	}
	
			
 		if (theForm.Email.value == "")
 {
		alert("Por favor, informe um valor para o campo \"E-mail\".");
		theForm.Email.focus();
		
		if (theForm.Assunto.value == "")
	{
		alert("Por favor, informe um valor para o campo \"Assunto\".");
		theForm.Assunto.focus();
		return (false);
	}
	    return (false);
 } else {
  var x = Verifica_Email(theForm.Email);
  if (x == false)
  {
   return(false);
   }
  }

	if (theForm.Mensagem.value == "")
	{
		alert("Por favor, informe um valor para o campo \"Mensagem\".");
		theForm.Mensagem.focus();
		return (false);
	}

 }

function Verifica_Email(field)
{
  if (field.value != '') {
    var emailok = 0;
    var priaroba = field.value.indexOf('@');
    var ultponto = field.value.lastIndexOf('.');

        if (field.value.indexOf('@') > 0 ) {
           if (field.value.lastIndexOf('@') == field.value.indexOf('@')) {
              if (field.value.lastIndexOf('.') > 0 ) {

                 if ( field.value.lastIndexOf('.')  !=  field.value.length - 1) {
		    if ( ultponto > priaroba ) {
                       var emailok = 1;
 		    }
                 }
              }
           }
        }

        if (emailok != 1) {
           alert('E-mail inválido.');
           field.focus();
           return (false);
        }
    }

}
