var xmlHttp = createXMLHttpRequestObject();

function showProd(str)
{ 

if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return
 } 
	var url="compImgDisplay.php"; /*getproducts.php is REAL PHP 5 version*/
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	document.getElementById("productDivDisplay").innerHTML=xmlHttp.responseText 
 } 
}

function showProd2(str)
{ 

if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return
 } 
	var url="compImgDisplay.php"; /*getproducts.php is REAL PHP 5 version*/
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged2;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged2() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	document.getElementById("productDivDisplay2").innerHTML=xmlHttp.responseText 
 } 
}

function createXMLHttpRequestObject(){
	
	var xmlHttp;
	
	try{
		
		xmlHttp = new XMLHttpRequest();
	
	}
	catch(e)
	{
		
		var XmlHttpVersions = new array('MSXML2.XMLHTTP.6.0',
										'MSXML2.XMLHTTP.5.0',
										'MSXML2.XMLHTTP.4.0',
										'MSXML2.XMLHTTP.3.0',
										'MSXML2.XMLHTTP',
										'Microsoft.XMLHTTP');
		
		for(var i=0; i<XmlHttpVersions.length && ! xmlHttp; i++){
			
			try{
				
				xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			
			}
			catch(e){}
			
		}
	
	}
	
	if(!xmlHttp)
		alert("Error creating the XMLHttpRequest object.")
	else
		return xmlHttp;

}

function handleRequestStateChange(){
	
	if(xmlHttp.readyState == 4){
		
		if(xmlHttp.status == 200){
			
			try{
				handServerResponse();
			}
			catch(e){
				alert("Error reading the response: " +e.toString());
			}
		
		}
		else{
			alert("there was a problem retrieving data:\n" + xmlHttp.statusText);
		}
	}
}

function handServerResponse(){

	var xmlResponse = xmlHttp.reponseXML;
	name = encodeURIComponent(document.getElementById("selectProduct").value);
	xmlRoot = xmlResponse.documentElement;
	
	titleArray = xmlRoot.getElementByTagName("title");
	imageArray = xmlRoot.getElementByTagName("image");
	
	var html = "";
	
	for(var i=0; $i<titleArray.length; $i++ ){
		
		if(titleArray.item($i).firstChild.data == name){
			
			html += imageArray.item($i).firstChild.data;
			
		}
	
	}
	
	myDiv = document.getElementById("productDivDisplay");
	myDiv.innerHTML = "<img src=\"" + html + " \" />";

}