var v3rid="prodinfozone";function initStoreZone(){}function initRetrieveProductTier(overridelabel){if(overridelabel==0){return}replaceText(overridelabel)}function initProductListPage(){attachFilterEvents();$.appear("#prodgrid div.invprodimg",{interval:2e3,force_process:true});$("#prodgrid div.invlink").click(function(e){var item=$(this).find("div.invprodimg");var selectedPrice=$(this).find("div.price");if(item.length){var evData={};evData.event="productClick";evData.ecommerce={};evData.ecommerce.currencyCode=item.attr("data-cur");evData.ecommerce.click={};evData.ecommerce.click.actionField={list:"Product List Page"};evData.ecommerce.click.products=[];var prod={};var prod_name=item.attr("data-nm");prod.name=decodeURIComponent(prod_name);prod.id=item.attr("data-id");prod.price=item.attr("data-pr");prod.brand=item.attr("data-lid");prod.category=catIDs[item.attr("data-cid")];prod.position=parseInt(item.attr("data-pos"));document.cookie="selectedProdPos="+JSON.stringify(setProductPosition($("#obstore31").data("oid"),prod.id,prod.position))+";path=/";prod.dimension40="CFS";prod.dimension44=$("#obstore31").attr("data-tm");prod.dimension45=$("#obstore31").attr("data-tn");prod.dimension66=parseInt(item.attr("data-discounted"))==1?"Discounted":"Regular";prod.dimension49=$("#obstore31").attr("data-tsn");prod.dimension76=selectedPrice.length?selectedPrice.text().substring(selectedPrice.text().indexOf("$")+1).trim():item.attr("data-pr");var imgSrc=item.find("img").attr("src");var imgFileName=imgSrc.substring(imgSrc.lastIndexOf("/")+1);prod.dimension86=prod.id+"|"+prod.name+"|"+imgFileName;evData.ecommerce.click.products.push(prod);window.dataLayer.push(evData)}var url=window.location.href+"/"+$(this).attr("data-href");url=url.replace("/sympathy","");url=url.replace("/send-flowers","");window.location=url;return true});$("#prodgrid div.invprodimg").on("appear",function(event,items){var products=[];var dimension40="CFS";var dimension44=$("#obstore31").attr("data-tm");var dimension45=$("#obstore31").attr("data-tn");var dimension49=$("#obstore31").attr("data-tsn");var currencyCode="";items.each(function(){if(false===$(this).is(".inview")){var prod={};var prod_name=$(this).attr("data-nm");prod.name=decodeURIComponent(prod_name);prod.id=$(this).attr("data-id");prod.price=$(this).attr("data-pr");prod.brand=$(this).attr("data-lid");prod.category=catIDs[$(this).attr("data-cid")];prod.list="Product List Page";prod.position=parseInt($(this).attr("data-pos"));prod.dimension40=dimension40;prod.dimension44=dimension44;prod.dimension45=dimension45;prod.dimension49=dimension49;prod.dimension66=parseInt($(this).attr("data-discounted"))==1?"Discounted":"Regular";prod.dimension76=$(this).attr("data-pr");var item=$(this);var imgSrc=item.find("img").attr("src");var imgFileName=imgSrc.substring(imgSrc.lastIndexOf("/")+1);prod.dimension86=prod.id+"|"+prod.name+"|"+imgFileName;currencyCode=$(this).attr("data-cur");products.push(prod);$(this).addClass("inview")}});if(products.length){var evData={};evData.event="productListView";evData.ecommerce={};evData.ecommerce.currencyCode=currencyCode;evData.ecommerce.impressions=products;window.dataLayer.push(evData)}})}function initProdPage(){var selItem=$("#prodpg31 .pricepoint.selected");if(selItem.length)onSelectProduct(selItem);$("#prodpg31 .pricepoint").click(function(){$("#prodpg31 .pricepoint").removeClass("selected");$(this).addClass("selected");onSelectProduct($(this))});if($("#treeoptgp").length){$("#treeoptgp div.tree-qty").click(function(){$("#treeoptgp div.tree-qty").removeClass("selected");$(this).addClass("selected")});setTimeout(function(){$("#treeoptgp div.tree-qty").removeClass("selected");var ck=$("#treeoptgp input[name=obpid]:checked");if(ck.length){ck.closest("div.tree-qty").addClass("selected");$("#flex-tree-price").text("$"+$(".tree-qty.selected").find("input[name='obpid']").attr("data-p"));var discountPrice=$(".tree-qty.selected").find("input[name='obpid']").attr("data-pid").length?"$"+$(".tree-qty.selected").find("input[name='obpid']").attr("data-pid"):"";$("#discounted-tree-price").text(discountPrice)}},1e3)}var item=$("#prodpg31 .prodtip");var name=item.attr("data-nr");var nameP=item.attr("data-nrp");var partner=item.attr("data-p");var numTrees=window.dataLayer[3].pageInfo.countTreePurchases+window.dataLayer[3].pageInfo.countFreeTrees;var treeIcon='Memorial Tree Icon';if(window.dataLayer[3].pageInfo.productType==="Flowers"){treeIcon='Memorial Tree Icon'}var title='
Show your support for '+name+" by planting a memorial tree
";var body='
A beautiful memorial tree will be planted in memory of '+name+". This will be done in partnership with our planting partner.
Each memorial tree includes a certificate that can be sent to the recipient of your choosing to demonstrate the gift that you have given. Your name will also be listed on "+nameP+" Tribute Wall.
";var treesOrderedHTML="";if(numTrees>0){var numTreesText=numTrees>1?numTrees+" trees":"One tree has been";treesOrderedHTML='
'+treeIcon+""+numTreesText+" planted in memory of "+name+"
";body=treesOrderedHTML+body}item.popover({html:true,placement:"top",trigger:"hover",title:title,content:body});$("#prodnavtabs .navcell31").click(function(){var tab=$(this).attr("data-tab");$("#prodnavtabs .navcell31").removeClass("nav-selected");$(this).addClass("nav-selected");$("#prodnavpanels .prod-nav-content").hide();$("#"+tab).show()});$("#deliverytarget").change(function(){onDeliveryTargetChange()});onDeliveryTargetChange();function pushBuyNowData(e){if(window["google_tag_manager"]){e.preventDefault();var clickedButton=$(this);var action="PDP - Continue to Checkout";var label=e.data.label;if(clickedButton.attr("data-tag")==="buy-multiple-tree"||clickedButton.find('[data-tag="buy-multiple-tree"]').length){action="Grove PDP - Add to Cart Click";label=$(".radio.tree-qty.selected").find("span").text()}window.dataLayer=window.dataLayer||[];window.dataLayer.push({event:"gaEvent",category:"Store",action:action,label:label,eventCallback:function(containerId){if(containerId.startsWith("GTM")){$(clickedButton).off("click",pushBuyNowData);$(clickedButton).trigger("click")}},eventTimeout:2e3})}}$("#buynow").on("click",{label:"Primary"},pushBuyNowData);$("div.buy-now button.btn-buy-now").not("[id='buynow']").on("click",{label:"Secondary"},pushBuyNowData);$("[data-tab='details']","#prodnavtabs").on("click",function(){if($(this).data("tag")=="tab-tree-details")return;dataLayer.push({event:"gaEvent",category:"Store",action:"PDP - Product Specs Tab Clicks",label:"Item Description"})});$("[data-tab='guarantee']","#prodnavtabs").on("click",function(){dataLayer.push({event:"gaEvent",category:"Store",action:"PDP - Product Specs Tab Clicks",label:"Delivery & Guarantee"})});$(".accordion-mob:first").addClass("active");$(".accordion-mob:not(:first)").next(".panel-block").hide();$(document).on("click",".accordion-mob",function(){$(this).toggleClass("active");var panel=$(this).next(".panel-block");panel.slideToggle()});checkDesktopSize();$(window).resize(checkDesktopSize);$("#back-to-product-page").click(function(e){e.preventDefault();var url=$(this).attr("href");dataLayer.push({event:"ga4Event",category:"Store",action:"PDP - Return to Products Link Click",label:"Return to Products"});window.open(url,"_self")});$("#back-to-product-page-flower").click(function(e){e.preventDefault();var url=$(this).attr("href");dataLayer.push({event:"ga4Event",category:"Store",action:"PDP - Return to Products Link Click",label:"Send Flowers"});window.open(url,"_self")})}function replaceText(override=0){if(override==0){var priceLabel=$(".price-label").size();if(priceLabel>0){$(".price-label").each(function(){var priceLabelText=$(this).text();var dataOrValue=$(this).attr("data-or");if($(window).width()>=992&&dataOrValue!=0){if(priceLabelText.toLowerCase()=="good"||priceLabelText.toLowerCase()=="standard"){$(this).text("Standard")}else if(priceLabelText.toLowerCase()=="better"||priceLabelText.toLowerCase()=="deluxe"){$(this).text("Deluxe")}else if(priceLabelText.toLowerCase()=="best"||priceLabelText.toLowerCase()=="premium"){$(this).text("Premium")}else{return true}}else{var prevText=$(this).first().parent().attr("id");$(this).text(prevText)}})}else{return true}}else{if($(window).width()>=992&&override==1){var priceLabelText=$("#item-price-label").text();var priceLabelText=priceLabelText.replace(/[*]/g,"");if(priceLabelText.toLowerCase().trim()=="better"||priceLabelText.toLowerCase().trim()=="deluxe"){$("#item-price-label").text("*Deluxe*")}else if(priceLabelText.toLowerCase().trim()=="best"||priceLabelText.toLowerCase().trim()=="premium"){$("#item-price-label").text("*Premium*")}else{return true}}}}function checkDesktopSize(){replaceText()}function onSelectProduct(item){$("#prodprice").text("$"+item.attr("data-p"));$("#obpid").val(item.attr("data-pid"))}function onDeliveryTargetChange(){var opt=$("#deliverytarget option:selected");$("#delnar").text(" "+opt.attr("data-n"));$("#delftr").text(" "+opt.attr("data-n"))}function initOrderSummaryTooltips(){$("#scinfo").tooltip();if($("#mtinfo").length){var item=$("#mtinfo");item.popover({html:true,placement:"auto",trigger:"hover",title:item.attr("data-title"),content:item.attr("data-txt")})}}function initCardMsgPanel(){previewCardMsg();if($("#pmtwopts").length){$("#pmtwopts div.ptwopt").click(function(){$("#pmtwopts div.ptwopt").removeClass("selected");$(this).addClass("selected")})}setInterval(previewCardMsg,200);$("#msgs").change(function(){$("#cardmsg").val($(this).val());$(this).val("");previewCardMsg()});$("#submsg").click(function(){submitCardMsg()})}function previewCardMsg(){if($("#cardmsg").length==0){$("#msgs").val("");return}var msg=$("#cardmsg").val();var sig=$("#signature").val().trim();var max=$("#msglen");var maxLen=$("#msglen").attr("data-mx");var remaining=maxLen-msg.length;if(remaining<0){var txt=msg.substr(0,maxLen);$("#cardmsg").val(txt);msg=txt;remaining=0}msg=msg.replace(/(?:\r\n|\r|\n)/g,"
");max.text(remaining);if(parseInt(remaining)!=200){$("#msgstatus").hide()}if(parseInt(remaining)==200){$("#msgstatus").show()}if(remaining<20)$("#msglen-warning").addClass("warning");else $("#msglen-warning").removeClass("warning")}function submitCardMsg(){var msg=$("#cardmsg").val();if(""==msg){var conf=$("#submsg").attr("data-conf");if(1!=conf){var txt="You have not entered a card message. If you do not wish to provide one, click on the 'Continue' button once more";$("#msgstatus").text(txt);$("#submsg").attr("data-conf",1);return}}var premiumTWOption=0;if($("#pmtwopts").length){premiumTWOption=$("#pmtwopts div.ptwopt.selected").attr("data-id")}var cardMsgWithoutEmoji=$("#cardmsg").val().replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,"");var signMsgWithoutEmoji=$("#signature").val().replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,"");var cm=LZString.compressToEncodedURIComponent(cardMsgWithoutEmoji);var sig=LZString.compressToEncodedURIComponent(signMsgWithoutEmoji);var pub;if($("input[name=pubopt]:checked").is(":radio")){pub=$("input[name=pubopt]:checked").val()}else{pub=$('input[name="pubopt"]').val()}var sn=$("#submsg").attr("data-sid");var params="st=domsg&cm="+cm+"&sig="+sig+"&sn="+sn+"&po="+pub+"&ptw="+premiumTWOption;axpost("/pax/ckoutnos",params,function(data){$("#checkout31").html(data)})}function onBypassCardMsg(){$("#cardmsg").val("");$("#signature").val("");$("#submsg").attr("data-conf",1);dataLayer.push({event:"gaEvent",category:"Checkout",action:"Navigation",label:"Skip Message"});submitCardMsg()}function initDeliveryPanel(){updateDeliverySummary();$("#delivery").change(function(){updateDeliverySummary()});$("#subdel").click(function(){submitDelivery()})}function updateDeliverySummary(){var opt=$("#delivery option:selected");if($("#handdeltext").length){var stock="hand deliver your arrangement";var txt=opt.attr("data-p")+stock+opt.attr("data-n");$("#handdeltext").text(txt)}var summaryText="";var delSummary=opt.attr("data-s");var delID=parseInt($("#delivery").val());var earliest=false;switch(delID){case 0:summaryText="";earliest=true;break;case 2:summaryText="
"+delSummary+"";earliest=true;break;default:summaryText="
"+delSummary+"";earliest=false;break}if(earliest)$("#earliestdelivery").show();else $("#earliestdelivery").hide();$("#deliverysummary").html(summaryText);if(0==delID){$("#delsumzone").hide();$("#deladdress").show()}else{$("#delsumzone").show();$("#deladdress").hide()}}function submitDelivery(){var delID=$("#delivery").val();if(0==delID){var fm=$("#addrform");if(false==validateForm(fm))return}var data=deliveryData();let sessionID=$("#subdel").attr("data-sid");var params="st=dodel&"+data+"&sn="+sessionID;axpost("/pax/ckoutnos",params,function(data){let paymentMethod=getPaymentMethod();if(paymentMethod=="PAYPAL"){let formData=new FormData;formData.append("sn",sessionID);formData.append("st","update-paypal-order");var jqxhr=""!==spfx?"/"+spfx:"";return fetch(jqxhr+"/pax/ckoutnos",{method:"POST",body:formData}).then(response=>({status:response.status,response:response.json()})).then(response=>{console.log(response);if(response.status==200){$("#checkout31").html(data)}else{$("#checkout31").find("#pmtstatus").text(response.message)}})}else{$("#checkout31").html(data)}})}function validateForm(fm){var outcome=true;fm.find("div.has-error").removeClass("has-error");fm.find("div.cfs-check").remove();var fields=fm.find("input,textarea,select").filter("[required]");var valid=true;fields.each(function(){var field=$(this);var reqText="";valid=true;if(false==field[0].checkValidity()){reqText="Please provide a response in the highlighted (red) area below";valid=false}else if(undefined!=field.attr("data-type")){var type=field.attr("data-type");switch(type){case"email":var email=field.val().trim();var emailRegExp=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;if(false==emailRegExp.test(email)){reqText="Please ensure that you typed a valid email address";valid=false}break;case"telephone":var tel=field.val();tel=tel.replace(/\D/g,"");var exp=/^(?:(1\-?)|(\+1 ?))?\(?(\d{3})[\)\-\.]?(\d{3})[\-\.]?(\d{4})$/;if(tel.length<9||false==exp.test(tel)){reqText="Please ensure that you entered a valid telephone number";valid=false}break}}if(false==valid){var div=field.closest("div");div.addClass("has-error");var alert='";fm.prepend(alert);field.focus();outcome=false;return false}});if(false==outcome)return false}function delBack(){var data=deliveryData();var params="st=delback&"+data+"&sn="+$("#subdel").attr("data-sid");axpost("/pax/ckoutnos",params,function(data){$("#checkout31").html(data)})}function deliveryData(){var data=$("#addrform").serialize();data+="&delid="+$("#delivery").val();return data}var cardNumber=null;var stripe=null;function initPaymentPanel(){$("#custeml").blur(function(){updateCustInfo()});$("#subpay").click(function(){submitPayment()});var style={base:{fontSize:"16px",lineHeight:"24px"}};$("#pmtform").submit(function(ev){ev.preventDefault();return false});var stripePublicKey=$("#subpay").attr("data-pk");stripe=Stripe(stripePublicKey);var ozip=$("#postalcode").attr("data-ov");var elements=stripe.elements();cardNumber=elements.create("cardNumber",{style:style});cardNumber.mount("#cardnumber");var cvc=elements.create("cardCvc",{style:style});cvc.mount("#cvc");var expiration=elements.create("cardExpiry",{style:style});expiration.mount("#expiration");var postalCode=elements.create("postalCode",{style:style});postalCode.mount("#postalcode");var zip=$("#postalcode").attr("data-ov");if(""!=zip)postalCode.update({value:zip});let paymentMethodMenu=$("#checkout31").data("paymentMethodMenu")?0:1;if(paymentMethodMenu==1){$("#checkout31").data("paymentMethodMenu",1);$(document).on("click",".accordion-header-checkout",function(){let arrow=$(this).find(".arrow-solid-icon");var panel=$(this).next();if($(panel).css("max-height")!=="0px"){$(panel).css("max-height","0px");$(arrow).removeClass("down");$(panel).css("margin-bottom","0px")}else{$(panel).css("max-height",$(panel).prop("scrollHeight")+"1px");$(arrow).addClass("down");$(panel).css("margin-bottom","20px")}if($("#debitCreditLine").next().css("max-height")!=="0px"){var panel2=$("#debitCreditPanel");$(panel2).css("margin-bottom","0px");$(".back-to-delivery-btn").addClass("open-header-checkout")}else{$(".back-to-delivery-btn").removeClass("open-header-checkout")}});$(document).on("click",function(event){if($(event.target).closest(".modal-dialog").length===0&&$(event.target).attr("id")!=="open-modal-paypal"){$(".cancel-btn").click()}})}var secondAccordion=$("#debitCreditLine");$(".back-to-delivery-btn").addClass("open-header-checkout");var secondPanel=$("#debitCreditPanel");$(secondPanel).css("max-height",$(secondPanel).prop("scrollHeight")+"1px");$(secondAccordion).find(".arrow").addClass("down");$(".accordion-header-checkout:first").click(function(){dataLayer.push({event:"checkoutOption",ecommerce:{checkout_option:{actionField:{step:2,list:"Product List Page",option:"PayPal"}}}})});$(".accordion-header-checkout:last").click(function(){dataLayer.push({event:"checkoutOption",ecommerce:{checkout_option:{actionField:{step:2,list:"Product List Page",option:"Credit Card"}}}})})}function updateCustInfo(){var email=$("#custeml").val();var sn=$("#subpay").attr("data-sid");var params="st=upcmem&sn="+sn+"&em="+email;axpost("/pax/ckoutnos",params,function(data){})}function submitPayment(){var fm=$("#pmtform");if(false==validateForm(fm))return;stripe.createToken(cardNumber).then(function(result){if(result.error){$("#pmtstatus").text(result.error.message);$("#pmtstatus").show();$("#pmttoken").val("")}else{$("#pmttoken").val(result.token.id);$("#expmonth").val(result.token.card.exp_month);$("#expyear").val(result.token.card.exp_year);$("#lastfour").val(result.token.card.last4);$("#zip").val(result.token.card.address_zip);payAction("dopay")}})}function payBack(){payAction("payback")}function payAction(act){var data=paymentData();var autoBill=$("#subpay").attr("data-ab");var params="st="+act+"&"+data+"&ab="+autoBill+"&sn="+$("#subpay").attr("data-sid");axpost("/pax/ckoutnos",params,function(data){$("#checkout31").html(data)})}function paymentData(){var data=$("#pmtform").serialize();return data}function initConfirmOrderPage(){$("#placeorder").click(function(){$("#placeorder").hide();$("#ordplwait").show();var sessionID=$("#placeorder").attr("data-sid");var params="st=doconf&sn="+sessionID;axpost("/pax/ckoutnos",params,function(data){$("#ordplwait").hide();$("#placeorder").show();$("#checkout31").html(data)})})}function createOrder(){let formData=new FormData;let sid=$("#paypal-button-container").data("sid");formData.append("sn",sid);formData.append("st","create-paypal-order");var jqxhr=""!==spfx?"/"+spfx:"";return fetch(jqxhr+"/pax/ckoutnos",{method:"POST",body:formData}).then(response=>response.json()).then(order=>order.id).catch(error=>{console.error("Error occurred during order creation:",error);$(document).find("#pmtstatus").html(`Error occurred during order creation: ${error}`)})}function onApprove(){let formData=new FormData;let sid=$("#paypal-button-container").data("sid");formData.append("sn",sid);formData.append("st","get-paypal-order");var jqxhr=""!==spfx?"/"+spfx:"";return fetch(jqxhr+"/pax/ckoutnos",{method:"POST",body:formData}).then(response=>{if(!response.ok){$(document).find("#pmtstatus").html("Error occurred while fetching PayPal order.")}return response.json()}).then(result=>{let fm=$("#pmtform");fm.find('input[name="telephone"]').val(result?.payment_source?.paypal?.phone_number?.national_number);fm.find('input[name="email"]').val(result?.payment_source?.paypal?.email_address);fm.find('input[name="first"]').val(result?.payment_source?.paypal?.name?.given_name);fm.find('input[name="last"]').val(result?.payment_source?.paypal?.name?.surname);fm.find('input[name="city"]').val(result?.payment_source?.paypal?.address?.admin_area_2);fm.find('input[name="street"]').val(result?.payment_source?.paypal?.address?.address_line_1);fm.find('input[name="zip"]').val(result?.payment_source?.paypal?.address?.postal_code);fm.find('input[name="postal"]').val(result?.payment_source?.paypal?.address?.postal_code);fm.find('select[name="state"]').val(result?.payment_source?.paypal?.address?.admin_area_1);fm.find('input[name="paymentMethod"]').val("PAYPAL");$(document).find("#checkout31").data("payment-method","PAYPAL");payAction("dopay")}).catch(error=>{console.error("Error occurred during PayPal order processing:",error);$(document).find("#pmtstatus").html(`An error occurred during PayPal order processing: ${error}`)})}function getPaymentMethod(){return $(document).find("#checkout31").data("payment-method")?$(document).find("#checkout31").data("payment-method"):null}function initPaypalButton(){if(window.paypal&&window.paypal.Buttons){paypal.Buttons({style:{shape:"pill",height:38,tagline:false},createOrder:createOrder,onApprove:onApprove,onError(error){console.error("PayPal checkout error:",error);if(window.newrelic){window.newrelic.noticeError(error)}$(document).find("#pmtstatus").html("An error occurred during PayPal checkout. Please try again.")}}).render("#paypal-button-container")}else{}}function removeTree(finalStage,sessionID){if(confirm("Are you sure that you want to remove the memorial tree option from your order?")){var params="st=rmtree&sn="+sessionID+"&finst="+finalStage;axpost("/pax/ckoutnos",params,function(data){if(1!=finalStage){$("#chgsum").html(data)}else{let paymentMethod=getPaymentMethod();if(paymentMethod=="PAYPAL"){let formData=new FormData;formData.append("sn",sessionID);formData.append("st","update-paypal-order");var jqxhr=""!==spfx?"/"+spfx:"";return fetch(jqxhr+"/pax/ckoutnos",{method:"POST",body:formData}).then(response=>({status:response.status,response:response.json()})).then(response=>{if(response.status==200){$("#checkout31").html(data)}else{$("#checkout31").find("#pmtstatus").text(response.message)}})}else{$("#checkout31").html(data)}}})}}function ckstep(step,sessionID,checkPay=true){var params="st="+step+"&sn="+sessionID;if(step=="pay"&&!checkPay){$(document).find("#checkout31").removeAttr("data-payment-method")}if(step=="pay"&&checkPay){$("#paypalModal").modal("show")}else{axpost("/pax/ckoutnos",params,function(data){$("#checkout31").html(data)})}}async function initStoreInventory(){$("#invfilters input[name=invpftr]").click(function(){var fid=$(this).val();$("#xsfilters .xspfltr").removeClass("selected");if($(this).is(":checked"))$("#xsfilters .xspfltr[data-id="+fid+"]").addClass("selected");if(0==fid&&$(this).is(":checked")){$("#invfilters input[name=invpftr]").not($(this)).prop("checked",false);localStorage.setItem("0",1);localStorage.setItem("1",0);localStorage.setItem("2",0);localStorage.setItem("3",0)}else{$("#invfilters input[name=invpftr]:first").prop("checked",false);localStorage.setItem("0",0)}if(0==$("#invfilters input[name=invpftr]:checked").length){$("#invfilters input[name=invpftr]:first").prop("checked","true");$("#xsfilters .xspfltr[data-id=0]").addClass("selected");localStorage.setItem("0",1)}if(0==$("#xsfilters .xspfltr.selected").length){var opt=$("#invfilters input[name=invpftr]:checked:first");$("#xsfilters .xspfltr[data-id="+opt.val()+"]").addClass("selected")}$.each($("#invfilters input[name=invpftr]"),function(){$("#xsfilters input[name=invpftr][value="+$(this).val()+"]").prop("checked",$(this).prop("checked"))});if(0!=fid){localStorage.setItem($(this).attr("value"),$(this).is(":checked")?1:0)}applyFilters(true)});$("#xsfilters .xspfltr").click(function(){var fid=$(this).attr("data-id");$("#xsfilters .xspfltr").removeClass("selected");$("#invfilters input[name=invpftr]").prop("checked",false);$(this).addClass("selected");$("#invfilters input[name=invpftr][value="+fid+"]").prop("checked",true);applyFilters(true)});$("#invfilters input[name=invcftr]").click(function(){var fid=$(this).val();if(0==fid&&$(this).is(":checked")){$("#invfilters input[name=invcftr]").not($(this)).prop("checked",false)}else{$("#invfilters input[name=invcftr]:first").prop("checked",false)}if(0==$("#invfilters input[name=invcftr]:checked").length){$("#invfilters input[name=invcftr]:first").prop("checked","true")}$.each($("#invfilters input[name=invcftr]"),function(){fid=$(this).val();$("#xsfilters input[name=invcftr][value="+fid+"]").prop("checked",$(this).prop("checked"))});applyFilters(true)});$("#xsfilters input[name=invcftr]").click(function(){var fid=$(this).val();if(0==fid&&$(this).is(":checked")){$("#xsfilters input[name=invcftr]").not($(this)).prop("checked",false)}else{$("#xsfilters input[name=invcftr]:first").prop("checked",false)}if(0==$("#xsfilters input[name=invcftr]:checked").length){$("#xsfilters input[name=invcftr]:first").prop("checked","true")}$.each($("#xsfilters input[name=invcftr]"),function(){fid=$(this).val();$("#invfilters input[name=invcftr][value="+fid+"]").prop("checked",$(this).prop("checked"))});applyFilters(true)});if(0==$("#invfilters input[name=invcftr]:checked").length)$("#invfilters input[name=invcftr]:first").prop("checked","true");if(0==$("#invfilters input[name=invpftr]:checked").length)$("#invfilters input[name=invpftr]:first").prop("checked","true");await applyFilters(false)}async function applyFilters(updateServerState){var priceAll=$("#invfilters input[name=invpftr]:first");var catAll=$("#invfilters input[name=invcftr]:first");var state="";$("#invnomatch").hide();if(priceAll.is(":checked")&&catAll.is(":checked")){adjustPricesWhenAllChecked();$("#inventoryzone .inv-cell").show();await axpost("/pax/invflr","st=p0,c0",function(){});return}$("#inventoryzone .inv-cell").hide();$("#inventoryzone .inv-cell").attr("data-sh",0);if(catAll.is(":checked")){$("#inventoryzone .inv-cell").attr("data-sh",1);state+=",c0"}else{$.each($("#invfilters input[name=invcftr]:checked"),function(){var catID=$(this).val();$("#inventoryzone .inv-cell[data-cfid="+catID+"]").attr("data-sh",1);state+=",c"+catID})}var collection=$("#inventoryzone .inv-cell[data-sh=1]");if(priceAll.is(":checked")){adjustPricesWhenAllChecked();collection.show();state+=",p0"}else{$.each($("#invfilters input[name=invpftr]:checked"),function(){var priceID=$(this).val();var pfidElementsAlreadyVisible=$("#inventoryzone .inv-cell[data-sh=1][data-pfid="+priceID+"]");pfidElementsAlreadyVisible=adjustPriceString(pfidElementsAlreadyVisible,"");var pfid2ElementsAlreadyVisible=$("#inventoryzone .inv-cell[data-sh=1][data-pfid2="+priceID+"]");pfid2ElementsAlreadyVisible=adjustPriceString(pfid2ElementsAlreadyVisible,"");var pfid3ElementsAlreadyVisible=$("#inventoryzone .inv-cell[data-sh=1][data-pfid3="+priceID+"]");pfid3ElementsAlreadyVisible=adjustPriceString(pfid3ElementsAlreadyVisible,"");$("#inventoryzone .inv-cell[data-sh=1][data-pfid="+priceID+"]").show();var pfid2ElementsHidden=$("#inventoryzone .inv-cell[data-sh=1][data-pfid2="+priceID+"]:hidden");pfid2ElementsHidden=adjustPriceString(pfid2ElementsHidden,2);$(pfid2ElementsHidden).show();var pfid3ElementsHidden=$("#inventoryzone .inv-cell[data-sh=1][data-pfid3="+priceID+"]:hidden");pfid3ElementsHidden=adjustPriceString(pfid3ElementsHidden,3);$(pfid3ElementsHidden).show();state+=",p"+priceID})}if(0==$("#inventoryzone .inv-cell:visible").length&&false==priceAll.is(":checked")){$("#invnomatch").show()}if($("#invfilters input[name=invcftr]")[0].checked||$("#invfilters input[name=invcftr]")[1].checked){$("#inventoryzone .inv-cell[data-pfid=4]").show()}await axpost("/pax/invflr","st="+state,function(){})}function adjustPricesWhenAllChecked(){var pfidElementsAlreadyVisible=$("#inventoryzone .inv-cell[data-sh=1][data-pfid]");pfidElementsAlreadyVisible=adjustPriceString(pfidElementsAlreadyVisible,"")}function adjustPriceString(elementArray,pfid){$(elementArray).each(function(index,element){var fromPrice2Text=$("div.price",element).text().trim();if(0===fromPrice2Text.indexOf("From ")){var discountedText=$("span.discounted.price",element);if($(discountedText).length){discountedText=discountedText[0].outerHTML}else{discountedText=""}var substitutePrice=$("div.invprodimg",element).data("pr"+pfid);$("div.price",element).html("\t\t\tFrom $"+substitutePrice+"\t\t"+discountedText)}});return elementArray}function attachFilterEvents(){$("#invfilters input:checkbox").change(function(e,triggerDataLayer=true){if(this.checked){if(typeof $(this).parent()==="undefined")return;let label=$(this).parent().text().trim();let prefix=label!="All"?"":$(this).attr("name")==="invcftr"?"Type ":"Price ";if(triggerDataLayer){dataLayer.push({event:"gaEvent",category:"Store",action:"Filter Click",label:prefix+label})}}});$("#xsfilters input:checkbox").change(function(e,triggerDataLayer=true){if(this.checked){if(typeof $(this).parent()==="undefined")return;let label=$(this).parent().text().trim();let prefix=label!="All"?"":$(this).attr("name")==="invcftr"?"Type ":"Price ";console.log(prefix+label);if(triggerDataLayer){dataLayer.push({event:"gaEvent",category:"Store",action:"Filter Click",label:prefix+label})}}})}function editMsg(){var data=deliveryData();var snId=$("button[data-sid]").attr("data-sid");var params="st=editmsg&"+data+"&sn="+snId;dataLayer.push({event:"gaEvent",category:"Checkout",action:"Navigation",label:"Optional: Add a Card Message"});axpost("/pax/ckoutnos",params,function(data){$("#checkout31").html(data)})}$.fn.isInViewport=function(){var elementTop=$(this).offset().top;var elementBottom=elementTop+$(this).outerHeight();var viewportTop=$(window).scrollTop();var viewportBottom=viewportTop+$(window).height();return elementBottom>viewportTop&&elementTop