function hidephoneoptions() {
	document.getElementById('phoneoptions').style.display="none";
}

function phoneoptions() {
	if (document.form.contactphone.checked && !document.form.contactemail.checked) {
		document.getElementById('phoneoptions').style.display="block";
	} else {
		document.getElementById('phoneoptions').style.display="none";
	}	
}

function submitit()
{
	var errorMsg = "Error: The following fields must be filled in: ";
	
		if (!document.form.name.value) {
			errorMsg += "name, ";}
			
		if (document.form.phone.value=="") {
			errorMsg += "phone number, ";}
		
		if (errorMsg=="Error: The following fields must be filled in: ") {
			errorMsg ="Error: ";
		} else {
			errorMsg +="\n";
		} 
		
		var match = /^1?(-| |.)?\(?([0-9]{3})\)?(-| |.)?([0-9]{3})(-| |.)?[0-9]{4}$/i.test(document.form.phone.value);
					
			if (match==false && document.form.phone.value) {
				errorMsg += "Your phone number appears to be invalid or incomplete. ";
			} 	
			
		var match = /^([A-z0-9]|_|.)+[@][A-z0-9]+[.][A-z]+$/i.test(document.form.email.value);
		
			if (match==false && document.form.email.value) {
				errorMsg += "Your email address appears to be invalid or incomplete.";
			} 
			
		var match = /^([A-z]| )+$/i.test(document.form.city.value);
					
			if (match==false && document.form.city.value) {
				errorMsg += "Your city appears to contain invalid characters. ";
			} 
			
			
		var match = /^[0-9]{5}-?([0-9]{4})?$/i.test(document.form.zip.value);
					
			if (match==false && document.form.zip.value) {
				errorMsg += "Your zip code appears to be invalid or incomplete. ";
			} 	

		if (document.form.contactemail.checked && document.form.email.value=="") {
			errorMsg +="Email has been indicated as the prefered method of contact, but no email address was entered. ";
		}
		if (!(document.form.contactemail.checked) && !(document.form.contactphone.checked) && document.form.email.value=="") {
			errorMsg +="Please indicate your preferred method of contact.";
		}
	if (errorMsg !="Error: The following fields must be filled in: " && errorMsg !="Error: ")
	{
		errorMsg = errorMsg.replace(/\, \n/, '.\n');
		alert(errorMsg);
		return 0;
	} else {
		document.form.fun.value="yes";
		document.form.submit();
		return 1;
	}
}

