var xhrCar = createXHR();

function getZnacky(){
    if(xhrCar){
        try{
            xhrCar.open("GET","./getCarType.php",true);
            xhrCar.onreadystatechange = callBackZnacky;
            xhrCar.send(null);
        }catch(e){
            alert("Nelze se připojik k serveru:\n" + e.toString());
        }
    }else{
        alert("Funkce \"precitSoubor()\": chybí objekt XMLHttpRequest");
    }
}
function callBackZnacky(){
    if(xhrCar.readyState == 4){
        if(xhrCar.status == 200){
            try{
                var XMLRes = xhrCar.responseXML;
                //zachycení chyb IE a Opery
                if(!XMLRes || !XMLRes.documentElement){
                    throw("Chybná struktura XML:\n" + xhrCar.responseText);
                }
                //zachycení chyb ohnivé lišky :-)
                var rootNodeName = XMLRes.documentElement.nodeName;
                if(rootNodeName == "parsererror"){
                    throw("Chybná struktura XML:\n" + xhrCar.responseText);
                }
                //čtu dokument, jelikož je vše ok :-)

                xmlRoot = XMLRes.documentElement;
                id = xmlRoot.getElementsByTagName("id");
                nameE = xmlRoot.getElementsByTagName("name");

                //sem budem ukládat výstup

                //vytvoříme obsah
                var options = document.getElementById("sel1").options;
                for(var i = 0; i < id.length; i++){
                        newOpt = document.createElement('option');
                        newOpt.text = nameE.item(i).firstChild.data;
                        newOpt.value = id.item(i).firstChild.data;
                        options.add(newOpt);
                }

            }catch(e){
                alert("Chyba při čtení odpovědi:" + e.toString());
            }
        }else{
            alert("Požadavek HTTP není v pořádku.")
        }
    }
}
