
	var req = new Array();
	var t;
	var lastData;
	var lastReqNum = 0;

	function abortPreviousReqs()
	{
		for (i=0; i<lastReqNum; i++) {
			if (req[i]) {
				req[i].abort();
			}
		}
	}

	function processReqChange()
	{
		// only if req shows 'loaded'
		if (req[lastReqNum].readyState == 4) {
			// only if 'OK'
			if (req[lastReqNum].status == 200) {
				hideContactSearchingIcon();
				DisplayResults(req[lastReqNum].responseText);
			}
		}
	}

	function DoCallback(data)
	{
		var url = akbPath + '/xmlsearch.php';

		lastData = data;

		abortPreviousReqs();

		// branch for native XMLHttpRequest object
		if (window.XMLHttpRequest) {
			lastReqNum++;
			req[lastReqNum] = new XMLHttpRequest();
			req[lastReqNum].onreadystatechange = processReqChange;
			req[lastReqNum].open('POST', url, true);
			req[lastReqNum].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			req[lastReqNum].send(data);
		// branch for IE/Windows ActiveX version
		} else if (window.ActiveXObject) {
			lastReqNum++;
			req[lastReqNum] = new ActiveXObject('Microsoft.XMLHTTP')
			req[lastReqNum].onreadystatechange = processReqChange;
			req[lastReqNum].open('POST', url, true);
			req[lastReqNum].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			req[lastReqNum].send(data);
		}
	}

	function SearchQuestions(query, searchType, categoryIDs)
	{
		var	data = 'q=' + query + '&type=' + searchType + '&c=' + categoryIDs;

		if (query.length > 0 && data != lastData) {
			showContactSearchingIcon();
			DoCallback(data);
		} else {
			hideContactSearchingIcon();
		}
	}

	function DisplayResults(html)
	{
		if (html) {
			document.getElementById("SearchResults").innerHTML = html;
		}
	}

	function CloseXMLDiv()
	{
		document.getElementById("SearchResults").innerHTML = '';
	}

	function hideContactSearchingIcon()
	{
		if (document.getElementById('contactImgSearching')) {
			document.getElementById('contactImgSearching').style.display = 'none';
		}
		if (document.getElementById('contactImgNotSearching')) {
			document.getElementById('contactImgNotSearching').style.display = 'inline';
		}
	}

	function showContactSearchingIcon()
	{
		if (document.getElementById('contactImgSearching')) {
			document.getElementById('contactImgSearching').style.display = 'inline';
		}
		if (document.getElementById('contactImgNotSearching')) {
			document.getElementById('contactImgNotSearching').style.display = 'none';
		}
	}

	function ARS(id)
	{
		m = document.getElementById(id);

		if (m.value.length > 2) {
			if (t) {
				window.clearTimeout(t);
			}
			t = window.setTimeout("SearchQuestions(m.value,'ars',0)",400);
		}
	}
