

// 1111111111111111111111111111111111
// Функция, осуществляющая AJAX запрос.
function loadXMLDoc(method,url){
    if(window.XMLHttpRequest){
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open(method, url, true);
        req.send(null);
    }else if(window.ActiveXObject){
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if(req){
            req.onreadystatechange = processReqChange;
            req.open(method, url, true);
            req.send(null);
        }
    }
}
// Функция, выполняемая при изменении статуса
// запроса, если статус  равен 200, данные получены.
function processReqChange(){
    if(req.readyState == 4){
        if(req.status == 200){
			getColors(req.responseXML.documentElement);
        }else{
            alert("There was a problem retrieving the XML data:\\n" + req.statusText);
        }
    }
}
function onChange(_this){
	document.getElementById("WCities_1").className='progress';
	var url = "/country.php?country_id="+_this.value+"&lang_id=1";
	loadXMLDoc("get",url);
}
function getColors(xml){
	var cities = xml.getElementsByTagName("c");
	var _select = document.getElementById("cities_1");
	_select.innerHTML = ""; // Удаляем всех потомков.
	// Создаем список с доступными цветами.
	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",cities[i].getAttribute("value"));
		_select.appendChild(option);
	}
	document.getElementById("WCities_1").className='progressOff';
}

// 22222222222222222222222222222222222
// Функция, осуществляющая AJAX запрос.
function loadXMLDoc2(method,url){
    if(window.XMLHttpRequest){
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange2;
        req.open(method, url, true);
        req.send(null);
    }else if(window.ActiveXObject){
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if(req){
            req.onreadystatechange = processReqChange2;
            req.open(method, url, true);
            req.send(null);
        }
    }
}
// Функция, выполняемая при изменении статуса
// запроса, если статус  равен 200, данные получены.
function processReqChange2(){
    if(req.readyState == 4){
        if(req.status == 200){
			getColors2(req.responseXML.documentElement);
        }else{
            alert("There was a problem retrieving the XML data:\\n" + req.statusText);
        }
    }
}
function onChange2(_this){
	document.getElementById("WCities_2").className='progress';
	var url = "/country.php?country_id="+_this.value+"&lang_id=1";
	loadXMLDoc2("get",url);
}
function getColors2(xml){
	var cities = xml.getElementsByTagName("c");
	var _select = document.getElementById("cities_2");
	_select.innerHTML = ""; // Удаляем всех потомков.
	// Создаем список с доступными цветами.
	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",cities[i].getAttribute("value"));
		_select.appendChild(option);
	}
	document.getElementById("WCities_2").className='progressOff';
}

// 333333333333333333333333333333333333
// Функция, осуществляющая AJAX запрос.
function loadXMLDoc3(method,url){
    if(window.XMLHttpRequest){
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange3;
        req.open(method, url, true);
        req.send(null);
    }else if(window.ActiveXObject){
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if(req){
            req.onreadystatechange = processReqChange3;
            req.open(method, url, true);
            req.send(null);
        }
    }
}
// Функция, выполняемая при изменении статуса
// запроса, если статус  равен 200, данные получены.
function processReqChange3(){
    if(req.readyState == 4){
        if(req.status == 200){
			getColors3(req.responseXML.documentElement);
        }else{
            alert("There was a problem retrieving the XML data:\\n" + req.statusText);
        }
    }
}
function onChange3(_this){
	document.getElementById("WCities_3").className='progress';
	var url = "/country.php?country_id="+_this.value+"&lang_id=1";
	loadXMLDoc3("get",url);
}
function getColors3(xml){
	var cities = xml.getElementsByTagName("c");
	var _select = document.getElementById("cities_3");
	_select.innerHTML = ""; // Удаляем всех потомков.
	// Создаем список с доступными цветами.
	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",cities[i].getAttribute("value"));
		_select.appendChild(option);
	}
	document.getElementById("WCities_3").className='progressOff';
}

// 44444444444444444444444444444444444
// Функция, осуществляющая AJAX запрос.
function loadXMLDoc4(method,url){
    if(window.XMLHttpRequest){
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange4;
        req.open(method, url, true);
        req.send(null);
    }else if(window.ActiveXObject){
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if(req){
            req.onreadystatechange = processReqChange4;
            req.open(method, url, true);
            req.send(null);
        }
    }
}
// Функция, выполняемая при изменении статуса
// запроса, если статус  равен 200, данные получены.
function processReqChange4(){
    if(req.readyState == 4){
        if(req.status == 200){
			getColors4(req.responseXML.documentElement);
        }else{
            alert("There was a problem retrieving the XML data:\\n" + req.statusText);
        }
    }
}
function onChange4(_this){
	document.getElementById("WCities_4").className='progress';
	var url = "/country.php?country_id="+_this.value+"&lang_id=1";
	loadXMLDoc4("get",url);
}
function getColors4(xml){
	var cities = xml.getElementsByTagName("c");
	var _select = document.getElementById("cities_4");
	_select.innerHTML = ""; // Удаляем всех потомков.
	// Создаем список с доступными цветами.
	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",cities[i].getAttribute("value"));
		_select.appendChild(option);
	}
	document.getElementById("WCities_4").className='progressOff';
}
