/***********************************************
* Validate function - checks input fields from
* the "Contact Us" form to make sure they are
* filled in correctly.
***********************************************/

function validate() {

//Start with no errors - blank alert message
var OutputMessage = "Please complete the following: \n-----------------------------------\n"

//If OutputMessage changes (due to at least one error), then
//noErrors will not match at end of function.
var noErrors = OutputMessage

// make sure name field is not blank
if (document.getElementById('name').value=="") {
	 OutputMessage = OutputMessage + "\n --> Your name";
}

// make sure email address is valid
var email = document.getElementById('email').value
if (email == "") {
    OutputMessage = OutputMessage + "\n --> Your E-mail address";
}
else {
		 var emailFilter=/^.+@.+\..{2,3}$/;
		 if (!(emailFilter.test(email))) { 
   	 		OutputMessage = OutputMessage + "\n --> Please enter a valid E-mail address";
		 }
     else {
     			 //test email for illegal characters 
      		 var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
      		 if (email.match(illegalChars)) {
         	 		OutputMessage = OutputMessage + "\n --> The E-mail address contains illegal characters";
      	   }
     }
}
// make sure comments field is not blank
if (document.getElementById('comments').value=="") {
	 OutputMessage = OutputMessage + "\n --> Comments";
}


// If no errors, submit the form
if (OutputMessage == noErrors) {
return true;
} 
	else {

	// If errors were found, show alert message
	alert(OutputMessage);
	return false;
	}
}