var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject() {
    var xmlHttp;
    if (window.ActiveXObject) {
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            xmlHttp = false;
        }
    } else {
        try {
            xmlHttp = new XMLHttpRequest();
        }
        catch (e) {
            xmlHttp = false;
        }	
    }
    if (!xmlHttp) {
        alert("ERROR");
    } else {
        return xmlHttp;
    }
}

function processCountry() {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
        wer = document.getElementById("country");
        name = encodeURIComponent(wer.options[wer.selectedIndex].value);			
        xmlHttp.open("GET","/mods/ru/regions_response.php?country_id="+name,true);
        xmlHttp.onreadystatechange = handleServerResponse;
        xmlHttp.send(null);
    }	
}

function handleServerResponse() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200)
        {
            xmlResponse = xmlHttp.responseText;
            document.getElementById("regions").innerHTML = xmlResponse;
        }
        else
        {
            alert(xmlHttp.statusText );
        }
    }
}
