//load variable
var xmlHttp;

//function called when dropdown is changed
function showcity(str){ 
	//load the proper syntax into the variable
	xmlHttp=GetXmlHttpObject();
	
	//double check ajax-useablity
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	//url from which info is grabbed
	var url="http://www.cheshirepubguide.co.uk/gencity.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();

	//check if state is changed
	xmlHttp.onreadystatechange=stateChanged;
	//if so send necessary info
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

//function checks ready state
function stateChanged(){ 
	if (xmlHttp.readyState==4){ 
		//if state is ready, load the div tag with the response from the info sent
		document.getElementById("pubDropdown").innerHTML=xmlHttp.responseText;
	}
}

//function checks browser
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;
}
