var xmlHttp

function AutoCompleter(qry) {
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  		}

	if (qry.length > 0) {
		var url = "../search_history.php";
		url = url+"?complete="+qry;
		url = url+"&sid="+Math.random();
		xmlHttp.onreadystatechange = function() { write(xmlHttp, 'completer'); }
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
		}
	else {
		document.getElementById('completer').style.display = 'none';
		}
	}

function write(xmlHttp, id) {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			pom = document.getElementById(id);
			pom.style.display = '';
			pom.innerHTML = xmlHttp.responseText;
			}
		}
	}

function GetXmlHttpObject() {
	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");
    			}
  		}
	return xmlHttp;
	}
