// validate comment form ----------------------------------------------------

function validate(form) {
	
	var isValid = true;
	var errormsg = "Please correct the following errors: \n";
	
	var teacher = form.teacher.value; 
	if (teacher == "")
	{
		errormsg = errormsg + "\n" + "Please enter a field trip teacher or leader.";
		isValid = false;
	}
	
	var coordinator = form.coordinator.value; 
	if (coordinator == "")
	{
		errormsg = errormsg + "\n" + "Please enter a field trip coordinator or contact person.";
		isValid = false;
	}  
	
	var organization = form.organization.value; 
	if (organization == "")
	{
		errormsg = errormsg + "\n" + "Please enter a school name or organization.";
		isValid = false;
	}
	
	var street = form.street.value; 
	if (street == "")
	{
		errormsg = errormsg + "\n" + "Please enter a street address.";
		isValid = false;
	}
	
	var city = form.city.value; 
	if (city == "")
	{
		errormsg = errormsg + "\n" + "Please enter a city."
		isValid = false;
	}
	
	var zip1 = form.zip1.value; 
	if (zip1 == "")
	{
		errormsg = errormsg + "\n" + "Please enter a zip code."
		isValid = false;
	}
	
	var isChecked = false;
	for (var j=0; j<form.pref_contact.length; j++){
		if (form.pref_contact[j].checked){
			isChecked = true;
		}
	}
	if (isChecked == false){
		errormsg = errormsg + "\n" + "Please check the best way(s) to contact you."
		isValid = false;	
	}
	
	var ph_office = form.ph_office.value; 
	if (ph_office == "" && form.pref_contact[0].checked)
	{
		errormsg = errormsg + "\n" + "You have selected to contact you by office phone number. Please enter an office phone number."
		isValid = false;
	}
	
	var ph_home = form.ph_home.value; 
	if (ph_home == "" && form.pref_contact[1].checked)
	{
		errormsg = errormsg + "\n" + "You have selected to contact you by home phone number. Please enter a home phone number."
		isValid = false;
	}
	
	var ph_cell = form.ph_cell.value; 
	if (ph_cell == "" && form.pref_contact[2].checked)
	{
		errormsg = errormsg + "\n" + "You have selected to contact you by cell phone number. Please enter a cell phone number."
		isValid = false;
	}
	
	var email = form.email.value; 
	if (email == "" && form.pref_contact[3].checked)
	{
		errormsg = errormsg + "\n" + "You have selected to contact you by email. Please enter an email address."
		isValid = false;
	}
	
	if (email == "" && form.copy.checked)
	{
		errormsg = errormsg + "\n" + "Please enter an email address."
		isValid = false;
	}
	
  // check email address
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	
	var email = form.email.value; // email string
	if (email != "")
	{
	  if (!reg1.test(email) && reg2.test(email))  // if syntax is valid
		isValid = isValid;
	  else 
	  {
		errormsg = errormsg + "\n" + "\"" + email + "\" is an invalid e-mail address."
		isValid = false;
	  }
	}
	
	var grade = form.grade.value; 
	if (grade == "")
	{
		errormsg = errormsg + "\n" + "Please enter a grade level."
		isValid = false;
	}
	
	var students = form.students.value; 
	if (students == "")
	{
		errormsg = errormsg + "\n" + "Please enter the number of students."
		isValid = false;
	}
	
	var adults = form.adults.value; 
	if (adults == "")
	{
		errormsg = errormsg + "\n" + "Please enter the number of adults."
		isValid = false;
	}
	
	if (form.vc.selectedIndex == 0)
	{
		errormsg = errormsg + "\n" + "Please select a park."
		isValid = false;
	}
	
	if (form.programs.selectedIndex == 0)
	{
		errormsg = errormsg + "\n" + "Please select a program."
		isValid = false;
	}
		
	var isSeasonChecked = false;
	for (var i=0; i<form.season.length; i++){
		if (form.season[i].checked){
			isSeasonChecked = true;
		}
	}
	if (isSeasonChecked == false){
		errormsg = errormsg + "\n" + "Please check which season you are applying."
		isValid = false;	
	}
	
/*  
  var cfemail = form.cfemail.value; 
  if (cfemail == "")
  {
  	errormsg = errormsg + "\n" + "Please enter your confirm email address"
  	isValid = false;
  }else{
	  if (email != cfemail)
	    {
			errormsg = errormsg + "\n" + "Your email address and confirm email address do not match. Please re-enter your email address" 
			isValid = false;
		}
  }
  
*/
  
	if (!isValid)
	alert(errormsg); // this is also optional
	return isValid;

}

// -->

