<!--
  var xmlHttp;
  var dokonceniDiv;
  var vstupniPole;
  var tabulkaJmen;
  var tabulkaJmenTelo;

  function vytvorXMLHttpRequest() {
    if (window.ActiveXObject) {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
      xmlHttp = new XMLHttpRequest();
    }
  }

  function inicializujPromenne() {
    vstupniPole = document.getElementById("misto");
    tabulkaJmen = document.getElementById("tabulkaJmen");
    dokonceniDiv = document.getElementById("suggest");
    tabulkaJmenTelo = document.getElementById("tabulkaJmenTelo");
  }

  function vyhledejJmena(typ) {
    inicializujPromenne();
    if (vstupniPole.value.length > 0) {
      vytvorXMLHttpRequest();
      var url = "ajax.php?event=suggest&typ=" + typ + "&misto=" + Base64.encode(vstupniPole.value);
      xmlHttp.open("GET", url, true);
      xmlHttp.onreadystatechange = zpracujZmenuStavu;
      xmlHttp.send(null);
    } else {
      vymazJmena();
    }
  }

  function zpracujZmenuStavu() {
    if (xmlHttp.readyState == 4) {
      if (xmlHttp.status == 200) {
        var jmeno = xmlHttp.responseXML
          .getElementsByTagName("misto")[0].firstChild.data;
        nastavJmena(xmlHttp.responseXML.getElementsByTagName("misto"));
      } else if (xmlHttp.status == 204){
        vymazJmena();
      }
    }
  }

  function nastavJmena(jmena) {
    vymazJmena();
    var velikost = jmena.length;
    nastavUmisteni();
    var rada, bunka, txtUzel;
    for (var i = 0; i < velikost; i++) {
      var dalsiUzel = jmena[i].firstChild.data;
      rada = document.createElement("tr");
      bunka = document.createElement("td");
      bunka.onmouseout = function() {this.className='mouseOver';};
      bunka.onmouseover = function() {this.className='mouseOut';};
      bunka.setAttribute("bgcolor", "#FFFAFA");
      bunka.setAttribute("border", "0");
	  if(i==0)
		  bunka.style.borderBottom = 'black 1px dotted';
	  bunka.style.cursor = 'hand';
      bunka.onclick = function() { vyplnJmeno(this); } ;
      txtUzel = document.createTextNode(dalsiUzel);
      bunka.appendChild(txtUzel);
      rada.appendChild(bunka);
      tabulkaJmenTelo.appendChild(rada);
    }
  }

  function nastavUmisteni() {
    var konec = 2*vstupniPole.offsetWidth;
/*    var levy = vypoctiUmisteniLevy(vstupniPole);*/
/*    var horni = vypoctiUmisteniHorni(vstupniPole) + vstupniPole.offsetHeight;*/
    dokonceniDiv.style.border = "black 1px solid";
/*    dokonceniDiv.style.left = levy + "px";*/
/*    dokonceniDiv.style.top = horni + "px";*/
    tabulkaJmen.style.width = konec + "px";
  }

  function vypoctiUmisteniLevy(pole) {
    return vypoctiUmisteni(pole, "offsetLeft");
  }

  function vypoctiUmisteniHorni(pole) {
    return vypoctiUmisteni(pole, "offsetTop");
  }
    
  function vypoctiUmisteni(pole, atribut) {
    var umisteni = 0;
    while(pole) {
      umisteni += pole[atribut];
      pole = pole.offsetParent;
    }
    return umisteni;
  }

  function vyplnJmeno(bunka) {
    vstupniPole.value = bunka.firstChild.nodeValue;
    vymazJmena();
  }

  function vymazJmena() {
    var velikost = tabulkaJmenTelo.childNodes.length;
    for (var i = velikost - 1; i >= 0 ; i--) {
      tabulkaJmenTelo.removeChild(tabulkaJmenTelo.childNodes[i]);
    }
    dokonceniDiv.style.border = "none";
  }
//-->
