//******************************************
//*Inicio da rotina de Validação dos Campos*
//******************************************
// --- INICIO ---

function enviar(){

// Checa o departamento
if (document.contato.recipient.selectedIndex <= 0)
{
alert("Por favor, selecione o Departamento.");
document.contato.recipient.focus();
return;
}


// Verifica se Nome não está vazio
if (document.contato.Nome.value == "")
{
alert("Por favor, digite o seu Nome.");
document.contato.Nome.focus();
return;
}


// Verifica se Empresa não está vazio
if (document.contato.Empresa.value == "")
{
alert("Por favor, digite o nome da sua Empresa.");
document.contato.Empresa.focus();
return;
}


// Checa se o campo E-mail está em branco
if (document.contato.E_mail.value == "")
{
alert("Por favor, digite seu E-mail.");
document.contato.E_mail.focus();
return;
}

// Verifica se o E-mail contem @ e pelo menos 1 .
var checkremetente = "@.";
var checkStr = document.contato.E_mail.value;
var remetenteValid = false;
var remetenteAt = false;
var remetentePeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkremetente.length;  j++)
{
if (ch == checkremetente.charAt(j) && ch == "@")
remetenteAt = true;
if (ch == checkremetente.charAt(j) && ch == ".")
remetentePeriod = true;
	  if (remetenteAt && remetentePeriod)
		break;
	  if (j == checkremetente.length)
		break;
	}

// Se existir @ na string
if (remetenteAt && remetentePeriod)
{
		remetenteValid = true
		break;
	}
}
if (!remetenteValid)
{
alert("Por favor, digite um E-mail válido!");
document.contato.E_mail.focus();
return;
}

// Verifica se DDD não está vazio
if (document.contato.DDD.value == "")
{
alert("Por favor, digite seu DDD.");
document.contato.DDD.focus();
return;
}

// Verifica se DDD tem dois dígitos
if (document.contato.DDD.value.length < 2)
{
alert("O DDD deve ter 2 dígitos.");
document.contato.DDD.focus();
return;
}

// Verifica se o campo Telefone contém apenas números
var checkOK = "0123456789";
var checkStr = document.contato.DDD.value;
var allValid = true;
var allNum = "";
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 (ch != ",")
allNum += ch;
}
if (!allValid)
{
alert("Por favor, digite apenas números no campo DDD.");
document.contato.DDD.focus();
return;
}

// Verifica se Telefone não está vazio
if (document.contato.Telefone.value == "")
{
alert("Por favor, digite seu Telefone.");
document.contato.Telefone.focus();
return;
}

// Verifica se Telefone tem entre sete e oito dígitos
if (document.contato.Telefone.value.length < 7)
{
alert("O Telefone deve ter entre 7 e 8 dígitos.");
document.contato.Telefone.focus();
return;
}

// Verifica se o campo Telefone contém apenas números
var checkOK = "0123456789";
var checkStr = document.contato.Telefone.value;
var allValid = true;
var allNum = "";
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 (ch != ",")
allNum += ch;
}
if (!allValid)
{
alert("Por favor, digite apenas números no campo Telefone.");
document.contato.Telefone.focus();
return;
}

// Verifica se a Mensagem não está vazia
if (document.contato.Consulta_Feedback.value == "")
{
alert("Por favor, digite sua Mensagem.");
document.contato.Consulta_Feedback.focus();
return;
}

else{

		document.contato.submit();
}
}



//--- FECHA ---
//-->