var url = 'http://reis24.ee/';

var ajax_city = url+'ajax/ajax.city.php';

var xmlRequest_to_city = createRequestObject();
var xmlRequest_from_city = createRequestObject();

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        //ro = new ActiveXObject("Microsoft.XMLHTTP");
        try {
       		ro = new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
       		ro = new ActiveXObject("Microsoft.XMLHTTP");
    }
        //alert('Internet Explorer ');
    }else{
        ro = new XMLHttpRequest();
        //alert('Firefox, Safari...');
    }
    return ro;
}

function getAjaxFromCity(countryID, cityID, retID){
	var args = ajax_city+'?d=from&countryID='+countryID+'&cityID='+cityID;
	xmlRequest_from_city.open('GET', args, true);
	xmlRequest_from_city.setRequestHeader("Content-Type", "application/x-www-formurlencoded");
	xmlRequest_from_city.onreadystatechange = function() { AjaxFromCity(retID); };
    xmlRequest_from_city.send(null);	
}
function AjaxFromCity(retID){
	var ret = document.getElementById(retID);
 	if(xmlRequest_from_city.readyState == 1) ret.innerHTML = "<center>LOADING...</center>";
    if(xmlRequest_from_city.readyState == 4) ret.innerHTML = xmlRequest_from_city.responseText; 
}

function getAjaxToCity(countryID, cityID, retID){
	var args = ajax_city+'?d=to&countryID='+countryID+'&cityID='+cityID;
	xmlRequest_to_city.open('GET', args, true);
	xmlRequest_to_city.setRequestHeader("Content-Type", "application/x-www-formurlencoded");
	xmlRequest_to_city.onreadystatechange = function() { AjaxToCity(retID); };
    xmlRequest_to_city.send(null);	
}
function AjaxToCity(retID){
	var ret = document.getElementById(retID);
 	if(xmlRequest_to_city.readyState == 1) ret.innerHTML = "<center>LOADING...</center>";
    if(xmlRequest_to_city.readyState == 4) ret.innerHTML = xmlRequest_to_city.responseText; 
}