/* This is custom and tries to be generic 
 * - Assign a different name to each webform
     + Inquiries is used in contactus.shtml
     + ProductRequest is used in downloadinfo.shtml 
   - Use those names in validate() to switch to different
     validations modes. 
 */

/* Checks for a valid E-Mail regular expression 
 */
function validate_email(field) 
{
 with(field)
 {
 {
  var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
  var ret;
  if (re.test(value)==false)
  {
   alert("E-Mail address doesn't seem to be valid");
   focus(); 
   return(false);  
  }
  else
  {
   return(true);
  } 
 }
 }
}

/* Checks if a field is NON blank (ie FILLED), if it is "EMail" 
   further checks are made in validate_email */
function validate_filled(field)
{
 with(field)
 {
 if (field.name == "EMail")
 {
  return (validate_email(field)); 
 }

 if ( (value == "") || (value == null) )
 {
  text = field.name + " must be filled";  
  alert(text);
  focus(); 
  return (false);
 }
 else {return (true);}
 }
}


function validate(thisform)
{
 with (thisform)
 {

 /* Form in contactus.shtml */
 if(thisform.name=="Inquiries")
 {

 if (validate_filled(Name)==false)
 {
  return (false);
 }
 if (validate_filled(Company)==false)
 {
  return(false); 
 }
 if (validate_filled(EMail)==false)
 {
  return(false); 
 }
 if (validate_filled(Subject)==false)
 {
  return(false); 
 }
 if (validate_filled(Comments)==false)
 {
  return(false); 
 }

 }

 /* Form in downloadinfo.shtml */
 else if(thisform.name=="ProductRequest") 
 {
   if (validate_filled(Name)==false)
   {
    return (false);
   }
//   if (validate_filled(Company)==false)
//   {
//    return(false); 
//   }
   if (validate_filled(EMail)==false)
   {
    return(false); 
   }
 }
}
}
