var go_firstpaymentpicker;enquire.register("screen and (min-width: 981px)",{match:function(){$("body").addClass("desktop")},unmatch:function(){initselect2();$("body").removeClass("desktop")}}).register("screen and (min-width: 601px) and (max-width: 980px)",{match:function(){$("body").addClass("tablet")},unmatch:function(){$("body").removeClass("tablet")}}).register("screen and (max-width: 600px)",{match:function(){$("body").addClass("mobile")},unmatch:function(){$("body").removeClass("mobile")}});
var checkinputerror=function(){var a=$(this).attr("name");a=$('[data-input="'+a+'"]');"undefined"!=typeof a.html()&&a.hasClass("j-show")&&a.removeClass("j-show")},postformfields=function(a){a=$(this).attr("name");a=$('[data-input="'+a+'"]');"undefined"!=typeof a.html()&&a.hasClass("j-show")&&a.removeClass("j-show");console.log("checking..");$.ajax({type:"POST",url:"/"+gs_pagename,data:$("#appform").serializeArray(),error:function(a){}}).done(function(a){a.success?($(".switchBtnWrap").removeClass("j-disabledBtn"),
console.log("success")):($(".switchBtnWrap").addClass("j-disabledBtn"),console.log("fail"));renderminicart()})},creditformfields=function(a){a=$("#creditform").serializeArray();var b=!0;$.each(a,function(a,d){""===d.value&&(b=!1)});b?$(".switchBtnWrap").removeClass("j-disabledBtn"):$(".switchBtnWrap").addClass("j-disabledBtn")};initselect2();function initselect2(){initselectelement($(".p-defSelect:not(.breedSelect) select"));$(".breedSelect select").select2()}
function initfirstpaymentpicker(a){$(".j-firstpayment").show();switch(a){case "weekly":$("#creditnote").html("");a=moment();a.add(8,"d");var b=moment();b.add(14,"d");go_firstpaymentpicker=new Pikaday({field:document.getElementById("firstpaymentpicker"),format:"DD/MM/YYYY",defaultDate:a.toDate(),minDate:a.toDate(),maxDate:b.toDate(),onSelect:function(){$("#commencedate").html(this.getMoment().format("DD/MM/YYYY"))}});break;case "fortnightly":$("#creditnote").html("");a=moment();a.add(8,"d");b=moment();
b.add(21,"d");go_firstpaymentpicker=new Pikaday({field:document.getElementById("firstpaymentpicker"),format:"DD/MM/YYYY",defaultDate:a.toDate(),minDate:a.toDate(),maxDate:b.toDate(),onSelect:function(){$("#commencedate").html(this.getMoment().format("DD/MM/YYYY"))}});break;case "monthly":a=moment(),a.add(2,"d"),b=moment(),b.add(1,"M"),b.add(1,"d"),go_firstpaymentpicker=new Pikaday({field:document.getElementById("firstpaymentpicker"),format:"DD/MM/YYYY",defaultDate:a.toDate(),minDate:a.toDate(),maxDate:b.toDate(),
onSelect:function(){$("#commencedate").html(this.getMoment().format("DD/MM/YYYY"))}})}}function renderminicart(){$.ajax({type:"POST",url:"/cart-ajax",data:{action:"render-cart-mini"},error:function(a){console.log(a.error)}}).done(function(a){a.success?a.count?$(".planAdded.j-active").replaceWith(a.html):$(".planAdded.j-active").html(""):console.log(a);a.outstanding&&"apply-step-3"==gs_pagename&&($("#debitamount").html(a.outstanding),$("#creditamount").html(a.outstanding))})}
function initselectelement(a){a&&a.select2({minimumResultsForSearch:Infinity});a.on("select2:select",function(a){var b=$(this).attr("name"),d=$(this).val();" undefined"!=typeof d&&d&&$('[data-input="'+b+'"]').removeClass("j-show");switch(b){case "paymentmethod":$(".paymentOption").hide();$(".deetsBtn").hide();switch(d){case "directdebit":$(".debitCardWrap").show();$(".completeBtn").show();break;case "creditcard":$(".creditCardWrap").show(),$(".makePaymentBtn").show()}togglepaymentmsg();break;case "paymentfrequency":$('select[name="paymentmethod"]').val("").trigger("change");
$(".paymentOption").hide();$(".deetsBtn").hide();"object"===typeof go_firstpaymentpicker&&go_firstpaymentpicker.destroy();switch(d){case "weekly":$(".debitCardWrap").show();$(".completeBtn").show();initfirstpaymentpicker("weekly");break;case "fortnightly":$(".debitCardWrap").show();$(".completeBtn").show();initfirstpaymentpicker("fortnightly");break;case "monthly":$(".completeBtn").show();initfirstpaymentpicker("monthly");break;case "annually":$(".j-firstpayment").hide(),$(".creditCardWrap").show(),
$(".makePaymentBtn").show()}togglepaymentmsg();break;case "applicant_pet[gender]":b=""!=$('input[name="applicant_petname"]').val()?$('input[name="applicant_petname"]').val():$("#spayedOrNeutered").attr("data-petname"),"Male"==d?$("#spayedOrNeutered").html('Has <span class="petName">'+b+'</span> been neutered? <span class="required">*</span>'):"Female"==d&&$("#spayedOrNeutered").html('Has <span class="petName">'+b+'</span> been spayed? <span class="required">*</span>')}"undefined"!==typeof gs_pagename&&
("apply-step-4"==gs_pagename?creditformfields(a):postformfields(a))})}$(".searchBtn").click(function(){$("body").hasClass("mobile")?($(".mobileSearch").toggleClass("j-show"),$(".menuIcon").removeClass("j-active"),$("body").removeClass("j-mobmenu"),$(".mobileSearch .searchInput").focus()):($(".searchWrap").addClass("j-activesearch"),$(".searchInput").focus())});$(document).on("click touchend",".searchBar i",function(){$(".searchWrap").removeClass("j-activesearch");$(".searchInput").val("").blur()});
$(document).keydown(function(a){27==a.which&&($(".searchWrap").removeClass("j-activesearch"),$(".searchInput").val(""),$(".menuIcon").removeClass("j-active"),$("body").removeClass("j-mobmenu"))});
$(document).on("change",'select[data-type="animalSelect"]',function(){var a=$(this).find(":selected").data("children"),b=$(this).parents(".inputRow").next();b.find('select[data-type="breedSelect"]').select2("destroy").empty().select2({data:a});b.on("select2:select",function(a){a=$(this).attr("name");var b=$(this).val();" undefined"!=typeof b&&b&&$('[data-input="'+a+'"').removeClass("j-show")})});
$(function(){$('a[href*="#"]:not([href="#"])').click(function(){if(location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname){var a=$(this.hash);a=a.length?a:$("[name="+this.hash.slice(1)+"]");if(a.length)return $("html, body").animate({scrollTop:a.offset().top},500),!1}})});$(".menuIcon").on("click",function(){$(this).toggleClass("j-active");$("body").toggleClass("j-mobmenu")});
$(document).on("click",".hasSub > a",function(a){a.preventDefault();$("body").hasClass("desktop")||$(this).next(".subMenu").slideToggle()});$(window).scroll(function(){var a=$(window).scrollTop(),b=$("header").height();a>b?$(".planAdded").addClass("down"):$(".planAdded").removeClass("down")});$(".insuranceDevice").slick();if($("body").hasClass("mobile")){var li_slideto=$(".insuranceDeviceSlide[data-slideto]").data("slideto");"undefined"!=li_slideto&&$(".insuranceDevice").slick("slickGoTo",li_slideto)}
$(".insuranceDevice").on("beforeChange",function(a,b,c){$("body").hasClass("mobile")&&($(".moreBtn").prev().slideUp("fast"),$(".moreBtn").text("More Info"))});$(document).on("click",".termsLink",function(){$(this).text("Confirmation of Application Details");$(this).removeClass("u-cursorPointer");$(this).next().removeClass("j-hidden");$("#agree_terms").removeAttr("disabled");$(".inputCheckbox").removeClass("j-disabled")});
$(document).on("click touchend",".apply-step-1 .selectPet",function(a){a.preventDefault();if(!$(this).hasClass("j-disabled")){$(".apply-step-1 .selectPet").removeClass("j-selected");$("input").blur();$(".insuranceDesktop .selectPet, .petOptsWrap").removeClass("j-selected");$(this).addClass("j-selected");a=$(this).parent("td").index()+1;var b=$(this).parents(".petOptsWrap").index()+1;$(".rowSelect td").removeClass("j-highlight");$(".rowSelect td:nth-child("+a+")").addClass("j-highlight");$(".insuranceDevice .petOptsWrap:nth-child("+
b+")").addClass("j-selected");$(".petOptsWrap:not(.j-selected)").addClass("j-hide");$(".viewPlansBtn").removeClass("j-hide");$('input[name="applicant_planid"]').attr("value",$(this).data("petcover"));console.log("planid:"+$('input[name="applicant_planid"]').attr("value"))}});$(document).on("click",".viewPlansBtn",function(a){a.preventDefault();$(".petOptsWrap").removeClass("j-hide");$(".viewPlansBtn").addClass("j-hide");window.location.href="/apply-step-1#insuranceDevice"});
function update(){$(".petNameDetails").addClass("j-hidden");var a=$(".selectAnimal li.j-selected").data("breedid"),b=$(".selectAnimal li.j-selected").data("petplan"),c=$('select[name="applicant_petbreed['+b+']"]').val();$("#otherbreed").removeClass("j-hidden");"Other"!=c&&$("#otherbreed").addClass("j-hidden");var d=$("select[name=applicant_ageyears]").val();d=""==d||isNaN(d)?-1:d;var f=$("select[name=applicant_agemonths]").val();f=""==f||isNaN(f)?-1:f;if(""==c||0>=d&&0>=f)$("#plancontent").html(""),
$(".protectPet").addClass("j-hidden");else{var e={};e.breedid=a;e.breed=c;e.ageyears=d;e.agemonths=f;a=!1;switch(b){case "cat":case "dog":case "rabbit":updateplantable(e);a=!0;break;case "horse":b=$('select[name="applicant_pethorse_cover"]').val(),e.cover=""==b||isNaN(b)?0:b,0>=e.cover||(b=$('select[name="applicant_pethorse_saddlery"]').val(),e.saddlery=""==b||isNaN(b)?null:b,b=$('select[name="applicant_pethorse_trailer"]').val(),e.trailer=""==b||isNaN(b)?null:b,updateplantable(e),a=!0)}"our-plans"==
gs_pagename&&(a?$(".protectPet").removeClass("j-hidden"):($("#plancontent").html(""),$(".protectPet").addClass("j-hidden")))}}$(document).ready(function(){$(".p-inError").hasClass("j-show")?$("html, body").animate({scrollTop:$(".p-inError.j-show").first().closest(".inputWrap").offset().top},1E3):$(".j-scrollTo").length&&$("html, body").animate({scrollTop:$(".j-scrollTo").offset().top},1E3)});
$(document).on("change",'select[name="applicant_ageyears"], select[name="applicant_agemonths"], select.horseDetails ',function(a){$('input[name="applicant_planid"]').attr("value","");$(".selectPet").removeClass("j-selected");console.log("Animal details has changed, reset plan")});
$(document).on("click touch",".selectAnimal > li",function(a){$('input[name="applicant_planid"]').attr("value","");console.log("Animal has changed, reset plan");$(".selectAnimal li").removeClass("j-selected");$(this).addClass("j-selected");$('input[name="applicant_petplan"]').val($(this).data("petplan"));console.log($(this).data("petplan"));if("apply-step-1"==gs_pagename){var b="horse"==$(this).data("petplan")?["Mare","Gelding","Stallion"]:["Male","Female"];$('select[name="applicant_pet[gender]"]').select2("destroy").empty().select2({data:b,
minimumResultsForSearch:Infinity});$('select[name="applicant_pet[gender]"]').on("select2:select",function(a){a=$(this).attr("name");var b=$(this).val();" undefined"!=typeof b&&b&&$('[data-input="'+a+'"').removeClass("j-show")})}"horse"==$(this).data("petplan")?($(".horseFields").removeClass("j-hidden"),$(".horseFields").addClass("j-show")):($(".horseFields").removeClass("j-show"),$(".horseFields").addClass("j-hidden"));if("apply-step-1"==gs_pagename){var c=""+$(this).data("breedid");$.each($(".healthQuestions .inputYesNo "),
function(){-1<(""+$(this).data("questionmap")).split(",").indexOf(c)?$(this).removeClass("j-hidden"):$(this).addClass("j-hidden")});postformfields(a)}a=$(this).children(".text").text().toLowerCase().replace(" plans","");""!=a&&$(".petName").text("your "+a);$(".deetsBtn").text("Next");$(".petHeading").removeClass("j-hidden");$(".petHeading").addClass("j-show");$(".breedSelect").removeClass("j-show");$(".breedSelect."+a+"").addClass("j-show");$(".p-info.p-top").addClass("j-hidden");update()});
$(".petDetails select").on("change",function(a){update()});
function updateplantable(a){gs_pagename="undefined"==typeof gs_pagename?"":gs_pagename;""!=gs_pagename&&(a.gspage=gs_pagename);"undefined"!=typeof a&&$.ajax({type:"POST",url:"/plan-table-ajax",data:a,error:function(a){console.log(a.error)}}).done(function(a){a.success&&($("#plancontent").html(a.html),a.noplans?($(".deetsBtn").addClass("j-hidden"),$(".petNameDetails").addClass("j-hidden"),"apply-step-1"==gs_pagename?($(".protectPet").addClass("j-hidden"),$(".p-info.p-top").html($(".p-info.p-bottom").html()),
$(".p-info.p-top").removeClass("j-hidden"),$("#basic-details").addClass("j-hidden")):"our-plans"==gs_pagename&&($(".insuranceDesktop").addClass("j-hidden"),$(".insurancePlansDevice").addClass("j-hidden"))):($(".deetsBtn").removeClass("j-hidden"),$(".petNameDetails").removeClass("j-hidden"),"apply-step-1"==gs_pagename?($(".protectPet").removeClass("j-hidden"),$(".p-info.p-top").addClass("j-hidden"),$("#basic-details").removeClass("j-hidden")):"our-plans"==gs_pagename&&($(".insuranceDesktop").removeClass("j-hidden"),
$(".insurancePlansDevice").removeClass("j-hidden"))),$(".plansSlider").slick({arrows:!0,touchMove:!0,touchThreshold:3}),$(".plansSlider").on("swipe",function(a,b,f){$("body").hasClass("mobile")&&($(".plansSlide .moreBtn").parent().prev().slideUp("fast"),$(".plansSlide .moreBtn").text("More Info"))}))})}
$(document).ready(function(){if("undefined"!=typeof gs_pagename&&"apply-step-1"==gs_pagename){$(".plansSlider").slick({arrows:!0,touchMove:!0,touchThreshold:3});$(".plansSlider").on("swipe",function(a,c,d){$("body").hasClass("mobile")&&($(".plansSlide .moreBtn").parent().prev().slideUp("fast"),$(".plansSlide .moreBtn").text("More Info"))});var a=$(".selectPet[data-slideto]").data("slideto");"undefined"!=typeof a&&$(".plansSlider").slick("slickGoTo",a)}});
$(document).on("keyup",".searchAddress input",function(a){3>$(this).val().length?$(".searchTypeAhead").removeClass("j-show"):$(".searchTypeAhead").addClass("j-show")});$(document).on("keyup",function(a){27==a.which&&($(".searchTypeAhead").removeClass("j-show"),$(".searchAddress input").val(""))});$(document).on("keyup",".inputPetsName",function(a){a=$(this).find('input[name="applicant_petname"]').val();""==a&&(a="pet");$(".petName").html(a)});
$(document).on("click",'input[name="petage_choice"]',function(a){$(".petAge").hide();a=$(this).data("choice");$("."+a).show()});
$(document).on("click",".addOwnerBtn",function(a){a=$(this).closest(".formSection.ownerAddressDetails");var b=a.find('input[name*="street"]').val(),c=a.find('input[name*="city"]').val(),d=a.find('input[name*="suburb"]').val(),f=a.find('input[name*="postcode"]').val();a.next(a).find('input[name*="street"]').val(b);a.next(a).find('input[name*="city"]').val(c);a.next(a).find('input[name*="suburb"]').val(d);a.next(a).find('input[name*="postcode"]').val(f);a.next(a).removeClass("j-hidden")});
$(document).on("click touchend",".deleteRow",function(){var a=$(this).closest(".formSection.ownerAddressDetails");a.addClass("j-hidden");a.find('input[name*="street"]').val("");a.find('input[name*="city"]').val("");a.find('input[name*="suburb"]').val("");a.find('input[name*="postcode"]').val("");a.find('input[id*="addresssearch"]').val("")});$(document).on("change",'input[name*="applicant_pethealth"]',function(){$(this).val()});
$(document).ready(function(){$("body").hasClass("desktop")?($(".planAdded").addClass("j-active"),$(".planAdded .arrow i").removeClass("ion-chevron-down").addClass("ion-chevron-up")):($(".planAdded").removeClass("j-active"),$(".planAdded .arrow i").removeClass("ion-chevron-up").addClass("ion-chevron-down"))});$(".planAdded .title").on("click",function(){$(".planAdded").toggleClass("j-active");$(".planAdded .arrow i").toggleClass("ion-chevron-down ion-chevron-up")});
$(document).on("click touchend",".planMiniCart li .close",function(){var a=$(this),b={action:"cart-mini",item:a.data("item").item};$.ajax({type:"POST",url:"/cart-ajax",data:b,error:function(a){console.log(a.error)}}).done(function(b){b.success?($(".planAdded").html(b.cart),$(".planAdded .number").html(b.count),b.count||(window.location="/apply-step-1"),setTimeout(function(){a.parent("li").remove()},100)):console.log(b)})});
$(document).on("click touch",".faqQ",function(){if("none"==$(this).next(".faqA").css("display")){if($("body").hasClass("mobile")){var a=$(this).parent().attr("id");$("html, body").animate({scrollTop:$("#"+a).offset().top},300)}else $(".faqA").slideUp(),$(".faqQ i").removeClass().addClass("ion-ios-arrow-down");$(this).next(".faqA").slideDown();$(this).children("i").removeClass().addClass("ion-ios-arrow-up")}else $(this).next(".faqA").slideUp(),$(this).children("i").removeClass().addClass("ion-ios-arrow-down")});
$(document).on("ready",function(){"http://petnsur.blackpepper.co.nz/faq#faq15"===window.location.href&&($("#faq15").find(".faqA").slideDown(),$("#faq15").children("i").removeClass().addClass("ion-ios-arrow-up"))});$(".storiesThumbs").slick({slidesToShow:6,dots:!0,arrows:!0,infinite:!1,responsive:[{breakpoint:980,settings:{slidesToShow:4,slidesToScroll:4}},{breakpoint:600,settings:{slidesToShow:2,slidesToScroll:2}}]});
$(".storiesSlider").slick({slidesToShow:1,slidesToScroll:1,arrows:!1,dots:!1,infinite:!1,draggable:!1,adaptiveHeight:!0,asNavFor:".storiesThumbs"});$(document).on("ready",function(){activateThumb()});$(document).on("click",".slick-slide.thumb",function(a){var b=$(this).index();a.preventDefault();$(".storiesSlider").slick("slickGoTo",b);activateThumb()});
var activateThumb=function(){var a=$(".slide.slick-active").index();$(".thumb").removeClass("j-activeThumb");$(".thumb.slick-slide:nth-child("+parseInt(a+1)+")").addClass("j-activeThumb")},lb_stories=!0;
$(document).ready(function(){var a=$(".testimonialGrid").masonry({itemSelector:".gridItemWrap",hiddenStyle:{opacity:0},transitionDuration:0});$(".testimonials .loadMoreBtn").on("click",function(b){if(lb_stories){b.preventDefault();var c=0;$(".gridItemWrap").each(function(a){a=parseFloat($(this).data("number"));c=a>c?a:c});0<c&&$.ajax({type:"POST",url:"/testimonial-ajax",data:{start:c+1},error:function(a){console.log(a.error)}}).done(function(b){b.success?$.each(b.html,function(b,c){var d=$(c);a.append(d).masonry("appended",
d).masonry("reloadItems")}):"empty"==b.error?(lb_stories=!1,$(".loadMoreBtn").html("View our cover options")):console.log(b.error)})}})});$(document).on("click touch",".plansSlide .moreBtn",function(a){a=$(this).parent().prev();"none"==a.css("display")?(a.slideDown("fast"),$(this).text("Hide Info")):(a.slideUp("fast"),$(this).text("More Info"),$("html, body").animate({scrollTop:$(".protectPet").offset().top},500));$(document).on("touch",".plansTable",function(a){a.stopPropagation()})});
$(document).on("click touchend",".pageOverlay",function(a){a.preventDefault();$(".pageOverlay").removeClass("j-active");$(".sidebarPlans").removeClass("j-active");$("html, body").animate({scrollTop:$("#plans").offset().top},500)});
$(document).on("click touch",".moreInfo, .moreBtn",function(a){a.stopPropagation();a.preventDefault();var b=$(this);if("undefined"!=typeof $(this).data("info")){a=$(this).data("info");a.breedid=$(".selectAnimal li.j-selected").data("breedid");var c=$('select[name="applicant_petbreed['+a.animal.toLowerCase()+']"]').val();a.breed=c;c=$("select[name=applicant_ageyears]").val();a.years=""==c||isNaN(c)?-1:c;c=$("select[name=applicant_agemonths]").val();a.months=""==c||isNaN(c)?-1:c;"Horse"==a.animal&&
(""!=$('select[name="applicant_pethorse_cover"]').val()&&(a.cover=$('select[name="applicant_pethorse_cover"]').val()),""!=$('select[name="applicant_pethorse_saddlery"]').val()&&(a.saddlery=$('select[name="applicant_pethorse_saddlery"]').val()),""!=$('select[name="applicant_pethorse_trailer"]').val()&&(a.trailer=$('select[name="applicant_pethorse_trailer"]').val()));$.post("/plan-table-more-info-ajax",a,function(a){$("#ourplan-moreinfo").html(a.html);b.hasClass("j-disabled")||setTimeout(function(){$(".pageOverlay").addClass("j-active");
$(".sidebarPlans").addClass("j-active");$(".menuIcon").removeClass("j-active");$("body").removeClass("j-mobmenu")},300)},"json")}});$(document).on("submit",".form-subscribe",function(a){a.preventDefault();var b=$(this);a=b.find("input").val();$.getJSON("/subscribe",{e:a},function(a){b.find(".p-error, .p-success").addClass("j-hidden");a.success?b.find(".p-success").html(a.content).removeClass("j-hidden"):b.find(".p-error").html(a.content).removeClass("j-hidden")});return!1});
function togglepaymentmsg(){var a=$('select[name="paymentfrequency"]').val(),b=$('select[name="paymentmethod"]').val(),c=$('.debitCardWrap input[name="application_bankaccount"]').val(),d=$('.debitCardWrap input[name="application_bankaccountname"]').val();$(".paymentSuccess").hide();if("undefined"!=typeof $(".creditcard").data("prices")[a])switch(a){case "annually":$("#creditfrequency").html("annual");break;case "monthly":$("#creditfrequency").html("monthly")}switch(a){case "annually":$(".j-paymentmethod").addClass("j-hidden");
$(".paymentSuccess.creditcard").show();return;case "monthly":$(".j-paymentmethod").removeClass("j-hidden");break;default:$(".j-paymentmethod").addClass("j-hidden")}"creditcard"==b?$(".paymentSuccess.creditcard").show():"directdebit"==b&&""!=c&&""!=d&&$(".paymentSuccess.directdebit").show();if(-1!=jQuery.inArray(a,["weekly","fortnightly"])||"directdebit"==b&&"monthly"==a){if("undefined"!=typeof $(".directdebit").data("prices")[a]){switch(a){case "weekly":$("#debitinstalments").html(52);break;case "fortnightly":$("#debitinstalments").html(26);
break;case "monthly":$("#debitinstalments").html(12)}$("#debitfrequency").html(a)}""!=c&&""!=d&&($(".paymentSuccess.directdebit .account-number").html(c),$(".paymentSuccess.directdebit .account-name").html(d),$(".paymentSuccess.directdebit").show())}"monthly"==a&&"creditcard"==b?go_firstpaymentpicker.getMoment().format("Do"):$("#creditnote").html("")}$(document).on("change",".debitCardWrap input",togglepaymentmsg);
$(document).on("click",".termsLink",function(a){a.preventDefault();$("#agree_terms").removeAttr("disabled");$(".inputCheckbox").removeClass("j-disabled");$(".termsBox .inner").removeClass("j-hidden")});$(document).on("click","input[data-healthquestion]",function(a){a=$(this).data("healthquestion");"yes"==$(this).val()?$('div[data-healthquestion="'+a+'"]').removeClass("j-hidden"):$('div[data-healthquestion="'+a+'"]').addClass("j-hidden")});$(".gallerySlider").slick({arrows:!0});
if($("main").hasClass("apply-step-1")){var duedatepicker=new Pikaday({field:document.getElementById("horsePurchaseDate"),format:"DD/MM/YYYY"});$('input[name="applicant_pethorse_purchaseprice"]').on("blur",function(){var a=parseFloat($(this).val());"undefined"!=typeof a&&!isNaN(a)&&a&&$(this).val("$"+a.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g,"$1,"))})}
$(document).on("change","#blogfilter",function(){var a=$(this).val();$.ajax({type:"POST",url:"/blog-list-ajax",data:JSON.parse(a),error:function(a){console.log(a.error)}}).done(function(a){a.success&&$("#bloglist").html(a.html)})});$(document).on({change:postformfields,keyup:checkinputerror},"#appform input");$(document).on("click touchend",".apply-step-1 .selectPet",function(){postformfields()});$(document).on({change:creditformfields},"#creditform input");
$(document).on("click",".body-cart-summary .j-removeitem",function(a){var b=$(this);a=JSON.parse(b.data("item"));console.log(a);var c=a.item;$.ajax({type:"POST",url:"/cart-ajax",data:{action:"cart-summary",item:c},error:function(a){console.log(a.error)}}).done(function(a){a.success?($(".cartSummary").html(a.html),a.count||(window.location="/apply-step-1"),setTimeout(function(){b.closest(".j-row-"+c).remove()},100)):console.log(a)})});
$(document).on("click",".j-applycode",function(a){event.preventDefault();a=$('input[name="discountcode"]').val();""!=a&&$.ajax({type:"POST",url:"/cart-ajax",data:{discountcode:a,action:"apply-code"},error:function(a){console.log(a.error)}}).done(function(a){console.log(a);a.success?(a.html&&$(".cartSummary").html(a.html),$(".j-response.p-error").addClass("j-hidden"),$(".j-response.p-success").removeClass("j-hidden")):($(".j-response.p-error").removeClass("j-hidden"),$(".j-response.p-success").addClass("j-hidden"))})});