	function loadXMLDoc2(url){
	    
		if(window.XMLHttpRequest){
	        req = new XMLHttpRequest();
	        req.onreadystatechange = processReqChange2;
	        req.open("GET", url, true);
	        req.send(null);
	        }
	     else if(window.ActiveXObject){
	        req = new ActiveXObject("Microsoft.XMLHTTP");
	        if(req){
	            req.onreadystatechange = processReqChange2;
	            req.open("GET", url, true);
	            req.send(null);
	        }
	    }
	}
	
	// Функция, выполняемая при изменении статуса запроса, если статус  равен 200, данные получены.
	function processReqChange2(){
	    
		//alert(req.readyState);
		
		if(req.readyState == 4){
	        if(req.status == 200){ getcities(req.responseXML.documentElement); }
	        else{ alert("There was a problem retrieving the XML data:" + req.statusText); }
	    }
	}

	function ChangeCountry(_this)
	{		loadXMLDoc2("/user/country/"+_this.value); 
	}
	
	function getcities(xml)
	{
		var cities = xml.getElementsByTagName("city");
		var city_ids = xml.getElementsByTagName("city_id");

		var City_Select = document.getElementById("city_id");
		
		City_Select.innerHTML = ""; 
		
		if(cities.length == 0)
		{
			var option = document.createElement("option");
			var optionText = document.createTextNode('Недоступно');
			
			option.appendChild(optionText);
			option.setAttribute("value", '0');
			
			City_Select.appendChild(option);
		}
			else
			{
				var option = document.createElement("option");
				var optionText = document.createTextNode('Выбрать');
				
				option.appendChild(optionText);
				option.setAttribute("value", '0');
				
				City_Select.appendChild(option);
			}
		
		for(i=0; i<cities.length; i++)
		{
			var option = document.createElement("option");
			var optionText = document.createTextNode(cities[i].firstChild.data);
			
			option.appendChild(optionText);
			option.setAttribute("value", city_ids[i].firstChild.data);
			City_Select.appendChild(option);
		}
	}