
function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}


function FormValidator_pedido(theForm)
{
	if (theForm.nome.value == "")
	{
	alert("Por favor escreva os seus dados no campo Nome.");
	theForm.nome.focus();
	return (false);
	}
	
	if (theForm.email.value == "")
	{
	alert("Por favor escreva os seus dados no campo Email.");
	theForm.email.focus();
	return (false);
	}
	
	if (theForm.email.value.length >0)
	{
	if (!isEmailAddr(theForm.email.value))
	{
	alert("Por favor escreva um endereço de email completo no formato oseunome@oseudominio.com");
	theForm.email.focus();
	return (false);
	}
	}
	
	if (theForm.assunto.value == "")
	{
	alert("Por favor escreva o Assunto.");
	theForm.assunto.focus();
	return (false);
	}
	
	if (theForm.mensagem.value == "")
	{
	alert("Por favor escreva a Mensagem.");
	theForm.mensagem.focus();
	return (false);
	}
	
	if (theForm.newsletter.value == "")
	{
	alert("Por favor coloque o seu Email.");
	theForm.newsletter.focus();
	return (false);
	}
	
	if (theForm.newsletter.value.length >0)
	{
	if (!isEmailAddr(theForm.newsletter.value))
	{
	alert("Por favor escreva um endereço de email completo no formato oseunome@oseudominio.com");
	theForm.newsletter.focus();
	return (false);
	}
	}
	
return (true);
}
