function getHTTPObject()

{

	var xmlhttp; 

	if(window.XMLHttpRequest)

	{     

		xmlhttp = new XMLHttpRequest(); 

	}

	else if (window.ActiveXObject)

	{    

		 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");   

		 if (!xmlhttp)

		 {        

		   xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");

		 }

	}

	 return xmlhttp;

}



var http = getHTTPObject();

 // We create the HTTP Object

function showCity()   //--------------- For Cities ---//

{      

	 var tidval = document.getElementById("state").value; 

	 var url = "Scripts/showcity.php?state="+escape(tidval);     	 

	 http.open("GET",url,true);   

	 http.onreadystatechange = handleUser; 

	 http.send(null); 

}



function showBadCity()   //--------------- For Cities ---//

{      

	 var tidval = document.getElementById("state").value; 

	 var url = "Scripts/showBadCity.php?state="+escape(tidval);     	 

	 http.open("GET",url,true);   

	 http.onreadystatechange = handleUser; 

	 http.send(null); 

}



function handleUser() 

{              

	if (http.readyState == 4)

	{                

		if(http.status==200) 

		{  

		  var results=http.responseText;  

		  document.getElementById('divCity').innerHTML = results;    

		}

	}

}   





 

function showStores() 

{      

	 document.getElementById("divStores").innerHTML = "<img src='images/loading.gif'>";

	 

	 var tidval = document.getElementById("city").value; 
	 var stateval = document.getElementById("state").value; 

	 var url = "Scripts/showcity.php?city="+escape(tidval)+"&state="+escape(stateval);

	 http.open("GET",url,true);   

	 http.onreadystatechange = handleUserStores; 

	 http.send(null); 

}



function showBadStores() 

{      

	 document.getElementById("divStores").innerHTML = "<img src='images/loading.gif'>";

	 

	 var tidval = document.getElementById("city").value; 

	 var url = "Scripts/showBadCity.php?city="+tidval;   

	   	 

	 http.open("GET",url,true);   

	 http.onreadystatechange = handleUserStores; 

	 http.send(null); 

}



function handleUserStores() 

{              

	if (http.readyState == 4)

	{                

		if(http.status==200) 

		{  

		  var results=http.responseText;  

		  document.getElementById("divStores").innerHTML = "";

		  document.getElementById('divStores').innerHTML = results;    

		}

	}

} 
