function PaymentWidgetsProductLoadPrice(){var selector="";jq("#trCurrentPrice span.currentprice").length?selector="#trCurrentPrice span.currentprice":jq(".productdescription span.spn_CP").length&&(selector=".productdescription span.spn_CP");selector!=""&&(ke_Actpmts.indexOf("|10|")>-1&&setBuyNowPayLaterPaymentType1ProductPage(selector,"Afterpay",4,"AUD,NZD",!0),ke_Actpmts.indexOf("|11|")>-1&&setBuyNowPayLaterPaymentType1ProductPage(selector,"Laybuy",6,"NZD,AUD,GBP",!1),ke_Actpmts.indexOf("|12|")>-1&&setBuyNowPayLaterPaymentType1ProductPage(selector,"Zip",4,"NZD",!0));ke_Actpmts.indexOf("|13|")>-1&&setBuyNowPayLaterPaymentType2ProductPage("ZipPay","AUD")}function PaymentWidgetsCartGetDetails(){var selector=".footerstyle .cell_footer_amount .cell_footer_totalvalue",pmt;(jq(selector).length||(selector=".footerstyle .cell_footer_amount",jq(selector).length||(selector=".pd-footer .cell_footer_amount")),jq(selector).attr("data-isrunning")!="1")&&(jq(selector).attr("data-isrunning","1"),jq(selector).length&&(ke_Actpmts.indexOf("|10|")>-1&&(pmt="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("#"+pmt+"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("#"+pmt+"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("#"+pmt+"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("#"+pmt+"WidgetContainer").hide():(jq("#"+pmt+"WidgetContainer").show(),setBuyNowPayLaterPaymentType1CartPage(selector,pmt,4,"AUD,NZD",!0))),ke_Actpmts.indexOf("|11|")>-1&&(pmt="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("#"+pmt+"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("#"+pmt+"WidgetContainer").hide():(jq("#"+pmt+"WidgetContainer").show(),setBuyNowPayLaterPaymentType1CartPage(selector,pmt,6,"NZD,AUD,GBP",!1))),ke_Actpmts.indexOf("|12|")>-1&&(pmt="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("#"+pmt+"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("#"+pmt+"WidgetContainer").hide():(jq("#"+pmt+"WidgetContainer").show(),setBuyNowPayLaterPaymentType1CartPage(selector,pmt,4,"NZD",!0)))),ke_Actpmts.indexOf("|13|")>-1&&(pmt="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("#"+pmt+"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("#"+pmt+"WidgetContainer").hide():(jq("#"+pmt+"WidgetContainer").show(),setBuyNowPayLaterPaymentType2CartPage(pmt,"AUD"))),jq(selector).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(id,src,width,height){if(id=="")window.open(src,"_blank");else{var html="<iframe style='border:0;width:"+width+";height:"+height+";' data-iso3166='"+(ke_CountryBill2!=""?ke_CountryBill2:ke_CountryISO3166)+"' src='"+src+"'><\/iframe>";popupWindowExist();InitialisePopup(id,-1,!1,!0);jq("#"+popupContainerId+" .popupDetails").html(html);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(xhr){xhr.setRequestHeader("STicket",jq("#hidWebserviceTicket").val())},success:function(data){var html="";data!=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="+data.minSpend+"&max="+data.maxSpend+"&amount="+spend+"'><\/script>")):(AfterpayWidgetHtml==""&&(AfterpayWidgetHtml=jq("#"+containerId).html()),data.message!=""?jq("#"+containerId).html(data.message):data.exceeded?typeof AfterpaySpendingRangeErrorHtml!="undefined"?(html=AfterpaySpendingRangeErrorHtml,html.indexOf("{0}")>-1&&(html=ReplaceAll(html,"{0}",GetTotalPrefix()+data.minSpend)),html.indexOf("{1}")>-1&&(html=ReplaceAll(html,"{1}",GetTotalPrefix()+data.maxSpend)),jq("#"+containerId).html(html)):jq("#"+containerId).html('<div class="payment-widget-invalid">Spending between '+GetTotalPrefix()+data.minSpend+" and "+GetTotalPrefix()+data.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"?(html=AfterpayGenericErrorHtml,html.indexOf("{0}")>-1&&(html=ReplaceAll(html,"{0}",payment+" is NOT eligible. Please check account details at admin.")),jq("#"+containerId).html(html)):jq("#"+containerId).html('<div class="payment-widget-invalid">'+payment+" is NOT eligible. Please check account details at admin.<\/div>"))},error:function(xhr){xhr.status!="0"&&(AfterpayWidgetHtml==""&&(AfterpayWidgetHtml=jq("#"+containerId).html()),typeof AfterpayGenericErrorHtml!="undefined"?(html=AfterpayGenericErrorHtml,html.indexOf("{0}")>-1&&(html=ReplaceAll(html,"{0}",xhr.status+" "+xhr.statusText)),jq("#"+containerId).html(html)):jq("#"+containerId).html('<div class="payment-widget-invalid">Sorry but there was an error: '+xhr.status+" "+xhr.statusText+"<\/div>"))}})}function setBuyNowPayLaterPaymentType1ProductPage(selector,payment,times,currency,getConfig){if(jq("#"+payment+"WidgetContainer").length)if(currency.indexOf(ke_Currency)>-1)if(jq(selector).html().trim()=="")setTimeout(function(){setBuyNowPayLaterPaymentType1ProductPage(selector,payment,times,currency,getConfig)},200);else if(getConfig){var rule=jq("#"+payment+"WidgetContainer").attr("data-validationrule")||"0";getPaymentConfig(payment+"WidgetContainer",payment,PriceCurrencyToNumber(jq(selector).html()).toString(),"price",rule,times);jq("#"+payment+"WidgetContainer").data("widgetloaded","0")}else jq("#"+payment+"WidgetContainer ."+payment.toLowerCase()+"-amount").html(PriceWithCurrency(Round(PriceCurrencyToNumber(jq(selector).html())/times,2)));else jq("#"+payment+"WidgetContainer").hide()}function setBuyNowPayLaterPaymentType2ProductPage(payment,currency){if(jq("#"+payment+"WidgetContainer").length)if(currency==""||ke_Currency==currency){if(jq("#"+payment+"WidgetConfiguration").length&&jq("#"+payment+"WidgetConfiguration").attr("data-zm-merchant",ke_Zpkey).attr("data-env",ke_Zpenv=="1"?"sandbox":"production"),jq("#"+payment+"WidgetContainer").show(),jq("#"+payment+"WidgetScriptContainer").length){var script=document.createElement("script");script.src="https://static.zipmoney.com.au/lib/js/zm-widget-js/dist/zip-widget.min.js";jq("#"+payment+"WidgetScriptContainer").html(script)}}else jq("#"+payment+"WidgetContainer").hide()}function setBuyNowPayLaterPaymentType1CartPage(selector,payment,times,currency,getConfig){jq("#"+payment+"WidgetContainer").length&&(currency.indexOf(ke_Currency)>-1?getConfig?getPaymentConfig(payment+"WidgetContainer",payment,TotalCurrencyToNumber(jq(selector).html()).toString(),"total","0",times):jq("#"+payment+"WidgetContainer ."+payment.toLowerCase()+"-amount").html(TotalWithCurrency(Round(TotalCurrencyToNumber(jq(selector).html())/times,2))):jq("#"+payment+"WidgetContainer").hide())}function setBuyNowPayLaterPaymentType2CartPage(payment,currency){setBuyNowPayLaterPaymentType2ProductPage(payment,currency)}function setBuyNowPayLaterPaymentType1CheckoutPage(payment,times,currency){if(jq("#"+payment+"WidgetContainer").length)if(currency.indexOf(ke_Currency)>-1){var rounding=payment.toLowerCase()=="zip"?1:0;jq("#"+payment+"WidgetContainer ."+payment.toLowerCase()+"-amount").html(TotalWithCurrency(Round(TotalCurrencyToNumber(jq("#"+lblOrderSummaryTotalClientID).html())/times,2,rounding)));jq("#"+payment+"WidgetContainer ."+payment.toLowerCase()+"-total-amount").html(jq("#"+lblOrderSummaryTotalClientID).html())}else jq("#"+payment+"WidgetContainer").hide()}function setBuyNowPayLaterPaymentType2CheckoutPage(payment,currency){setBuyNowPayLaterPaymentType2ProductPage(payment,currency)}var AfterpaySpendingRangeErrorHtml,AfterpayGenericErrorHtml,AfterpayWidgetHtml="";jq(function(){jq("body").hasClass("EPSHOPPINGCART")&&jq("#divShoppingCart").length&&PaymentWidgetsCartGetDetails();jq("body").hasClass("EPCHECKOUT")&&jq(".stepshipping").length&&PaymentWidgetsCheckoutSetOrderSummary()});
