function Cart(a){var b=a;this.addItem=function(d,g,f,c,e,h){$.getJSON("cart.php",{cmd:"add",id:d,quantity:g,accessory:f,popup:c?1:0,hash:b}).done(function(l){b=l.hash;l.success?"function"===typeof e&&e(l):"function"===typeof h&&h()}).fail(function(){"function"===typeof h&&h()})};this.setItem=function(d,g,f,c){$.getJSON("cart.php",{cmd:"set",id:d,quantity:g,hash:b}).done(function(e){b=e.hash;e.success?"function"===typeof f&&f(e):"function"===typeof c&&c()}).fail(function(){"function"===typeof c&&c()})}; this.setItemAccessory=function(d,g,f,c){$.getJSON("cart.php",{cmd:"set-accessory",id:d,accessory:g,hash:b}).done(function(e){b=e.hash;e.success?"function"===typeof f&&f(e):"function"===typeof c&&c()}).fail(function(){"function"===typeof c&&c()})};this.empty=function(d,g){$.getJSON("cart.php",{id:"all",quantity:0}).done(function(f){b=f.hash;"function"===typeof d&&d(f)}).fail(function(){"function"===typeof g&&g()})};this.checkItem=function(d,g,f){$.getJSON("check.php",{id:d}).done(function(c){c.hash&& (b=c.hash);"function"===typeof g&&g(c)}).fail(function(){"function"===typeof f&&f()})};this.getPopup=function(d,g){$.getJSON("cart.php",{get:"popup"}).done(function(f){b=f.hash;"function"===typeof d&&d(f)}).fail(function(){"function"===typeof g&&g()})}} function number_format(a,b,d,g){a=a.toString().replace(/[^0-9+\-Ee.]/g,"");a=isFinite(+a)?+a:0;b=isFinite(+b)?Math.abs(b):0;g="undefined"===typeof g?",":g;d="undefined"===typeof d?".":d;var f="";f=function(c,e){var h=Math.pow(10,e);return(Math.round(c*h)/h).toFixed(e)};f=(b?f(a,b):Math.round(a)).toString().split(".");3 header .cart div.cart-content").remove(),$("main .cart").remove(),$("main .cart-sum").remove(),$("main .cart-control").remove(), $("main .ordering-process").html('"),$("header .cart").removeClass("priority"),$("header .search, header .search-alt").addClass("priority"))} function addItemToCart(a,b,d){if("FORM"==$(a).prop("nodeName")){null==b&&(b=$(a).find('input[name="item[id]"]').val());var g=$(a).find('input[name="item[quantity]"]');null==d&&(d=g.val());if(0==d)return!1;var f=[];$(a).find('input[name^="item[accessory]["]:checked').each(function(){$(this).val()&&f.push($(this).val())});if(b&&d){g.prop("disable",!0);var c=$(a).find('button[type="submit"]');c.prop("disable",!0);cart.addItem(b,d,f,!0,function(e){if(e.reload)location.reload();else{g.prop("disable",!1); c.prop("disable",!1);updateCartInfo(e);var h=1*e.item.oldQuantity,l=null;e.popupHtml&&(showPopupWindow(e.popupHtml),$(".cart-popup .info").append('
\u00a0'+localized({cs:"Prob\u00edh\u00e1 ov\u011b\u0159en\u00ed dostupnosti a\u00a0ceny zbo\u017e\u00ed\u2026",en:"Checking availability and price of goods\u2026"})+"
"),l=setInterval(function(){$(".cart-popup .info .item-check .fa-spinner").parent().css("visibility", "hidden")},1E4),cart.checkItem(b,function(k){clearInterval(l);var q="";k.updated?0==k.newQuantity||null===k.newPriceWithVat||0==k.newPriceWithVat?($(".cart-popup h1").html(' '+localized({cs:"Zbo\u017e\u00ed nebylo vlo\u017eeno do ko\u0161\u00edku",en:"The product was not added to the cart"})),$(".cart-popup .info .item-check").html('\u00a0'+localized({cs:"Je n\u00e1m l\u00edto, ale toto zbo\u017e\u00ed ji\u017e nen\u00ed dostupn\u00e9.", en:"Sorry, this item is no longer available."}))):(k.oldQuantity!=k.newQuantity&&(q=localized({cs:"Dostupnost",en:"Availability and price of goods\u2026"})),k.oldPriceWithVat!=k.newPriceWithVat&&(q=""!=q?q+localized({cs:" a\u00a0cena",en:" and price"}):localized({cs:"Cena",en:"Price"})),""!=q?(q+=localized({cs:" zbo\u017e\u00ed byla aktualizov\u00e1na.",en:" of goods has been updated."}),k.oldPriceWithVat!=k.newPriceWithVat&&(q+=localized({cs:" Nov\u00e1 cena je",en:" New price is"})+" "+ myMoneyFormat(k.newPriceWithVat)+"\u00a0K\u010d.",$(".item-"+b+"-price").html(myMoneyFormat(k.newPriceWithVat)+"\u00a0K\u010d")),q='\u00a0'+q,$(".cart-popup .info .item-check").html(q).css("visibility","visible")):$(".cart-popup .info .item-check").css("visibility","hidden")):h+1*d>1*k.maxQuantity&&k.maxQuantityMessage?(""!=q&&(q+="
"),q+='\u00a0'+k.maxQuantityMessage, $(".cart-popup .info .item-check").html(q).css("visibility","visible")):$(".cart-popup .info .item-check").css("visibility","hidden")},function(){$(".cart-popup .info .item-check").css("visibility","hidden")}))}},function(){g.prop("disable",!1);c.prop("disable",!1);$(a).prop("onsubmit","").unbind("submit").submit()});return!1}}else if("A"==$(a).prop("nodeName")&&b&&d)return cart.addItem(b,d,null,!1,function(e){e.reload?location.reload():(updateCartInfo(e),e.item.quantity?($(a).closest("table").find(".quantity").text(e.item.quantity+ (e.item.quantityUnit?"\u00a0"+e.item.quantityUnit:"")),$(a).closest(".cart").find('tr.cart-item[data-id="'+b+'"] .price-with-vat').html(myMoneyFormat(e.item.finalPriceWithVat)+'\u00a0K\u010d'),$(a).closest(".cart").find('tr.cart-item[data-id="'+b+'"] .price-with-vat-sum').html(myMoneyFormat(e.item.finalPriceWithVat*e.item.quantity)+'\u00a0K\u010d'),$(a).closest(".cart").find('tr.cart-item.accessory[data-id="'+b+'"] strong[data-price]').each(function(){$(this).html(myMoneyFormat($(this).data("price")* e.item.quantity)+'\u00a0K\u010d')}),$(a).closest(".cart").find('tr.cart-item[data-id="'+b+'"] strong.accessory[data-price]').each(function(){$(this).html(myMoneyFormat($(this).data("price")*e.item.quantity)+'\u00a0K\u010d')}),e.item.quantity==e.item.maxQuantity&&e.item.maxQuantityMessage&&showBalloonTip($(a).closest("table").find(".quantity"),' '+e.item.maxQuantityMessage),cart.checkItem(b)): $(a).closest(".cart").find('tr.cart-item[data-id="'+b+'"]').remove())},function(){$(a).prop("onclick","").unbind("click").click()}),!1;return!0} function setItemInCart(a,b,d){cart.setItem(b,d,function(g){g.reload?location.reload():(g.item.quantity?($(a).closest("table").find(".quantity").data("quantity",g.item.quantity).text(g.item.quantity+(g.item.quantityUnit?"\u00a0"+g.item.quantityUnit:"")),$(a).closest(".cart").find('tr.cart-item[data-id="'+b+'"] .price-with-vat').html(myMoneyFormat(g.item.finalPriceWithVat)+'\u00a0K\u010d'),$(a).closest(".cart").find('tr.cart-item[data-id="'+b+'"] .price-with-vat-sum').html(myMoneyFormat(g.item.finalPriceWithVat* g.item.quantity)+'\u00a0K\u010d'),g.item.quantity==g.item.maxQuantity&&g.item.maxQuantityMessage&&showBalloonTip($(a).closest("table").find(".quantity"),' '+g.item.maxQuantityMessage),cart.checkItem(b)):$(a).closest(".cart").find('tr.cart-item[data-id="'+b+'"]').remove(),updateCartInfo(g))})} function setItemAccessory(a,b,d){cart.setItemAccessory(b,d,function(g){g.reload?location.reload():updateCartInfo(g)})}function removeItemFromCart(a,b){return b?(cart.setItem(b,0,function(d){d.reload?location.reload():($(a).closest(".cart").find('tr.cart-item[data-id="'+b+'"]').remove(),updateCartInfo(d))},function(){$(a).prop("onclick","").unbind("click").click()}),!1):!0} function emptyCart(a){$(a).prop("disable",!0);cart.empty(function(b){b.itemsQuantity?location.reload():updateCartInfo(b)},function(){$(a).prop("disable",!1).prop("onclick","").unbind("click").click()});return!1}function hidePopupWindow(){$("body").removeClass("no-scrollbar");$("div#popup-window").remove()} function showPopupWindow(a){var b=$("#popup-window");0==b.length&&($("body").append(''),b=$("#popup-window"),b.children("div.popup-window").children("span.close").on("click",hidePopupWindow));b.children(".popup-window").children(".content").html(a);b.show();$("body").addClass("no-scrollbar")} function checkSPForm(a){var b=$(".shipping-and-payment .shipping label.option .control input:checked"),d=b.length,g=!0;d&&(b=b.closest("label.option").find("select.branch"),b.length&&(g=b.val()));b=$(".shipping-and-payment .payment label.option .control input:checked").length;if(g){if(d||b){if(d){if(b)return!0;showBalloonTip($(a).find("button.main"),' '+localized({cs:"Pros\u00edm, zvolte zp\u016fsob platby.",en:"Please select the method of payment."})); return!1}showBalloonTip($(a).find("button.main"),' '+localized({cs:"Pros\u00edm, zvolte zp\u016fsob dopravy.",en:"Please select the method of shipping."}));return!1}showBalloonTip($(a).find("button.main"),' '+localized({cs:"Pros\u00edm, zvolte zp\u016fsob dopravy a\u00a0platby.",en:"Please select the method of shipping and payment."}));return!1}showBalloonTip($(a).find("button.main"), ' '+localized({cs:"Pros\u00edm, up\u0159esn\u011bte zvolen\u00fd zp\u016fsob dopravy.",en:"Please specify the selected method of shipping."}));return!1} function checkDeliveryForm(a){var b=$("#company-ic");if(isIc(b.val()))return!0;showBalloonTip($(a).find("button.main"),' '+localized({cs:"Pros\u00edm, zadejte I\u010c ve spr\u00e1vn\u00e9m form\u00e1tu.",en:"Please enter the company ID in the correct format."}));return!1}var loadBranchesTimeout=null,cartBranchSelectMap=null,cartBranchSelectMapLayer=null,$shipping=null; function selectBranch(a){if(a){cartBranchSelectMap.removeCard();for(var b=cartBranchSelectMapLayer.getMarkers(),d=0;d";2< $shipping.children("option").length&&(g=localized({cs:"Zvolen\u00e9 m\u00edsto",en:"Selected pickup location"})+":
"+g+'
'+localized({cs:"Zm\u011bnit m\u00edsto p\u0159evzet\u00ed",en:"Change pickup location"})+"");$shipping.closest("div.info").children("div.selected-branch").html(g).find("a.open-branch-select").on("click keypress",function(f){("click"==f.type||"keypress"==f.type&&13==f.which)&&openBranchSelect($(this).closest("label.option").find("select.branch"))}); $shipping.val()||$shipping.closest("label.option").find(".control input").prop("checked",!1).trigger("change");hidePopupWindow()}else b[d].setURL("images/drop-free.png")}} function showBranches(a){cartBranchSelectMapLayer.removeAll();for(var b=$("div.cart-branch-select .list").data("id"),d=[],g=null,f=0;f'+localized({cs:"V\u00fddejn\u00ed m\u00edsto",en:"Delivery point"})+' '+ a[f].shippingTitle+"
"+a[f].name+"";k.getBody().innerHTML=""+e+a[f].openingTime+'
";h=SMap.Coords.fromWGS84(h,l);c== b?(e={title:e,url:"images/drop-here.png",anchor:{left:11,top:26}},g=h):e={title:e,url:"images/drop-free.png",anchor:{left:11,top:26}};c=new SMap.Marker(h,"branchMarker"+c,e);c.decorate(SMap.Marker.Feature.Card,k);cartBranchSelectMapLayer.addMarker(c);d.push(h)}}d.length&&(g?cartBranchSelectMap.setCenterZoom(g,14):(a=cartBranchSelectMap.computeCenterZoom(d),cartBranchSelectMap.setCenterZoom(a[0],a[1]),17b.height()&&b.scrollTop(b.scrollTop()+(d-b.height()));0>a.position().top&&b.scrollTop(b.scrollTop()+a.position().top)} function loadBranches(a,b){var d={},g=$.trim($("div.cart-branch-select .input input").val());g&&(d.q=g);if(b){d.get_shipping=1;var f=$("div.cart-branch-select .input").data("shipping-id");f&&(d.shipping_id=f);f=$("div.cart-branch-select .input select").val()}else if(f=$("div.cart-branch-select .input select").val())d.shipping_id=f;$.getJSON("branch.php",d).done(function(c){var e="";if(c.shipping&&c.shipping.length){var h=$("div.cart-branch-select .input select");h.children("option:not(:first)").remove(); for(var l="",k=0;k'+c.shipping[k].name+""),l&&(l=k',c.branch[k].id&&(e+='"),e+=h,c.branch[k].id&&(h=$.trim(c.branch[k].zip+" "+c.branch[k].city),c.branch[k].street&&(h&&(h="
"+h),h=c.branch[k].street+h),e+="

"+localized({cs:"V\u00fddejn\u00ed m\u00edsto", en:"Delivery point"})+" "+c.branch[k].shippingTitle+(c.branch[k].name?"
"+c.branch[k].name:"")+(h?"
"+h:"")+'

"),e+="";c.cities?g?localized({cs:"Up\u0159esn\u011bte zad\u00e1n\u00ed nebo vyberte m\u011bsto v\u00a0seznamu a\u00a0na map\u011b m\u00edsto p\u0159evzet\u00ed\u2026",en:"Specify the entry or select a\u00a0city in the list and the map instead of the takeover\u2026"}): localized({cs:"\u2026nebo vyberte m\u011bsto v\u00a0seznamu a\u00a0na map\u011b m\u00edsto p\u0159evzet\u00ed\u2026",en:"\u2026or select a\u00a0city in the list and the map instead of the takeover\u2026"}):localized({cs:"Vyberte m\u00edsto p\u0159evzet\u00ed v\u00a0seznamu nebo na map\u011b\u2026",en:"Select place to take in a\u00a0list or map\u2026"})}else c.tooMuch?(e=""+localized({cs:"P\u0159\u00edli\u0161 mnoho v\u00fdsledk\u016f, up\u0159esn\u011bte zad\u00e1n\u00ed\u2026",en:"Too many results, please specify\u2026"})+ "",localized({cs:"P\u0159\u00edli\u0161 mnoho v\u00fdsledk\u016f, up\u0159esn\u011bte zad\u00e1n\u00ed\u2026",en:"Too many results, please specify\u2026"})):(e=""+localized({cs:"Nenalezeno, zm\u011b\u0148te zad\u00e1n\u00ed\u2026",en:"Not found, change entries\u2026"})+"",localized({cs:"Nenalezeno, zm\u011b\u0148te zad\u00e1n\u00ed\u2026",en:"Not found, change entries\u2026"}));$("div.cart-branch-select .output .list").html(e).scrollTop(0);showBranches(c.branch);$("div.cart-branch-select .output .list a").on("click", function(){var p=$(this).data("id");if(p){cartBranchSelectMap.removeCard();for(var t=cartBranchSelectMapLayer.getMarkers(),x=0;x';m.branch[n].id&&(v+='');v+=u;m.branch[n].id&&(u=$.trim(m.branch[n].zip+" "+m.branch[n].city),m.branch[n].street&&(u&&(u="
"+u),u=m.branch[n].street+u),v+="

"+localized({cs:"V\u00fddejn\u00ed m\u00edsto",en:"Delivery point"})+" "+m.branch[n].shippingTitle+(m.branch[n].name?"
"+m.branch[n].name:"")+(u?"
"+u:"")+m.branch[n].openingTime+ '

");v+=""}v&&(v=$(v),v.find("a").on("click keypress",function(r){if("click"==r.type||"keypress"==r.type&&13==r.which)if("keypress"==r.type&&13==r.which&&$(this).find("input").prop("checked",!0).trigger("change"),r=$(this).data("id")){cartBranchSelectMap.removeCard();for(var w=cartBranchSelectMapLayer.getMarkers(),y=0;y"+$(a).children("option:selected").text()+"",2<$(a).children("option").length&&(r=localized({cs:"Zvolen\u00e9 m\u00edsto",en:"Selected pickup location"})+":
"+r+'
'+localized({cs:"Zm\u011bnit m\u00edsto p\u0159evzet\u00ed", en:"Change pickup location"})+""),$(a).closest("div.info").children("div.selected-branch").html(r).find("a.open-branch-select").on("click keypress",function(w){("click"==w.type||"keypress"==w.type&&13==w.which)&&openBranchSelect($(this).closest("label.option").find("select.branch"))}));$(a).val()||$(a).closest("label.option").find(".control input").prop("checked",!1).trigger("change");hidePopupWindow()}),v.find("input").on("change",makeVisibleBranch),z.after(v),z.data("loaded",!0))}showBranches(m.branch)})}}); $("div.cart-branch-select .output .list a").on("keypress",function(p){13==p.which&&(p.preventDefault(),p.stopPropagation(),$(this).trigger("click"))});$("div.cart-branch-select .output .list a input").on("change",makeVisibleBranch);$("div.cart-branch-select .output .list button").on("click",function(){var p=$(this).closest("a").find("input:checked").val();p&&($(a).val(p).trigger("change"),p=""+$(a).children("option:selected").text()+"",2<$(a).children("option").length&&(p=localized({cs:"Zvolen\u00e9 m\u00edsto", en:"Selected pickup location"})+":
"+p+'
'+localized({cs:"Zm\u011bnit m\u00edsto p\u0159evzet\u00ed",en:"Change pickup location"})+""),$(a).closest("div.info").children("div.selected-branch").html(p).find("a.open-branch-select").on("click keypress",function(t){("click"==t.type||"keypress"==t.type&&13==t.which)&&openBranchSelect($(this).closest("label.option").find("select.branch"))}));$(a).val()||$(a).closest("label.option").find(".control input").prop("checked", !1).trigger("change");hidePopupWindow()})})} function openBranchSelect(a){$shipping=$(a);var b='

'+(localized({cs:"V\u00fdb\u011br m\u00edsta p\u0159evzet\u00ed",en:"Select pickup location"})+"

");b=b+'
');b+='
';b+='
";b=b+'
');showPopupWindow(b+'
');b=$("div#popup-window > div.popup-window");b.css("min-width","60%");var d=b.offset().top,g=b.height();d+g>$(window).height()&& b.css("top",0);d=b.find("div.content").height();if(d>g){var f=b.find("div.output").height();b.find("div.output > div.part-1, div.output > div.part-2").css("height",f-(d-g)+"px")}$("div.cart-branch-select .input select").on("change",function(){loadBranches(a)});cartBranchSelectMap=new SMap(JAK.gel("cart-branch-select-map"),null,7);cartBranchSelectMap.addDefaultLayer(SMap.DEF_BASE).enable();cartBranchSelectMap.addDefaultControls();cartBranchSelectMapLayer=new SMap.Layer.Marker;cartBranchSelectMap.addLayer(cartBranchSelectMapLayer); cartBranchSelectMapLayer.enable();b=new SMap.Control.Sync;cartBranchSelectMap.addControl(b);$("div.cart-branch-select .input input").on("input",function(){loadBranchesTimeout&&clearTimeout(loadBranchesTimeout);loadBranchesTimeout=setTimeout(function(){loadBranches(a)},250)}).focus();if($(a).val()){b={};var c=$("div.cart-branch-select .input select").val();c&&(b.shipping_id=c);b.id=$(a).val();$.getJSON("branch.php",b).done(function(e){if(e.branch&&$(a).val()==e.branch.id){var h=$.trim(e.branch.zip+ " "+e.branch.city);e.branch.street&&(h&&(h=", "+h),h=e.branch.street+h);e.branch.name&&(h&&(h=", "+h),h=e.branch.name+h);e.branch.city&&(h={},c&&(h.shipping_id=c),h.city=e.branch.city,$.getJSON("branch.php",h).done(function(l){showBranches(l.branch)}))}})}loadBranches(a,!0);$("div#popup-window > div.popup-window > span.close").on("click",function(){$(a).val()||$(a).closest("label.option").find(".control input").prop("checked",!1).trigger("change");hidePopupWindow()})} jQuery(function(a){a(".shipping-and-payment label.option .payment .control").prop("disabled",!0);a(".shipping-and-payment label.option .control input").attr("tabindex","-1").change(function(){var b=null,d=null;a(".shipping-and-payment .payment label.option").show().find(".control input").prop("disabled",!1);a(".shipping-and-payment .shipping label.option").each(function(){var c=a(this).find(".control input");if(c.prop("checked")){paymentTitle=a(".shipping-and-payment .payment .control input:checked").data("title"); var e=c.data("payment-id");e=e.toString().split("|");a(".shipping-and-payment .payment .control input").each(function(){-1==e.indexOf(a(this).val())?(a(this).prop("disabled",!0),a(this).prop("checked",!1)):a(this).prop("disabled",!1)});var h=a('.shipping-and-payment .payment .control input[data-title="'+paymentTitle+'"]').not(":disabled");1==h.length&&(h.prop("checked",!0),a('.shipping-and-payment .payment .control input[data-title="'+paymentTitle+'"]:disabled').closest("label.option").hide());a(this).find("select:visible").length&& a(this).find("select").prop("required",!0);a(this).removeClass("not-selected");b=c.val();!a(this).find("select.branch").length||a(this).find("select.branch").val()||a("#popup-window div.cart-branch-select").length||openBranchSelect(a(this).find("select.branch"))}else a(this).find("select").prop("required",!1),a(this).addClass("not-selected");c.prop("disabled")?(a(this).addClass("disabled"),a(this).attr("tabindex","")):(a(this).removeClass("disabled"),a(this).attr("tabindex","0"))});a(".shipping-and-payment .payment label.option").each(function(){var c= a(this).find(".control input");1==a('.shipping-and-payment .payment .control input[data-title="'+c.data("title")+'"]').not(":disabled").length&&a('.shipping-and-payment .payment .control input[data-title="'+c.data("title")+'"]:disabled').closest("label.option").hide();c.prop("checked")?(a(this).removeClass("not-selected"),d=c.val(),a(this).find(".subcontrol").show()):(a(this).find(".subcontrol").hide(),a(this).addClass("not-selected"));c.prop("disabled")?(a(this).find(".subcontrol").hide(),a(this).addClass("disabled"), a(this).attr("tabindex","")):(a(this).removeClass("disabled"),a(this).attr("tabindex","0"))});b&&0!=b?a(".shipping-and-payment .payment label.option").each(function(){var c=a(this).find(".control input"),e=a('.shipping-and-payment .payment .control input[data-title="'+c.data("title")+'"]'),h=a('.shipping-and-payment .payment .control input[data-title="'+c.data("title")+'"]:disabled');if(1 a(this).data("price")&&(l=a(this).data("price"));ka(this).data("price")&&(h=a(this).data("price"));l');a(this).hide();a(this).closest("label.option").click(function(){var d=a(this).find(".control input");!d.prop("disabled")&&d.prop("checked")&&d.trigger("change")});if(a(this).val()){var b= ""+a(this).children("option:selected").text()+"";2"+b+'
'+localized({cs:"Zm\u011bnit m\u00edsto p\u0159evzet\u00ed",en:"Change pickup location"})+"");a(this).closest("div.info").children("div.selected-branch").html(b).find("a.open-branch-select").on("click keypress",function(d){("click"==d.type||"keypress"==d.type&& 13==d.which)&&openBranchSelect(a(this).closest("label.option").find("select.branch"))})}});a(".shipping-and-payment .country select").on("change",function(){var b=a(this),d=a(".shipping-and-payment .shipping label.option input:checked").val();a(".shipping-and-payment .shipping label.option").each(function(){var g=a(this).find(".control input"),f=g.data("country-id");f=f.toString().split("|");""!=f&&-1==f.indexOf(b.val())?a(this).hide():(a(this).show(),g.val()==d&&g.prop("checked",!0).trigger("change"))})}).trigger("change")});