/*
In the form tag add this =>
 onSubmit="return validate(this);" 
*/
function validate() {

  var theMessage = "Please complete the following: \n-----------------------------------\n";
  var noErrors = theMessage

  if (document.regform.fname.value=="") {
    theMessage = theMessage + "\n --> Your Frist Name";
  }
  if (document.regform.lname.value=="") {
    theMessage = theMessage + "\n --> Your Last Name";
  }

  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.regform.email.value)){
    theMessage = theMessage + "\n --> Enter a valid e-mail address";
  }
  
  if (document.regform.phone.value=="") {
    theMessage = theMessage + "\n --> Your Phone Number";
  }
  
  if (document.regform.company.value=="") {
    theMessage = theMessage + "\n --> Your Company Name";
  }
  
  if (document.regform.city.value=="") {
    theMessage = theMessage + "\n --> Your City";
  }
  
  if (document.regform.zip.value=="") {
    theMessage = theMessage + "\n --> Your Zip Code";
  }
  
// validate First Contact radio buttons
  myOption = -1;
  for (i=document.regform.firstcontact.length-1; i > -1; i--) {
    if (document.regform.firstcontact[i].checked) {
      myOption = i; i = -1;
    }
  }
  if (myOption == -1) {
    theMessage = theMessage + "\n --> How we should contact you";
  }


// validate Facility radio buttons
  myOption2 = -1;
  for (i=document.regform.facility.length-1; i > -1; i--) {
    if (document.regform.facility[i].checked) {
      myOption2 = i; i = -1;
    }
  }
  if (myOption2 == -1) {
    theMessage = theMessage + "\n --> The type of facility";
  }
  
  
  
  if ( 
  	(!document.regform.services_Janitor.checked) && (!document.regform.services_postConstruction.checked) &&
	(!document.regform.services_project.checked) && (!document.regform.services_shipping.checked) &&
	(!document.regform.services_mailroom.checked) ) {
    	theMessage = theMessage + "\n --> The services you require";
  }
  

  // If no errors, submit the form
  if (theMessage == noErrors) {
    return true;
  } else {
    // If errors were found, show alert message
    alert(theMessage);
    return false;
  }

}
// End -->


