function loadScript(e,a){var t=document.createElement("script");t.type="text/javascript",t.readyState?t.onreadystatechange=function(){"loaded"!=t.readyState&&"complete"!=t.readyState||(t.onreadystatechange=null,a())}:t.onload=function(){a()},t.src=e,document.getElementsByTagName("head")[0].appendChild(t)}function getSTLScriptUrl(){return void 0!==document.currentScript?document.currentScript.src:"https://sharethelove.w3apps.co/"}function extractSTLDomain(e){e=-1<e.indexOf("://")?e.split("/")[2]:e.split("/")[0];return e=e.split(":")[0]}var domainSTLURL="https://"+extractSTLDomain(getSTLScriptUrl()),donationTrackerJS=function(i){var d,e,t,a,n;0<i(".w3-donation-tracker:not(.loaded)").length&&(d=i(".w3-donation-tracker:not(.loaded)"),a=Shopify.shop,n=d.closest("form")[0],e="",null!=n&&n.action.includes("/cart")||(e=" form='cart' "),d.addClass("loaded"),i.ajax({type:"POST",url:domainSTLURL+"/api/causes?shopName="+a,dataType:"jsonp",success:function(n){var o,s;1!=n.disableApp&&(d.append("<h2 class='cause-title'>"+n.introTitle+"</h2>"),d.append("<div>"+n.introText+"</div>"),o=i("<select "+e+" id='share-the-love-drop-down' name='attributes[w3-cause]'></select>"),d.append(o),s=i("<input "+e+" type='hidden' name='attributes[w3-cause-name]' value='' />"),1==n.optional&&o.append(i("<option value='-1'>"+n.pleaseSelectText+"</option>")),i.each(n.causes,function(e,a){var t=i("<option value='"+a.CauseID+"'>"+a.Title+"</option>"),t=(o.append(t),a.Description),t=(n.showDescription&&(1==a.IsDefault&&0==n.optional?d.append("<div style='padding-top:10px' class='w3-description'  id='share-the-love-"+a.CauseID+"'>"+t+"</div>"):d.append("<div style='display:none;padding-top:10px' class='w3-description'  id='share-the-love-"+a.CauseID+"'>"+t+"</div>")),a.URL);n.showURL&&(null!=a.URLText&&0<a.URLText.length?d.append("<a style='display:none;margin-top:10px' href='"+t+"' class='w3-cause-link "+n.CauseLinkClass+"' target='_blank' id='share-the-love-link-"+a.CauseID+"'>"+a.URLText+"</a>"):d.append("<a style='display:none;margin-top:10px' href='"+t+"' class='w3-cause-link "+n.CauseLinkClass+"' target='_blank' id='share-the-love-link-"+a.CauseID+"'>"+t+"</a>"))}),i(".w3-description,.w3-cause-link").wrapAll(i("<div class='w3-cause-info'>")),d.append(s),d.append(i("<input "+e+" type='hidden' name='attributes[w3-cause-method]' value='"+n.method+"' />")),d.append(i("<input "+e+" type='hidden' name='attributes[w3-cause-amount]' value='"+n.amount+"' />")),i("#share-the-love-drop-down").change(function(){var e=i(this).find("option:selected").text(),a="share-the-love-"+i(this).find("option:selected").val(),t="share-the-love-link-"+i(this).find("option:selected").val();i(".w3-description").each(function(){i(this).hide()}),i(".w3-cause-link").each(function(){i(this).hide()}),i("#"+a).show(),i("#"+t).show(),s.val(e)}),o.change())},error:function(e,a,t){console.log(t)}})),0<i(".w3-donation-tracker-total:not(.loaded)").length&&(t=i(".w3-donation-tracker-total:not(.loaded)"),a=Shopify.shop,t.addClass("loaded"),n="",t.attr("data-cause")&&(n=t.attr("data-cause")),i.ajax({type:"GET",url:domainSTLURL+"/api/DonationTotal?cause="+n+"&shopName="+a,dataType:"json",success:function(e){var a=e.total.toFixed(2);""!=e.causeName&&void 0!==e.causeName&&null!=e.causeName&&t.append('<span class="donation-name">'+e.causeName+"</span>"),t.append('<span class="donation-total">'+a+"</span>")},error:function(e,a,t){console.log(t)}}))};function hasData(e){return null!=e}function saveSelection(e){Cookies.set("sel-cause",e.value)}"undefined"==typeof jQuery||parseFloat(jQuery.fn.jquery)<3.6?loadScript("//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js",function(){W3jQuery360=jQuery.noConflict(!0),donationTrackerJS(W3jQuery360)}):donationTrackerJS(jQuery),window.jQuery;