function isTouchCapable(){return"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch?!0:!1}function getbaseurl(){return"/"}function getParameterByName(n){n=n.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var i=new RegExp("[\\?&]"+n+"=([^&#]*)"),t=i.exec(location.search);return t===null?"":decodeURIComponent(t[1].replace(/\+/g," "))}function logFlashEvent(n){try{n!=undefined&&(n.id!=undefined?event!=undefined?logFlashEventAPI(n.id+"_"+event.type):logFlashEventAPI(n.id):logFlashEventAPI(n))}catch(t){}}function logFlashEventAPI(n){var t=getbaseurl()+"api/PageInteraction?userEvent="+n;$.ajax({type:"POST",url:t,dataType:"json",success:function(){},statusCode:{},error:function(){}})}function showDialog(n){logFlashEventAPI(n+"_click");$("#"+n).modal("show")}function closeDialog(n){$("#"+n).modal("hide")}function capitalizeFirstLetter(n){return n.charAt(0).toUpperCase()+n.slice(1)}function showStartQuote(){console.error("calling the old showStart Quote")}function isCurrentPageHomePage(){return $("body").hasClass("homepage ygdl-home")}function handleSummitScenario(n){var i=$.parseJSON(n.FastFlow),r=$.parseJSON(n.ShowCallUs),t=$.parseJSON(n.IsMobile),u=n.CountryCode,f=isCurrentPageHomePage();showDebugLogs=getQueryString("debug")==="true";logGroupStartIfDebug("handleSummitScenario");logIfDebug("inhours test set to false",i);logIfDebug("fastflow",i);logIfDebug("inhours",r);logIfDebug("isMobile",t);logIfDebug("countryCode",u);logIfDebug("isHomePage",f);handleShowRequestCall(t,i,r,u);handleButtonStrip(t,i,r,f);handleShowCallUs(t,r);i?(logIfDebug("Fastflow"),handleShowStartQuote(t,n)):(logIfDebug("Longflow"),t?handleHideStartQuote(n):handleShowStartQuote(t,n));u==="NZ"&&(logIfDebug('countryCode === "NZ"'),showBtnDynamicStartQuote_Default());logIfDebug("#btnDynamicStartQuote-Default values");logIfDebug($("#btnDynamicStartQuote-Default").attr("onclick"));logIfDebug($("#btnDynamicStartQuote-Default").attr("href"));logIfDebug("finito");logGroupEndIfDebug()}function showBtnDynamicStartQuote_Default(){$("#btnStartQuote-Default").show()}function handleHideStartQuote(n){var t,u,f;logGroupStartIfDebug("handleHideStartQuote");logIfDebug("start quote no");t=n.CountryCode;logIfDebug("countryCode",t);logIfDebug('countryCode !== "NZ"',t!=="NZ");$("[id^=btnStartQuote]").hide();var i=$.parseJSON(n.IsMobile),r=$.parseJSON(n.FastFlow),e=$.parseJSON(n.ShowCallUs);i&&!r&&$("[id^=btnMobileRequestCallReveal]").hide();t==="NZ"&&$("[id^=btnDynamicStartQuote-Default]").text("Get a Quote");i&&!r&&($("#btnStartQuote-Car").show(),$("#btnStartQuote-Home").show());u=$(".Product-Car").length;u&&(logIfDebug("On car page. Showing Start Quote."),$("[id^=btnStartQuote-Car]").show(),$("[id^=btnDynamicStartQuote-Car]").show());f=$(".Product-Home").length;f&&(logIfDebug("On Home page. Showing Start Quote."),$("[id^=btnStartQuote-Home]").show(),$("[id^=btnDynamicStartQuote-Home]").show());$("#aMobileCallUs").hide();$("[id^=dvYouiContactNumber]").hide();logGroupEndIfDebug()}function replaceStartQuoteButtonHref(n,t){var i=$(n);i&&i.length&&!i.data("dontTouchHref")&&i.prop("href",t)}function handleShowStartQuote(n,t){logGroupStartIfDebug("handleShowStartQuote");logIfDebug("start quote yes");var i=t.CountryCode;n||i=="NZ"?(t.Car!=undefined&&i=="NZ"&&(logIfDebug("changed Car from "+$("[id^=btnStartQuote-Car]").prop("href")+" to "+t.Car),replaceStartQuoteButtonHref("[id^=btnStartQuote-Car]",t.Car)),t.Home!=undefined&&i=="NZ"&&(logIfDebug("changed Home from "+$("[id^=btnStartQuote-Home]").prop("href")+" to "+t.Home),replaceStartQuoteButtonHref("[id^=btnStartQuote-Home]",t.Home)),t.BuildingInsurance!=undefined&&replaceStartQuoteButtonHref("[id^=btnStartQuote-BuildingInsurance]",t.BuildingInsurance),t.BuildingContentsInsurance!=undefined&&replaceStartQuoteButtonHref("[id^=btnStartQuote-BuildingContentsInsurance]",t.BuildingContentsInsurance),t.ContentsInsurance!=undefined&&replaceStartQuoteButtonHref("[id^=btnStartQuote-ContentsInsurance]",t.ContentsInsurance),t.LandlordInsurance!=undefined&&replaceStartQuoteButtonHref("[id^=btnStartQuote-LandlordInsurance]",t.LandlordInsurance),t.Motorcycle!=undefined&&replaceStartQuoteButtonHref("[id^=btnStartQuote-Motorcycle]",t.Motorcycle),t.Watercraft!=undefined&&replaceStartQuoteButtonHref("[id^=btnStartQuote-Watercraft]",t.Watercraft),t.CaravanTrailer!=undefined&&replaceStartQuoteButtonHref("[id^=btnStartQuote-CaravanTrailer]",t.CaravanTrailer),t.BusinessLiability!=undefined&&replaceStartQuoteButtonHref("[id^=btnStartQuote-BusinessLiability]",t.BusinessLiability),showAdditional_handleShowStartQuoteButtons()):($("[id^=btnStartQuote]").removeAttr("href"),$("[id^=btnDynamicStartQuote]").removeAttr("href"),$("[id^=btnStartQuote-Default]").removeAttr("href"));logGroupEndIfDebug()}function showAdditional_handleShowStartQuoteButtons(){$("[id^=btnStartQuote]").show();$("[id^=btnDynamicStartQuote]").show();$("[id^=btnDynamicStartQuote-Default]").show();$("#aMobileCallUs").show()}function showOrHideMobileShowRequestCall(n){n.shouldShowRequestCall()?$(".btnMobileRequestCall").removeClass("display-none"):$(".btnMobileRequestCall").addClass("display-none")}function handleShowRequestCall(n,t,i,r){if(logGroupStartIfDebug("handleShowRequestCall"),i?logIfDebug("request call: yes"):logIfDebug("request call: no"),n){var u=$(".Product-Car").length,f=$(".Product-Home").length;logIfDebug("On car page: ",!!u);logIfDebug("On home page: ",!!f);u||f?logIfDebug("On car or home page. Leave RequestCall hidden."):(i?t||r==="AU"&&(logIfDebug("showing btnMobileRequestCall because long flow and AU"),$(".btnMobileRequestCall").removeClass("display-none")):(logIfDebug("Mobile out of hours, showing request call button"),r==="AU"&&t||$("#btnMobileRequestCallReveal").removeClass("display-none")),i||t||(logIfDebug("showing btnMobileRequestCall because long flow and out of hours"),$(".btnMobileRequestCall").removeClass("display-none"),$(".btnMobileRequestCall").html("Request a Quote")));logIfDebug("removing onclick and href attr from [id^=btnDynamicStartQuote-Default] because NZ");$("[id^=btnDynamicStartQuote-Default]").each(function(){var n=$(this);n.attr("onclick","showQuoteSelectModal()");n.removeAttr("href")})}logGroupEndIfDebug()}function handleShowCallUs(n,t){logGroupStartIfDebug("handleShowCallUs");var i="";t||(i="Sorry we're out of hours.<br/>Please choose from one of the options below:");logIfDebug("call us yes - "+i);n?t?$("#btnMobileCallUs").removeClass("display-none"):($("#dvMobileOutOfHours").html(i),$("#dvMobileOutOfHours").removeClass("display-none")):showAll_dvYouiContactNumber();logGroupEndIfDebug()}function showAll_dvYouiContactNumber(){$("[id^=dvYouiContactNumber]").show()}function handleButtonStrip(n,t,i,r){logGroupStartIfDebug("handleButtonStrip");n||($(".buttonstrip").removeClass("display-none"),logIfDebug("show button strip"));var u=n&&(t||!i);if(logIfDebug("isMobileAndFastFlowOrOutOfHours: ",u),u){if(n&&!t&&!i&&r)return;$(".buttonstrip").removeClass("display-none");logIfDebug("show button strip")}logGroupEndIfDebug()}function webInitComplete(n){var e=$.parseJSON(n.FastFlow),o=$.parseJSON(n.ShowCallUs),u=$.parseJSON(n.IsMobile),s=n.CountryCode,h=isCurrentPageHomePage(),c=$(".Product-Home").length,l=$(".Product-Car").length,i,f,t,r;if(handleSummitScenario(n),maybeShowTopNavStartQuote(n.ShowCallUs),$("#dvWebHitKey").attr("webHitKey",n.WebHitKey),n.WebHitKey!=="")for(i=$(".manage-policy-link"),f="&hitID="+n.WebHitKey,t=0;t<i.length;t++)i[t].href+=f;getQueryString("showModal")==="true"&&$("#btnDynamicStartQuote-Default")[0].click();u||$(window).scroll(function(){maybeShowTopNavStartQuote(n.ShowCallUs)});$.parseJSON(n.LoadWall)===!0&&(r=new PositiveFeedbackWidget($("#wallSatPerc"),$(".wall-score-perc"),$(".wallCountTotal"),u),checkIsInternalUserAPI(checkIsInternalUserComplete),$("#hdnShowFeedback").val()=="True"?(showFeedbackForm("webinit",n.TypeUser),loadYouiWall(!1,!0,!0)):loadYouiWall(!1,!0,!1),r.satWidget.length&&getSatisfactionWidgetDataAPI(r.loadSatisfaction));try{$("[class*='OptimizingBlock']").children().each(function(){var n=$(this).data("id");n&&logFlashEventAPI(n)})}catch(a){}}function maybeShowTopNavStartQuote(){if(!isMobile){var n=isBtnStartQuoteVisible();(n==0||n==1)&&(n=n==1);n?($(".topnavquotebuttons").css("display","none"),$("#navbar").removeClass("scroll")):($(".topnavquotebuttons").css("display","inline-block"),$("#dvYouiContactNumber .callbutton").hide(),$("#navbar").addClass("scroll"))}}function isBtnStartQuoteVisible(){return $("[id^=btnStartQuote]").visible(!1,!1,"vertical")||$("[id^=auBtnStartQuote]").visible(!1,!1,"vertical")}function callFromMobile(){logIfDebug("callFromMobile");getDynamicContactNumberAPI(getDynamicContactNumberComplete)}function getDynamicContactNumberComplete(n){window.location.href="tel:"+n}function getQueryString(n){if(n){n=n.toLowerCase();var t=RegExp("[?&]"+n+"=([^&]*)").exec(window.location.search.toLowerCase());return t&&decodeURIComponent(t[1].replace(/\+/g," "))}return""}function logIfDebug(n,t){showDebugLogs&&console.log(n,t)}function logGroupStartIfDebug(n){showDebugLogs&&console.group(n)}function logGroupEndIfDebug(){showDebugLogs&&console.groupEnd()}function showQuoteSelectModal(){var n;if(event&&(event.preventDefault(),event.stopPropagation()),n=$("#quoteSelectToolModal"),n.length)n.find("#btnStartQuote-Default").show(),n.modal("show");else{var t=$("#startQuoteModal_Desktop"),i=!document.querySelector("body[class*='Product-']"),r=document.querySelector("body[data-variant='B']");if(i&&r)return;t.length&&t.modal("show")}}function handleStartQuoteClick(n,t,i,r){t?(logFlashEvent(n,event),location.href=getMobileUrlLink()):r==="NZ"?i?showQuoteSelectModal():(logFlashEvent(n,event),window.open(n.href,"_blank"),event.preventDefault()):(alert("handleStartQuoteClick Danger\n"+n),showStartQuote(n))}function webInitAPI(n){var t=getbaseurl()+"api/webinit?isTouchCapable="+isTouchCapable();$.ajax({type:"GET",url:t,dataType:"json",success:function(t){n(t)},statusCode:{},error:function(){}})}function loadYouiWallAPI(n,t,i,r,u,f,e,o,s,h,c,l){t||(t="");i||(i="");r||(r="");u||(u="");f||(f="");o||(o="");var a=getbaseurl()+"api/YouiWall?getHotTopics="+n;a+="&searchText="+t;a+="&userName="+i;a+="&startDate="+r;a+="&endDate="+u;a+="&satisfactionCode="+f;a+="&lastFeedbackCode="+e;a+="&loadFeedbackCode="+o;a+="&lastSearchedTimestamp="+s;a+="&feedbacksPerPage="+h;$.ajax({type:"GET",url:a,dataType:"json",success:function(n){c(n)},statusCode:{404:function(){c("error")},500:function(){c("error")}},error:function(n){l(JSON.parse(n.responseText).ExceptionMessage)}})}function loadYouiWallPositiveFeedbackAPI(n,t){var i=getbaseurl()+"api/YouiWall/GetPositiveFeedback";i+="?feedbacksPerPage="+n;$.ajax({type:"GET",url:i,dataType:"json",success:function(n){t(n)},statusCode:{404:function(){t("error")},500:function(){t("error")}},error:function(){t("error")}})}function getSatisfactionWidgetDataAPI(n){var t=getbaseurl()+"api/SatisfactionWidget";$.ajax({type:"GET",url:t,dataType:"json",success:function(t){n(t)},statusCode:{404:function(){n("error")},500:function(){n("error")}},error:function(){n("error")}})}function getDynamicContactNumberAPI(n){var t=getbaseurl()+"api/dynamiccontactnumber";$.ajax({type:"GET",url:t,dataType:"json",success:function(t){n(t)},statusCode:{},error:function(){n("error")}})}function getOperationHoursAPI(n){var t="001",i=(new Date).getTimezoneOffset()/-60,r;switch(i.toString()){case"13":t="015";break;case"12":t="015";break;case"11":t="002";break;case"10":t="001";break;case"10.5":t="004";break;case"9.5":t="003";break;case"9":t="006";break;case"8":t="006"}r=getbaseurl()+"api/OperationHours?homeDepartment="+t+"&hoursOffset="+i.toString();$.ajax({type:"Get",url:r,dataType:"html",success:function(t){n(t)},statusCode:{},error:function(){}})}function incrementStartQuoteCountAPI(){var n=getbaseurl()+"api/startquotecount";$.ajax({type:"POST",url:n,dataType:"json",success:function(){},statusCode:{},error:function(){}})}function OperationalHours(){var t=function(){$("#department-container-new").length&&getOperationHoursAPI(n)},n=function(n){var i=jQuery.parseJSON(n),t,e,r,u;for($("#department-container-new").html(""),$("#tzDescription-new").html(""),t=0;t<i.length;t++){var o="department-wrapper-"+(t+1),f="#department-container-new ."+o,s=i[t].Version.indexOf("Nz")>=0?"NZ Services":i[t].Version;for($("#department-container-new").append('<div class="'+o+' department-wrapper"><\/div>'),$(f).append('<h4 class="name"><strong>'+s+"<\/strong><\/h4>"),e=i[t].Hours,r=document.createElement("p"),r.className="hours",u=0;u<e.length;u++)$(r).append(e[u]+"<br />");$(f).append(r);$(f).append('<hr class="hr--grayf" />')}$("#tzDescription-new").append(i[0].TimeZone)};return{showBusinessHours:t,getHoursComplete:n}}var showDebugLogs,youi;(function(n){var t=n(window);n.fn.visible=function(n,i,r){if(!(this.length<1)){var e=this.length>1?this.eq(0):this,o=e.get(0),s=t.width(),h=t.height(),r=r?r:"both",f=i===!0?o.offsetWidth*o.offsetHeight:!0;if(typeof o.getBoundingClientRect=="function"){var u=o.getBoundingClientRect(),y=u.top>=0&&u.top<h,p=u.bottom>0&&u.bottom<=h,w=u.left>=0&&u.left<s,b=u.right>0&&u.right<=s,k=n?y||p:y&&p,d=n?w||b:w&&b;if(r==="both")return f&&k&&d;if(r==="vertical")return f&&k;if(r==="horizontal")return f&&d}else{var c=t.scrollTop(),g=c+h,l=t.scrollLeft(),nt=l+s,tt=e.offset(),a=tt.top,it=a+e.height(),v=tt.left,rt=v+e.width(),ut=n===!0?it:a,ft=n===!0?a:it,et=n===!0?rt:v,ot=n===!0?v:rt;if(r==="both")return!!f&&ft<=g&&ut>=c&&ot<=nt&&et>=l;if(r==="vertical")return!!f&&ft<=g&&ut>=c;if(r==="horizontal")return!!f&&ot<=nt&&et>=l}}}})(jQuery);showDebugLogs=!1;youi=youi||{};youi.state=function(){}();$(document).ready(function(){if(webInitAPI(webInitComplete),$(".video-modal").length>0&&$(".video-modal").prependTo("body"),$("a.video-thumb").length>0){$("a.video-thumb").click(function(){var n=$(this).attr("data-youtube-id"),t="//www.youtube.com/embed/"+n+"?autoplay=1&rel=0";return $("#youtube").attr("src",t),!1});function n(){$(".js-trigger-modal").on("click",function(n){n.preventDefault();$("body").addClass("show-video-modal")});$("body").on("click",".close-video-modal, .video-modal .overlay",function(n){n.preventDefault();$("body").removeClass("show-video-modal");$("#youtube").attr("src","")})}n()}$(".cover-type-accordion").length>0&&($(".cover-type-accordion .product-toggle.Comprehensive").addClass("active"),$(".cover-type-accordion .product-toggle.Building.Contents").addClass("active"),$(".cover-type-accordion .product-toggle").hasClass("active")&&$(".product-toggle.active .product-toggle-inner").show(),$(".cover-type-accordion .product-toggle").click(function(){jQuery(this).hasClass("active")?($(this).removeClass("active"),$(this).parent().children(".product-toggle-inner").slideUp(200)):($(this).addClass("active"),$(this).parent().children(".product-toggle-inner").slideDown(200))}));(new OperationalHours).showBusinessHours();$("#dvWebMessage").on("closed.bs.alert",function(){hideWebMessageAPI()})});var width=$(window).width(),height=$(window).height(),isMobile=!1;(function(){window.onpageshow=function(n){n.persisted&&window.location.reload()}})()