function loadWeatherCity(countryid) {
    url = "cityList.php?countryid="+ countryid;
    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = loadWeatherCity_triggered;
        http_request.open('GET', url, true );
        
        http_request.send(null);


}


function loadWeatherCity_triggered() {
    if(http_request.readyState == 4 && http_request.status == 200) {
        text = http_request.responseText;
        document.getElementById("weather_cityid").options.length = 0;
          try{
             document.getElementById("weather_cityid").add(new Option(" - Miestas - ", -1 ), null); //add new option to end of "sample"
            }
            catch(e){ 
             document.getElementById("weather_cityid").add(new Option(" - Miestas - ",-1 ));
             }
        
        var options = text.split("|"); 
        for (var i = 0; i<options.length; ++i)
        {
            try{
             document.getElementById("weather_cityid").add(new Option(options[i].split(":")[1], options[i].split(":")[0]), null); //add new option to end of "sample"
            }
            catch(e){ 
             document.getElementById("weather_cityid").add(new Option(options[i].split(":")[1], options[i].split(":")[0]));
             }
        }
        
    }
}

function makeWeather(value)
{
     if (value ==  -1)
     {
          value = "26730";
     }
     document.cookie = "weatherCityId=" + value;
     window.location=window.location;
     //alert(value);
     //document.getElementById("weather_result").className="weather_result_loading";
    //document.getElementById("weather_result").src="http://informer.gismeteo.ru/"+value+"-31E.GIF";
}
