
var req = null;

function InitXMLHttpRequest() {
	// Make a new XMLHttp object
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
}


function SelectRegion(id_country, destination, destination2) {
	if (id_country != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					destination.innerHTML = "<select style=\"width: 150px;\"><option>Loading data...</option></select>";
				}
			}
			req.open("GET", "location.php?sel=region&id_country=" + id_country + "rand=" + Math.random(), true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}
	} else {
		destination.innerHTML = "Country is not selected";
	}
	destination2.innerHTML = "<select style=\"width: 150px;\"><option>Please select...</option></select>";
}

function SelectCity(id_region, destination) {
	if (id_region != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					destination.innerHTML = "<select style=\"width: 150px;\"><option>Loading data...</option></select>";
				}
			}
			req.open("GET", "location.php?sel=city&id_region=" + id_region + "rand=" + Math.random(), true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}
	} else {
		destination.innerHTML = "Region is not selected";
	}
}