/* Minify: at least one missing file. See http://code.google.com/p/minify/wiki/Debugging */

;jQuery.fn.joustorahaPlugin=function(amount){this.rand=function(){var randomnumber=Math.floor(Math.random()*10000)
return randomnumber;}
this.roundNumber=function(num,dec){var result=Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);return result;}
this.fixNumber=function(num){var parts=num.toString().split(".");if(parts.length!=2){return num;}
if(parts[1].length==1){parts[1]+="0";}
return parts[0]+"."+parts[1];}
this.PMT=function(rate_per_period,number_of_payments,present_value,future_value,type){if(rate_per_period!=0.0){var q=Math.pow(1+rate_per_period,number_of_payments);return-(rate_per_period*(future_value+(q*present_value)))/((-1+q)*(1+rate_per_period*(type)));}else if(number_of_payments!=0.0){return-(future_value+present_value)/number_of_payments;}
return 0;}
this.nper=function(ir,pmt,pv,fv){var nbperiods;if(ir!=0)
ir=ir/100;nbperiods=Math.log((-fv*ir+pmt)/(pmt+ir*pv))/Math.log(1+ir)
return nbperiods;}
this.getTableFieldValue=function(fieldName){switch(fieldName){case"Osta Joustolla":return this.fixNumber(this.roundNumber(this.loanAmount,2))+' €';case"osamaksuerä alk./kk":return this.fixNumber(this.roundNumber(this.pmtAndBilling,2))+' €';case"maksueriä max yhteensä":return this.monthCount;}}
this.minLoanAmount=200;this.loanAmount=amount;this.monthCount=12;this.billingFee=4.9;this.monthlyInterest=0.0242;this.yearlyInterest=0.29;this.bigLoan=this.loanAmount>this.minLoanAmount;if(this.bigLoan){var max=2000;if(this.loanAmount>max)
return;}else{var min=30;if(this.loanAmount<min)
return;}
this.minLyhennys=10-this.billingFee;if(this.loanAmount<=200)this.monthCount=8;if(this.loanAmount<=140)this.monthCount=6;if(this.loanAmount<=110)this.monthCount=5;if(this.loanAmount<=90)this.monthCount=4;if(this.loanAmount<=70)this.monthCount=3;if(this.loanAmount<=50)this.monthCount=2;this.pmtVal=-this.PMT((this.yearlyInterest/12),this.monthCount,this.loanAmount,0,0);this.totalCost=this.pmtAndBilling*this.monthCount;this.pmtAndBilling=this.pmtVal+this.billingFee;var tableFields=new Array("Osta Joustolla","osamaksuerä alk./kk","maksueriä max yhteensä");var tableHtml='<table>';for(k=0;k<tableFields.length;k++){tableHtml+='<tr><td style="width: 140px;">'+tableFields[k]+': </td><td>'+this.getTableFieldValue(tableFields[k])+'</td></tr>';}
tableHtml+='</table>';var divCss='font-weight: bold; -moz-box-shadow: 5px 5px 5px #ccc; -webkit-box-shadow: 5px 5px 5px #ccc; box-shadow: 5px 5px 5px #ccc; font-size: 13px; font-family: Arial; color: #0072ce; z-index: 100; padding: 15px;display: none; background-color: #ffffff; border: 2px solid #0072ce; width:400px; position: absolute; top: 0px; left: 0px;';var pCss='font-weight: normal; font-size: 13px; font-family: Arial; color: #000000;';var html='';var imgHtml='<img src="./images/payment_methods/jousto.png" />';var infoHtml='<p style="'+pCss+'">Jousto on kotimainen palvelu, jolla rahoitat nettiostoksesi joustavasti, nopeasti ja turvallisesti. Laskulla saat aidosti korotonta maksuaikaa ostoksillesi ja maksat vasta tuotteen saatuasi. Osamaksulla voit maksaa ostoksesi jopa 12 erässä.</p>';var divId="joujoustorahaHoverBox"+this.rand();var spnId="minimumMonthlyAmount"+this.rand();var divHtml='<div id="'+divId+'" style="'+divCss+'">'+imgHtml+infoHtml+tableHtml+'</div>';html+='<span id="'+spnId+'">'+divHtml+'Osta Joustolla alk. '+this.fixNumber(this.roundNumber(this.pmtAndBilling,2))+' €/kk ('+this.monthCount+')</span>';$(this).html(html);$("span#"+spnId).mouseenter(function(e){if(!$("div#"+divId).is(":visible")){mouseX=e.pageX;mouseY=e.pageY;var position=$("span#"+spnId).position();var posLeft=position.left;var posTop=position.top;$("div#"+divId).css("top",mouseY-posTop/mouseY);$("div#"+divId).css("left",mouseX-posLeft/mouseX);$("div#"+divId).fadeIn("fast");}}).mouseleave(function(){$("div#"+divId).delay(500).fadeOut("fast");});};$(function(){$('.js-jousto-container').each(function(){var price=$(this).data('price');$(this).joustorahaPlugin(price);});});;var Core=(function(){var object={};object.ExtendClass=function(Superclass,Subclass)
{var f=function(){};f.prototype=Superclass.prototype;Subclass.prototype=new f();Subclass.prototype.constructor=Subclass;};return object;})();var TemplateEngine=(function(){var object={};$.extend(true,object,TemplateEngineData.Variables);var template_functions_by_name={};var template_functions_by_id={};var texts=$.extend(true,{},TemplateEngineData.Texts);var loaded_scripts={};object.InitTemplateFunctions=function(template_functions)
{$.each(template_functions,function(index,template_function){var template_function_id=template_function.id;var template_function_name=template_function.name;var template_function_data=template_function.data;var template_function_constructor;if(typeof window[template_function_name]=="function")
{template_function_constructor=window[template_function_name];}
else
{template_function_constructor=TemplateFunction;}
try
{var template_function_instance=new template_function_constructor(template_function_data);var template_function_already_exists=(typeof template_functions_by_id[template_function_id]=="object");if(template_function_already_exists)
{var existing_template_function_instance=template_functions_by_id[template_function_id];$.each(template_functions_by_name[template_function_name],function(index){if(this===existing_template_function_instance)
{template_functions_by_name[template_function_name][index]=template_function_instance;}});}
else
{if(typeof template_functions_by_name[template_function_name]=="undefined")
{template_functions_by_name[template_function_name]=[];}
template_functions_by_name[template_function_name].push(template_function_instance);}
template_functions_by_id[template_function_id]=template_function_instance;template_function_instance.ApplyHandlers("ready");}
catch(error)
{throw error;}});};object.GetTemplateFunction=function(template_function_id)
{var template_function=false;if(typeof template_functions_by_id[template_function_id]=="object")
{template_function=template_functions_by_id[template_function_id];}
return template_function;};object.GetTemplateFunctionsByName=function(template_function_name)
{var template_functions=false;if(typeof template_functions_by_name[template_function_name]=="object")
{template_functions=template_functions_by_name[template_function_name];}
return template_functions;};object.GetTemplateFunctionByName=function(template_function_name,template_function_instance_key)
{var template_function=false;var template_functions=object.GetTemplateFunctionsByName(template_function_name);if(typeof template_functions=="object")
{if(typeof template_function_instance_key=="undefined")
{template_function_instance_key=0;}
if(typeof template_functions[template_function_instance_key]=="object")
{template_function=template_functions[template_function_instance_key];}}
return template_function;};object.ForEachTemplateFunction=function(template_function_name,callback_function)
{if(typeof callback_function=="function")
{var template_functions=object.GetTemplateFunctionsByName(template_function_name);$.each(template_functions,function(index,template_function){callback_function.call(template_function,index);});}};object.GetText=function(key)
{return texts[key];};object.Ajax=function(data,b,c)
{var settings={};var callback=function(){};if(typeof b=="function")
{callback=b;}
else if(typeof b=="object")
{settings=b;if(typeof c=="function")
{callback=c;}}
var defaults={dataType:'json',type:'post',url:object.AJAX_URL};settings=$.extend(defaults,settings);data.referer_url_name=object.URL_NAME;settings.data=data;settings.success=function(data){callback(data);if(typeof data=="object"&&$.isArray(data.new_template_functions))
{object.InitTemplateFunctions(data.new_template_functions);}};$.ajax(settings);};object.LoadScript=function(script_src,callback_function)
{if(typeof callback_function!="function")
{callback_function=function(){};}
if(!loaded_scripts[script_src])
{loaded_scripts[script_src]=true;$.ajax({url:script_src,dataType:"script",success:function(){},error:function(){},complete:callback_function,cache:true});}
else
{callback_function();}};return object;})();$(function(){var template_functions=TemplateEngineData.TemplateFunctionsOnPageLoad;TemplateEngine.InitTemplateFunctions(template_functions);delete TemplateEngineData;});;function TemplateFunction(template_function_data)
{var __data=template_function_data;var __handlers={};var __last_error=null;this.HasData=function(field_name)
{return(this.GetData(field_name)!=undefined);};this.GetData=function(field_name)
{return __data[field_name];};this.SetData=function(field_name,value)
{__data[field_name]=value;};this.GetBlock=function(block_name)
{var code="";if(this.HasData("blocks_from_parameters"))
{var blocks_from_parameters=this.GetData("blocks_from_parameters");if(blocks_from_parameters[block_name]!=undefined)
{code=blocks_from_parameters[block_name];}}
return code;};this.SetLastError=function(error)
{__last_error=error;};this.GetLastError=function()
{return __last_error;};this.Bind=function(handler_name,handler_function,unbind_existing)
{if((typeof __handlers[handler_name]=="undefined")||(unbind_existing===true))
{this.Unbind(handler_name);}
__handlers[handler_name].push(handler_function);};this.Unbind=function(handler_name)
{__handlers[handler_name]=[];};this.ApplyHandlers=function(handler_name)
{var handler_arguments=Array.prototype.slice.call(arguments,1);if(typeof __handlers[handler_name]!="undefined")
{if(__handlers[handler_name]instanceof Array)
{try{var self=this;var handler_result=null;$.each(__handlers[handler_name],function(index,handler_function){handler_result=handler_function.apply(self,handler_arguments);});}
catch(handler_error)
{this.SetLastError(handler_error);handler_result=false;}
if(handler_name.split(".once").pop()=="")
{this.Unbind(handler_name);}
return handler_result;}}};var ready_handler_code=this.GetBlock("ready");if(ready_handler_code)
{this.Bind("ready",new Function(ready_handler_code));}};;String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,'');};var InitializeAddToCartFunctionality=function()
{$("[data-addtocart]").each(function(){var data=$(this).data("addtocart");switch(data.type)
{}
if(data.class)
{var add_class=data.class;$(this).addClass(add_class);}
$(this).removeAttr("data-addtocart");});$("[data-add-option-tocart]").each(function(){var data=$(this).data("add-option-tocart");switch(data.type)
{}
if(data.class)
{var add_class=data.class;$(this).addClass(add_class);}
$(this).removeAttr("data-add-option-tocart");});$("[data-tierprices]").each(function(){var data=$(this).data("tierprices");switch(data.type)
{}
if(data.class)
{var add_class=data.class;$(this).addClass(add_class);}
$(this).removeAttr("data-tierprices");});};var AddFaceBookPixel=function(id,pixel_data)
{var FB_script="fbq('track', 'AddToCart', {content_ids: ['"+id+"'], content_name:'"+pixel_data.name+"', content_category:'"+pixel_data.category+"', content_type:'product'}, {eventID:'"+pixel_data.event_id+"'});";var s=document.createElement("script");s.type="text/javascript";s.innerHTML=FB_script;$("head").append(s);};function AddToCartAction()
{this.name="AddToCart";this.product_id=null;this.quantity=1;this.options=null;this.variation_products=null;this.multiple_variation_products=null;this.bundle_product=null;this.customer_text=null;this.customer_product_image_filename=null;this.SetProductId=function(product_id)
{this.product_id=product_id;};this.SetQuantity=function(quantity)
{this.quantity=quantity;};this.SetOptions=function(options)
{this.options=options;};this.SetVariationProducts=function(variation_products)
{this.variation_products=variation_products;};this.SetMultipleVariationProducts=function(multiple_variation_products)
{this.multiple_variation_products=multiple_variation_products;};this.SetBundleProduct=function(bundle_product)
{this.bundle_product=bundle_product;};this.SetCustomerText=function(customer_text)
{this.customer_text=customer_text;};this.SetCustomerProductImageFilename=function(customer_product_image_filename)
{this.customer_product_image_filename=customer_product_image_filename;};this.Execute=function()
{var params={action:this.name,product_id:this.product_id,quantity:this.quantity,options:this.options,variation_products:this.variation_products,multiple_variation_products:this.multiple_variation_products,bundle_product:this.bundle_product,customer_text:this.customer_text,customer_product_image_filename:this.customer_product_image_filename};TemplateEngine.Ajax(params,function(data){if(data.success)
{if(data.extra_tag_or_pixel_information.pixel_id&&typeof(fbq)!="undefined")
{AddFaceBookPixel(params.product_id,data.extra_tag_or_pixel_information);}
if(data.google_tag_manager_id&&typeof(dataLayer)!="undefined")
{dataLayer.push({ecommerce:null});dataLayer.push({'event':'add_to_cart','ecommerce':{'currency':'EUR','value':data.extra_tag_or_pixel_information.price.replace(",",".").toString(),'items':[{'item_name':data.extra_tag_or_pixel_information.name,'item_id':params.product_id,'item_category':data.extra_tag_or_pixel_information.category,'quantity':data.added_amount,'item_brand':data.extra_tag_or_pixel_information.manufacturer_name,'price':data.extra_tag_or_pixel_information.price.replace(",",".").toString()}]}});}
if(typeof(klaviyo)!=="undefined"&&data.klaviyo_array)
{klaviyo.push(["track","Added to Cart",data.klaviyo_array]);}
if(data.redirect_to_shopping_cart_page)
{window.location=data.shopping_cart_url;}
else
{if($(data.overlay).hasClass("modal"))
{ShowModalOverlay(null,data.overlay);}
else if(data.use_quick_top_addtocart_overlay)
{ShowFadingOverlay(data.overlay,data.overlay_delay);}
TemplateEngine.ForEachTemplateFunction("ShoppingCartPreview",function(){this.Update();});if(!$(data.overlay).hasClass("modal")&&!data.use_quick_top_addtocart_overlay)
{var overlay_params={action:"ShowRightSideAddToCartOverlay"}
TemplateEngine.Ajax(overlay_params,function(overlay_data){if(overlay_data.success)
{ShowFadingOverlay(overlay_data.overlay,overlay_data.overlay_delay);}});}}
if($("#sc_highlight_products").length>0)
{var refresh_params={action:"RefreshShoppingCart"}
Ajax.Call(refresh_params,function(data){UpdateAllHtml(data);});}}
else if(data.cookie_not_found)
{ShowModalOverlay(null,data.overlay);}
else
{if(data.product_options_overlay)
{ShowModalOverlay(null,data.product_options_overlay,params.options);}
else
{ShowModalOverlay(null,data.overlay);}}});};};var AddToCart=function(product_id,quantity,product_option_id){var action=new AddToCartAction();action.SetProductId(product_id);action.SetQuantity(quantity);var options=null;if(product_option_id!=undefined&&product_option_id)
{options=[];options.push(product_option_id);}
else
{var option_groups=$(".js-product-option-group-"+product_id);if(option_groups.length>0)
{options=[];option_groups.each(function(){var input=$(this).find(":input");if(input.length>1)
{input=input.filter(":checked");}
options.push(input.val());});}}
action.SetOptions(options);var variation_products=null;var variation_groups=$(".js-variation-group-"+product_id);if(variation_groups.length>0)
{selected_products=[];multiple_selected_products=[];variation_groups.each(function(){var selected=$("option:selected",this);if(selected.length>0)
{var product_ids=selected.data("selectlist").product_ids;selected_products.push(product_ids);}
else
{var radio_selected=$('input[name="product"]:checked');if(radio_selected.length>0)
{var product_ids=radio_selected.data("selectlist").product_ids;selected_products.push(product_ids);}}});action.SetVariationProducts(selected_products);action.SetMultipleVariationProducts(multiple_selected_products);}
var bundle_groups=$(".js-bundle-group-"+product_id);var bundle_from_list=$(".bundle-product-list-"+product_id);if(bundle_groups.length>0||bundle_from_list.length>0)
{action.SetBundleProduct(product_id);}
var customer_text_field=$(".js-add-to-cart-customer-text-"+product_id);if(customer_text_field.length)
{var customer_text=customer_text_field.val().trim();action.SetCustomerText(customer_text);}
var upload_image_first=false;var uploader=ProductImageUploader.GetInstanceForProduct(product_id);if(uploader instanceof ProductImageUploader)
{if(uploader.IsFileSelected())
{if(uploader.IsFileUploaded())
{action.SetCustomerProductImageFilename(uploader.GetUploadedFileName());}
else
{upload_image_first=true;}}
else
{}}
if(upload_image_first)
{uploader.UploadFile(function(upload_action_result){if(upload_action_result.success)
{action.SetCustomerProductImageFilename(uploader.GetUploadedFileName());action.Execute();}
else
{var product_was_not_added_to_cart_message=TemplateEngine.GetText("product_was_not_added_to_cart");var result_output=upload_action_result.result_output+" "+product_was_not_added_to_cart_message;ShowModalOverlay(null,result_output);}});}
else
{action.Execute();}};function AddBuyAlsoToCart()
{$(".js-buy-also-checkbox").each(function(){if($(this).attr("checked")=="checked")
{var product_id=$(this).attr("id").split("-")[2];var option_id=$(this).siblings("buy-also-option-container:first").find("input").val();AddToCart(product_id,1,option_id);}});}
$(function(){InitializeAddToCartFunctionality();$("body").on("click",".js-add-to-cart-trigger",function(event){event.preventDefault();var product_id=$(this).data("addtocart").product_id;if(product_id)
{var quantity=1;var quantity_field=$(".js-add-to-cart-quantity-"+product_id);if(quantity_field.length)
{var quantity_value=parseInt(quantity_field.val());if(quantity_value>0)
{quantity=quantity_value;}}
AddToCart(product_id,quantity);}
else
{var variation_id=$(this).data("addtocart").variation_id;var quantity=1;var quantity_field=$(".js-add-to-cart-quantity-"+variation_id);if(quantity_field.length)
{var quantity_value=parseInt(quantity_field.val());if(quantity_value>0)
{quantity=quantity_value;}}
AddToCart(variation_id,quantity);}
AddBuyAlsoToCart();});$("body").on("click",".js-add-product-option-to-cart-trigger",function(event){event.preventDefault();var product_id=$(this).data("add-option-tocart").product_id;var product_option_id=$(this).data("add-option-tocart").product_option_id;var quantity=1;var quantity_field=null;if(product_option_id===0)
{var option_group_id=$(this).data("add-option-tocart").option_group_id;if(option_group_id!=undefined)
{product_option_id=$(".product-option-group-"+option_group_id+" .product-option-select").val();quantity_field=$(".js-add-selected-product-option-to-cart-quantity-"+option_group_id);}}
else
{quantity_field=$(".js-add-product-option-to-cart-quantity-"+product_option_id);}
if(quantity_field!=null&&quantity_field.length)
{var quantity_value=parseInt(quantity_field.val());if(quantity_value>0)
{quantity=quantity_value;}}
AddToCart(product_id,quantity,product_option_id);});$("body").on("click",".js-tier-prices-add-to-cart-trigger",function(event){event.preventDefault();var product_id=$(this).data("tierprices").product_id;var quantity=$(this).data("tierprices").quantity;AddToCart(product_id,quantity);});$("body").on("click",".js-product-options-overlay-add-to-cart-trigger",function(event){event.preventDefault();var product_id=$(this).data("product_id");var quantity=$(this).data("quantity");AddToCart(product_id,quantity);});$("body").on("click",".buy-also-option-container",function(event){event.preventDefault();});$("body").on("click",".buy-also-container",function(event){event.preventDefault();var container=$(this);var input=container.find("input");if(input.attr("checked")=="checked")
{input.removeAttr("checked");}
else
{input.attr("checked","checked");}
container.html(container.html());});$("body").on("click",".js-sc-highlight-product",function(event){event.preventDefault();var product_id=$(this).attr("id").split("-")[2];AddToCart(product_id,1);});});;$(document).ready(function(){var form=$(document).find("form.accept-data-collecting");if(form.length>0)
{var ajax_url="/shop/accept_data_collecting_ajax.php";var data={"action":"get-gdpr-checkbox"};$.ajax({url:ajax_url,type:"POST",data:data,dataType:"json",success:function(data){var button=form.find("button");button.before(data.html);form.on("submit",function(){if(DataCollectingAccepted($(this))==false)
{return false;}});},error:function(){}});}});function DataCollectingAccepted(form_element)
{if(form_element.hasClass("accept-data-collecting"))
{var gdpr_checkbox=form_element.find(".accept-data-collecting-input");if(gdpr_checkbox.prop("checked")==false)
{gdpr_checkbox.parents(".accept-data-collecting-container").first().css("background","pink");return false;}}};$("body").on("click",".overlay-message",function(){$(this).remove();});$("body").on("click","#fading_overlay_wrapper",function(){$(".sc-preview-right").remove();});$("body").on("click",".sc-close-preview",function(){$(".sc-preview-right").remove();});function ShowModalOverlay(overlay_container,overlay_html,options)
{$.fancybox.open(overlay_html);}
function ShowFadingOverlay(overlay_html,delay)
{if($("#fading_overlay_wrapper").length==0)
{var fading_overlay_wrapper="<div id='fading_overlay_wrapper' class='noselect'></div>";$(fading_overlay_wrapper).appendTo("body").css({position:"fixed",width:"100%",top:"0px",left:"0px"});}
$(overlay_html).hide().appendTo("#fading_overlay_wrapper").fadeIn().delay(delay).slideUp().fadeOut(function(){$(this).remove();});};function FormHandler(template_function_data)
{TemplateFunction.call(this,template_function_data);if(this.HasFormElement())
{var $form=this.GetFormElement();$form.prop("action",template_function_data.action);$form.prop("method",template_function_data.method);var self=this;$form.submit(function(event){event.preventDefault();self.HandleFormSubmit();});}
else
{throw"FormHandler error: Form element is not found with id: "+template_function_data.id;}
if(this.HasResultElement())
{var $result_element=this.GetResultElement();template_function_data.result_element_original_classes=$result_element.prop("class");}
this.Bind("success",this.SlideUp);this.Bind("complete",function(data){this.SetResult(data.result_output,data.result_element_class);});}
Core.ExtendClass(TemplateFunction,FormHandler);FormHandler.prototype.HasFormElement=function()
{return(this.GetFormElement().length>0);};FormHandler.prototype.GetFormElement=function()
{var $form=$("#"+this.GetData("id"));return $form;};FormHandler.prototype.HasResultElement=function()
{return((this.HasData("result_element_id"))&&(this.GetResultElement().length>0));};FormHandler.prototype.GetResultElement=function()
{var $result_element=$("#"+this.GetData("result_element_id"));return $result_element;};FormHandler.prototype.SetResult=function(content,classes)
{if(content!=undefined)
{if(this.HasResultElement())
{var $result_element=this.GetResultElement();$result_element.html(content);$result_element.attr("class",this.GetData("result_element_original_classes"));if(this.HasData("result_element_basic_class"))
{$result_element.addClass(this.GetData("result_element_basic_class"));}
if(classes!=undefined)
{$result_element.addClass(classes);}}}};FormHandler.prototype.ClearResult=function(content,classes)
{if(this.HasResultElement())
{var $result_element=this.GetResultElement();$result_element.empty();$result_element.attr("class",this.GetData("result_element_original_classes"));}};FormHandler.prototype.GetText=function(key)
{return this.GetData("texts")[key];};FormHandler.prototype.HandleFormSubmit=function()
{if(DataCollectingAccepted(this.GetFormElement())==false)
{return false;}
var form_id=this.GetData("id");var form_type=this.GetData("type");var action=this.GetData("ajax_action");var form_fields={};this.GetFormElement().find(":input").each(function(){var input_field=this;var field_name=input_field.name;if(field_name)
{if(input_field.type=="radio"||input_field.type=="checkbox")
{if(!$(input_field).prop("checked"))
{return;}}
var field_value=$.trim($(input_field).val());form_fields[field_name]=field_value;}});var params={action:action,form_id:form_id,form_fields:form_fields};var before_submit_result=this.ApplyHandlers("beforeAction");if(before_submit_result===false)
{return false;}
var self=this;TemplateEngine.Ajax(params,function(action_result){if(action_result.redirect_url)
{window.location=action_result.redirect_url;}
self.ApplyHandlers("afterAction",action_result);if(action_result.success)
{self.ApplyHandlers("success",action_result);}
else
{self.ApplyHandlers("error",action_result);}
self.ApplyHandlers("complete",action_result);});};FormHandler.prototype.SetSuccessHandler=function(handler_function)
{this.Bind("success",handler_function,true);};FormHandler.prototype.SetErrorHandler=function(handler_function)
{this.Bind("error",handler_function,true);};FormHandler.prototype.SetCompleteHandler=function(handler_function)
{this.Bind("complete",handler_function,true);};FormHandler.prototype.SlideUp=function(data)
{this.GetFormElement().slideUp(300,function(){$(this).empty();});};function ProductImageUploader(template_function_data)
{FormHandler.call(this,template_function_data);this.Unbind("success");this.Init();};Core.ExtendClass(FormHandler,ProductImageUploader);ProductImageUploader.prototype.Init=function()
{var self=this;this.GetErrorActionResult=function(error_message)
{var action_result={"success":false,"result_output":error_message,"result_element_class":this.GetData("result_element_error_class")};return action_result;};var $form=this.GetFormElement();$form.addClass("dropzone");var action=this.GetData("action");var product_id=this.GetData("product_id");Dropzone.autoDiscover=false;var dropzone=new Dropzone($form.get(0),{url:action,autoProcessQueue:false,maxFilesize:this.GetData("max_filesize"),acceptedFiles:"image/*",maxFiles:1,init:function(){this.on("addedfile",function(file){if(this.files.length>1)
{this.removeFile(this.files[0]);}
self.ClearResult();delete self.current_uploaded_file_name;});},dictDefaultMessage:self.GetText("customer_product_image_dropzone_info"),dictInvalidFileType:self.GetText("customer_product_image_extension_not_supported"),dictFileTooBig:self.GetText("selected_file_too_big")});dropzone.on("sending",function(file,xhr,formData){formData.append("image_upload_ajax",true);formData.append("image_type","customer_product_image");formData.append("product_id",product_id);});this.UploadNotStartedError=function(error_message,file)
{if(typeof file!="undefined")
{this.dropzone.removeFile(file);}
var action_result=this.GetErrorActionResult(error_message);this.SetResult(action_result.result_output,action_result.result_element_class);};this.UploadActionDone=function(response,file)
{if(typeof response=="object")
{var action_result=response;}
else
{try
{var action_result=JSON.parse(response);if(typeof action_result.success=="undefined")
{throw"Unknown error";}}
catch(error)
{var message=this.GetText("customer_product_image_upload_failed");var action_result=this.GetErrorActionResult(message);}}
if(typeof action_result.result_element_class=="undefined")
{action_result.result_element_class=(action_result.success?this.GetData("result_element_success_class"):this.GetData("result_element_error_class"));}
this.ApplyHandlers("afterAction",action_result);if(action_result.success)
{if(action_result.image_filename)
{this.current_uploaded_file_name=action_result.image_filename;}
this.ApplyHandlers("success",action_result);}
else
{if(typeof file!="undefined")
{this.dropzone.removeFile(file);}
this.ApplyHandlers("error",action_result);}
this.ApplyHandlers("complete",action_result);this.ApplyHandlers("afterUpload.once",action_result);};dropzone.on("success",function(file,response,e){self.UploadActionDone(response,file);});dropzone.on("error",function(file,error_response,xhr){if(typeof xhr=="object")
{self.UploadActionDone(error_response,file);}
else
{if(file.accepted!==true)
{var error_message=error_response;}
else
{var error_message=self.GetText("customer_product_image_upload_failed");}
self.UploadNotStartedError(error_message,file);}});this.dropzone=dropzone;ProductImageUploader.SetInstanceForProduct(product_id,this);};ProductImageUploader.prototype.IsFileSelected=function()
{return(this.dropzone.getAcceptedFiles().length>0);};ProductImageUploader.prototype.IsFileUploaded=function()
{return(typeof this.current_uploaded_file_name!="undefined");};ProductImageUploader.prototype.GetUploadedFileName=function()
{return this.current_uploaded_file_name;};ProductImageUploader.prototype.UploadFile=function(callback_function)
{var before_submit_result=this.ApplyHandlers("beforeAction");if(before_submit_result===false)
{var error_message=this.GetLastError();this.UploadNotStartedError(error_message);return false;}
this.Bind("afterUpload.once",callback_function);this.dropzone.processQueue();};ProductImageUploader.prototype.HandleFormSubmit=function()
{};ProductImageUploader.SetInstanceForProduct=function(product_id,uploader)
{if(typeof this.instances=="undefined")
{this.instances={};}
this.instances[product_id]=uploader;};ProductImageUploader.GetInstanceForProduct=function(product_id)
{if(typeof this.instances=="undefined")
{return false;}
return this.instances[product_id];};;function ProductListPagination(template_function_data)
{TemplateFunction.call(this,template_function_data);if(this.CheckRequirements())
{this.Bind("ready",function(){this.Init();});}
else
{this.InitPageLinks();}
this.InitPageMetadata();};Core.ExtendClass(TemplateFunction,ProductListPagination);ProductListPagination.prototype.CheckRequirements=function()
{return((this.GetTotalPageCount()>1)&&this.HasPaginationWrapper());};ProductListPagination.prototype.HasPaginationWrapper=function()
{return((this.GetData("pagination_wrapper_element_selector")!=undefined)&&(this.GetPaginationWrapper().length>0));};ProductListPagination.prototype.GetPaginationWrapper=function()
{return $(this.GetData("pagination_wrapper_element_selector"));};ProductListPagination.prototype.InitLoadNextPageTrigger=function()
{if(this.GetData("next_page_link")!=undefined)
{if(this.next_page_link==undefined)
{this.next_page_link=$(this.GetData("next_page_link"));}
var page_number=this.highest_page_number+1;if(page_number>this.GetTotalPageCount())
{this.next_page_link.fadeOut();return false;}
var link_added=($("body").find(this.next_page_link).length>0);if(!link_added)
{this.GetPaginationWrapper().after(this.next_page_link);var self=this;this.next_page_link.on("click",function(e){e.preventDefault();self.LoadNextPage();});}
this.next_page_link.attr("href",this.GetPageHref(page_number));this.next_page_link.show();}};ProductListPagination.prototype.GetLoadNextPageTrigger=function()
{return this.next_page_link;};ProductListPagination.prototype.HasLoadNextPageTrigger=function()
{return((this.next_page_link!=undefined)&&(this.next_page_link.length>0));};ProductListPagination.prototype.UpdateLoadNextPageTrigger=function()
{if(this.HasLoadNextPageTrigger())
{var $trigger=this.GetLoadNextPageTrigger();if($trigger.length>0)
{var page_number=this.highest_page_number+1;if(page_number>this.GetTotalPageCount())
{$trigger.fadeOut();return false;}
$trigger.attr("href",this.GetNextPageHref());}}};ProductListPagination.prototype.InitLoadPreviousPageTrigger=function()
{if(this.GetData("previous_page_link")!=undefined)
{if(this.previous_page_link==undefined)
{this.previous_page_link=$(this.GetData("previous_page_link"));}
var page_number=this.lowest_page_number-1;if(page_number<1)
{this.previous_page_link.fadeOut();return false;}
var link_added=($("body").find(this.previous_page_link).length>0);if(!link_added)
{this.GetPaginationWrapper().before(this.previous_page_link);var self=this;this.previous_page_link.on("click",function(e){e.preventDefault();self.LoadPreviousPage();});}
this.previous_page_link.attr("href",this.GetPageHref(page_number));this.previous_page_link.show();}};ProductListPagination.prototype.GetLoadPreviousPageTrigger=function()
{return this.previous_page_link;};ProductListPagination.prototype.HasLoadPreviousPageTrigger=function()
{return((this.previous_page_link!=undefined)&&(this.next_page_link.length>0));};ProductListPagination.prototype.UpdateLoadPreviousPageTrigger=function()
{if(this.HasLoadPreviousPageTrigger())
{var $trigger=this.GetLoadPreviousPageTrigger();if($trigger.length>0)
{var page_number=this.lowest_page_number-1;if(page_number<1)
{$trigger.fadeOut();return false;}
$trigger.attr("href",this.GetPreviousPageHref());}}};ProductListPagination.prototype.SetVisiblePageListener=function($new_elements,page_number)
{var self=this;var middle_element_index=Math.floor($new_elements.length/2);var $middle_element=$new_elements.eq(middle_element_index);$middle_element.data("page_number",page_number);$middle_element.waypoint({offset:"50%",handler:function(direction){self.SetCurrentPageNumber(page_number);}});};ProductListPagination.prototype.SetPageLoadingStatus=function(direction)
{var loading_class=this.GetData("page_loading_class");var direction_loading_class=loading_class+"-"+direction;if(direction=="next")
{if(this.HasLoadNextPageTrigger())
{var $trigger=this.GetLoadNextPageTrigger();}}
else
{if(this.HasLoadPreviousPageTrigger())
{var $trigger=this.GetLoadPreviousPageTrigger();}}
var trigger_exists=(typeof $trigger=="object");if(this.IsLoading())
{this.GetPaginationWrapper().addClass(loading_class).addClass(direction_loading_class);if(trigger_exists)
{$trigger.addClass(loading_class);}}
else
{this.GetPaginationWrapper().removeClass(loading_class).removeClass(direction_loading_class);if(trigger_exists)
{$trigger.removeClass(loading_class);}}};ProductListPagination.prototype.GetPageHref=function(page_number)
{var href=this.GetData("page_link_href_template").replace("{page_number}",page_number);return href;};ProductListPagination.prototype.GetNextPageHref=function()
{var next_page_number=this.highest_page_number+1;return this.GetPageHref(next_page_number);};ProductListPagination.prototype.GetPreviousPageHref=function()
{var previous_page_number=this.lowest_page_number-1;return this.GetPageHref(previous_page_number);};ProductListPagination.prototype.UpdateCurrentUrl=function(page_number)
{var new_url=this.GetPageHref(page_number);if(typeof window.history.replaceState=="function")
{window.history.replaceState(null,null,new_url);}};ProductListPagination.prototype.SetCurrentPageNumber=function(page_number)
{if(page_number!=this.GetCurrentPageNumber())
{this.SetData("current_page_number",page_number);this.SelectPageLink(page_number);this.UpdateCurrentUrl(page_number);}};ProductListPagination.prototype.GetCurrentPageNumber=function()
{return parseInt(this.GetData("current_page_number"));};ProductListPagination.prototype.GetFirstPageNumber=function()
{return this.lowest_page_number;};ProductListPagination.prototype.GetLastPageNumber=function()
{return this.highest_page_number;};ProductListPagination.prototype.GetTotalPageCount=function()
{return parseInt(this.GetData("page_count"));};ProductListPagination.prototype.GetProductsPerPage=function()
{return parseInt(this.GetData("products_per_page"));};ProductListPagination.prototype.IsLoading=function()
{return this.is_loading;};ProductListPagination.prototype.LoadNextPage=function()
{this.LoadPage("next");};ProductListPagination.prototype.LoadPreviousPage=function()
{this.LoadPage("previous");};ProductListPagination.prototype.LoadPage=function(direction)
{if(this.IsLoading())
{return;}
if(direction=="previous")
{page_number=this.lowest_page_number-1;}
else
{page_number=this.highest_page_number+1;}
if((page_number<1)||(page_number>this.GetTotalPageCount()))
{return false;}
var params={action:"PaginateProductList",product_list_name:this.GetData("product_list_name"),page_number:page_number};this.ApplyHandlers("beforeAction");this.is_loading=true;this.SetPageLoadingStatus(direction);var self=this;TemplateEngine.Ajax(params,function(data){self.ApplyHandlers("afterAction",data);if(data.success)
{if(data.products_rendered_count>0)
{var $new_elements=null;var $product_list_output=$(data.product_list_output);if($product_list_output.is(self.GetData("pagination_wrapper_element_selector")))
{$new_elements=$product_list_output.children();}
else
{$product_list_output=$product_list_output.find(self.GetData("pagination_wrapper_element_selector"));if($product_list_output.length>0)
{$new_elements=$product_list_output.children();}
else
{$new_elements=$product_list_output;}}
self.SetCurrentPageNumber(page_number);self.SetVisiblePageListener($new_elements,page_number);if(direction=="previous")
{self.GetPaginationWrapper().prepend($new_elements);self.lowest_page_number-=1;self.UpdateLoadPreviousPageTrigger();}
else
{self.GetPaginationWrapper().append($new_elements);self.highest_page_number+=1;self.UpdateLoadNextPageTrigger();}
InitializeAddToCartFunctionality();InitProductListSecondImages();Waypoint.refreshAll();}}
else
{}
self.is_loading=false;self.SetPageLoadingStatus(direction);self.ApplyHandlers("complete",data);});};ProductListPagination.prototype.CreateDividerElement=function()
{var divider_class=this.GetData("link_divider_class");var $divider_element=$(this.GetData("link_divider"));$divider_element.addClass(divider_class);return $divider_element;};ProductListPagination.prototype.ClearDividerElements=function()
{var divider_class=this.GetData("link_divider_class");this.GetPageLinks().siblings("."+divider_class).remove();};ProductListPagination.prototype.GetPageLinks=function()
{return $(this.GetData("pagination_link_selector"));};ProductListPagination.prototype.SelectPageLink=function(page_number)
{var $pagination_links=this.GetPageLinks();var show_near_count=parseInt(this.GetData("show_near_count"));var visible_class=this.GetData("visible_class");var hidden_class=this.GetData("hidden_class");var selected_class=this.GetData("selected_class");var selected_index=(page_number-1);var last_index=($pagination_links.length-1);$pagination_links.removeClass(visible_class).removeClass(hidden_class).removeClass(selected_class);this.ClearDividerElements();$pagination_links.each(function(index){var is_first=(index==0);var is_last=(index==last_index);var is_selected=(index==selected_index);var is_close_to_selected_left=((index>=(selected_index-show_near_count))&&(index<selected_index));var is_close_to_selected_right=((index<=(selected_index+show_near_count))&&(index>selected_index));if(is_first||is_last||is_selected||is_close_to_selected_left||is_close_to_selected_right)
{$(this).addClass(visible_class);}
else
{$(this).addClass(hidden_class);}
if(is_selected)
{$(this).addClass(selected_class);}});var $selected_link=$pagination_links.filter("."+selected_class);var $hidden_before_selected=$selected_link.prevAll("."+hidden_class);var $hidden_after_selected=$selected_link.nextAll("."+hidden_class);if($hidden_before_selected.length>0)
{$hidden_before_selected.first().after(this.CreateDividerElement());}
if($hidden_after_selected.length>0)
{$hidden_after_selected.last().before(this.CreateDividerElement());}};ProductListPagination.prototype.Init=function()
{this.is_loading=false;var initial_page_number=parseInt(this.GetData("initial_page_number"));this.highest_page_number=initial_page_number;this.lowest_page_number=initial_page_number;if(this.GetData("autoload"))
{this.InitAutoload();}
this.InitPageLinks();this.InitLoadNextPageTrigger();this.InitLoadPreviousPageTrigger();var $elements_on_page=this.GetPaginationWrapper().children();this.SetVisiblePageListener($elements_on_page,initial_page_number);};ProductListPagination.prototype.Reset=function()
{if(!this.CheckRequirements())
{return false;}
if(this.GetData("autoload"))
{this.InitAutoload();}
var $elements=this.GetPaginationWrapper().children();var products_per_page=this.GetProductsPerPage();var start_index=0;var end_index=products_per_page;for(var page_number=this.lowest_page_number;page_number<=this.highest_page_number;page_number++)
{var $elements_on_page=$elements.slice(start_index,end_index);this.SetVisiblePageListener($elements_on_page,page_number);start_index+=products_per_page;end_index+=products_per_page;}};ProductListPagination.prototype.InitPageMetadata=function()
{var current_page_number=this.GetCurrentPageNumber();var total_page_count=this.GetTotalPageCount();if(total_page_count>1)
{var $meta_prev_link=$("head").children("[rel='prev']");if(current_page_number>1)
{if(!$meta_prev_link.length)
{$meta_prev_link=$("<link>").attr("rel","prev").appendTo("head");}
var prev_link_href=this.GetPageHref(current_page_number-1);$meta_prev_link.attr("href",prev_link_href);}
else
{$meta_prev_link.remove();}
var $meta_next_link=$("head").children("[rel='next']");if(current_page_number<total_page_count)
{if(!$meta_next_link.length)
{$meta_next_link=$("<link>").attr("rel","next").appendTo("head");}
var next_link_href=this.GetPageHref(current_page_number+1);$meta_next_link.attr("href",next_link_href);}
else
{$meta_next_link.remove();}}};ProductListPagination.prototype.InitAutoload=function()
{var self=this;if(this.HasData("autoload_distance"))
{this.SetData("autoload_distance",parseInt(this.GetData("autoload_distance")));}
else
{this.SetData("autoload_distance",0);}
if(this.waypoint_elements!=undefined)
{this.waypoint_elements.down.waypoint('destroy');this.waypoint_elements.up.waypoint('destroy');}
$(document).ready(function(){this.waypoint_elements={};this.waypoint_elements.down=new Waypoint({element:document.getElementsByClassName('product-list'),handler:function(direction){if(direction=="down")
{self.LoadNextPage();}},offset:'bottom-in-view'});this.waypoint_elements.up=new Waypoint({element:document.getElementsByClassName('product-list'),handler:function(direction){if(direction=="up")
{self.LoadPreviousPage();}},offset:self.GetData("autoload_distance")});});};ProductListPagination.prototype.InitPageLinks=function()
{var self=this;var current_page_number=this.GetCurrentPageNumber();var $pagination_links=this.GetPageLinks();$pagination_links.each(function(index){var page_number=(index+1);$(this).data("page_number",page_number);$(this).attr("href",self.GetPageHref(page_number));if(page_number==current_page_number)
{self.SelectPageLink(page_number);}});};;function ProductListUpdater(template_function_data)
{TemplateFunction.call(this,template_function_data);if(this.CheckRequirements())
{this.Init();}};Core.ExtendClass(TemplateFunction,ProductListUpdater);ProductListUpdater.prototype.CheckRequirements=function()
{if(!this.HasUpdaterWrapper()&&!this.GetData("filters_in_use"))
{return false;}
return true;};ProductListUpdater.prototype.HasUpdaterWrapper=function()
{return((this.GetData("updater_wrapper_element_selector")!=undefined)&&(this.GetUpdaterWrapper().length>0));};ProductListUpdater.prototype.GetUpdaterWrapper=function()
{return $(this.GetData("updater_wrapper_element_selector"));};ProductListUpdater.prototype.Update=function($trigger){var data=$trigger.data("productlistupdater");var trigger_name=data.name;var trigger_data=this.GetData("triggers")[trigger_name];var trigger_class=trigger_data.trigger_class;var selected_trigger_class=trigger_data.selected_trigger_class;if($trigger.hasClass(selected_trigger_class))
{return false;}
var product_list_name=data.product_list_name;var product_list_parameters=data.parameters;var params={action:"UpdateProductList",product_list_name:product_list_name,product_list_parameters:product_list_parameters};var product_list_pagination=TemplateEngine.GetTemplateFunctionByName("ProductListPagination");if(typeof product_list_pagination=="object")
{params.use_pagination=true;params.first_page=product_list_pagination.GetFirstPageNumber();params.last_page=product_list_pagination.GetLastPageNumber();}
this.ApplyHandlers("beforeAction");var self=this;TemplateEngine.Ajax(params,function(data){self.ApplyHandlers("afterAction",data);if(data.success)
{var new_content_html="";var $product_list_output=$(data.product_list_output);if($product_list_output.is(self.GetData("updater_wrapper_element_selector")))
{new_content_html=$product_list_output.html();}
else
{$product_list_output=$product_list_output.find(self.GetData("updater_wrapper_element_selector"));if($product_list_output.length>0)
{new_content_html=$product_list_output.html();}
else
{new_content_html=data.product_list_output;}}
self.GetUpdaterWrapper().html(new_content_html);InitializeAddToCartFunctionality();InitProductListSecondImages();$("."+trigger_class).removeClass(selected_trigger_class);$trigger.addClass(selected_trigger_class);var product_list_pagination=TemplateEngine.GetTemplateFunctionByName("ProductListPagination");if(typeof product_list_pagination=="object")
{product_list_pagination.Reset();}}
else
{}
self.ApplyHandlers("complete",data);});};ProductListUpdater.prototype.UpdateFilters=function(filter_data){var data=filter_data.trigger.data("productlistupdater");var trigger_name=data.name;var trigger_data=this.GetData("triggers")[trigger_name];var trigger_class=trigger_data.trigger_class;var selected_trigger_class=trigger_data.selected_trigger_class;var product_list_name=data.product_list_name;var product_list_parameters={filters:filter_data.filters,filter_id:filter_data.filter_id};var params={action:"UpdateProductList",product_list_name:product_list_name,product_list_parameters:product_list_parameters};var product_list_pagination=TemplateEngine.GetTemplateFunctionByName("ProductListPagination");if(typeof product_list_pagination=="object")
{params.use_pagination=true;params.first_page=product_list_pagination.GetFirstPageNumber();params.last_page=product_list_pagination.GetLastPageNumber();}
this.ApplyHandlers("beforeAction");var self=this;TemplateEngine.Ajax(params,function(data){self.ApplyHandlers("afterAction",data);if(data.success)
{if(!$(".product-list").length)
{location.reload();}
var new_content_html="";var $product_list_output=$(data.product_list_output);if($product_list_output.is(self.GetData("updater_wrapper_element_selector")))
{new_content_html=$product_list_output.html();}
else
{$product_list_output=$product_list_output.find(self.GetData("updater_wrapper_element_selector"));if($product_list_output.length>0)
{new_content_html=$product_list_output.html();}
else
{new_content_html=data.product_list_output;}}
self.GetUpdaterWrapper().html(new_content_html);InitializeAddToCartFunctionality();var product_list_pagination=TemplateEngine.GetTemplateFunctionByName("ProductListPagination");if(typeof product_list_pagination=="object")
{product_list_pagination.Reset();}}
else
{}
self.ApplyHandlers("complete",data);});};ProductListUpdater.prototype.Init=function()
{var self=this;$("[data-productlistupdater]").each(function(){var data=$(this).data("productlistupdater");if(data.class)
{$(this).addClass(data.class);}
if($(this).is("a"))
{$(this).click(function(event){event.preventDefault();var $trigger=$(this);self.Update($trigger);});}
else if($(this).is("option"))
{if(data.selected)
{$(this).prop("selected",true);}
var select=$(this).parents("select").first();if(select.data("product-list-updater-select-trigger")!==true)
{select.data("product-list-updater-select-trigger",true);select.change(function(event){event.preventDefault();var $trigger=$(this).find("option:selected");self.Update($trigger);});}}
else if($(this).is("button"))
{$(this).click(function(event){event.preventDefault();var $trigger=$(this);var filters=data.parameters.filters;var selected_filters={};var select_all_filters=$(this).hasClass("js-select-all-filters");var empty_all_filters=$(this).hasClass("js-empty-all-filters");if(select_all_filters)
{$.each(filters,function(key,value){var filter=[];var select_filters_class=".js-checkbox-select-"+value;var slider_filter_class=".js-slider-"+value;var is_button_desktop=$trigger.parents('.hide-mobile').length;var is_slider_desktop=$(slider_filter_class).parents('.hide-mobile').length;if($(select_filters_class).length>0)
{$(select_filters_class).each(function(){var is_filter_desktop=$(this).parents('.hide-mobile').length;if(this.checked&&is_button_desktop==is_filter_desktop){filter.push($(this).val());}});selected_filters_count=filter.length;$(".selected-count-"+value).html("("+selected_filters_count+")");}
else if($(slider_filter_class).length>0)
{var slider_min=$(slider_filter_class).find(".noUi-handle-lower").attr("aria-valuemin");var slider_min_now=$(slider_filter_class).find(".noUi-handle-lower").attr("aria-valuenow");var slider_max=$(slider_filter_class).find(".noUi-handle-upper").attr("aria-valuemax");var slider_max_now=$(slider_filter_class).find(".noUi-handle-upper").attr("aria-valuenow");if(slider_min!=slider_min_now||slider_max!=slider_max_now)
{var filters_values={"min":slider_min_now,"max":slider_max_now};filter.push(filters_values);}}
selected_filters[value]=filter;});}
else if(empty_all_filters)
{selected_filters=[];$.each(filters,function(key,value){$(".selected-count-"+value).html("");var select_filters_class=".js-checkbox-select-"+value;var slider_filter_class=".js-slider-"+value;if($(select_filters_class).length>0)
{$(select_filters_class).prop('checked',false);}
else if($(slider_filter_class).length>0)
{var slider_min=$(slider_filter_class).find(".noUi-handle-lower").attr("aria-valuemin");var slider_max=$(slider_filter_class).find(".noUi-handle-upper").attr("aria-valuemax");$(slider_filter_class).each(function(){$(this)[0].noUiSlider.set([Math.round(slider_min),Math.round(slider_max)]);});}});var category_id=$(".js-select-all-filters").data("productlistupdater").category;var params={action:"UpdateSearchButton",selected_filters:selected_filters,category_id:category_id};TemplateEngine.Ajax(params,function(data){if(data.success)
{$(".js-product-count").html(data.product_count);}});}
else
{var filter_id=$(this).data("id");var select_filters_class=".js-checkbox-select-"+filter_id;var slider_filter_class=".js-slider-"+filter_id;var filter=[];if($(select_filters_class).length>0)
{$(select_filters_class).each(function(){if(this.checked){filter.push($(this).val());}});}
else if($(slider_filter_class).length>0)
{var slider_min=$(slider_filter_class).find(".noUi-handle-lower").attr("aria-valuenow");var slider_max=$(slider_filter_class).find(".noUi-handle-upper").attr("aria-valuenow");var filters_values={"min":slider_min,"max":slider_max};filter.push(filters_values);}
selected_filters[filter_id]=filter;}
$(".js-product-count").html("");var update_data={"trigger":$trigger,"filters":selected_filters,"filter_id":filter_id};self.UpdateFilters(update_data);$('.filters-mobile').addClass('hidden');if($('html').hasClass('has-overlay'))
{$('html').removeClass('has-overlay');}});}
$(this).removeAttr("data-productlistupdater");});$(".category-search-filters-select-dropdown .js-checkbox-select").each(function(){$(this).change(function(event){event.preventDefault();var $trigger=$(this);var category_id=$(".js-select-all-filters").data("productlistupdater").category;var filters=$(".js-select-all-filters").data("productlistupdater").parameters.filters;var selected_filters={};$.each(filters,function(key,value){var filter=[];var select_filters_class=".js-checkbox-select-"+value;var slider_filter_class=".js-slider-"+value;var is_button_desktop=$trigger.parents('.hide-mobile').length;var is_slider_desktop=$(slider_filter_class).parents('.hide-mobile').length;if($(select_filters_class).length>0)
{$(select_filters_class).each(function(){if(this.checked){filter.push($(this).val());}});}
else if($(slider_filter_class).length>0)
{var slider_min=$(slider_filter_class).find(".noUi-handle-lower").attr("aria-valuemin");var slider_min_now=$(slider_filter_class).find(".noUi-handle-lower").attr("aria-valuenow");var slider_max=$(slider_filter_class).find(".noUi-handle-upper").attr("aria-valuemax");var slider_max_now=$(slider_filter_class).find(".noUi-handle-upper").attr("aria-valuenow");if(slider_min!=slider_min_now||slider_max!=slider_max_now)
{var filters_values={"min":slider_min_now,"max":slider_max_now};filter.push(filters_values);}}
selected_filters[value]=filter;});var params={action:"UpdateSearchButton",selected_filters:selected_filters,category_id:category_id};TemplateEngine.Ajax(params,function(data){if(data.success)
{$(".js-product-count").html(data.product_count);}});});});$(".js-slider").each(function(){$(this).mouseup(function(event){event.preventDefault();var $trigger=$(this);var category_id=$(".js-select-all-filters").data("productlistupdater").category;var filters=$(".js-select-all-filters").data("productlistupdater").parameters.filters;var selected_filters={};$.each(filters,function(key,value){var filter=[];var select_filters_class=".js-checkbox-select-"+value;var slider_filter_class=".js-slider-"+value;var is_button_desktop=$trigger.parents('.hide-mobile').length;var is_slider_desktop=$(slider_filter_class).parents('.hide-mobile').length;if($(select_filters_class).length>0)
{$(select_filters_class).each(function(){if(this.checked){filter.push($(this).val());}});}
else if($(slider_filter_class).length>0)
{var slider_min=$(slider_filter_class).find(".noUi-handle-lower").attr("aria-valuemin");var slider_min_now=$(slider_filter_class).find(".noUi-handle-lower").attr("aria-valuenow");var slider_max=$(slider_filter_class).find(".noUi-handle-upper").attr("aria-valuemax");var slider_max_now=$(slider_filter_class).find(".noUi-handle-upper").attr("aria-valuenow");if(slider_min!=slider_min_now||slider_max!=slider_max_now)
{var filters_values={"min":slider_min_now,"max":slider_max_now};filter.push(filters_values);}}
selected_filters[value]=filter;});var params={action:"UpdateSearchButton",selected_filters:selected_filters,category_id:category_id};TemplateEngine.Ajax(params,function(data){if(data.success)
{$(".js-product-count").html(data.product_count);}});});});};;function ShoppingCartPreview(template_function_data)
{TemplateFunction.call(this,template_function_data);if(this.CheckRequirements())
{this.Init();}};Core.ExtendClass(TemplateFunction,ShoppingCartPreview);ShoppingCartPreview.prototype.CheckRequirements=function()
{if(!this.HasWrapper())
{throw"ShoppingCartPreview error: Wrapper element missing";}
return true;};ShoppingCartPreview.prototype.HasWrapper=function()
{return((this.GetData("wrapper_element_selector")!=undefined)&&(this.GetWrapper().length>0));};ShoppingCartPreview.prototype.GetWrapper=function()
{return $(this.GetData("wrapper_element_selector"));};ShoppingCartPreview.prototype.Init=function()
{};ShoppingCartPreview.prototype.Update=function()
{var $shopping_cart_preview_wrapper=this.GetWrapper();if(!$shopping_cart_preview_wrapper.length)
{return false;}
var params={action:"UpdateShoppingCartPreview",preview_id:this.GetData("preview_id")};this.ApplyHandlers("beforeAction");var self=this;TemplateEngine.Ajax(params,function(data){self.ApplyHandlers("afterAction",data);if(data.success)
{$new_shopping_cart_preview_wrapper=$(data.shopping_cart_preview_html);$shopping_cart_preview_wrapper.html($new_shopping_cart_preview_wrapper.html());}
else
{}
self.ApplyHandlers("complete",data);});};;(function($){$.fn.overlay=function(params){var foo=$.fancybox(this);if(params.close)
{$('body').on('click',params.close,function(){$.fancybox.close()});}
return $.fancybox;}}(jQuery));$(document).ready(function(){$(".delete_periodic_order").click(function(){var row=$(this).closest(".js-periodic-order-row");var id=row.attr("id");var params={action:"delete_periodic_order",periodic_order_id:id};$.post(AJAX_URL+"/user_account_ajax.php",params,function(data){if(data=="ok")
{row.fadeOut(function(){$(this).remove();});}});return false;});$('body').on('click',"#new_address",function(e){var new_address_overlay_id="#add_new_customer_address";var new_address_overlay=$(new_address_overlay_id);$(this).blur();CreateAddressOverlay(new_address_overlay_id,null);return false;});$("#save_details").click(function(){var first_name_elem=$("input[name='first_name']");var last_name_elem=$("input[name='last_name']");var ret=true;if(!first_name_elem.val()){first_name_elem.parent().children(".required").show();ret=false;}
else{first_name_elem.parent().children(".required").hide();}
if(!last_name_elem.val()){last_name_elem.parent().children(".required").show();ret=false;}
else{last_name_elem.parent().children(".required").hide();}
return ret;});$("#save_password").click(function(){var old_password_elem=$("input[name='old_password']");var password_elem=$("input[name='password']");var password_again_elem=$("input[name='password_again']");var ret=true;if(!old_password_elem.val()){old_password_elem.parent().children(".required").show();ret=false;}
else{old_password_elem.parent().children(".required").hide();}
if(!password_elem.val()){password_elem.parent().children(".required").show();ret=false;}
else{password_elem.parent().children(".required").hide();}
if(!password_again_elem.val()){password_again_elem.parent().children(".required").show();ret=false;}
else{password_again_elem.parent().children(".required").hide();}
return ret;});$('body').on('click',".edit_address",function(e){var new_address_overlay_id="#add_new_customer_address";var new_address_overlay=$(new_address_overlay_id);var address_id=($(this).parents(".js-address-row").attr("id"))?$(this).parents(".js-address-row").attr("id"):null;$(this).blur();CreateAddressOverlay(new_address_overlay_id,address_id);return false;});$('body').on("click",".delete_address",function(e){e.preventDefault();var address_id=($(this).parents(".js-address-row").attr("id"))?$(this).parents(".js-address-row").attr("id"):null;$.post(AJAX_URL+"/user_account_ajax.php",{action:"delete_address",address_id:address_id},function(data){window.location=window.location;});});$('body').on("click",".delete_cart",function(e){e.preventDefault();var cart_id=($(this).parents(".js-cart-row").attr("id"))?$(this).parents(".js-cart-row").attr("id"):null;$.post(AJAX_URL+"/user_account_ajax.php",{action:"delete_cart",cart_id:cart_id},function(data){window.location=window.location;});});$('body').on("click","#send_return_form",function(e){var first_name_elem=$("input[name='bill_first_name']");var last_name_elem=$("input[name='bill_last_name']");var street_address_elem=$("input[name='bill_street_address']");var postcode_elem=$("input[name='bill_postcode']");var city_elem=$("input[name='bill_city']");var country_elem=$("input[name='bill_country']");var ret=true;if(!first_name_elem.val()){first_name_elem.parent().children(".required").show();ret=false;}
else{first_name_elem.parent().children(".required").hide();}
if(!last_name_elem.val()){last_name_elem.parent().children(".required").show();ret=false;}
else{last_name_elem.parent().children(".required").hide();}
if(!street_address_elem.val()){street_address_elem.parent().children(".required").show();ret=false;}
else{street_address_elem.parent().children(".required").hide();}
if(!postcode_elem.val()){postcode_elem.parent().children(".required").show();ret=false;}
else{postcode_elem.parent().children(".required").hide();}
if(!city_elem.val()){city_elem.parent().children(".required").show();ret=false;}
else{city_elem.parent().children(".required").hide();}
if(!country_elem.val()){country_elem.parent().children(".required").show();ret=false;}
else{country_elem.parent().children(".required").hide();}
return ret;});$("body").ajaxStop(function(){$(".ajax_loader").fadeOut(function(){$(this).data("trigger").attr("disabled",false);$(this).remove();});});$(".return_form_quantity").keyup(function(){CheckReturnFormQuantity($(this));});$(".return_form_quantity").change(function(){CheckReturnFormQuantity($(this));});});$("#save_email_div").hide();$("#change_email_div_1").hide();$("#change_email_div_2").hide();$("#user_account_error_span").hide();$("#user_account_success_span").hide();$("#user_account_error_div").hide();$("#user_account_success_div").hide();$("#change_email_button").click(function(){$("#change_email_button").hide();$("#print_email_div").hide();$("#save_email_div").show();$("#change_email_div_1").show();$("#change_email_div_2").show();});$("#save_email_button").click(function(){var message="";if($("#change_email_input_1").val()!=$("#change_email_input_2").val()||$("#change_email_input_1").val()=="")
{message=NON_MATCHING_EMAILS;$("#user_account_error_span").text(message);$("#user_account_error_div").show();$("#user_account_error_span").show();$("#user_account_success_div").hide();$("#user_account_success_span").hide();}
else
{SaveNewEmail();}});function CheckReturnFormQuantity(elem){var given_count=parseInt(elem.val(),10);var max_count=parseInt(elem.parent().siblings(".product_quantity").text(),10);elem.val(given_count);if(given_count<0||given_count%1!=0){elem.val(0);}
else if(given_count>max_count){elem.val(max_count);}
else if(given_count[0]=="0"){elem.val(0);}}
function CreateAddressOverlay(new_address_overlay_id,address_id)
{var params={action:'get_new_address_overlay',new_address_overlay_id:new_address_overlay_id.substring(1),address_id:address_id};$.post(AJAX_URL+"/user_account_ajax.php",params,function(data){$('#address_overlay_container').remove();$.fancybox.open($("<div id = '#address_overlay_container'>"+data+"</div>"));$(new_address_overlay_id).data("address_id",address_id);$(new_address_overlay_id).addClass('address-overlay-container');$(new_address_overlay_id+" .customer_fields :text").keypress(function(e){if(e.keyCode==13)
{$(new_address_overlay_id+" .address_save:enabled").click();}});var delivery_areas=$(new_address_overlay_id+" .delivery_areas");$(new_address_overlay_id).on('click',".address_save",function(e){$(new_address_overlay_id+" .customer_fields .error").empty();$(new_address_overlay_id+" .customer_fields input").val(function(){return $.trim(this.value);});var delivery_area_id=GetSelectedDeliveryArea(delivery_areas);var params={action:'save_address',delivery_area_id:delivery_area_id};var form=$(new_address_overlay_id).find("form");form.ajaxSubmit({type:"post",dataType:"json",url:AJAX_URL+"/user_account_ajax.php",data:params,success:function(data){var customer_errors=data.customer_errors;if($.isEmptyObject(customer_errors))
{$.fancybox.close();window.location=window.location;}
else
{$('.address-overlay-container .alert').remove();$('.address_save').before('<div class="alert alert-error">'+USER_FIELD_MISSING+'</div>');}}});});});}
function ShowAjaxLoader(element,side)
{var loader_html="<span class='ajax_loader'></span>";var loader=$(loader_html).data("trigger",element);element.attr("disabled",true);if(!side||side=="after")
{element.after(loader);}
else if(side=="before")
{element.before(loader);}
return loader;}
function GetSelectedDeliveryArea(delivery_areas_container)
{if($(delivery_areas_container).hasClass("delivery_areas"))
{var delivery_area=delivery_areas_container.find("input:checked:last");if(delivery_area.length)
{var da=delivery_area.attr("id").substring(4);}}
if(/\d+/.test(da))
{return da;}
else if($("#default_delivery_area").length)
{return $("#default_delivery_area").val();}
else
{return-10;}}
function SaveNewEmail(){var message="";var change_email_input_1=$("#change_email_input_1").val();var change_email_input_2=$("#change_email_input_2").val();var ajax_path=AJAX_URL+"/user_account_ajax.php";$.post(ajax_path,{change_email_input_1:change_email_input_1,change_email_input_2:change_email_input_2,action:"save_new_email"},function(data){var data_obj=jQuery.parseJSON(data);if(data_obj.success)
{message=CHANGING_EMAIL_SUCCESS;$("#user_account_success_span").text(message);$("#user_account_success_div").show();$("#user_account_success_span").show();$("#user_account_error_div").hide();$("#user_account_error_span").hide();}
else if(data_obj.email=="duplicate")
{message=EXISTING_EMAIL;$("#user_account_error_span").text(message);$("#user_account_error_div").show();$("#user_account_error_span").show();$("#user_account_success_div").hide();$("#user_account_success_span").hide();}
else
{message=EMAIL_GHANGE_NOT_SUCCESFUL;$("#user_account_error_span").text(message);$("#user_account_error_div").show();$("#user_account_error_span").show();$("#user_account_success_div").hide();$("#user_account_success_span").hide();}});};$(document).ready(function(){var variation_group=$("div.variation-product-group");var variation_group_radio=$("div.variation-product-group-radio");var product_option_group=$("div.product-option-group-select");if(variation_group.length>0||variation_group_radio.length>0)
{$("div.variation-product-group").change(function(){var index_of_group=$(this).index('.variation-product-group')+1;var selection=$(".product-option-select-1 option:selected");var product=GetSelectedVariations(selection,index_of_group,false);CallChangeAjax(product);});var first_selection=$(".product-variation-input option:not(:disabled):first");if(first_selection.length>0)
{first_selection.attr('checked',true);var product=GetSelectedVariations(first_selection,1,true);CallChangeAjax(product);}
$(".product-variation-label").click(function(){var selection=$(this).prev();var product=GetSelectedVariations(selection,1,false);CallChangeAjax(product);});}
else if(product_option_group.length>0)
{var first_selection=$(".product-option-select-1 option:first");if(first_selection.length>0)
{var product=GetSelectedVariations(first_selection,1,true);CallChangeAjax(product);}}});function UpdatePricesAndStocks(data){var product_element=$(".content").find(".product").first();if(product_element.length>0&&data!=null){var actual_price_element=product_element.find('.actual-price');var old_price_element=product_element.find('.old-price');if(actual_price_element.length){var actual_price=actual_price_element.text();if(typeof actual_price!="undefined"){var new_actual_price=(parseFloat(data.actual_price))/100;product_element.find('.actual-price span:first').html(new_actual_price.toFixed(2).replace(".",","));}}
if(old_price_element.length&&data.discounted){var old_price=old_price_element.text();if(typeof old_price!="undefined"){var new_old_price=(parseFloat(data.normal_price))/100;product_element.find('.old-price').html(new_old_price.toFixed(2).replace(".",",")+"&nbsp;&euro;");}}
else if(data.discounted){var new_old_price=(parseFloat(data.normal_price))/100;var span=$('<span />').attr('class','old-price').html(new_old_price.toFixed(2).replace(".",",")+"&nbsp;&euro;");$(".actual-price").after(span);}
else if(!data.discounted){if(old_price_element){old_price_element.remove();}}
var saldo=parseInt(data.saldo,10);var availability=product_element.first('.availability');if(availability.length)
{$('.availability span').attr('class',data.stock_class);$('.availability span').html(data.stock_text);}
var unit_price=product_element.find('.product-unit-price');if(unit_price.length){$('.product-unit-price').html(data.unit_html)}
var history_price_element=product_element.find(".js-history-price");if(typeof(history_price_element)!='undefined')
{history_price_element.html(data.lowest_price);}}}
function GetSelectedVariations(selection,order,first)
{var product_id="";var product_ids=selection.data("selectlist").product_ids;product_id=product_ids[0];var order=order+1;var selections=$('.variation-product-group .product-option-select').length;for(order;order<=selections;order++)
{var next_selection=$(".product-option-select-"+order);if(next_selection.length>0)
{product_id=UpdateSelections(next_selection,order,product_ids,first);}}
return product_id;}
function UpdateSelections(selection,order,product_ids,first)
{var product_id="";$(".product-option-select-"+order+" option").prop("disabled",true);var select_is_chosen=false;$(".product-option-select-"+order+" > option").each(function(index){var this_product_ids=$(this).data("selectlist").product_ids;var selected=$(this).is(":selected");var is_found=false;$.each(this_product_ids,function(key,value){var index=$.inArray(value,product_ids);if(index!=-1){if(first){product_id=value;first=false;}
else if(selected){product_id=value;}
is_found=true;}});if(is_found)
{$(this).prop("disabled",false);}
if(!select_is_chosen&&is_found)
{$(this).prop("selected",true);select_is_chosen=true;}});return product_id;}
function UpdateImage(data)
{if(data!=null)
{var product_thumb=$(".js-thumb-change-"+data.image);if(product_thumb.length)
{product_thumb.click();}}}
function CallChangeAjax(product)
{$.post(TemplateEngine.REAL_URL+'/shop/change_variation_ajax.php',{product:product},function(data){UpdatePricesAndStocks(data);UpdateImage(data);},'json');};jQuery(document).ready(function($){var waitForFinalEvent=(function(){var timers={};return function(callback,ms,uniqueId){if(!uniqueId){uniqueId="Don't call this twice without a uniqueId";}
if(timers[uniqueId]){clearTimeout(timers[uniqueId]);}
timers[uniqueId]=setTimeout(callback,ms);};})();$('.js-toggle-nav').on('click',function(e){e.preventDefault();$('html').toggleClass('has-overlay');setTimeout(function(){$('html').toggleClass('menu-active');},10);$('.flyout-nav a.is-active.has-children').siblings('ul').show();});$('.js-flyout-nav-link-open').on('click',function(e){e.preventDefault();var parent=$(this).parents('.flyout-nav-link');if(!parent.hasClass('is-open')){parent.addClass('is-open');$('.flyout-nav-link.has-children').not(parent).removeClass('is-open');$('.flyout-nav-link.has-children').not(parent).siblings('.flyout-nav-lvl-2').hide();}
else{parent.removeClass('is-open');}
parent.siblings('.flyout-nav-lvl-2').toggle();});$('body').on('click','.js-header-link',function(e){if(($(window).width())<776){e.preventDefault();var target='#'+$(this).attr('rel');$(this).toggleClass('is-active');$('#'+$(this).attr('rel')).toggleClass('is-active');$('.js-header-link').not($(this)).removeClass('is-active');$('.header-dropdown').not($(target)).removeClass('is-active');}});var header_link_array=$('body').find('.js-header-link');for(var index=0;index<header_link_array.length;index++)
{header_link_array[index].addEventListener('touchstart',function(e){if(($(window).width())<776){e.preventDefault();var target='#'+$(this).attr('rel');$(this).toggleClass('is-active');$('#'+$(this).attr('rel')).toggleClass('is-active');$('.js-header-link').not($(this)).removeClass('is-active');$('.header-dropdown').not($(target)).removeClass('is-active');}},{passive:false});}
$(window).resize(function(){if(($(window).width())>776){$('html').removeClass('menu-active');$('.js-header-link').removeClass('is-active');$('.header-dropdown').removeClass('is-active');$('.table-extra').hide();$('.table-item').removeClass('is-active');}});$('.overlay').on('click touchstart',function(){$('html').removeClass('menu-active');$('html').removeClass('has-overlay');});$('body').on('click','.js-listing-item',function(){$(this).addClass('u--display-none').siblings().removeClass('u--display-none');});$(".rslides").responsiveSlides({auto:true,speed:700,timeout:5000,pager:true,nav:false,random:false,pause:false,pauseControls:true,prevText:"&lsaquo;",nextText:"&rsaquo;",maxwidth:"",navContainer:"",manualControls:"",namespace:"rslides",before:function(){},after:function(){}});$(".sidebar-banners").responsiveSlides({auto:true,speed:700,timeout:5000,pager:false,nav:false,random:false,pause:false,pauseControls:true,prevText:"&lsaquo;",nextText:"&rsaquo;",maxwidth:"",navContainer:"",manualControls:"",namespace:"rslides",before:function(){},after:function(){}});$(".fancybox").fancybox({nextEffect:'none',prevEffect:'none',openSpeed:200,closeSpeed:0,helpers:{title:'inside'}});$(".fancybox-gallery:not(.owl-item.cloned)").fancybox({nextEffect:'none',prevEffect:'none',openSpeed:200,closeSpeed:0,helpers:{title:'inside'}});$(".js-open-modal").fancybox({padding:28,helpers:{title:'inside'}});$('body').on('click','.js-modal-close',function(){$.fancybox.close();});InitProductListSecondImages();var owl=$('.product-main-images').owlCarousel({nav:false,items:1,margin:0});$('.js-product-thumb').on('click',function(e){e.preventDefault();$(this).parents('.product-thumbs').find('.js-product-thumb').removeClass('is-active');$(this).addClass('is-active');var index=$(this).data('slide-index');owl.trigger('to.owl.carousel',[index]);});$('.js-product-thumb:first').addClass('is-active');$('.product-list-slider').owlCarousel({nav:true,navText:['\ue001','\ue002'],navRewind:false,dots:false,margin:0,loop:false,smartSpeed:150,responsiveClass:true,responsive:{0:{items:2,slideBy:2,margin:7},544:{items:3,slideBy:3,margin:7},776:{items:4,slideBy:4},928:{items:3,slideBy:3},992:{items:4,slideBy:4}}});var firstItem=$('.js-description-link:first');$(firstItem).addClass('is-selected');$('#'+$(firstItem).attr('rel')).css('display','block');$('.js-description-link').click(function(e){e.preventDefault();$('.js-description-link.is-selected').removeClass('is-selected');$(this).addClass('is-selected');var element=this;$('.js-description-item:visible').hide();$('#'+$(element).attr('rel')).show();});var $allVideos=$("iframe[src^='http://player.vimeo.com'], iframe[src^='https://www.youtube.com'], object, embed");$allVideos.each(function(){$(this).attr('data-aspectRatio',this.height/this.width).removeAttr('height').removeAttr('width');});$(window).resize(function(){$allVideos.each(function(){var newWidth=$(this).parent().width();var $el=$(this);$el.width(newWidth).height(newWidth*$el.attr('data-aspectRatio'));});}).resize();var is_active_class="is-active";var is_selected_class="is-selected";var js_add_review_point_selector="."+"js-add-review-point";$("body").on("click",js_add_review_point_selector,function(){$(this).siblings(js_add_review_point_selector).removeClass(is_selected_class).removeData(is_selected_class);$(this).addClass(is_selected_class).data(is_selected_class,true);});$("body").on("mouseover",js_add_review_point_selector,function(){var all_points=$(this).siblings(js_add_review_point_selector).addBack();var selected_point=all_points.filter("."+is_selected_class);if(selected_point.length>0)
{selected_point.removeClass(is_selected_class);}
$(this).nextAll(js_add_review_point_selector).removeClass(is_active_class);$(this).prevAll(js_add_review_point_selector).addBack().addClass(is_active_class);});$("body").on("mouseout",js_add_review_point_selector,function(){var all_points=$(this).siblings(js_add_review_point_selector).addBack();all_points.each(function(){if($(this).data(is_selected_class))
{$(this).addClass(is_selected_class);}});var selected_point=all_points.filter("."+is_selected_class);if(selected_point.length>0)
{selected_point.nextAll(js_add_review_point_selector).removeClass(is_active_class);selected_point.prevAll(js_add_review_point_selector).addBack().addClass(is_active_class);}
else
{all_points.removeClass(is_active_class);}});$('.js-show-extra-data').on('click',function(e){if(($(window).width())<960){$(this).siblings('.table-extra').slideToggle('fast');$(this).parent().toggleClass('is-active');$('.table-extra').not($(this).siblings('.table-extra')).hide('fast');$('.table-item').not($(this).parent()).removeClass('is-active');}});$('.main-nav-link.has-children').on('mouseenter',function(e){var hoverElement=$(this).siblings('ul');var pageElement=$(".page-wrap");var pageWidth=pageElement.width();var elementWidth=hoverElement.width();var elementLeft=hoverElement.offset().left;if(pageWidth<(elementWidth+elementLeft)){$(this).siblings('ul').addClass('dropdown-right');}});$(window).resize(function(){waitForFinalEvent(function(){var dropdownElement=$('.dropdown-right');var pageElement=$(".page-wrap");dropdownElement.each(function(){var pageWidth=pageElement.width();var elementWidth=dropdownElement.width();var elementLeft=dropdownElement.offset().left;if(pageWidth>(elementWidth+elementLeft)){dropdownElement.removeClass('dropdown-right');}});},200,"clear dropdown fix");});$('.js-store-notification-close').on('click',function(e){e.preventDefault();$(this).parents('.store-notification').slideUp();});$('.input-select').wrap("<div class='input-select-wrap'></div>");if(navigator.userAgent.match(/iemobile/i))
{$('html').addClass('iemobile');}
else{$('html').addClass('no-iemobile');}
$('.js-to-reviews').on('click',function(e){e.preventDefault();$(window).scrollTo('#reviews',200,{offset:{top:-100}});});if($('body').hasClass('page_lang_fi')){$(this).find('.product-option-group-1').addClass('product-option-group-fi');}
if($('body').hasClass('page_lang_se')){$(this).find('.product-option-group-1').addClass('product-option-group-se');}
if($('body').hasClass('page_lang_en')){$(this).find('.product-option-group-1').addClass('product-option-group-en');}
if($('body').hasClass('page_lang_de')){$(this).find('.product-option-group-1').addClass('product-option-group-de');}
$(document).ready(function(){var offset=500;var duration=400;var back=200;$(window).scroll(function(){if($(this).scrollTop()>offset&&($(window).width())>776){$('.o--back-to-top').fadeIn(duration);}else{$('.o--back-to-top').fadeOut(duration);}});$('.o--back-to-top').click(function(event){event.preventDefault();$('html, body').animate({scrollTop:0},back);return false;});});$('.js-toggle-search-parameter').on('click',function(e){$(this).next().toggleClass('u--sidebar-radio-button-slide');});$('.flyout-nav ul.flyout-nav-lvl-1').children('li').appendTo('.flyout-nav ul.flyout-nav-lvl-1:first');$('.flyout-nav ul.flyout-nav-lvl-1').not(':first').remove();$('.side-nav ul.side-nav-lvl-1').children('li').appendTo('.side-nav ul.side-nav-lvl-1:first');$('.side-nav ul.side-nav-lvl-1').not(':first').remove();$('.main-nav ul.main-nav-lvl-1').children('li').appendTo('.main-nav ul.main-nav-lvl-1:first');$('.main-nav ul.main-nav-lvl-1').not(':first').remove();if(!$(".product-option-group .product-option-item input:checked").length){$(".product-option-group .product-option-item input:enabled").first().prop("checked",true);}
if(!$(".product-variation-item input:checked").length){$(".product-variation-item input:enabled").first().prop("checked",true);}
$(document).click(function(e){if(!$(e.target).closest(".category-search-filters-anchor").length&&!$(e.target).closest(".category-search-filters-select-dropdown").length){$(".category-search-filters-select-dropdown").each(function(){if($(this).hasClass('show'))
{$(this).toggleClass('show');}});};});$(document).on("click",".category-search-filters-anchor",function(e){var target=$(this).next(".category-search-filters-select-dropdown");var target_was_shown=target.hasClass('show');$(".category-search-filters-select-dropdown").each(function(){if($(this).hasClass('show'))
{$(this).toggleClass('show');}});if(!target_was_shown)
{target.toggleClass('show');}});$('.js-select-filter').click(function(e){var target=$(this).parent(".category-search-filters-select-dropdown");target.toggleClass('show');});$('.js-select-all-filters').click(function(e){e.stopPropagation();$(".category-search-filters-select-dropdown").each(function(){if($(this).hasClass('show'))
{$(this).toggleClass('show');}});});$('.js-empty-search-filter').click(function(e){var filter_id=$(this).data('id');var selected=[];$("input:checkbox[name=checkbox-select-"+filter_id+"]:checked").each(function(){$(this).prop("checked",false);});});$('.js-show-all-filters').click(function(e){$(".category-search-filters").show();$(this).hide();});var sliders=document.getElementsByClassName("js-slider");var marginMins=document.getElementsByClassName("js-slider-min-value");var marginMaxs=document.getElementsByClassName("js-slider-max-value");for(var index=0;index<sliders.length;index++){var range_min=$(sliders[index]).data("min");var range_max=$(sliders[index]).data("max");var start_min=$(sliders[index]).data("usedmin");var start_max=$(sliders[index]).data("usedmax");;var unit=" "+$(sliders[index]).data("unit");noUiSlider.create(sliders[index],{connect:true,behaviour:'tap',start:[start_min,start_max],step:1,range:{'min':[range_min],'max':[range_max]}});bindValues(sliders[index],marginMins[index],marginMaxs[index],unit);}
$('.js-show-filters').click(function(e){e.preventDefault();if($('html').hasClass('has-overlay'))
{$('html').removeClass('has-overlay');}
$('.filters-mobile').removeClass('hidden');});$('.js-close-filters-mobile').click(function(e){e.preventDefault();if($('html').hasClass('has-overlay'))
{$('html').removeClass('has-overlay');}
$('.filters-mobile').addClass('hidden');});});function InitProductListSecondImages(){$('.product-item-grid').on({mouseenter:function(){if($(this).has('.product-list-second-img').length){$(this).find('.product-list-first-img').addClass('is-hidden');$(this).find('.product-list-second-img').addClass('is-visible');}},mouseleave:function(){if($(this).has('.product-list-second-img').length){$(this).find('.product-list-first-img').removeClass('is-hidden');$(this).find('.product-list-second-img').removeClass('is-visible');}}});};$(document).ready(function(){var form=$(document).find("form.add-captcha");var ajax_url="/shop/add_captcha/add_captcha_ajax.php";var functions_url="/shop/add_captcha/recaptchaForm.php";form.wrap('<div class="recaptcha-form"></div>');var form_id=form.attr('id');if(form.length>0)
{var url="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit";$.getScript(url,function(){});}});var onloadCallback=function(){var form=$(document).find("form.add-captcha");var ajax_url="/shop/add_captcha/add_captcha_ajax.php";var functions_url="/shop/add_captcha/recaptchaForm.php";var data={"action":"get-sitekey"}
var form_id=form.attr('id');$.ajax({url:ajax_url,type:"POST",data:data,dataType:"json",success:function(data){if(data.success==true)
{form.append('<input type="hidden" name="g-recaptcha-response" value="">');var button=form.find("button");button.prop('disabled',true);button.parent().before('<div><div id="recaptch-'+form_id+'" class="g-recaptcha"></div><br></div>');widgetId=grecaptcha.render('recaptch-'+form_id,{'sitekey':data.sitekey,'callback':verifyCallback,'data-expired-callback':expiredCallback,'theme':'light'});}},error:function(){}});};var verifyCallback=function(response){var form=$(document).find("form.add-captcha");form.find('input[name="g-recaptcha-response"]').val(response);var button=form.find("button");button.prop('disabled',false);};var expiredCallback=function(response){var form=$(document).find("form.add-captcha");form.find('input[name="g-recaptcha-response"]').val(response);var button=form.find("button");button.prop('disabled',true);};;$(document).ready(function(){$('#cookie-select-all').click(function(){$('.cookie-consent-checkbox').prop('checked',true);consentGrantedAdStorage();consentGrantedUserData();consentGrantedAdPersonalization();consentGrantedAnalyticsStorage();})
$('.cookie-select-info-button').click(function(){$('.cookie-help-text').toggle();});$(".cookie-made-changes").click(function(event){$(".first-page-of-accept-cookies").hide();$(".second-page-of-accept-cookies").show();});$(".cookie-go-back").click(function(event){$(".second-page-of-accept-cookies").hide();$(".first-page-of-accept-cookies").show();});$("#cookie-select-checked").click(function(event){if($('#cookies-marketing').prop('checked')){consentGrantedAdStorage();consentGrantedUserData();consentGrantedAdPersonalization();}
if($('#cookies-statistics').prop('checked')){consentGrantedAnalyticsStorage();}});});function consentGrantedAdStorage(){gtag('consent','update',{'ad_storage':'granted'});}
function consentGrantedUserData(){gtag('consent','update',{'ad_user_data':'granted'});}
function consentGrantedAdPersonalization(){gtag('consent','update',{'ad_personalization':'granted'});}
function consentGrantedAnalyticsStorage(){gtag('consent','update',{'analytics_storage':'granted'});}