(function($){window._bilingualTheme.bilingualElements=[],window.Bilingual=function(){$(function(){var langAttributes=$(".lang-attr"),langSelect=$(".lang-select");_bilingualTheme.settings.use_lang2||($(".lang-select").remove(),eraseCookie("sn-multiling")),langSelect.show(),setUpBilingualElements(),setStartLanguage(),langSelect.on("click","span",function(){currentLang=switchLang($(this).data("lang"))});function switchLang(lang){var lang;_bilingualTheme.settings.primary_language=="1"?lang=lang==null?"lang1":lang:lang=lang==null?"lang2":lang,languages=$(".lang"),newLang=$("."+lang),languages.hide(),newLang.show(),$.each(newLang,function(i,obj){obj=$(obj),obj.hasClass("inline-block")?obj.css("display","inline-block"):obj.css("display","block")}),$.each(window._bilingualTheme.bilingualElements,function(i,obj){var elem=obj.elem;if(obj.attr!="text")obj[lang]!=""&&elem.attr(obj.attr,obj[lang]);else{var text="";obj[lang]!=""?(text=obj[lang],elem.data("price")&&(text+=" - "+elem.data("price"))):text=elem.text(),text!=""&&elem.text(text)}});var title="";if(_bilingualTheme.template=="index")title=_bilingualTheme.shopName;else{var tabTitle=$(".tab-title");tabTitle.find(".lang").length>0?title=$(".tab-title ."+lang).first().text():title=tabTitle.text()}return title!=_bilingualTheme.shopName&&(title+=" | "+_bilingualTheme.shopName),setTitle(title),createCookie("sn-multiling",lang,1),lang}function setTitle(newTitle){window.document.title=newTitle}function setStartLanguage(){var lang=readCookie("sn-multiling");switchLang(lang)}function createCookie(name,value,days){if(days){var date=new Date;date.setTime(date.getTime()+days*24*60*60*1e3);var expires="; expires="+date.toGMTString()}else var expires="";document.cookie=name+"="+value+expires+"; path=/"}function readCookie(name){for(var nameEQ=name+"=",ca=document.cookie.split(";"),i=0;i<ca.length;i++){for(var c=ca[i];c.charAt(0)==" ";)c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length)}return null}function eraseCookie(name){createCookie(name,"",-1)}function setUpBilingualElements(){var isProductTemplate=_bilingualTheme.template.indexOf("product")!=-1;if($.each(langAttributes,function(i,obj){if(obj=$(obj),attr=obj.data("attr"),obj.length!=0){var bilingualText=obj.data("bilingual").toString(),pipePos=bilingualText.indexOf("|"),lang1=bilingualText.substring(0,pipePos),lang2=bilingualText.substring(pipePos+1,obj.data("bilingual").length);window._bilingualTheme.bilingualElements.push({elem:obj,attr:attr,lang1:lang1,lang2:lang2})}}),isProductTemplate){var selectors=$(".selector-wrapper");$.each(selectors,function(i,obj){var $obj=$(obj),label=$obj.find("label"),options=$obj.find("option"),labelText=label.text().toString(),pipePos=labelText.indexOf("|");if(pipePos!=-1){var lang1=labelText.substring(0,pipePos),lang2=labelText.substring(pipePos+1,labelText.length);label.text(""),$("<span></span>",{class:"lang lang1",text:lang1}).appendTo(label),$("<span></span>",{class:"lang lang2",text:lang2}).appendTo(label)}$.each(options,function(i2,obj2){var $obj2=$(obj2),text=$obj2.val().toString(),pipePos2=text.indexOf("|"),lang12=text.substring(0,pipePos2),lang22=text.substring(pipePos2+1,text.length),sameIndex;lang12=lang12==""?lang22:lang12,$.each(window._bilingualTheme.bilingualElements,function(i3,item){var currentText=obj2.nodeName+" "+$obj2.text(),testText=item.elem[0].nodeName+" "+item.elem.text();currentText==testText&&(sameIndex=i3)}),window._bilingualTheme.bilingualElements.push({elem:$obj2,attr:"text",lang1:lang12,lang2:lang22})})})}var languages2=$(".lang1");$.each(languages2,function(i,obj){$(obj).next().hasClass("lang")||$(obj).removeClass("lang lang1")})}})},Bilingual()})(jQuery);
//# sourceMappingURL=/cdn/shop/t/2/assets/bl-scripts.js.map?v=63916719907177140801448030256