// Get the HTTP Object
function getHTTPObject(){
   if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
   else if (window.XMLHttpRequest) return new XMLHttpRequest();
   else {
      return null;
   }
}

// Change the value of the outputText field
function setOutput(co){
    if(httpObject.readyState == 4){
        var combo = document.getElementById(co);
        combo.options.length = 0;

        var response = httpObject.responseText;
        var items = response.split(";");
        var count = items.length;
        for (var i=0;i<count-1;i++){
            var options = items[i].split("=");
            combo.options[i] =
			    new Option(options[0],options[1]);
        }
    }
}

// Implement business logic
function zobrazit(z,co){
    httpObject = getHTTPObject();
    if (httpObject != null) {
        httpObject.open("GET", "http://www.nabidka-ubytovani.cz/function/dynamic-select.php?id="+document.getElementById(z).value+"&zobrazit="+co, true);
        httpObject.send(null);
        httpObject.onreadystatechange = function(){setOutput(co)};
    }
}

var httpObject = null;