var xmlHttp
var city
function showUser(str)
{ 	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		 alert ("Browser does not support HTTP Request")
		 return
	}
	var url="get_home_links.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}


function stateChanged() 
{ 
	
	div_id="expanded_links"
	document.getElementById(div_id).innerHTML="<p><i>Loading links...</i>" 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 	{ 
 		document.getElementById(div_id).innerHTML=xmlHttp.responseText 
 	} 
}

function showCity(i)
{ 

	var id="city"+i;
	city=document.getElementById(id).value;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="get_city.php"
	url=url+"?q="+city
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedCity 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}


function stateChangedCity() 
{ 
	
	div_id="timetable"
	document.getElementById(div_id).innerHTML="<p><i>Loading timetable...</i>" 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 	{ 
 		document.getElementById(div_id).innerHTML=xmlHttp.responseText 
 		div_id="Selected_city";
 		document.getElementById(div_id).innerHTML=city+" time is shown." 		
 	} 
}


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;
}
