  // ---- jazyk ----
  // var lang = document.location.toString().indexOf("/sk/")>-1?"sk":"cz";
  //alert (lang);
  var lang = "cz";
  /** texty **/
  var texty = new Array();
  texty["mena"] = new Array();
  texty["cena"] = new Array();
  texty["dohodou"] = new Array();
  texty["polozek"] = new Array();
  texty["neplatne_ean"] = new Array();
  texty["musite_zadat_aspon_1ks"] = new Array();
  texty["chcete_smazat"] = new Array();
  texty["chcete_vyprazdnit_kosik"] = new Array();
  texty["mena"]["cz"] = "Kč";
  texty["mena"]["sk"] = "Sk";
  texty["cena"]["cz"] = "cena";
  texty["cena"]["sk"] = "cena";
  texty["dohodou"]["cz"] = "dohodou";
  texty["dohodou"]["sk"] = "dohodou";
  texty["polozek"]["cz"] = "položek";
  texty["polozek"]["sk"] = "položiek";
  texty["neplatne_ean"]["cz"] = "Neplatné EAN zboží!";
  texty["neplatne_ean"]["sk"] = "Neplatné EAN tovaru!";
  texty["musite_zadat_aspon_1ks"]["cz"] = "Musíte zadat alespoň 1 ks!";
  texty["musite_zadat_aspon_1ks"]["sk"] = "Musíte zadať aspoň 1 ks!";
  texty["chcete_smazat"]["cz"] = "Skutečně chcete tuto položku odstranit z košíku?"
  texty["chcete_smazat"]["sk"] = "Skutočne chcete túto položku odstrániť z košíku?"
  texty["chcete_vyprazdnit_kosik"]["cz"] = "Skutečně chcete vyprázdnit košík?"
  texty["chcete_vyprazdnit_kosik"]["sk"] = "Skutočne chcete vyprázdnit košík?"
  // ----- otevre obrazek -----
    function OpenImage(img_file)
    {
      page   = "open_file.php?type=img&open_file="+img_file;
      my_win = window.open(page,"show_image","height=480,width=640,scrollbars=no,status=no,toolbar=no,menubar=no,location=no,resizable=yes");
      my_win.focus();
    }
    function OpenImage2(img_file,w,h)
    {
      page   = "open_file.php?type=img2&open_file="+img_file+"&w="+w+"&h="+h;
      my_win = window.open(page,"show_image","height=480,width=640,scrollbars=no,status=no,toolbar=no,menubar=no,location=no,resizable=yes");
      my_win.focus();
    }
  // ----- otevre soubor -----
    function OpenFile(download_file)
    {
      page   = download_file;
      my_win = window.open(page,"download_file","height=480,width=640,scrollbars=no,status=no,toolbar=no,menubar=no,location=no,resizable=yes");
      my_win.focus();
    }
  // ----- otevre odkaz pro do okna pro tisk -----
    function OpenPrintPage(ppage)
    {
      my_win = window.open(ppage,"_print_","width=650,scrollbars=yes,status=no,toolbar=no,menubar=yes,location=no,resizable=yes");
      my_win.focus();
    }
  // ----- otevreni linku
  function OpenLink(page,params,aname)
  {
    document.location = page+"?"+params+(aname?"#"+aname:"");
    return false;
  }
  // ----
  function OpenProductDetail(page)
  {
      my_win = window.open(page,"_product_detail_","width=650,scrollbars=yes,status=no,toolbar=no,menubar=yes,location=no,resizable=yes");
      my_win.focus();
  }
  // ----- funkce pro kosik -----
  function SetItemCount(item_id,item_count,page,params,aname)
  {
    if (item_count==0) alert (texty["musite_zadat_aspon_1ks"][lang]);
    else               OpenLink(page,"set_item="+item_id+"&set_item_count="+item_count+"&"+params,aname);
  }
  function AddItemCount(item_id,item_count,page,params,aname)
  {
    if (item_count==0) alert (texty["musite_zadat_aspon_1ks"][lang]);
    else               OpenLink(page,"add_item="+item_id+"&add_item_count="+item_count+"&"+params,aname);
  }
  function DeleteItem(item_id,page,params,aname)
  {
    if (confirm(texty["chcete_smazat"][lang]))
    {
      OpenLink(page,"delete_item="+item_id+"&"+params,aname);
    }
  }
  function CalculatePrice(form,item_num)
  {
      item_count =  parseInt(eval ("document."+form+".item_count_"+item_num+".value"));
      if (isNaN(item_count)) item_count = 0;
      item_price   = parseFloat(eval ("document."+form+".item_price_"+item_num+".value"));
      action_valid = eval ("document."+form+".action_valid_"+item_num+".value");
      action_count = parseInt(eval ("document."+form+".action_count_"+item_num+".value"));
      action_price = parseFloat(eval ("document."+form+".action_price_"+item_num+".value"));
      if (action_valid=="1" && action_price>0 && (action_count==0 || action_count<=item_count)) item_price = action_price;
      iprice = RoundPrice(item_price);
      tprice = RoundPrice(item_count*item_price);
      return new Array(iprice,tprice);
  }
  function UpdatePrice(form,item_num,iprice_elm,tprice_elm)
  {
     prices = CalculatePrice(form,item_num)
     elm = document.getElementById(iprice_elm+item_num);
     elm.innerHTML=FormatPrice(prices[0]);
     elm = document.getElementById(tprice_elm+item_num);
     elm.innerHTML=FormatPrice(prices[1]);
  }
  function UpdatePriceObjednavka()
  {
     tdodani = document.products.id_typ_dopravy.options[document.products.id_typ_dopravy.selectedIndex].value;
     dcena   = 1*eval ("document.products.dcena_"+tdodani+".value");
     zcena   = 1*eval ("document.products.zbozi_price.value");
     t_price = RoundPrice(dcena + zcena);
     /*
     elm = document.getElementById("tprice_doprava_div");
     elm.innerHTML=FormatPrice(dcena)+" "+texty["mena"][lang];
     elm = document.getElementById("tprice_div");
     elm.innerHTML=FormatPrice(t_price)+" "+texty["mena"][lang];
     */
     document.products.li_cena_navic.value=dcena;
     elm = document.getElementById("tprice_doprava_div");
     elm.innerHTML=FormatPrice(dcena);
     elm = document.getElementById("tprice_div");
     elm.innerHTML=FormatPrice(t_price);
  }
  function UpdateAllKs(form,item_count)
  {
    all_ok = true;
    for (i=1;i<=item_count && all_ok ;i++)
    {
      icount  = eval ("document."+form+".item_count_"+eval(i)+".value");
      if (icount==0) all_ok=false;
    }
    if (all_ok)
    {
      eval("document."+form+".action_type.value='update_all_ks';");
      eval("document."+form+".submit();");
    } else {
      alert (texty["musite_zadat_aspon_1ks"][lang]);
    }
  }
  function UpdateAllKsNoTest(form,item_count)
  {
      eval("document."+form+".action_type.value='update_all_ks';");
      eval("document."+form+".submit();");
  }
  function EmptyBasket()
  {
    if (confirm(texty["chcete_vyprazdnit_kosik"][lang]))
    {
        OpenLink("index.php","show_page=basket&empty_basket=true");
    }
  }
  function SendLogin()
  {
    open_page = "send_login.php";
    my_win    = window.open(open_page,"send_login","width=300,height=120,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,resizable=yes");
    my_win.focus();
  }
  // plus baleni
  function PB(icount)
  {
    i_pbc    = eval("document.products.i_pbc_"+eval(icount)+".value;");
    i_count  = eval("document.products.item_count_"+eval(icount)+".value;");
    bal      = eval("document.products.bal_"+eval(icount)+".value;");
    balcount = parseInt(bal);
    i_count  = parseInt(i_count);
    if (isNaN(balcount) && isNaN(i_count)) balcount = 0;
    else if (isNaN(balcount))
    {
      balcount = Math.floor(i_count/i_pbc);
    }
    balcount++;
    ks = eval(i_pbc * balcount);
    eval("document.products.bal_"+eval(icount)+".value = '"+eval(balcount)+"';");
    eval("document.products.item_count_"+eval(icount)+".value = '"+ks+"';");
  }
  // minus baleni
  function MB(icount)
  {
    i_pbc    = eval("document.products.i_pbc_"+eval(icount)+".value;");
    i_count  = eval("document.products.item_count_"+eval(icount)+".value;");
    bal      = eval("document.products.bal_"+eval(icount)+".value;");
    balcount = parseInt(bal);
    if (isNaN(balcount) && isNaN(i_count)) balcount = 0;
    else if (isNaN(balcount))
    {
      balcount = Math.floor(i_count/i_pbc);
    }
    if (balcount<=0)  balcount = 0;
    else              balcount--;
    ks = eval(i_pbc * balcount);
    eval("document.products.bal_"+eval(icount)+".value = '"+eval(balcount)+"';");
    eval("document.products.item_count_"+eval(icount)+".value = '"+ks+"';");
  }