var searchReq = prodGetXmlHttpRequestObject();
var fType="";

function prodGetXmlHttpRequestObject() {
  var xmlHttp;
  
  if (window.ActiveXObject) {
    try {xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.6.0"); return xmlHttp;} catch (e) {}
    try {xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.5.0"); return xmlHttp;} catch (e) {}
    try {xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.4.0"); return xmlHttp;} catch (e) {}
    try {xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0"); return xmlHttp;} catch (e) {}
    try {xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); return xmlHttp;} catch (e) {}
    try {xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); return xmlHttp;} catch (e) {}
  } else {
    try {xmlHttp = new XMLHttpRequest(); return xmlHttp;} catch (e) {}
  }
}

function prodSearchSuggest(f) {
  fType=f;
  if (searchReq.readyState == 4 || searchReq.readyState == 0) {
    var str = escape(document.getElementById('prod'+fType).value);
    if (str.length>0){
	    searchReq.open("GET", '/prodSuggest.php?type=' + fType + '&s=' + str, true);
	    searchReq.onreadystatechange = prodHandleSearchSuggest; 
	    searchReq.send(null);
    } else {
    	prodClearSearchSuggest();
    }
  }		
}

function prodHandleSearchSuggest() {
  if (searchReq.readyState == 4) {
    var ss = document.getElementById('prodsuggest'+fType)
    ss.innerHTML = searchReq.responseText;
  }
}

function prodClearSearchSuggest() {
  var ss = document.getElementById('prodsuggest'+fType)
  ss.innerHTML = '';
}
