function displayError(text) {
	document.getElementById("result").innerHTML = "Error: " + text;
}

function displayResults(html) {
	var imgcode = '<a href="http://www.keeptheheaton.com/cgi-bin/ss000001.pl?SECTIONID=index%2ehtml&amp;NOLOGIN=1"><img src="images/400%20x%20150.gif" alt="" width="400" height="200" border="0" /></a>';
	var result = document.getElementById("result");
	if(html=='') {
		if(result.className=="hideme") {
			result.style.display = "none";
		}
		else if(result.innerHTML != imgcode) {
			result.innerHTML = imgcode;
			result.style.backgroundPosition = '0px 0px';
		}
	} else {
		result.style.display = 'block';
		result.innerHTML = html;
		result.style.backgroundPosition = '0px 200px';
	}
}

function doPartSearch() {
	var part = document.getElementById("SS").value;
	if(part.length<1) { displayResults(''); return; }
	var oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open("get", "http://www.keeptheheaton.com/acatalog/partcheck.php?html=1&fuzzy=1&part=" + part, true);
	oXmlHttp.onreadystatechange = function() {
		if(oXmlHttp.readyState == 4) {
			if(oXmlHttp.status == 200) {
				displayResults(oXmlHttp.responseText);
			} else {
				displayError(oXmlHttp.statusText);
			}
		}
	};
	oXmlHttp.send(null);
}
