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(theForm)
{

  if (theForm.Subject.value == "")
  {
    alert("What is the Subject of your inquiry?");
    theForm.Subject.focus();
	theForm.Subject.className = "contactFormFieldError";
	return (false);
  } else theForm.Subject.className = "contactFormField";
   
  
  if (theForm.CustomerName.value == "")
  {
    alert("Please enter your name.");
    theForm.CustomerName.focus();
	theForm.CustomerName.className = "contactFormFieldError";
	return (false);
  } else theForm.CustomerName.className = "contactFormField";
  
  if (theForm.EmailFrom.value == "")
  {
    alert("Please enter your email address.");
    theForm.EmailFrom.focus();
	theForm.EmailFrom.className = "contactFormFieldError";
	return (false);
  } else theForm.EmailFrom.className = "contactFormField";
  
  if (!isEmailAddr(theForm.EmailFrom.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.EmailFrom.focus();
	theForm.EmailFrom.className = "contactFormFieldError";
	return (false);
  } else theForm.EmailFrom.className = "contactFormField";
   
  if (theForm.EmailFrom.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"email\" field.");
    theForm.EmailFrom.focus();
	theForm.EmailFrom.className = "contactFormFieldError";
	return (false);
  } else theForm.EmailFrom.className = "contactFormField";
  
  if (theForm.MessageBody.value == "")
  {
    alert("What is your question or problem?");
    theForm.MessageBody.focus();
	theForm.EmailFrom.className = "contactFormFieldError";
	return (false);
  } else theForm.EmailFrom.className = "contactFormField";
  
  return (true);
}