if(typeof(window._BIG_CITY) == 'undefined')
	window._BIG_CITY = 15;
var req;

function loadCities(countryCode)
{
	loadXMLDoc('/getAllCities.php?country_code=' + countryCode);
}

function loadXMLDoc(url)
{
    if (window.XMLHttpRequest)
    {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    }
    else if (window.ActiveXObject)
    {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req)
        {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function processReqChange() 
{
	var title = "Выберите город";
	// only if req shows "complete"
	if (req.readyState == 4)
	{
		// only if "OK"
		if (req.status == 200)
		{
			el = document.forms[0].elements["city_id"];
			while(el.options.length > 0)
				el.removeChild(el.options[0]);

	    	option = document.createElement("OPTION");
	    	el.options.add(option);
	    	option.appendChild(document.createTextNode(title));
	    	option.value = "";

		    xml = req.responseXML;
		    cities = xml.getElementsByTagName('city');
		    for(var j = 0; j < cities.length; j++)
		    {
		    	option = document.createElement("OPTION");
		    	el.options.add(option);
		    	option.appendChild(document.createTextNode(cities[j].firstChild.nodeValue));
		    	option.value = cities[j].getAttribute("id");
		    	if(cities[j].getAttribute("hotels") > _BIG_CITY)
					option.className = "strong";
		    }
        }
    }
}

