function DisableZipCities()
{
	document.getElementById("zipCityRow").style.display = "none";
}

function DisablezipZipContainer()
{
	document.getElementById("zipZipRow").style.display = "none";
}

function LoadZipCities()
{
	var o = document.getElementById("zipState");
	DisablezipZipContainer();
	DisableZipCities();
	
	if (o.value != "")
	{
		if (window.ActiveXObject) {try {r = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {r = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}}}
		else if (window.XMLHttpRequest) {r = new XMLHttpRequest();}//Mozilla, Safari, etc.
		else {return false;}
		r.onreadystatechange = function() {ReturnZipCities(r)};
		r.open("GET", "/zips/?abv="+o.value+"&cache="+new Date().getTime(), true);// open(Method, Url, Async)
		r.send(null);
	}
}

function LoadZipStates()
{
	var a = States.split(";");
	var o = document.getElementById("zipState"); o.length = 0;
	o.options[0] = new Option("");
	o.options[0].value = "";
	
	for (var i = 0; i < a.length; i++)
	{
		var b = a[i].split(":");
		o.options[i+1] = new Option(b[1]);
		o.options[i+1].value = b[3];
	}
}

function LoadzipZipContainer()
{
	var x = document.getElementById("zipCity").value;
	
	if (x == "")
		DisablezipZipContainer();
	else
	{
		document.getElementById("zipZipRow").style.display = (w3 == true) ? "table-row" : "inline";
		document.getElementById("zipZipContainer").innerHTML = "<a href=\"#\" onClick=\"javascript: document.getElementById('zip').value='" + x + "'; document.getElementById('zip').select(); VeilObj.Close(); return false;\">" + x + "</a>";
	}
}

function ReturnZipCities(r)
{
	var o = document.getElementById("zipCityRow");
	var p = document.getElementById("zipCityContainer");
	o.style.display = (w3 == true) ? "table-row" : "inline";
	p.innerHTML = "<img alt=\"\" id=\"spinner\" src=\"" + Spin16.src + "\" title=\"\" />";
	
	if (r.readyState == 4 && (r.status==200 || window.location.href.indexOf("http")==-1) && r.responseText.substring(r.responseText.length-9,r.responseText.length) == "</select>")
		p.innerHTML = r.responseText;
	else if (r.readyState == 4)
	{
		VeilObj.Close();
		alert("There was a connection timeout. Please try your selection again. If you continue to experience problems, please try a different browser such as Internet Explorer 7.0 (or above) or FireFox 2.0 (or above).");
	}
}

function ShowZipFinder()
{
	var x = "<div id=\"veilZips\">";
	x = x + "<h1>Zip Code Lookup</h1>";
	x = x + "<p>Select a state and city to find its zip code.</p>"
	x = x + "<form action=\"\" method=\"\" id=\"formZips\">";
	x = x + "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
	x = x + "<tr><td class=\"l\">State:</td><td class=\"r\"><select id=\"zipState\" name=\"zipState\" onChange=\"LoadZipCities();\" onKeyUp=\"LoadZipCities();\"></select></td></tr>";
	x = x + "<tr id=\"zipCityRow\"><td class=\"l\">City:</td><td class=\"r\" id=\"zipCityContainer\"></td></tr>";
	x = x + "<tr id=\"zipZipRow\"><td class=\"l\">Zip Code:</td><td class=\"z\" id=\"zipZipContainer\"></td></tr>";
	x = x + "</table>";
	x = x + "</form>";
	x = x + "</div>";
	
	OpenVeil("350px", "Zip Code Lookup", x, "");
	LoadZipStates();
}
