$(document).ready(function(){$("#obchodni_partneri").click(function(){window.open("/obchodni-zastupcovia","zastupcovia","width=650, height=400")});$("div.externals").each(function(){var d=$(this).attr("class").split(" ")[1];var c={},f=$(this).children("div.externals_data");if(f.length>0){c=f.text()}$(this).load("externals/"+d,c)});$("#gallery ul, img.gallery_zoom").live("click",function(){var e={},d=[];e=$.extend({data:"pid="+$(".gallery_zoom_wrapper").attr("data-pid"),title:"",closeable:true,unloadOnHide:true,type:"get",afterShow:function(){$(".close").parent().css("cursor","pointer");$(".boxy-content").removeClass("boxy-content").css({margin:"30px"});$(".boxy-modal-blackout").click(function(){$(".close").trigger("click")});var f=$(".ad-gallery").adGallery({loader_image:"media/styles/plugins/images/loader.gif",effect:"fade"});$(".ad-slideshow-controls").hide();this.center()}},e||{});var c=Boxy.load("product/inc/gallery",e);d.push(c)}).live("mouseover",function(){$(this).css("cursor","pointer")});$("#gallery .gallery_img").live("mouseover",function(){$(this).css("cursor","pointer")}).live("click",function(){min=$(this).attr("src").split("/");big=$(".productBig").attr("src").split("/");out="";for(i=0;i<big.length;i++){if(i==big.length-1){big[i]=min[min.length-1]}out+=big[i];if(i!=big.length-1){out+="/"}}$(".productBig").attr("src",out)});$('input[name="search"]').focus(function(){if($(this).val()!==""&&$(this).val()==="vyhľadávanie..."){$(this).val("")}if($(this).val().length>0){$(this).catcomplete("search",$(this).val())}}).blur(function(){if($(this).val()===""){$(this).val("vyhľadávanie...")}}).keydown(function(c){if(c.which==13){switch($('input[name="search"]').val()){case"":case"vyhľadávanie...":c.preventDefault();return false;break;default:c.preventDefault();$('form[name="search"]').submit()}}});$("#search_box .box img").live("click",function(){switch($('input[name="search"]').val()){case"":case"vyhľadávanie...":return false;break;default:$('form[name="search"]').submit()}}).mouseover(function(){$(this).css("cursor","pointer")});$.widget("custom.catcomplete",$.ui.autocomplete,{_renderMenu:function(e,d){var c=this,f="";$.each(d,function(g,h){if(h.category!=f){e.append('<li class="ui-menu-item ui-corner-all ui-widget-header ui-category">&nbsp;'+h.category+"</li>");f=h.category}c._renderItem(e,h)})},_suggest:function(c){var d=this.menu.element.empty().zIndex(this.element.zIndex()+10),e,f;this._renderMenu(d,c);this.menu.deactivate();this.menu.refresh();e=d.width("").width();f=this.element.width();d.width(Math.max(e,f));this.menu.element.show().position({my:"right top",at:"right bottom",of:this.element,collision:"none"})},_renderItem:function(c,d){var g=this.term.split(" ").join("|").replace(/(\(|\)|\+|\")/gi,"\\$1");var f=new RegExp("("+g+")","gi");var e=d.label.replace(f,'<b class="acmp">$1</b>');return $('<li class="autocomplete_row"></li>').data("item.autocomplete",d).append('<a class="atc_a">&nbsp;'+e+"&nbsp;</a>").appendTo(c)}});var a={};$("input[name=search]").catcomplete({source:function(d,c){if(d.term in a){c(a[d.term]);return}$.ajax({url:"search_respond",data:d,success:function(e){a[d.term]=e;c(e)}},"json")},minLength:1,delay:300,select:function(c,d){window.location.href="/"+d.item.target},focus:function(c,d){$(".ui-menu-item").css("cursor","pointer")}});var b=new Array("splatena","najlahsia","oblubena");$("select[name=insurance]").live("change",function(){var c,h=$(this),f,j,d=$(this).val(),g=false;if($(this).parent().hasClass("ins_product")||$(this).parent().hasClass("ins_ispopup")){g=true;j=d.split("^")[0];input={months:$("input[name=months]:checked").val(),payment:$("input[name=payments]:checked").val(),price:$('input[name="cns"]').val(),catalogue_id:$('input[name="catalogue_id"]').val(),product_id:$('input[name="product_id"]').val(),insurance:j};$.fn.handleData(input,"product")}$.ajax({url:"calc/respond",dataType:"json",data:"iid="+d,type:"get",beforeSend:function(k,e){if(!g){h.parents(".cat_box").mask(" ")}},success:function(m){$(".info_tooltip").qtip("destroy");$.fn.tooltip();if(h.parent().hasClass("ins_ispopup")){return}if(!g){h.parents(".cat_box").unmask()}if(m!=""){if(!g){h.parent().prev().attr("href",m.default_link);$("a.ins_title_link").attr("href",m.default_link)}var l=f,k,e;$.each(b,function(n,o){c=m.values[o].split(".");if(!g){e=h.parent().parent().next()}else{e=h.parent().parent()}e.find(".ins_"+o).empty().html(c[0]);e.find(".ins_"+o+"_cents").empty().html(c[1]);if(!g){h.parent().parent().next().find(".ins_"+o+"_link").val(m.links[o])}})}}})});$(".do_login").live("click",function(){$.fn.login();return false}).live("mouseover",function(){$(this).css({cursor:"pointer","text-decoration":"underline"})}).live("mouseout",function(){$(this).css("text-decoration","none")});$('#login_box input[name="user_name"], #login_box input[name="user_password"]').keypress(function(c){if(c.which==13){$.fn.login();c.preventDefault()}});$.fn.login=function(){$("#login_box .login_loading").ajaxStart(function(){$(this).show();$(this).unbind("ajaxStart")});$("#login_box .login_loading").ajaxStop(function(){$(this).hide()});$("#loading_respond").ajaxComplete(function(){$(".temp").remove();$(this).hide()});$.post("responder",{TYPE:"login",user_name:$('#login_box input[name="user_name"]').val(),user_password:$('#login_box input[name="user_password"]').val()},function(c){window.location.reload()},"json")};$("img").each(function(){var c=$(this).attr("src").split("/");if(c[1]=="MediaLibrary"){var d=$(this).attr("id");$(this).attr("src","img?id="+d)}});$(".prevedenia img").each(function(){$(this).tooltip({loading:true,bodyHandler:function(){var d,e,f,c;d=$(this).attr("src").split("?");e=d[0].split("/");f=e[e.length-1];c=f.search(/.jpg/);if(c==-1){f=f+".jpg"}return $("<img />").attr("src","obrazok/tooltip_top/"+f)}})});$("#floating_baner .cclose, #floating_baner .content").live("mouseover",function(){if($("input[name=poplink]").length>0){$(this).css("cursor","pointer")}});$("#floating_baner .content").live("click",function(){if($("input[name=poplink]").length>0){if($(this).hasClass("isneww")){window.open($("input[name=poplink]").val())}else{window.location=$("input[name=poplink]").val()}}});$("#floating_baner .cclose").live("click",function(){$.post("responder",{TYPE:"close_b"});$(this).parent().hide()}).live("mouseover",function(){$(this).css("cursor","pointer")});$(".reservation_tooltip").live("hover",function(){$(this).css("cursor","pointer")});$.fn.reservation_tooltip=function(){$(".reservation_tooltip").qtip({content:$(".reservation_text").text(),style:{width:375,padding:"5px 0 5px 5px",background:"#E3E3E5",color:"black",textAlign:"left","line-height":"normal",border:{width:7,radius:5,color:"#E3E3E5"},tip:"bottomLeft",name:"dark"},position:{corner:{target:"topRight",tooltip:"bottomLeft"}}})};$.fn.tooltip=function(){$(".info_tooltip").qtip({content:{url:"poistenie",data:{id:$("select[name=insurance]").val().split("^")[0]},method:"get"},style:{width:275,padding:"5px 0 5px 5px",background:"#E3E3E5",color:"black",textAlign:"left","line-height":"normal",border:{width:7,radius:5,color:"#E3E3E5"},tip:"bottomLeft",name:"dark"},position:{corner:{target:"topRight",tooltip:"bottomLeft"}}})};if($("select[name=insurance]").length>0){$.fn.tooltip()}$.ajaxSetup({cache:false});$.fn.prevedenia_click();$(".pc_add_to_cart").live("click",function(){$(".cart_wrap").trigger("click")});$(".dev_pridaj_do_kosika").live("click",function(){$('form[name="calc"]').submit()});$(".cart_wrap").live("click",function(){if($(this).hasClass("waiting")){alert("Prosím počkajte, prebieha výpočet.")}if($("select[name=insurance]").length>0){$("input[name=product_insurance]").val($("select[name=insurance]").val().split("^")[0])}if($('input[name="is_blocked"]').val()=="false"){if($('input[name="is_furniture"]').val()!=""){if($('input[name="has_suplement"]').val()==""){$('input[name="cproduct_id"]').val($('input[name="product_id"]').val());$('form[name="calc"]').submit()}else{$.fn.supplements()}}else{$('form[name="calc"]').submit()}}else{switch(true){case $('input[name="months"]:checked').val()!="12"&&$('input[name="payments"]:checked').val()=="8":$(".calc_error2").html("Pri 8% akontácií, môžete mať len 12 mesiacov.").show();$('input[name="payments"]:radio[value=10]').trigger("click");break}}}).live("mouseover",function(){$(this).css("cursor","pointer")});$(".najlahsia_click, .oblubena_click, .splatena_click").live("click",function(f){if($(".product_detail_cenovka").hasClass("cis_blocked")){return false}var e=$(this).children().find("input[name=link]").val();if($(this).hasClass("iscat")){if($(this).hasClass("halved")){switch($(this).attr("class").split(" ")[0]){case"oblubena_click":e=$("input.halved_repayment_click_url").val();break;case"najlahsia_click":case"splatena_click":e=$(".najlahsia_click").children().find("input[name=link]").val();break}}window.location.href=e;return false}else{if($(this).hasClass("halved")){return false}}var d=$('input[name="click_months"]').dataReader(),j=$('input[name="click_payment"]').dataReader(),g=$(this),h,c;switch($(this).attr("class").split(" ")[0]){case"najlahsia_click":h=d.najlahsia;c=j.najlahsia;break;case"oblubena_click":h=d.oblubena;c=j.oblubena;break;case"splatena_click":h=d.splatena;c=j.splatena;break}$(".payment_choice input:radio, .months_choice input:radio").each(function(){$(this).attr("checked","");if($(this).parent().attr("class")=="payment_choice"){if($(this).val()==c){$(this).attr("checked","checked")}}else{if($(this).val()==h){$(this).attr("checked","checked")}}});input={months:h,payment:c,price:$('input[name="cns"]').val(),catalogue_id:$('input[name="catalogue_id"]').val(),product_id:$('input[name="product_id"]').val(),insurance:$("select[name=insurance]").val().split("^")[0]};$.fn.handleData(input,e)}).live("mouseover",function(){if($(this).hasClass("cis_blocked")){return false}if($(this).hasClass("halved")&&!$(this).hasClass("iscat")){return false}$(this).css("cursor","pointer")});$(".payment_choice input:radio, .months_choice input:radio").live("click",function(){var c={},e=$('input[name="history"]').val(),f=false,d;c.price=$('input[name="cns"]').val();switch($(this).parent().attr("class")){case"payment_choice":c.payment=$(this).val();switch(c.payment){case"8":f=true;d=12;break}$(".months_choice input").each(function(){if(f){if($(this).val()==d){$(this).attr("checked","checked")}}if($(this).attr("checked")===true){c.months=$(this).val()}});break;case"months_choice":c.months=$(this).val();$(".payment_choice input").each(function(){if(f){if($(this).val()==d){$(this).attr("checked","checked")}}if($(this).attr("checked")===true){c.payment=$(this).val()}});break}switch(true){case c.months!="12"&&c.payment=="8":$(".calc_error2").html("Pri 8% akontácií, môžete mať len 12 mesiacov.").show();$('input[name="payments"]:radio[value=10]').trigger("click");$(".calc_error2").addClass("block_hiding");f=true;break;default:if($(".calc_error2").hasClass("block_hiding")){$(".calc_error2").hide().removeClass("block_hiding")}c.catalogue_id=$('input[name="catalogue_id"]').val();c.product_id=$("input[name=product_id]").val();c.insurance=$("select[name=insurance]").val().split("^")[0];$.fn.handleData(c,"")}if(f){$('input[name="is_blocked"]').val("true")}else{$('input[name="is_blocked"]').val("false")}});$.fn.reservation_tooltip();$("#cart .cart_delete, #cart .cart_actions .qty img").live("click",function(){var c=$(this).next("input").dataReader();$.ajax({type:"post",url:"sc_respond",data:c,dataType:"text/html",beforeSend:function(){$("#cart_loading").show()},complete:function(){$("#cart_loading").hide()},success:function(d){$("#cart").load("shopping_cart/inc/cart_load",function(){$(".cart_message").show().html(d);$.fn.reservation_tooltip();$("#cart_loading").hide()})}})}).live("mouseover",function(){$(this).css("cursor","pointer")});$(".testor").live("mouseover",function(){$(this).css({background:"#fff888",cursor:"pointer"})}).live("mouseout",function(){$(this).css("background","#fff")});$("#cart .testor").live("click",function(){var e={},d=[],f=$(this).next("input").dataReader();e=$.extend({data:f,title:"",closeable:true,unloadOnHide:true,type:"POST",afterShow:function(){$(".boxy-content").removeClass("boxy-content").addClass("boxy_suplements");$.fn.prevedenia_click();$(".close, .save").mouseover(function(){$(this).css("cursor","pointer")});$(".save").click(function(){$.fn.supplements("cart")});$(".boxy-modal-blackout").click(function(){$(".close").trigger("click")});this.center()}},e||{});var c=Boxy.load("shopping_cart/supplements",e);d.push(c)}).live("mouseover",function(){$(this).css("cursor","pointer")});$("#cart .show_calc").live("click",function(){var e={},d=[],f=$(this).next("input").dataReader();e=$.extend({data:f,title:"",closeable:true,unloadOnHide:true,type:"POST",afterShow:function(){$.fn.tooltip();$(".boxy-content").removeClass("boxy-content").addClass("boxy_suplements");$(".boxy-modal-blackout").click(function(){$(".close").trigger("click")});$(".save").live("click",function(){var g={};$(".close").trigger("click");$(".auto_fill").each(function(){var h=$(this).attr("name");g[h]=$('input[name="'+h+'"]').val()});g.history=$('input[name="temp[history]"]').val();g.payment=$('input[name="payment"]').val();g.repayment=$('input[name="repayment"]').val();g.key=$('input[name="key"]').val();g.key2=$('input[name="key2"]').val();g.pid=$('input[name="pid"]').val();g.is_furniture=$('input[name="is_furniture"]').val();g.cns=$('input[name="cns"]').val();g.product_insurance=$('select[name="insurance"]').val().split("^")[0];$.ajax({type:"POST",url:"sc_respond",data:g,dataType:"text/html",beforeSend:function(){$("#cart_loading").show()},complete:function(){$("#cart_loading").hide()},success:function(h){$("#cart").load("shopping_cart/inc/cart_load",function(k,j,l){$(".cart_message").show().html(h);$("#cart_loading").hide()})}})}).live("mouseover",function(){$(this).css("cursor","pointer")});this.center()}},e||{});var c=Boxy.load("shopping_cart/inc/calc",e);d.push(c)}).live("mouseover",function(){$(this).css("cursor","pointer")});$("#cart_preview").bind("mouseenter mouseleave",function(c){var d='<div id="cart_preview_body"><div class="header"></div><div class="body" id="preview_body"><div class="body_wrap"></div></div><div class="bottom"></div></div>';switch(c.type){case"mouseenter":$("#cart_preview").append(d);$("#cart_preview .body_wrap").ajaxStart(function(){$(this).html('<div style="text-align:center; clear:both; padding: 20px 0 0 0;"><strong>Nahrávam...</strong></div>')});$("#cart_preview .header").html('<td id="cart_preview" valign="top" class="cms_menu_right reload_cart"><div style="float:right;"><img src="media/images/cart/cart_preview.jpg" alt="" /></div><div class="" style="padding: 6px 0 0 0; float:right;"><a href="kosik" title="Košík">ZOBRAZIŤ KOŠÍK</a> &nbsp;</div></td>');$("#cart_preview .body_wrap").load("shopping_cart/inc/cart_preview",function(){if($("#preview_body").length>0){if($("#preview_body").height()>400){$("#cart_preview .body_wrap").css({height:"400px","overflow-y":"scroll"})}}if($('input[name="preview_show"]').val()=="true"){}else{$("#cart_preview .bottom").html('<div style="margin: 0 0 0 25px"><a href="kosik"><img src="media/images/prejst.jpg" /></a>&nbsp;&nbsp;<a href="objednat-tovar"><img src="media/images/tovar.jpg" /></a></div>')}});break;case"mouseleave":$("#cart_preview").find("#cart_preview_body").remove();break}});$.fn.dataReader=function(h){var e,d,g={};switch(h){case"element":e=$(this).attr("class");break;default:e=$(this).val()}if(typeof(e)==="undefined"){return false}var c=e.split(","),j=c.length;for(var f=0;f<j;f++){d=c[f].split(":");g[d[0].replace("{","")]=d[1].replace("}","")}return g}});$.fn.prevedenia_click=function(){$(".prevedenia").each(function(){$(this).css("cursor","pointer");var b=$(".counter").val(),c=$.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),a;if(c){a="top"}else{a="bottom"}$(this).click(function(){switch(b){case"1":if($(this).find(".dselected").val()=="false"){$(".prevedenia").each(function(){if($(this).find(".dselected").val()=="true"){$(this).css("background","");$(this).find(".dselected").val("false")}});$(this).css("background","url(media/images/doplnky_sel.jpg) "+a+" no-repeat");$(this).find(".dselected").val("true");$("#set_suplement").val($(this).find(".did").val()+"^"+$(this).find(".gid").val())}else{$(this).css("background","");$(this).find(".dselected").val("false");$("#set_suplement").val("")}break;default:if($(this).find(".dselected").val()=="false"){var d=$(this).find(".title").val();$(".prevedenia").each(function(){if($(this).find(".dselected").val()=="true"&&$(this).find(".title").val()==d){$(this).css("background","");$(this).find(".dselected").val("false")}});$(this).css("background","url(media/images/doplnky_sel.jpg) "+a+" no-repeat");$(this).find(".dselected").val("true");$('input[name="'+d+'"]').val($(this).find(".did").val()+"^"+$(this).find(".gid").val())}else{var d=$(this).find(".title").val();$(this).css("background","");$(this).find(".dselected").val("false");$('input[name="'+d+'"]').val("")}}})})};Array.prototype.in_array=function(c){for(var b=0,a=this.length;b<a;b++){if(this[b]==c){return true}}return false};$.fn.supplements=function(b){if(typeof(b)=="undefined"){b=""}var a=$(".counter").val();if(a>1){var c=new Array();$("input.temp_id").each(function(e){if($(this).val()!=""){c[e]="true"}else{c[e]="false"}});if(c.in_array("false")){test=$("#set_suplement").val();if(!test){alert("Vyberte si klikom farebné prevedenie.");return false}else{$("input.temp_id").each(function(){$("#set_suplement").val($("#set_suplement").val()+","+$(this).val())});$('input[name="cproduct_id"]').val($('input[name="product_id"]').val());$('input[name="cset_suplement"]').val($("#set_suplement").val());$('form[name="calc"]').submit()}}else{$("input.temp_id").each(function(){if($("#set_suplement").val()==""){$("#set_suplement").val($(this).val())}else{$("#set_suplement").val($("#set_suplement").val()+","+$(this).val())}});if($("#qty").val()==0){$("#qty").val("1")}$('input[name="cproduct_id"]').val($('input[name="product_id"]').val());$('input[name="cset_suplement"]').val($("#set_suplement").val());$('form[name="calc"]').submit()}}else{if($("#set_suplement").val()==""){alert("Vyberte si klikom farebné prevedenie.");return false}else{if($("#qty").val()==0){$("#qty").val("1")}if(b==""){$('input[name="cproduct_id"]').val($('input[name="product_id"]').val());$('input[name="cset_suplement"]').val($("#set_suplement").val());$('form[name="calc"]').submit();return false}else{$(".close").trigger("click");var d=$('input[name="data"]').dataReader();d.did_new=$("#set_suplement").val();$.ajax({type:"POST",url:"sc_respond",data:d,dataType:"text/html",beforeSend:function(){$("#cart_loading").show()},complete:function(){$("#cart_loading").hide()},success:function(e){$("#cart").load("shopping_cart/inc/cart_load",function(){$(".cart_message").show().html(e);$("#cart_loading").hide()})}})}}}return false};$.fn.handleData=function(b,a){var c=new Date(),d=c.getTime();$.ajax({type:"POST",url:"calc/respond?rand="+d,dataType:"json",data:b,cache:false,beforeSend:function(){$(".calc_content").mask(" ");$(".cart_wrap").addClass("waiting")},complete:function(){$(".calc_content").unmask();$(".cart_wrap").removeClass("waiting")},success:function(f){if(typeof(f.error)=="undefined"){$('input[name="temp[history]"]').val(b.payment+"-"+b.months);$('input[name="payment"]').val(f.payment+" €");$('input[name="repayment"]').val(f.repayment+" €");$(".auto_fill").each(function(){var g=$(this).attr("name");$('input[name="'+g+'"]').val(f[g])});if($("select[name=insurance]").val().split("^")[0]!="-1"){$(".poistenie_text").html(" s poistením")}else{$(".poistenie_text").empty()}$(".cptl").html($('input[name="price_total"]').val()+" €");$(".clt").html($('input[name="loan_total"]').val()+" €");$(".crpmn").html($('input[name="rpmn"]').val());$(".cprpmn").html($('input[name="prpmn"]').val());$('input[name="is_blocked"]').val("false")}else{alert(f.error_string+".");$('input[name="is_blocked"]').val("true")}if(typeof(pageTracker)!="undefined"){if(pageTracker&&a!==""){try{pageTracker._trackPageview("/"+a)}catch(e){}}}}})};var newwindow;function popup(c){var d=800;var f=330;var b=(screen.availWidth-d)/2;var a=(screen.availHeight-f)/2;var e="left="+b+",top="+a+",width="+d+",height="+f+",toolbar=0,location=0,status=0,scrollbars= 1,resizable=0";newwindow=window.open(c,"test",e);if(window.focus){newwindow.focus()}}function toggle_visibility(b){var a=document.getElementById(b);if(a.style.display=="none"){a.style.display="block"}else{a.style.display="none"}}function preloadImage(b,a){$(b).next().remove();if(typeof(a)=="undefined"){$(b).parentsUntil(".preloader").removeClass("preloader")}$(b).show()}window.onload=function(){$(".topky_img").each(function(){var a=$(this).height(),b=165-a;$(".topky_img_spacer").css("height",b+"px")})};
