
	var req;
	var t;

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

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

	function processReqChange()
	{
		// I dont think the icon will display on opera 8.5 or safari since
		// they apparantly dont have readystate 1
		if (req.readyState == 1) {
			showContactSearchingIcon();
		}
		// only if req shows 'loaded'
		if (req.readyState == 4) {
			// only if 'OK'
			if (req.status == 200) {
				setTimeout('hideContactSearchingIcon()', 500);
				setTimeout('DisplayResults(req.responseText)', 500);
			} else {
				//alert('There was a problem retrieving the XML data:\n' +
				//	req.responseText);
			}
		}
	}

	function SearchQuestions(query, searchType, categoryIDs)
	{
		if (query.length > 0) {
			DoCallback('q=' + query + '&type=' + searchType + '&c=' + categoryIDs);
		} else {
			hideContactSearchingIcon();
		}
	}

	function DisplayResults(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);
			}
			showContactSearchingIcon();
			t = window.setTimeout("SearchQuestions(m.value,'ars',0)",400);
		}
	}
