button1 = new Image();
button1.src = "/images/button1.gif";
button2 = new Image();
button2.src = "/images/button2.gif";

function zipClicked() {
	var zip = document.getElementById("zip");

	if (zip.value.match("Enter your ZIP here"))
		zip.value = "";
}

function locate() {
	var zip = document.getElementById("zip");

	if (zip.value.match("Enter your ZIP here")) {
		alert("Please enter your ZIP code.");
		zip.value = "";
		zip.focus();
	}
	else if (zip.value.match("^[0-9]{5}$")) {
		location.href = "http://www.abettertruckcap.com/locator.php?zip=" + zip.value;
	}
	else {
		alert("You have entered an invalid ZIP code.  Please re-enter.\n\nExample: \"44134\"");
		zip.value = "";
		zip.focus();
	}
}

function imageFlip(imageID, imageName) {
	document.images[imageID].src = eval(imageName + ".src");
}

function checkEnter(event) {
	if (event.keyCode == 13)
		locate();
}

