<!--
window.onload = initForms;

function initForms() {
	for (var i=0; i<document.forms.length; i++) {
	   document.forms[1].onsubmit = function() {return validForm();}
	}
}

function validForm() {
	var inputarray = document.getElementsByTagName("input");
	var selectarray = document.getElementsByTagName("select");
	var textarea = document.getElementsByTagName("textarea");

	// name
	if (document.forms[1].name.value == "") {
	   window.alert("Please enter your name.");
	   document.forms[1].name.focus();
	   document.forms[1].name.select();
	   return false;
	   }

	// email
	if (document.forms[1].email.value == "") {
	   window.alert("Please enter your email address.");
	   document.forms[1].email.focus();
	   document.forms[1].email.select();
	   return false;
	   }

	// email requirements
	var reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var address = document.forms[1].email.value;
	if (reg.test(address) == false) {
	   alert("Invalid email address.");
	   document.forms[1].email.focus();
	   document.forms[1].email.select();
	   return false;
	   }   

	// phone number
	if (document.forms[1].phone.value == "") {
	   window.alert("Please enter your phone number.");
	   document.forms[1].phone.focus();
	   document.forms[1].phone.select();
	   return false;
	   }

	// end time
	if (document.forms[1].start_time.value != "" && document.forms[1].end_time.value == "") {
	   window.alert("Please enter an end time.");
	   document.forms[1].end_time.focus();
	   document.forms[1].end_time.select();
	   return false;
	   }

	// message
	if (document.forms[1].message.value == "") {
	   window.alert("Please provide a message.");
	   document.forms[1].message.focus();
	   document.forms[1].message.select();
	   return false;
	   }

	// spam prevention
	if (document.forms[1].spam_prevention.value == "") {
	   window.alert("Please answer the spam prevention question.\nWhat is 1 + 2?");
	   document.forms[1].spam_prevention.focus();
	   document.forms[1].spam_prevention.select();
	   return false;
	   }

	// spam prevention requirements
	if (document.forms[1].spam_prevention.value != "3" && document.forms[1].spam_prevention.value != "three") {
	   window.alert("Incorrect answer to \"What is 1 + 2?\"\nPlease try again.");
	   document.forms[1].spam_prevention.focus();
	   document.forms[1].spam_prevention.select();
	   return false;
	   }
}
-->
