// JavaScript Document

function startList(thisDiv) {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById(thisDiv);
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

//Form validation functions
function validateContactForm(f){
	var validationMsg = "";
	
	if(f.Name.value == "" || f.Address.value == "" || f.City_or_Town.value == "" || f.State.value == "" || f.Zip.value == "" || f.Country.value == "" || f.Email_Address.value == ""){
		validationMsg += "All form fields are required.";
	}
	
	if(f.Zip.value != "" && !isZipCode(f.Zip.value)){
		validationMsg += "The Zip you entered does not appear to be valid. Please check your entry.\n";
	}
	
	if(f.Email_Address.value != "" && !isEmailAddress(f.Email_Address.value)){
		validationMsg += "The Email Address you entered does not appear to be valid. Please check your entry.";
	}
	
	if(validationMsg != ""){
		alert(validationMsg);
		return false;
	}
	return true;
}

function isZipCode(value){
   var RegExp = /^\d{5}([\-]\d{4})?$/;
   return (RegExp.test(value));
}
function isEmailAddress(value){
	var RegExp = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	return (RegExp.test(value));
}