  // window.setInterval("checkInput()",100)
   var xmlhttp;
   var stopInterVal;
   var lastValue="";
   var nowValue="";
   var objInput,objDiv;
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
   function stringLTrim(obj)
   {
      for(var i=0;i<=obj.length-1;i++)
	     if(obj.charAt(i)!=" ")
		    break;
	  return obj.substring(i,obj.length);
   }
   
   function getElementLeft(obj)
   { 
      var l=0;
	  
	  while(obj!=null)
	  { 
	      l=l+obj.offsetLeft;
		
		  obj=obj.offsetParent;
	   }  
	   return l;
    } 
	function getElementTop(obj)
	{
	   var h=0;
	   while(obj!=null)
	   {
	      h=h+obj.offsetTop;
		 
		  obj=obj.offsetParent; 
		  
		}
		return h;
    }
 
 
   function inputAutoComplete(inputID,divID)
   {    
       objInput=document.getElementById(inputID);
	   objDiv=document.getElementById(divID);
	   stopInterVal=window.setInterval("sendMsg()",10)
	   //alert("2");
   }
 
  function divDisplayNone(obj)
   {
      obj.innerHTML="";
	  obj.style.display="none";
	  
   }
   
    function sendMsg()
	{
	        //alert(1);
			
		    var tempValue=stringLTrim(objInput.value);
			if(tempValue.length==0)
			   lastValue="";
	        if(tempValue.length>=1)
			{ 
			if(tempValue!=lastValue)
			  { 
	           xmlhttp.open("POST","uio_serviceGetMsg.asp?word="+escape(tempValue),true);
	           xmlhttp.onreadystatechange=receiveMsg;
               xmlhttp.send(null);
			   lastValue=tempValue;
			  }
			}
			else divDisplayNone(objDiv)
	
	   
    }
	
	function receiveMsg()
	{
	    //alert("1");
		if(xmlhttp.readystate==4)
		   if(xmlhttp.status==200)
		      {    
					//alert(xmlhttp.responseText);
					var js=eval("(" + xmlhttp.responseText + ")");
					if(js.msg=="1") 
					{
				         objDiv.style.display="";
				         objDiv.style.width=parseInt(objInput.style.width,10)+"px";
	                     objDiv.style.top=getElementTop(objInput)+objInput.offsetHeight-1;
	                     objDiv.style.left=getElementLeft(objInput);
					     objDiv.innerHTML="";
			             var html="";
				         for(var i=0;i<=js.data.length-1;i++)
				           {   
						html=html + "<div style='padding-left:2px; cursor:default; line-height:19px; clear:right;height:19px; background-color:#FFFFFF;' onmouseover='mouseInDiv(this)' onmouseout='mouseOutDiv(this)' onclick='divClick(this)'> ";
					    html=html + "<div style='float:left;'>" + js.data[i].word + "</div>"
					    html=html + "<div style='float:right;color:#008000; padding-right:2px;'> " + js.data[i].renqi + " Hits</div>"
					    html=html + "</div>";
		                   } 
						
				         objDiv.innerHTML=html;
						// alert(html);
						
				     }
					 else 
					     divDisplayNone(objDiv);
			  }
	 }
	 function divClick(obj)
	 { 
	    // alert(objInput.value);
		 objInput.value=obj.childNodes[0].innerText;
		 divDisplayNone(objDiv);
		 lastValue=objInput.value;
		 window.clearInterval(stopInterVal);
	 }
	 function mouseInDiv(obj)
	 {
		 obj.childNodes[0].style.color="#FFFFFF";
		 obj.childNodes[1].style.color="#FFFFFF";
		 obj.style.backgroundColor="#3366CC";
		 nowValue=obj.childNodes[0].innerText;
	 }
	 function mouseOutDiv(obj)
	 {
	     obj.childNodes[1].style.color="#008000";
		 obj.childNodes[0].style.color="#000000";
		 obj.style.backgroundColor="#FFFFFF";
		 nowValue="";
	 }
     function inputLoseFocus()
	 {
		// alert(objInput.value);
		if(nowValue!="")
		   { 
		     objInput.value=nowValue;
			 lastValue=nowValue;
			 nowValue="";
		   }
		divDisplayNone(objDiv) 
	 }
		 