// validate comment form ----------------------------------------------------

function validate(form) {
	
	var isValid = true;
	var errormsg = "Please correct the following errors: \n";
	
	var fname = form.fname.value; 
	if (fname == "")
	{
		errormsg = errormsg + "\n" + "Please enter your first name.";
		isValid = false;
	}  
	
	var lname = form.lname.value; 
	if (lname == "")
	{
		errormsg = errormsg + "\n" + "Please enter your last name.";
		isValid = false;
	}
	
	var email = form.email.value; 
	if (email == "")
	{
		errormsg = errormsg + "\n" + "Please enter your 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;
	  }
	}
	
	if (form.rentchoice.selectedIndex == 0)
	{
		errormsg = errormsg + "\n" + "Please choose the facility you are interested in for future rental."
		isValid = false;
	}
	
	var comments = form.comments.value; 
	if (comments == "")
	{
		errormsg = errormsg + "\n" + "Please enter your comments/questions."
		isValid = false;
	}
  
	if (!isValid)
	alert(errormsg); // this is also optional
	return isValid;

}

// -->
