var searchReq = zipGetXmlHttpRequestObject();
var fType="";

function zipGetXmlHttpRequestObject() {
  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 brandSearchSuggest(f) {
  fType=f;
  if (searchReq.readyState == 4 || searchReq.readyState == 0) {
    var str = escape(document.getElementById('brand'+fType).value);
    if (str.length>0){

		searchReq.open("GET", '/brandSuggest.php?type=' + fType + '&s=' + str, true);
		searchReq.onreadystatechange = brandHandleSearchSuggest; 
		searchReq.send(null);
	} else {
		brandClearSearchSuggest();
	}
  }		
}

function brandHandleSearchSuggest() {

  if (searchReq.readyState == 4) {
    var ss = document.getElementById('brandsuggest'+fType)
    ss.innerHTML = searchReq.responseText;
  }
}

function brandClearSearchSuggest() {
  var ss = document.getElementById('brandsuggest'+fType)
  if (ss) ss.innerHTML = '';
}
