function checkWholeForm(theForm) {

  try {

    var why = "";

    why += checkText(theForm.title, "Title");      
    why += checkText(theForm.fname, "First name");
    why += checkText(theForm.lname, "Last name");    
    why += checkText(theForm.company, "Agency");       
    why += checkText(theForm.email, "Email address");    
    why += checkText(theForm.conf_email, "Email confirmation"); 
    why += checkEmail(theForm.email, theForm.conf_email);        
    why += checkText(theForm.addr1, "Address");    
    why += checkText(theForm.city, "City");    
    why += checkText(theForm.postal, "Postal Code");    
    why += checkText(theForm.province, "State/Province");    
    why += checkText(theForm.state, "State/Province");                            
    why += checkText(theForm.country, "Country");        
    why += checkText(theForm.subject, "Subject");      
    why += checkText(theForm.message, "Message");                    

    if (why != "") {
       alert("There were error(s) processing the form:\n\n" + why);
       return false;
     }
     
  // this is for better mail to do it's tracking functionality   
  try {
    BM_Track();
  } catch (e){}
  
  return true;
  
  } catch (e) {
    alert("There was a problem processing this form. Please email us directly with your request.")
  }  
  
}



function checkText (object, label) {
 var msg = "";
 if (object && object.value == "") {
    msg = label + " cannot be blank.\n";
 }
 return msg; 
}


function checkEmail (email, conf_email) {
  if (email) {
    
    var string=email.value;    
    var msg="";
    var emailFilter=/^.+@.+\..{2,3}$/;

    if (!(emailFilter.test(string))) { 
      msg = "Please enter a valid email address.\n";
    } else {
      var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
      if (string.match(illegalChars)) {
        msg = "The email address contains illegal characters.\n";
      }
    }
    
    if (email && conf_email) {
      if ((email.value != conf_email.value)) {
        msg = "The email and confirmation email must match.\n"
      }
    }
    
    return msg;
  }
}



