//==================  New England Wire Technologies Javascript File  =================

//=================Email Validator start=============================
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;
}
//=================Email Validator end=============================

//=================Contact Form Validator start=============================
function ContactFormValidator(contact_form)
{

  if (contact_form.contact.value == "")
  {
    alert("Please enter a value for the \"Contact Name\" field.");
    contact_form.contact.focus();
    return (false);
  } 
   if (contact_form.company.value == "")
  {
    alert("Please enter a value for the \"Company Name\" field.");
    contact_form.company.focus();
    return (false);
  }
  if (contact_form.email.value == "")
  {
    alert("Please enter a value for the \"email\" field.");
    contact_form.email.focus();
    return (false);
  }
  if (!isEmailAddr(contact_form.email.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    contact_form.email.focus();
    return (false);
  }
  if (contact_form.email.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Email\" field.");
    contact_form.email.focus();
    return (false);
  }
     if (contact_form.phone.value == "")
  {
    alert("Please enter a value for the \"Telephone\" field.");
    contact_form.phone.focus();
    return (false);
  } 
 	 if (contact_form.app.value == "")
  {
    alert("Please enter a value for the \"Application\" field.");
    contact_form.app.focus();
    return (false);
  } 
}
//=================Contact Form Validator end=============================

