// JavaScript Document

// JavaScript Document
var req;

function loadXMLDocCityCountry(url)
{
	document.getElementById("displayCity").style.display = "none";
	document.getElementById('HotelSearchImageDis').style.display = '';
	if (window.XMLHttpRequest) 
	{
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChangeCityCountry;
		req.open("GET", url, true);
		req.send(null);
		// branch for IE/Windows ActiveX version
	} 
	else if (window.ActiveXObject) 
	{
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) 
		{
			req.onreadystatechange = processReqChangeCityCountry;
			req.open("GET", url, true);
			req.send();
		}
	}
}



function processReqChangeCityCountry()
{
	// only if req shows "complete"
	if (req.readyState == 4) 
	{
		// only if "OK"

		if (req.status == 200) 
		{

			document.getElementById('displayCity').style.display ="";
			//document.getElementById('displayLink').style.display ="";
			

			// ...processing statements go here...
			response = req.responseXML.documentElement;

			TotalArt = response.getElementsByTagName('TotalCity')[0].firstChild.data;
			if ( TotalArt > 0 )
			{
				result_id = Array();
				result_name = Array();
				removeAllOptions(document.ProductForm.hotelfromcity);

				for ( i = 0 ; i < TotalArt ; i++ )
				{
					result_name[i] = response.getElementsByTagName('city')[i].firstChild.data;
					result_id[i] = response.getElementsByTagName('city')[i].firstChild.data;
					addOption(document.ProductForm.hotelfromcity,result_name[i],result_id[i])
				}	
			}
			else
			{
				removeAllOptions(document.ProductForm.hotelfromcity);
				//removeAllOptions(document.ProductForm.cmbAirport);
				addOption(document.ProductForm.hotelfromcity,"No City Found","");
			}
			setTimeout("document.getElementById('HotelSearchImageDis').style.display = 'none'", '300');
	 		setTimeout("document.getElementById('displayCity').style.display = ''", '300');
		} 
		else 
		{
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}


function GetCity(input)
{	
	url = SiteRootPath + "get_city_code.php?param=" + input;
	loadXMLDocCityCountry(url);
}
