<!--
window.onload = initForms;

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

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

	// name
	if (inputarray[2].value == "") {
	   window.alert("Please enter a contact name.");
	   inputarray[2].select();
	   inputarray[2].focus();
	   return false;
	   }

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

	// email requirements
	var reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var address = document.forms[0].email.value;
	if (reg.test(address) == false) {
	   alert("Invalid email address.");
	   inputarray[3].select();
	   inputarray[3].focus();
	   return false;
	   }   
	
	// phone
	if (inputarray[4].value != "") {
	   input.array[4].onblur = validateNum;
	   }

	// website or company name
	if (inputarray[5].value == "") {
	   window.alert("Please enter a website / company name.");
	   inputarray[5].select();
	   inputarray[5].focus();
	   return false;
	   }

	// select a package
	if (selectarray[0].value == "") {
	   window.alert("Please select a package.");
	   selectarray[0].focus();
	   return false;
	   }

	// terms of service
	if (document.forms[0].termsofservice.checked == false) { 
	   window.alert("You must read and understand the terms of service.");
	   document.forms[0].termsofservice.focus();
	   return false;
	}

	// privacy policy
	if (document.forms[0].privacypolicy.checked == false) { 
	   window.alert("You must read and understand the privacy policy.");
	   document.forms[0].privacypolicy.focus();
	   return false;
	}
}

function validateNum() {
	var num = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})((x|ext)\d{1,5}){0,1}$/;
	var number =  document.forms[0].phone.value;
	if(num.test(number) == false) {
			alert("Invalid phone number combination.");
			inputarray[4].focus();
			return false;
			}
}
-->