function validform(contactForm){
   if (contactForm.first_name.value=="") {
   	  alert ("Please enter a first name")
   	  contactForm.first_name.focus()
   	  contactForm.first_name.select()
   	  return false
   }
   if (contactForm.last_name.value=="") {
   	  alert ("Please enter a last name")
   	  contactForm.last_name.focus()
   	  contactForm.last_name.select()
   	  return false
   }
  
   if (!validateEmail(contactForm.email.value,contactForm.confirmemail.value)) {
   	  contactForm.email.focus()
   	  contactForm.email.select()
   	  return false
   }   
   if (contactForm.nbrpeople.value=="") {
   	  alert ("Please enter the number of people in the party")
   	  contactForm.nbrpeople.focus()
   	  contactForm.nbrpeople.select()
   	  return false
   }
   
  if (contactForm.lead_source.value=="Other" && contactForm.whereother.value=="") {
   	  alert ("Please enter where you heard about us in the Other – please state where box")
   	  contactForm.whereother.focus()
   	  contactForm.whereother.select()
   	  return false
   }    
 
   return true
}

function validateEmail(email,email2){
  invalidChars= " /:,;"
  if (email =="") {
   	  alert ("Please enter a valid email address")
      return false
  }
  if (email != email2) {
   	  alert ("The two email addresses do not match.")
      return false
  }
  for (i=0;i<invalidChars.length;i++){
      badChar= invalidChars.charAt(i)
	  if (email.indexOf(badChar,0) > -1) {
   	     alert ("There are invalid characters in the email address")
  	     return false
	  }
  }
  atPos = email.indexOf("@",1)
  if (atPos == -1){
   	  alert ("A valid email address needs a @!")
      return false
  }
  if (email.indexOf("@",atPos+1)!=-1){	 	 					    // check only 1 @
   	  alert ("A valid email address needs a @ but only one of them!")
      return false
  }
  periodPos=email.indexOf(".",atPos)
  if (periodPos == -1){
   	  alert ("A valid email address needs a .")
      return false
  }
  if (periodPos+3 > email.length){                                   // at least 2 chars after the .
   	  alert ("A valid email address needs at least 2 letters after the .")
      return false
  }
  return true
}
