var globalid="";
var globalvalue="";
var ajaxcallctrl="no";

function LoadPage(evt,searchterm,usediv,destid) {
		// Set up request varible
		//alert(" searchterm"+searchterm);
		ajaxcallctrl="no";
		if((searchterm.length)>=1 && searchterm!=""){
		//alert(" searchterm"+searchterm);
	var page="/cities/tw.jsp";
	try {
		xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
		}  catch (e) {
		 alert("Error: Could not load page.");
		 }
		 
		//scroll to top
		scroll(0,0);
		//send data
		var param="value="+searchterm+"&&destid="+destid+"&calldiv="+usediv;
		//alert(param);
		xmlhttp.onreadystatechange = function(){
				//Check page is completed and there were no problems.
				if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
				// Write data returned to page
				// alert(xmlhttp.responseText);
				////////////////// working with display /////////////////
				//alert(document.getElementById(destid).clientX);
				var divObject= document.getElementById(usediv);
				/*var posX=document.documentElement.scrollLeft+parseInt(evt.clientX);
    			var posY=parseInt(evt.clientY)+document.documentElement.scrollTop+10;
				divObject.style.left=posX+'px';
				divObject.style.top=posY+'px';
				alert(parseInt(evt.clientX) + "--"+posX +"  "+parseInt(evt.clientY)+"--"+posY);*/
				divObject.style.display='block';
				
				//////////////////////////////////////////////////////////
						if(ajaxcallctrl=="no") divObject.innerHTML = xmlhttp.responseText;
						// document.getElementById(globalid).style.height=divObject.offsetHeight;
						setTimeout("disposeInformationDiv2('"+usediv+"')",7000);
				}
		}
		       
		// Stop any link loading normaly
		 xmlhttp.open("POST", page,true);
		 xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		 xmlhttp.setRequestHeader("Content-String",param);
		 //xmlhttp.setRequestHeader("connection","close");
		 xmlhttp.send(param);
		 //return false;
		 }
		 if((searchterm.length)==0 || (searchterm.length)<2 || searchterm=="")
		 document.getElementById(usediv).innerHTML = '';
}
function disposeInformationDiv(usediv1)  ///// dispose information division.
{
ajaxcallctrl="yes";
//alert("hide");
//document.getElementById(usediv1).innerHTML="";
	document.getElementById(usediv1).style.display='none';
	//if(globalvalue=="1")document.getElementById(globalid).style.display='none';
}
function disposeInformationDiv2(usediv1)  ///// dispose information division.
{
ajaxcallctrl="yes";
	document.getElementById(usediv1).style.display='none';
	if(globalvalue=="1")document.getElementById(globalid).style.display='none';
}

function setValuetoform(searchval,formval,calldiv){
//alert(searchval+formval);
document.getElementById(formval).value=searchval;
document.getElementById(calldiv).innerHTML = '';
}

