function toggleDisplay(elem) { // used for show/hide features
	var elem = document.getElementById(elem);
	if ((elem.style.display == "none") || (elem.style.display == "")) {
		elem.style.display = "block";
	} else {
		elem.style.display = "none";
	}
	return false;
}
function validateContact() {
	var d = document;
	var name = d.getElementById("name");
	var email = d.getElementById("email");
	var comments = d.getElementById("comments");
	var e = new Array();
	
	// Validate name
	if (name.value == "") {
		e[e.length] = "You did not enter a name.";
	}
	
	// Validate email
	var validEmail = /^[a-z0-9._%-]+@[a-z0-9._%-]+\.[a-z0-9._%-]+$/i;
	if (email.value == "") {
		e[e.length] = "You did not enter an email address.";
	} else if (!email.value.match(validEmail)) {
		e[e.length] = "You did not enter a valid email address. Example: user@domain.com";
	}
	
	// Validate comments
	if (comments.value == "") {
		e[e.length] = "You did not enter any comments.";
	}
	
	// Prompt with errors if there were any
	if (e.length > 0) {
		var errorMsgs = "There are problems with your submission:\n\n";
		for (i=0; i<e.length; i++) {
			errorMsgs += "-" + e[i] + "\n";
		}
		alert(errorMsgs);
		return false;
	}
}

function validateDealerSearch() {
	var d = document;
	var f = document.getElementById("dealerSearch");
	var e = new Array();
	
	var validZIP = /^[0-9]{5}$/;
	if (f.zip.value == "") {
		e[e.length] = "You did not enter a ZIP code.";
	} else if (!f.zip.value.match(validZIP)) {
		e[e.length] = "You did not enter a valid five-digit ZIP code. Example: 90210";
	}
	var validRadius = /^[0-9]+$/;
	if (f.radius.value == "") {
		e[e.length] = "You did not enter a distance radius.";
	} else if (!f.radius.value.match(validRadius)) {
		e[e.length] = "You did not enter a valid distance radius. Example: 10,15,etc."
	}
	
	// Prompt with errors if there were any
	if (e.length > 0) {
		var errorMsgs = "There are problems with your submission:\n\n";
		for (i=0; i<e.length; i++) {
			errorMsgs += "-" + e[i] + "\n";
		}
		alert(errorMsgs);
		return false;
	}
}





