var xmlHttp

function lookupkey(inputString) 
{//var data="";
	//alert(inputString);
	//var temp =inputString;
	var temp = document.search.search_pc.value;
	//var help_state=document.getElementById("showdiv1").value;
	//var temp = document.getElementById("keywords").value;
	//alert(document.getElementById("keywords").value);
	//alert("Cat "+temp);
	if(inputString.length == 0)
	{// alert("yeppi");
		// Hide the suggestion box.
		document.getElementById('autoSuggestionsListkey').style.visibility ='hidden';
		document.getElementById('autoSuggestionsListkey').style.display = 'none';
		document.getElementById("suggestionskey").style.display = 'none';
			document.getElementById("suggestionskey").style.visibility ='visible';
	}
	else
	{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="http://www.mapsofindia.com/js_2009/rpc.php";
//str=str.replace("&","%26");
url=url+"?queryString="+temp;
url=url+"&sid="+Math.random();
//alert(url);
xmlHttp.onreadystatechange=function()
{ //alert(xmlHttp.readyState);
if (xmlHttp.readyState==4)
{ 
	//alert(xmlHttp.responseText);
	var data=xmlHttp.responseText;
	//alert(data.length);
		if(data.length >31) {
	//alert(data.length);
	document.getElementById("suggestionskey").style.visibility ='visible';
	document.getElementById("suggestionskey").style.display = 'block';
			//$('#suggestionskey').show();
			document.getElementById("autoSuggestionsListkey").style.visibility ='visible';
			document.getElementById("autoSuggestionsListkey").innerHTML=data;
			//alert(document.getElementById("autoSuggestionsListkey").innerHTML);
			document.getElementById("autoSuggestionsListkey").style.display = 'block';
			//$('#autoSuggestionsListkey').html(data);
		}
		else if(data.length==31)
	{//alert("yes");
			//alert(data.length);
			document.getElementById('suggestionskey').style.visibility ='hidden';
document.getElementById("suggestionskey").style.display = 'none';

	}
	}
}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
	}
	
}// lookup

function fill(thisValue)
{//alert(thisValue);
	//var temp1 = document.getElementById("tags").value;
	var temp1 =document.search.search_pc.value;
	num = temp1.lastIndexOf(",");
	num++;
	temp1 = temp1.substr(0,num);
		
	temp1 = temp1+thisValue;
	//alert(temp1);
	document.search.search_pc.value=temp1;
	//alert(document.getElementById("keywords").value);
document.getElementById('suggestionskey').style.visibility ='hidden';
document.getElementById("suggestionskey").style.display = 'none';
}
/** function to get xmlhttp object */
function GetXmlHttpSiteObject(){
	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 openUrl() {
//alert("yy");
//var myindex=document.hotel_form.dir.selectedIndex;
if (document.search.search_pc.value=="" || document.search.search_pc.value=="Type City Name...") {
alert("\nYou must write name of city.");
return false;
}
else
	{
	var city_nm=document.search.search_pc.value;
	get_htl(city_nm);
	}
//alert(document.hotel_form.htl_src.options[hotel_form.htl_src.selectedIndex].value);
//window.location=(document.hotel_form.htl_src.options[document.hotel_form.htl_src.selectedIndex].value);
}
function get_htl(city_nm)
{ 
	
//alert("in");

//idchange3();
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="http://www.mapsofindia.com/js_2009/getcities.php";


url=url+"?city_nm="+city_nm;
//alert(url);
xmlHttp.onreadystatechange=function()
{ 
if (xmlHttp.readyState==4)
{ 
var string=xmlHttp.responseText;
//alert(string);
document.getElementById("search_hotel").innerHTML=string;
if(string=="")
	{
	alert("Sorry.We are unable to find your query in our database.");
	}
	else
	{
window.location=(document.getElementById("search_hotel").innerHTML);
	}
}
}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}



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;
}


