var req;
function changeCountry(url, country_id)
{
    postForm(url + '?country_id='+country_id);
}

function postForm(url) {
    req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
        try {
            req = new XMLHttpRequest();
        } catch(e) {
            req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e) {
                req = false;
            }
        }
    }
    if(req) {
        req.onreadystatechange = processReqChange;
        req.open("POST", url, true);
        req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        req.send(null);
    }
}

function processReqChange() {
    if (req.readyState == 4) {
        if (req.status == 200) {
           eval(req.responseText)
           j = document.forms.searchform.state.options.length = 0;
           for (var i=0;i<arr_value.length;i++){
               document.forms.searchform.state.options.length = j+1;
               document.forms.searchform.state.options[i].value = arr_value[i]; 
               document.forms.searchform.state.options[i].text  = arr_text[i];
               if (document.forms.searchform.state.options[i].value =="")
                   document.forms.searchform.state.options[i].selected = true;
               j += 1;
            }
        } else {
            alert("There was a problem retrieving the XML data:\n" +
                req.statusText);
        }
    }
}
