  var IE = document.all?true:false;
  var NS = document.layers?true:false;
  var NS6 = document.getElementById&&!document.all?true:false;
  var Opera = navigator.userAgent.indexOf("Opera")>-1;

  // ----- prevede nepovolene znaky v URL -----
    function UrlEncode(str)
    {
      var hex_tab = "0123456789ABCDEF", result = "", ascii_tab = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ŠŚŤŽŹšśťžź Ą˘Ł¤ĽŚ§¨ŠŞŤŹ­ŽŻ°ą˛ł´ľśˇ¸šşťź˝žżŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖ×ŘŮÚŰÜÝŢßŕáâăäĺćçčéęëěíîďđńňóôőö÷řůúűüýţ˙";
      for (var i=0; i<str.length; i++)
      {
        var chr = str.charAt(i), ord = ascii_tab.indexOf(chr)+32;
        if (ord==32) result += "+";
        else if  (((ord>47)&&(ord<58))||((ord>64)&&(ord<91))||((ord>95)&&(ord<122))||(chr==".")||(chr=="/")) result += chr; else result += "%"+hex_tab.charAt(Math.floor(ord/16))+hex_tab.charAt(ord%16);
      }
      return result;
    }

  // --- funkce pro test formuláře  ---
    function CheckForm(form, params)
    {
      // syntaxe parametrů: "polozka1:název poloky1(:dolní_limit(:horní_limit))(;poloka2:...)"
      // příklad: checkFrom(this, "vek:věk:0;rok_narozeni:rok narození:1900:2000");

      var result = true;
      var errstr = "Chyba ve formuláři:\n";
      var pars   = params.split(";");
      var alert_str = "";
      for (i=0; i<pars.length; i++)
      {
        var par = pars[i].split(":");
        var val = parseInt(form[par[0]].value);
        if (!par[2]&&!form[par[0]].value)
        {
          if (result) form[par[0]].focus();
          alert_str += ("poloka \""+par[1]+"\" musí být vyplněna.\n");
          result = false;
        }
        else if (par[2]&&!par[3]&&(isNaN(val)||(val<par[2])))
        {
          if (result) form[par[0]].focus();
          alert_str += ("poloka \""+par[1]+"\" musí mít minimální číselnou hodnotu "+par[2]+".\n");
          form[par[0]].value = "";
          result = false;
        }
        else if (par[3]&&(isNaN(val)||(val<par[2])||(val>par[3])))
        {
          if (result) form[par[0]].focus();
          alert_str += ("poloka \""+par[1]+"\" musí mít číselnou hodnotu v intervalu "+par[2]+" a "+par[3]+".\n");
          form[par[0]].value = "";
          result = false;
        }
      }
      if (!result) alert (errstr+alert_str);
      return result;
    }


  // --- zpracovaní cen ---
    function RoundPrice(price)
    {
      return Math.round(100*price)/100;
    }

    function FormatPrice(price)
    {
       price = RoundPrice(price);
       eval("price_str = '"+eval(price)+"';");
       p_arr = price_str.split(".");
       if (p_arr.length==1) price_formated = price_str + ",00";
       else                 price_formated = p_arr[0] + "," + (p_arr[1].length==1? p_arr[1] + "0": p_arr[1].substr(0,2));
       return price_formated;
    }

  // --- zpracovani stisku klaves ---
    function GetKey(e)
    {
      var code;
      if (!e) var e = window.event;
      // nastaveni pro IE
      if (e.keyCode) code = e.keyCode;
      // IE a Mozilla
      else if (e.which) code = e.which;
      // NN4
      return code;
    }

    function EnterPressed(e)
    {
      return (GetKey(e)==13);
    }

    function NumericKey(e)
    {
      k = GetKey(e);
      return (k>=48 && k<=57);
    }


  // --- zjisteni sirky okna ---
  function GetWindowWidth()
  {
    var myWidth = 640;
    if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
    {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
    } else {
      if (document.body && (document.body.clientWidth || document.body.clientheight))
      {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
      }
    }
    if (document.layers) { myWidth = window.innerWidth; } // ns4 only
    return myWidth;
  }

  // --- zjisteni vysky okna ---
  function GetWindowHeight()
  {
    var myHeight = 480;
    if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
    {
      //IE 6+ in 'standards compliant mode'
      myHeight = document.documentElement.clientHeight;
    } else {
      if (document.body && ( document.body.clientWidth || document.body.clientheight))
      {
        //IE 4 compatible
        myHeight = document.body.clientheight;
      }
    }
    if (document.layers) { myHeight = window.innerHeight; } // ns4 only
    return myHeight;
  }


  // ---- verze obrazku na najeti ----
  function imgOn(imgName)
  {
    if (document.images) document[imgName].src = eval(imgName + "on.src");
  }

  // ---- verze obrazku v normalnim stavu ----
  function imgOff(imgName)
  {
    if (document.images) document[imgName].src = eval(imgName + "off.src");
  }

