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 zipSearchSuggest(f) {
  fType=f;
  if (searchReq.readyState == 4 || searchReq.readyState == 0) {
    var str = escape(document.getElementById('zip'+fType).value);
    if (str.length>0){

		searchReq.open("GET", '/zipSuggest.php?type=' + fType + '&s=' + str, true);
		searchReq.onreadystatechange = zipHandleSearchSuggest; 
		searchReq.send(null);
	} else {
		zipClearSearchSuggest();
	}
  }		
}

function zipSearchSuggestNoFav(f) {
  fType=f;
  if (searchReq.readyState == 4 || searchReq.readyState == 0) {
    var str = escape(document.getElementById('zip'+fType).value);
    if (str.length>0){

		searchReq.open("GET", '/zipSuggest.php?type=' + fType + '&s=' + str + '&skipfav=y', true);
		searchReq.onreadystatechange = zipHandleSearchSuggest; 
		searchReq.send(null);
	} else {
		zipClearSearchSuggest();
	}
  }		
}

function zipHandleSearchSuggest() {

  if (searchReq.readyState == 4) {
    var ss = document.getElementById('zipsuggest'+fType);
    ss.innerHTML = searchReq.responseText;
  }
}

function zipClearSearchSuggest() {
  var ss = document.getElementById('zipsuggest'+fType);
  if (ss) ss.innerHTML = '';
}
