function GetSearchXmlHttpObject() {
	var xmlHttp=null;
	try {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 } catch (e) {
	 // Internet Explorer
	 try {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  } catch (e) {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	}


	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return;
	} 
	
	return xmlHttp;
}


function sendAndLoad(ajx, url, callMe) {
	ajx.onreadystatechange = callMe;
	ajx.open("GET",url,true);
	ajx.send(null);


}

function showResult(str) {
	if (str.length<3) {
		hideSearchResults();
		return;
	}
	
	
	xmlHttp = GetSearchXmlHttpObject();

	var url="/product/list.php?mode=livesearch&searchStr="+str+"&sid="+Math.random();
	sendAndLoad(xmlHttp, url, searchResultFound);
} 

function searchResultFound() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		liveSearchBox = document.getElementById("livesearch");		
		liveSearchBox.innerHTML = xmlHttp.responseText;
		liveSearchBox.style.border = "1px solid #ffffff";
		liveSearchBox.style.backgroundColor = "#000000";		
		if (liveSearchBox.style.opacity) liveSearchBox.style.opacity = 0.9;
		if (liveSearchBox.style.filter) liveSearchBox.style.filter = 'alpha(opacity=90)'; 
	} 
}

function hideSearchResults() {
	d = document.getElementById("livesearch");
	d.innerHTML="";
	d.style.border="0px";
}

function getSearchResults() {

}

function setSearchBox(s, colour) {

	if (s.value =='Looking for something? Search for it here...') {
		s.style.fontStyle = 'normal';
		s.style.color = (colour==undefined) ? '#000000' : colour;
		s.value = '';
	}

}
