(function(){ var loadScript = function(url, callback) { var script = document.createElement("script"); script.type = "text/javascript"; if (script.readyState){ script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete") { script.onreadystatechange = null; callback(); } }; } else { script.onload = function() { callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }; var fix = function($) { var ml_lang; var listen = false; var env = ''; window.ml_domains_local = {}; function interceptCartSubmit() { $('form[action=\\/cart] input[name=checkout],form[action=\\/cart] button[name=checkout], a[href=\\/checkout],button.shopify-payment-button__button').click(function(e) { e.preventDefault(); var note_f = $('textarea[name=note]'); var note = ''; if(note_f.length > 0) { if(note_f.val().length > 0) note='¬e='+note_f.val(); } location.href='/checkout?locale='+ml_lang+note; }); } function setCookie(v) { document.cookie = "redirected="+v+"; path=/;"; } function delCookie() { document.cookie = "redirected=; path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC"; } function getCookie() { var name = "redirected="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1); if (c.indexOf(name) == 0) { return c.substring(name.length,c.length); } } return ""; } function swap(json) { var ret = {}; for(var key in json) ret[json[key]] = key; return ret; } function getUrlVars() { var vars = []; var jvars = {}; var hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); var cloc = window.location.host; for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); if(hash[1]!=null) jvars[hash[0]] = hash[1]; } return jvars; } window.setAtt = function(target) { var url = location.href.split('?'); if(url[0].charAt(url[0].length-1) =='#') url[0]=url[0].substr(0,url[0].length-1); var new_qs_arr = []; var new_qs = ''; var qs = getUrlVars(); for(var j=0; j< qs.length; j++) { if(qs[j]!='lang') new_qs_arr.push(qs[j]+'='+qs[qs[j]]); } new_qs = new_qs_arr.join('&'); if(new_qs.length>0) new_qs = '?'+new_qs; var dest = ''; var path = window.location.pathname; var update_url = ''; if(ml_domains_local[target]!=null) { update_url = 'https://'+ml_domains_local[target]; dest ='https://'+ml_domains_local[target]+path+new_qs; } else { update_url = 'https://'+location.host; dest =url[0]+new_qs; } update_url = update_url+'/cart/update?attributes[ml_lang]='+target; $('body').append(''); $('#ml_cart_update').attr('src', update_url) .on('error', function() { location.href = dest; }); return; }; function getLang() { $.ajax({ url : '/cart.js', type : 'GET', crossDomain: false, dataType:'json', success : function(data) { if(typeof ml_def_language_mf !== 'undefined') def_loc = ml_def_language_mf; ml_lang = data['attributes']['ml_lang']; if(ml_lang==null) ml_lang=def_loc; var bidi = ['ar','fa','ur','he','he-IL']; if( bidi.indexOf(ml_lang)>=0 && ($('#ml_lang_selector').attr('rtl') == 'rtl')) { //$('body').attr('dir','rtl'); $('body').css('direction','rtl'); $('body').addClass('rtl'); } else { $('body').css('direction',''); $('body').removeClass('rtl'); } var redirect; if(typeof ml_redirect_mf != 'undefined') redirect = ml_redirect_mf; else redirect = $('#ml_lang_selector').attr('redirect'); if(redirect===null) redirect = 'off'; if(redirect!='off') { var br_locale = 'en'; var br_locale_short = 'en'; var l_loc = new Array(); var target=''; var keys = ''; if(typeof ml_available_languages_mf != 'undefined') keys = Object.keys(ml_available_languages_mf); else keys = Object.keys(ml_loc); for(var i=0;i< keys.length;i++) l_loc.push(keys[i].toLowerCase()); if(l_loc.indexOf(br_locale) >=0 ) target = keys[l_loc.indexOf(br_locale)]; else if(l_loc.indexOf(br_locale_short) >=0 ) target = keys[l_loc.indexOf(br_locale_short)]; var t = location.href.split('#')[0] t = t.split('?')[0]+'?lang='+target; if(redirect=='once' && target != '' && target==ml_lang && getCookie().length==0) { setCookie('once'); return; } if(redirect=='once' && target != '' && target!=ml_lang && getCookie().length==0) { setCookie('once'); setAtt(target); return; } else if(redirect=='force' && target != '' && target!=ml_lang) { setAtt(target); return; } } $('#ml_switch_loc,#ml_custom_switch').val(ml_lang); var type = $('#ml_lang_selector').attr('type'); if(typeof type=='undefined') type =''; if(type.indexOf('flag_')==0) triggerFlagSelect($('.lang_tab[value="'+ml_lang+'"]')); var qs = getUrlVars(); if ('lang' in qs && ml_lang != qs['lang']) { setAtt(qs['lang']); return; } if(Object.keys(ml_domains_local).length >0) { var d_k = Object.keys(ml_domains_local); var c_host = location.host; for(var i=0;i< d_k.length;i++) { var t_host = ml_domains_local[d_k[i]]; if(t_host==c_host) { if(ml_lang!=d_k[i]) { setAtt(d_k[i]); return; } } } } $('#ml_lang_selector').show(); }, error : function(request,error) { } }); } function createFlagDropdown() { $('head').append(''); var sel = $('#ml_lang_selector'); sel.css('direction','ltr'); sel.hide(); var has_txt = true; var width_class = 'ml_lang_texts_long'; if (sel.attr('type')=='flag_no_txt_dropdown') { has_txt = false; width_class= 'ml_lang_texts_short'; } sel.append('