/*
  [*] Script: Valida Contato
  [*] Author: PictureWeb - Web System Projects
  [*] Copyright 2003 © PictureWeb http://www.pictureweb.com.br
*/


function enviar() {

// Verifica se ASSUNTO está selecionado
if (document.f_atendimento.recipient.value == "")
{
	alert("Selecione o ASSUNTO.");
	document.f_atendimento.recipient.focus();
	return;
}

// Verifica se NOME está preenchido
if (document.f_atendimento.nome.value == "")
{
	alert("Digite seu NOME.");
	document.f_atendimento.nome.focus();
	return;
}

// Verifica se E-MAIL está preenchido
if (document.f_atendimento.e_mail.value == "")
{
	alert("Digite seu E-MAIL.");
	document.f_atendimento.e_mail.focus();
	return;
}

// Verifica se DDD está preenchido
if (document.f_atendimento.ddd.value == "")
{
	alert("Digite seu DDD.");
	document.f_atendimento.ddd.focus();
	return;
}

// Verifica se telefone está preenchido
if (document.f_atendimento.telefone.value == "")
{
	alert("Digite seu Telefone de contato.");
	document.f_atendimento.telefone.focus();
	return;
}

// Verifica se CIDADE está preenchido
if (document.f_atendimento.cidade.value == "")
{
	alert("Digite sua CIDADE.");
	document.f_atendimento.cidade.focus();
	return;
}

// Verifica se ESTADO está preenchido
if (document.f_atendimento.uf.value == "")
{
	alert("Escolha seu ESTADO.");
	document.f_atendimento.uf.focus();
	return;
}

// Verifica se o E-MAIL contem @ e pelo menos 1 .
var checkcliemail = "@.";
var checkStr = document.f_atendimento.e_mail.value;
var cliemailValid = false;
var cliemailAt = false;
var cliemailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkcliemail.length;  j++)
{
if (ch == checkcliemail.charAt(j) && ch == "@")
cliemailAt = true;
if (ch == checkcliemail.charAt(j) && ch == ".")
cliemailPeriod = true;
	  if (cliemailAt && cliemailPeriod)
		break;
	  if (j == checkcliemail.length)
		break;
	}

// Se existir @ na string
if (cliemailAt && cliemailPeriod)
{
		cliemailValid = true
		break;
	}
}
if (!cliemailValid){
alert("Por favor, digite um E-MAIL válido!");
document.f_atendimento.e_mail.focus();
return;
}

else {
		document.f_atendimento.submit();
}
}