function PaymentWidgetsProductLoadPrice(){var n="";jq("#trCurrentPrice span.currentprice").length?n="#trCurrentPrice span.currentprice":jq(".productdescription span.spn_CP").length&&(n=".productdescription span.spn_CP");n!=""&&(ke_Actpmts.indexOf("|10|")>-1&&setBuyNowPayLaterPaymentType1ProductPage(n,"Afterpay",4,"AUD,NZD",!0),ke_Actpmts.indexOf("|11|")>-1&&setBuyNowPayLaterPaymentType1ProductPage(n,"Laybuy",6,"NZD,AUD,GBP",!1),ke_Actpmts.indexOf("|12|")>-1&&setBuyNowPayLaterPaymentType1ProductPage(n,"Zip",4,"NZD",!0));ke_Actpmts.indexOf("|13|")>-1&&setBuyNowPayLaterPaymentType2ProductPage("ZipPay","AUD")}function PaymentWidgetsCartGetDetails(){var t=".footerstyle .cell_footer_amount .cell_footer_totalvalue",n;(jq(t).length||(t=".footerstyle .cell_footer_amount",jq(t).length||(t=".pd-footer .cell_footer_amount")),jq(t).attr("data-isrunning")!="1")&&(jq(t).attr("data-isrunning","1"),jq(t).length&&(ke_Actpmts.indexOf("|10|")>-1&&(n="Afterpay","AUD"==ke_Currency&&typeof ke_BNPLExcl!="undefined"&&(ke_BNPLExcl.substring(0,1)=="2"||ke_BNPLExcl.substring(0,1)=="3")&&"has_sale_item"in ke_Cart&&ke_Cart.has_sale_item?jq("#"+n+"WidgetContainer").hide():"AUD"==ke_Currency&&typeof ke_BNPLExcl!="undefined"&&(ke_BNPLExcl.substring(0,1)=="1"||ke_BNPLExcl.substring(0,1)=="3")&&"has_gift_card"in ke_Cart&&ke_Cart.has_gift_card?jq("#"+n+"WidgetContainer").hide():"NZD"==ke_Currency&&typeof ke_BNPLExcl!="undefined"&&(ke_BNPLExcl.substring(1,2)=="2"||ke_BNPLExcl.substring(1,2)=="3")&&"has_sale_item"in ke_Cart&&ke_Cart.has_sale_item?jq("#"+n+"WidgetContainer").hide():"NZD"==ke_Currency&&typeof ke_BNPLExcl!="undefined"&&(ke_BNPLExcl.substring(1,2)=="1"||ke_BNPLExcl.substring(1,2)=="3")&&"has_gift_card"in ke_Cart&&ke_Cart.has_gift_card?jq("#"+n+"WidgetContainer").hide():(jq("#"+n+"WidgetContainer").show(),setBuyNowPayLaterPaymentType1CartPage(t,n,4,"AUD,NZD",!0))),ke_Actpmts.indexOf("|11|")>-1&&(n="Laybuy",typeof ke_BNPLExcl!="undefined"&&(ke_BNPLExcl.substring(2,3)=="2"||ke_BNPLExcl.substring(2,3)=="3")&&"has_sale_item"in ke_Cart&&ke_Cart.has_sale_item?jq("#"+n+"WidgetContainer").hide():typeof ke_BNPLExcl!="undefined"&&(ke_BNPLExcl.substring(2,3)=="1"||ke_BNPLExcl.substring(2,3)=="3")&&"has_gift_card"in ke_Cart&&ke_Cart.has_gift_card?jq("#"+n+"WidgetContainer").hide():(jq("#"+n+"WidgetContainer").show(),setBuyNowPayLaterPaymentType1CartPage(t,n,6,"NZD,AUD,GBP",!1))),ke_Actpmts.indexOf("|12|")>-1&&(n="Zip",typeof ke_BNPLExcl!="undefined"&&(ke_BNPLExcl.substring(4,5)=="2"||ke_BNPLExcl.substring(4,5)=="3")&&"has_sale_item"in ke_Cart&&ke_Cart.has_sale_item?jq("#"+n+"WidgetContainer").hide():typeof ke_BNPLExcl!="undefined"&&(ke_BNPLExcl.substring(4,5)=="1"||ke_BNPLExcl.substring(4,5)=="3")&&"has_gift_card"in ke_Cart&&ke_Cart.has_gift_card?jq("#"+n+"WidgetContainer").hide():(jq("#"+n+"WidgetContainer").show(),setBuyNowPayLaterPaymentType1CartPage(t,n,4,"NZD",!0)))),ke_Actpmts.indexOf("|13|")>-1&&(n="ZipPay",typeof ke_BNPLExcl!="undefined"&&(ke_BNPLExcl.substring(3,4)=="2"||ke_BNPLExcl.substring(3,4)=="3")&&"has_sale_item"in ke_Cart&&ke_Cart.has_sale_item?jq("#"+n+"WidgetContainer").hide():typeof ke_BNPLExcl!="undefined"&&(ke_BNPLExcl.substring(3,4)=="1"||ke_BNPLExcl.substring(3,4)=="3")&&"has_gift_card"in ke_Cart&&ke_Cart.has_gift_card?jq("#"+n+"WidgetContainer").hide():(jq("#"+n+"WidgetContainer").show(),setBuyNowPayLaterPaymentType2CartPage(n,"AUD"))),jq(t).attr("data-isrunning","0"))}function PaymentWidgetsCheckoutSetOrderSummary(){ke_Actpmts.indexOf("|10|")>-1&&setBuyNowPayLaterPaymentType1CheckoutPage("Afterpay",4,"AUD,NZD");ke_Actpmts.indexOf("|11|")>-1&&setBuyNowPayLaterPaymentType1CheckoutPage("Laybuy",6,"NZD,AUD,GBP");ke_Actpmts.indexOf("|12|")>-1&&setBuyNowPayLaterPaymentType1CheckoutPage("Zip",4,"NZD");ke_Actpmts.indexOf("|13|")>-1&&setBuyNowPayLaterPaymentType2CheckoutPage("ZipPay","AUD")}function showBuyNowPayLaterContentPopup(n,t,i,r){if(n=="")window.open(t,"_blank");else{var u="<iframe style='border:0;width:"+i+";height:"+r+";' data-iso3166='"+(ke_CountryBill2!=""?ke_CountryBill2:ke_CountryISO3166)+"' src='"+t+"'><\/iframe>";popupWindowExist();InitialisePopup(n,-1,!1,!0);jq("#"+popupContainerId+" .popupDetails").html(u);ShowPopup();CenterPopup()}}function popupWindowExist(){jq(".popupWindow").length&&(jq(".popupWindow").length!=1||jq(".popupWindow").prop("id")!="splashPopupPayment")||jq("#bodywrapper").append("<div id='popupContent' class='popupWindow'><a class='popupClose' href='javascript:void(0)'><\/a><div class='popupDetails'><\/div><\/div><div class='backgroundPopup'><\/div>")}function getPaymentConfig(containerId,payment,spend,priceType,rule,times){jq.ajax({type:"POST",url:"/webservice/orderservice.asmx/paymentconfig",data:"{payment:'"+payment.toLowerCase()+"', spend:"+spend+", currencySet:'"+ke_Currency+"', priceType:'"+priceType+"', rule:'"+rule+"'}",contentType:"application/json; charset=utf-8",dataType:"json",cache:!1,dataFilter:function(data){var msg;return msg=typeof JSON!="undefined"&&typeof JSON.parse=="function"?JSON.parse(data):eval("("+data+")"),msg.hasOwnProperty("d")?msg.d:msg},beforeSend:function(n){n.setRequestHeader("STicket",jq("#hidWebserviceTicket").val())},success:function(n){var t="";n!=null?payment.toLowerCase()=="zip"?jq("#"+containerId).attr("data-widgetloaded")=="1"?jq("#"+containerId+" #partPayCalculatorWidgetTextFromCopy>span").length&&jq("#"+containerId+" #partPayCalculatorWidgetTextFromCopy>span").text(PriceWithCurrency(Round(ParseFloat(spend)/times,2))):(jq("#"+containerId).attr("data-widgetloaded","1"),jq("#"+containerId).html("<script async src='https://widgets.partpay.co.nz/partpay-widget-0.1.1.js?type=calculator&min="+n.minSpend+"&max="+n.maxSpend+"&amount="+spend+"'><\/script>")):(AfterpayWidgetHtml==""&&(AfterpayWidgetHtml=jq("#"+containerId).html()),n.message!=""?jq("#"+containerId).html(n.message):n.exceeded?typeof AfterpaySpendingRangeErrorHtml!="undefined"?(t=AfterpaySpendingRangeErrorHtml,t.indexOf("{0}")>-1&&(t=ReplaceAll(t,"{0}",GetTotalPrefix()+n.minSpend)),t.indexOf("{1}")>-1&&(t=ReplaceAll(t,"{1}",GetTotalPrefix()+n.maxSpend)),jq("#"+containerId).html(t)):jq("#"+containerId).html('<div class="payment-widget-invalid">Spending between '+GetTotalPrefix()+n.minSpend+" and "+GetTotalPrefix()+n.maxSpend+" is eligible for "+payment+".<\/div>"):(AfterpayWidgetHtml==""||jq("#"+containerId+" ."+payment.toLowerCase()+"-amount").length||jq("#"+containerId).html(AfterpayWidgetHtml),jq("#"+containerId+" ."+payment.toLowerCase()+"-amount").text(PriceWithCurrency(Round(ParseFloat(spend)/times,2))))):(AfterpayWidgetHtml==""&&(AfterpayWidgetHtml=jq("#"+containerId).html()),typeof AfterpayGenericErrorHtml!="undefined"?(t=AfterpayGenericErrorHtml,t.indexOf("{0}")>-1&&(t=ReplaceAll(t,"{0}",payment+" is NOT eligible. Please check account details at admin.")),jq("#"+containerId).html(t)):jq("#"+containerId).html('<div class="payment-widget-invalid">'+payment+" is NOT eligible. Please check account details at admin.<\/div>"))},error:function(n){n.status!="0"&&(AfterpayWidgetHtml==""&&(AfterpayWidgetHtml=jq("#"+containerId).html()),typeof AfterpayGenericErrorHtml!="undefined"?(html=AfterpayGenericErrorHtml,html.indexOf("{0}")>-1&&(html=ReplaceAll(html,"{0}",n.status+" "+n.statusText)),jq("#"+containerId).html(html)):jq("#"+containerId).html('<div class="payment-widget-invalid">Sorry but there was an error: '+n.status+" "+n.statusText+"<\/div>"))}})}function setBuyNowPayLaterPaymentType1ProductPage(n,t,i,r,u){if(jq("#"+t+"WidgetContainer").length)if(r.indexOf(ke_Currency)>-1)if(jq(n).html().trim()=="")setTimeout(function(){setBuyNowPayLaterPaymentType1ProductPage(n,t,i,r,u)},200);else if(u){var f=jq("#"+t+"WidgetContainer").attr("data-validationrule")||"0";getPaymentConfig(t+"WidgetContainer",t,PriceCurrencyToNumber(jq(n).html()).toString(),"price",f,i);jq("#"+t+"WidgetContainer").data("widgetloaded","0")}else jq("#"+t+"WidgetContainer ."+t.toLowerCase()+"-amount").html(PriceWithCurrency(Round(PriceCurrencyToNumber(jq(n).html())/i,2)));else jq("#"+t+"WidgetContainer").hide()}function setBuyNowPayLaterPaymentType2ProductPage(n,t){if(jq("#"+n+"WidgetContainer").length)if(t==""||ke_Currency==t){if(jq("#"+n+"WidgetConfiguration").length&&jq("#"+n+"WidgetConfiguration").attr("data-zm-merchant",ke_Zpkey).attr("data-env",ke_Zpenv=="1"?"sandbox":"production"),jq("#"+n+"WidgetContainer").show(),jq("#"+n+"WidgetScriptContainer").length){var i=document.createElement("script");i.src="https://static.zipmoney.com.au/lib/js/zm-widget-js/dist/zip-widget.min.js";jq("#"+n+"WidgetScriptContainer").html(i)}}else jq("#"+n+"WidgetContainer").hide()}function setBuyNowPayLaterPaymentType1CartPage(n,t,i,r,u){jq("#"+t+"WidgetContainer").length&&(r.indexOf(ke_Currency)>-1?u?getPaymentConfig(t+"WidgetContainer",t,TotalCurrencyToNumber(jq(n).html()).toString(),"total","0",i):jq("#"+t+"WidgetContainer ."+t.toLowerCase()+"-amount").html(TotalWithCurrency(Round(TotalCurrencyToNumber(jq(n).html())/i,2))):jq("#"+t+"WidgetContainer").hide())}function setBuyNowPayLaterPaymentType2CartPage(n,t){setBuyNowPayLaterPaymentType2ProductPage(n,t)}function setBuyNowPayLaterPaymentType1CheckoutPage(n,t,i){if(jq("#"+n+"WidgetContainer").length)if(i.indexOf(ke_Currency)>-1){var r=n.toLowerCase()=="zip"?1:0;jq("#"+n+"WidgetContainer ."+n.toLowerCase()+"-amount").html(TotalWithCurrency(Round(TotalCurrencyToNumber(jq("#"+lblOrderSummaryTotalClientID).html())/t,2,r)));jq("#"+n+"WidgetContainer ."+n.toLowerCase()+"-total-amount").html(jq("#"+lblOrderSummaryTotalClientID).html())}else jq("#"+n+"WidgetContainer").hide()}function setBuyNowPayLaterPaymentType2CheckoutPage(n,t){setBuyNowPayLaterPaymentType2ProductPage(n,t)}var AfterpaySpendingRangeErrorHtml,AfterpayGenericErrorHtml,AfterpayWidgetHtml="";jq(function(){jq("body").hasClass("EPSHOPPINGCART")&&jq("#divShoppingCart").length&&PaymentWidgetsCartGetDetails();jq("body").hasClass("EPCHECKOUT")&&jq(".stepshipping").length&&PaymentWidgetsCheckoutSetOrderSummary()});
