var xmlHttp

function showHint(str,event)
{
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  document.getElementById("city").style.visibility="visible";
  return;
  }

  reg = /'/g;
  str = str.replace(reg, "''");

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

  var coords = findPos(document.getElementById("keyword"));
  document.getElementById("txtHint").style.left=coords[0];
  document.getElementById("txtHint").style.top=coords[1]+23;
  
  tt = document.getElementById("txtHint").style.visibility;

  //if(event.keyCode == 40)
  //	document.getElementById("hintSelect").focus();

var url="ajaxHint.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
  if(xmlHttp.responseText=="nothing")
  {
    document.getElementById("txtHint").style.visibility = "hidden";
    document.getElementById("city").style.visibility="visible";
  }
  else
  {    
    document.getElementById("txtHint").style.visibility = "visible";
    document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
    document.getElementById("city").style.visibility="hidden";
  }
}
}

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 cellOn(obj)
{
  obj.style.backgroundColor="#FFCC66";
}
function cellOff(obj)
{
  obj.style.backgroundColor="#FFFFFF";
}
function cellClick(obj)
{
  formValue = obj.innerHTML;
  reg = /&amp;/g;
  formValue = formValue.replace(reg, "&");
  sForm.keyword.value=formValue;
}

function bdClick()
{
  document.getElementById("txtHint").style.visibility="hidden";
  document.getElementById("city").style.visibility="visible";
}
function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
  