
function SubmitDialog(dlg) {
	dlg.dialog("close");
	$("<div class='zipcheck-dialog'><p>Checking Zipcode...</p></div>").dialog({
		modal: true,
		draggable: false,
		resizable: false
	});
	
	var zip = $("input", dlg).val();
	$("<form method='post' action='zipcheck.cfm'><input type='hidden' value='" + zip + "' name='zipcode' /></form>").appendTo(document.body).submit();
}

$(document).ready(function(){
	
	$(".zipcheck").click(function(){
		$(
			"<div class='zipcheck-dialog'><p>" +
			"We are required to provide local dealers in your area and will provide these to you once you input your zip code.</p>" +
			"<form onsubmit='SubmitDialog($(this).parent(\".zipcheck-dialog\")); return false;'><label for='zipcode'>Zip</label> <input type='text' name='zipcode' id='zipcode' /></form></div>"
		).dialog({
			modal: true,
			title: "Please enter your zip code",
			draggable: false,
			resizable: false,
			buttons: {
				"Submit": function() {
					SubmitDialog($(this));
				}
			}
		});
		
		return false;
	});
	
	$(".zipcheck-why").click(function() {
		$("<p>We have found that you are in close proximity to one of our local dealers so prices are not shown. Please feel free to place your order online now and we will forward your purchase request to the local dealer in order to offer faster service and convenience to you. You will not be charged; this will be done by your local dealer on your approval of the price after they contact you.</p>").dialog({
			modal: true,
			title: "Why can't I see prices?",
			draggable: false,
			resizable: false
		});
		return false;
	})
	
});
