var xmlHttp

function showHint(str)
{
	if (str.length<2)
	{ 
		document.getElementById("txtHint").innerHTML="";
		document.getElementById("txtHint").style.visibility="hidden";
		return;
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		//alert ("Your browser does not support AJAX!");
		return;
	} 
		var url="../SIGethint.asp";
		url=url+"?suggestquery="+escape(str);
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
} 

function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
		if(xmlHttp.responseText.length == 0)
		{
			document.getElementById("txtHint").style.visibility="hidden";
		}
		else
		{
			var hintWidth = $(Query).width();
			hintWidth+=50			
			hintWidth = hintWidth + 'px';
			document.getElementById("txtHint").style.width=hintWidth;
			document.getElementById("txtHint").style.visibility="visible";
			updateSelection('init');
		}
	}
}

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;
}

function search_delay(element,str) {
	// Create a function to get the search results
	var func = function() { showHint(str); };

	// Check to see if there is already a timeout and if so...
	// ...cancel it and create a new one
	if ( element.zid ) {
		clearTimeout(element.zid);
	}
	element.zid = setTimeout(func,300);
}
