const Header={calc:function(){let sizes=["watch","mobile","tablet","netbook","laptop","desktop"];let header=$("header").addClass(sizes.join(" "));let title=header.find("h1");let icons=header.find(".icons");let size;while(size=sizes.pop()){if(icons.position().top<=title.position().top+10){break}header.removeClass(size)}if(header.hasClass("laptop")&&header.find(".Burger").hasClass("open")){header.find(".Burger").click()}}};$(function(){if($(".Cart").length){let h=$("header").addClass("watch mobile");h.find("nav section").addClass("slim").find(".Burger, ul, form").remove();h.find("aside").remove();$("footer").remove();return}Header.calc();$(window).resize(function(){Header.calc()});$("header a.Burger").click(function(e){e.preventDefault();let s=$(this).siblings("ul.icons").find("li.search a");if(s.hasClass("open")){s.click();setTimeout(function(){$("header .Burger").click()},400);return}let toggle=$("header aside, header nav ul.views, header nav ul.langs").stop();if($(this).toggleClass("open").hasClass("open")){$("header").attr("style","height:100vh;z-index:2").siblings().attr("style","display:none");toggle.slideDown(400)}else{toggle.slideUp(400,function(){$("header").attr("style","").siblings().attr("style","")})}});$("header ul.icons li.search a").click(function(e){e.preventDefault();let b=$("header a.Burger");if(b.hasClass("open")){b.click();setTimeout(function(){$("header ul.icons li.search a").click()},400);return}$(this).toggleClass("open");$("header form").slideToggle(400,function(){$("header form input").focus()})});$("header form a").click(function(e){e.preventDefault();let f=$(this).closest("form");let i=f.find("input");if(!i.val()){i.focus();return}f.submit()})}); const Actions={};$(function(){let Actions_run=function(e){let list=$(this).data("action").split(" ");for(let k in list){Actions[list[k]](e,this)}};$("body").on("click","a[data-action]",Actions_run).on("change","input[data-action]",Actions_run).on("submit","form[data-action]",Actions_run);$("body").on("click",'a[href="#debt"]',function(e){e.preventDefault();Overlay.dialog("",$(this).attr("title"))});$(".Spec span[title]").on("click",function(){Overlay.dialog($(this).text(),$(this).attr("title"))});$("form.voucher input").on("change",function(){$.post("/lv/cart/",{coupon:this.checked?$(this).val():"none"},function(){window.location.reload()})})});const Api={};Api.call=function(method,get_data,post_data,callback){get_data.lang=$("html").attr("lang");$.post("/API/"+method+"/json?"+$.param(get_data),post_data,function(reply){if(reply){if(typeof reply.error!=="undefined"){Overlay.dialog("Error",reply.error[0].text);return}if(typeof reply.alert!=="undefined"){Overlay.dialog("Alert",reply.alert[0].text);reply.alert=null}}callback(reply)},"json")};Api.error=function(data){let req=new XMLHttpRequest;req.open("POST","/APP/js_error/");req.setRequestHeader("Content-type","application/x-www-form-urlencoded");req.send("msg="+encodeURIComponent(JSON.stringify(data)));Api.error=function(){}};window.onerror=function(msg,file,line,col,error){Api.error(window.location.href+": "+msg+" on "+file+":"+line+":"+col+", "+JSON.stringify(error))};function cookie_set(name,value,days){let expires="";if(days){let date=new Date;date.setTime(date.getTime()+days*24*60*60*1e3);expires="; expires="+date.toGMTString()}document.cookie=name+"="+value+expires+"; secure; path=/"}function cookie_get(name){let value="; "+document.cookie;let parts=value.split("; "+name+"=");return parts.length===2?parts.pop().split(";").shift():null}const Form={};Form.init=function(){$("input[data-datetime]").each(function(){$(this).datetimepicker({dayOfWeekStart:1,format:$(this).attr("data-datetime")})})};$(function(){$('.Form input[type="checkbox"], .Form input[type="radio"]').wrap('
').after("").closest("label").addClass("pointer");$(".Form").on("focus","label.text > input, label.text > textarea",function(){$(this).closest("label").addClass("active")}).on("blur","label.text > input, label.text > textarea",function(){$(this).closest("label").removeClass("active")});Form.init();$(".Form2").on("focus","input, textarea",function(){$(this).closest(".Form2 div.block").addClass("active")}).on("blur","input, textarea",function(){$(this).closest(".Form2 div.block").removeClass("active")})});const fitWindow={calc:function(){let top=$(window).scrollTop();let bot=top+$(window).height();$(".fitWindow").each(function(){let off_top=$(this).offset().top;let pos_top=$(this).position().top;let pos_bot=off_top+$(this).height()+parseInt($(this).css("bottom"));$(this).css("top",Math.max(top-(off_top-pos_top),0)+"px");$(this).css("bottom",Math.max(pos_bot-bot,0)+"px")})}};const Group={};$(function(){$("main section.Group.small .results").css("position","relative");$('main section.Group.big a[href="#filters"]').click(function(e){e.preventDefault();$(this).closest(".info").siblings(".filters").stop().slideToggle()});$('main section.Group.big select[name="sort"]').change(function(){cookie_set("sort",$(this).val());location.reload()});$("main section.Group.big div.filters div label input").on("click",function(e){e.preventDefault();document.location="?spec="+$(this).val()})});const Misc={cart_count:function(count){$("header .icons sup").text(count).css("display","inline");Header.calc()}};const Overlay={dialog:function(title,body){$("body").append($('"))}};const Price={init:function(){$(".Price").each(function(){let price,vat,t=$(this);if(this.hasAttribute("data-price")){price=t.attr("data-price")}else{price=t.text();t.attr("data-price",price)}if(this.hasAttribute("data-vat")){vat=t.attr("data-vat")}else{vat="X";t.attr("data-vat",vat)}t.text(Price.price_vat(parseFloat(price),vat).toFixed(2))})},price:function(price){return Math.round(price*100)/100},price_vat:function(price,vat_type){return Math.round(price*(vat_type==="R"||vat_type==="E"||vat_type==="0"?100:121))/100},vat:function(price,vat_type){return Math.round((Price.price_vat(price,vat_type)-Price.price(price))*100)/100}};$(function(){Price.init()});const Slider={x:null,y:null,speed:null,speed_ads:0,touch:null,timer:null,timer_ads:null,easing:"swing",resize:null,init:function(){$(".Slider ol.index li:first").addClass("open");$(".Slider ol.index li a").click(function(e){if(e.screenX||e.screenY){clearInterval(Slider.timer_ads)}e.preventDefault();$(this).parent().addClass("open").siblings(".open").removeClass("open");clearInterval(Slider.timer);let nr=$(this).parent().index();$(this).closest(".Slider").find(".stick").each(function(){let first=$(this).find("> *:first-child");let step=Math.round(first.outerWidth()*-100/$(this).outerWidth());$(this).find("> *:first-child").stop().animate({"margin-left":nr*step+"%"},{easing:Slider.easing})});let ct=$(this).parent().siblings().length;Slider.reset_ads($(this).closest(".Slider"))});$(".Slider.ads ol.index li a").first().click();$('.Slider.ads a[href="#back"]').click(function(e){if(e.screenX||e.screenY){clearInterval(Slider.timer_ads)}e.preventDefault();let open=$(this).siblings("ol").find("li.open");(open.prev().length?open.prev():open.siblings().last()).find("a").click()});$('.Slider.ads a[href="#next"]').click(function(e){if(e.screenX||e.screenY){clearInterval(Slider.timer_ads)}e.preventDefault();let open=$(this).siblings("ol").find("li.open");(open.next().length?open.next():open.siblings().first()).find("a").click()});Slider.timer_ads=setInterval(function(){$('.Slider a[href="#next"]').click()},1e4);$(".Slider.ads").each(function(){if($(this).find("> ol > li").length<=1){$(this).find("> a").css("display","none");$(this).find("> ol").css("display","none")}});if(!Slider.is_touch_device()){$(".Slider .swipe").removeClass("swipe").addClass("swipe_0")}$(".Slider .swipe").each(function(){this.addEventListener("touchstart",function(e){clearInterval(Slider.timer_ads);clearInterval(Slider.timer);let t=e.changedTouches[0];Slider.x=t.pageX;Slider.y=t.pageY},false);this.addEventListener("touchmove",function(e){let t=e.changedTouches[0];let x=t.pageX-Slider.x;let y=t.pageY-Slider.y;Slider.x=t.pageX;Slider.y=t.pageY;if(Math.abs(y)>Math.abs(x)){Slider.speed=0;return}e.preventDefault();Slider.swipe(this,x);Slider.speed=x},false);this.addEventListener("touchend",function(){if($(this).hasClass("stick")){let cw=parseFloat(getComputedStyle(this.children[0]).width);let cp=parseFloat(getComputedStyle(this.children[0]).marginLeft);let nr=-cp/cw;nr=Slider.speed<0?Math.ceil(nr):Math.floor(nr);Slider.easing="linear";$(this).closest(".Slider").find("ol.index li:nth-child("+(nr+1)+") a").click();Slider.easing="swing";return}Slider.touch=this;Slider.timer=setInterval(function(){Slider.speed=Math.round(Slider.speed*970)/1e3;if(Slider.speed>-1&&Slider.speed<1||!Slider.swipe(Slider.touch,Slider.speed/3)){clearInterval(Slider.timer)}},3)},false)})},reset:function(slider){$(slider).find(".swipe").each(function(){let width=0;for(let k=0;k"+Terms.chat_sent+"
")})}};Actions.maillist=function(e,t){e.preventDefault();let form=$(t);let email=form.find('input[name="email"]');if(!email.val().trim()){email.closest("label").addClass("error")}else{email.closest("label").removeClass("error")}if(!form.find("label.error").length){form.find('input[type="submit"]').attr("disabled","disabled");Api.call("maillists",{},form.serialize(),function(){Overlay.dialog(Terms.maillist_sent,"")});form[0].reset()}};