// make asynchronous HTTP request using the XMLHttpRequest object 
function loadLookAt() {

	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
  
		var oWant = document.getElementById('selWantTo');
		var sWant = oWant.options[oWant.selectedIndex].value;
				
		xmlHttp.open("GET", "/ajax/productfinder.php?want=" + sWant, true);
	
		xmlHttp.onreadystatechange = responseLookAt;
	
		xmlHttp.send(null);
  
	} else {

		setTimeout('loadLookAt()', 1000);
	}
}

function responseLookAt() {

	if (xmlHttp.readyState == 4) {
  
		if (xmlHttp.status == 200) {
		
			// extract the XML retrieved from the server
			xmlResponse = xmlHttp.responseXML;
			// obtain the document element (the root element) of the XML structure
			xmlDocumentElement = xmlResponse.documentElement;
			
			resultsID = xmlDocumentElement.getElementsByTagName('prod');
			resultsName = xmlDocumentElement.getElementsByTagName('look');
			
			var sel = document.getElementById('selLookAt');
			
			sel.options.length = 0;
			var selindex = 0;
			
			for(i=0; i < resultsID.length; i++) {
			
				sel.options[i] = new Option(resultsName[i].firstChild.data, resultsID[i].firstChild.data);
				
				if(iLookAt == resultsID[i].firstChild.data) {
				
					selindex = i;
					
				}
			
			}
			sel.selectedIndex = selindex;
	
		} else {
		
			alert("There was a problem accessing the server: " + xmlHttp.statusText);
		}
	}
}



