// JavaScript Document
function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser doesn't support javascript!  Please enable javascript on your browser via the preferences/options tab.");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxDiv');
			//ajaxDisplay.innerHTML = ajaxRequest.responseText;
			str = ajaxRequest.responseText

			out1 = str.match("Please use valid zipcodes.")
			if(out1=="false")
			{
				alert("One or more of the zipcodes you have entered is not a recognized zipcode.")
				return false;
			}
			
			out = str.match("false")
			if(out=="false")
			{
				alert("Oops!  Please check your Zipcodes and States, as they need to match.  i.e. the zipcode has to exist within a given State.")
				return false;
			}
		}
	}
	var fromzip = document.getElementById('fromzip').value;
	var fromcity = document.getElementById('fromcity').value;
	var tozip = document.getElementById('tozip').value;
	var tocity = document.getElementById('tocity').value;
	
	var queryString = "?fromzip=" + fromzip + "&fromcity=" + fromcity + "&tozip=" + tozip + "&tocity=" + tocity;

	ajaxRequest.open("GET", "zipstatecheck.asp" + queryString, true);
	ajaxRequest.send(null);
}