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 hideWebMessage(n){function t(){$("#dvWebMessage").hide()}hideWebMessageAPI(n,t)}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 handleShowStartQuote(n,t){logGroupStartIfDebug("handleShowStartQuote");logIfDebug("start quote yes");var i=t.CountryCode;n||i=="NZ"?($(".mobile-quote-btn-bar").attr("data-nodock",!1),t.Car!=undefined&&i=="NZ"&&(logIfDebug("changed Car from "+$("[id^=btnStartQuote-Car]").prop("href")+" to "+t.Car),$("[id^=btnStartQuote-Car]").prop("href",t.Car)),t.Home!=undefined&&i=="NZ"&&(logIfDebug("changed Home from "+$("[id^=btnStartQuote-Home]").prop("href")+" to "+t.Home),$("[id^=btnStartQuote-Home]").prop("href",t.Home)),t.BuildingInsurance!=undefined&&$("[id^=btnStartQuote-BuildingInsurance]").prop("href",t.BuildingInsurance),t.BuildingContentsInsurance!=undefined&&$("[id^=btnStartQuote-BuildingContentsInsurance]").prop("href",t.BuildingContentsInsurance),t.ContentsInsurance!=undefined&&$("[id^=btnStartQuote-ContentsInsurance]").prop("href",t.ContentsInsurance),t.LandlordInsurance!=undefined&&$("[id^=btnStartQuote-LandlordInsurance]").prop("href",t.LandlordInsurance),t.Motorcycle!=undefined&&$("[id^=btnStartQuote-Motorcycle]").prop("href",t.Motorcycle),t.Watercraft!=undefined&&$("[id^=btnStartQuote-Watercraft]").prop("href",t.Watercraft),t.CaravanTrailer!=undefined&&$("[id^=btnStartQuote-CaravanTrailer]").prop("href",t.CaravanTrailer),t.BusinessLiability!=undefined&&$("[id^=btnStartQuote-BusinessLiability]").prop("href",t.BusinessLiability),t.MobileQuoteUrl!=undefined&&$("[id^=btnStartQuote-Default]").prop("href",t.MobileQuoteUrl),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()?(console.log("Showing .btnMobileRequestCall"),$(".btnMobileRequestCall").removeClass("display-none")):(console.log("Hiding .btnMobileRequestCall"),$(".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");$(".mobile-quote-btn-bar").attr("data-nodock",!1);logIfDebug("show button strip")}logGroupEndIfDebug()}function webInitComplete(n){var r=$.parseJSON(n.FastFlow),u=$.parseJSON(n.ShowCallUs),t=$.parseJSON(n.IsMobile),f=n.CountryCode,e=isCurrentPageHomePage(),o=$(".Product-Home").length,s=$(".Product-Car").length;postiveFeedbackWidget=new PostiveFeedbackWidget($("#myStat"),$("#wallSatPerc"),$(".wall-score-perc"),$(".wallCountTotal"),t);handleSummitScenario(n);maybeShowTopNavStartQuote(n.ShowCallUs);$("#dvWebHitKey").attr("webHitKey",n.WebHitKey);getQueryString("showModal")==="true"&&$("#btnDynamicStartQuote-Default")[0].click();t||$(window).scroll(function(){maybeShowTopNavStartQuote(n.ShowCallUs)});$.parseJSON(n.LoadWall)===!0&&(checkIsInternalUserAPI(checkIsInternalUserComplete),$("#hdnShowFeedback").val()=="True"?(showFeedbackForm("webinit",n.TypeUser),loadYouiWall(!1,!0,!0)):loadYouiWall(!1,!0,!1));postiveFeedbackWidget.satWidgetAu.length&&!t&&getSatisfactionWidgetDataAPI(postiveFeedbackWidget.loadSatisfaction);postiveFeedbackWidget.satWidgetNz.length&&getSatisfactionWidgetDataAPI(postiveFeedbackWidget.loadSatisfaction);$("#myStat").length&&t&&($("#myStat").hide(),$("#satWidgetText").hide(),$(".Cloud").hide(),$(".recently_viewed").hide());$("#freewall-container").length&&!t&&initFreewallFeedback("#freewall-container",300,250);$("#postiveFeedbackGrid").length&&loadYouiWallPositiveFeedbackAPI(2,postiveFeedbackWidget.loadPostiveFeedbackGrid);try{$("[class*='OptimizingBlock']").children().each(function(){var n=$(this).data("id");n&&logFlashEventAPI(n)})}catch(i){console.warn(i)}}function maybeShowTopNavStartQuote(){if(!isMobile){var n=isBtnStartQuoteVisible();(n==0||n==1)&&(n=n==1);n?($(".dynamic-start-quote").css("display","none"),$(".topnavquotebuttons").css("display","none"),$("#navbar").removeClass("scroll")):($(".dynamic-start-quote").css("display","inline-block"),$(".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(){$("#quoteSelectToolModal").find("#btnStartQuote-Default").show();$("#quoteSelectToolModal").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){console.error(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 initFreewallFeedback(n,t){return freewallFeedback=new freewall(n),$(function(){freewallFeedback.reset({selector:".brick",animate:!1,cellW:t,cellH:"auto",delay:50,gutterX:-1,gutterY:-1,onResize:function(){freewallFeedback.fitWidth()}});freewallFeedback.fitWidth()}),loadYouiWallPositiveFeedbackAPI(feedbacksPerPage,loadDynamicWallFeedSuccess),freewallFeedback}function appendWallCommentHtml(n){return"<div class='col-sm-4 fw-item brick' data-fixSize=true><a href='/wall?feedbackCode="+n.FeedbackCode+"'><div class='quote-wrap'><div id='quote-"+n.FeedbackCode+"' class='qte'>"+n.Notes+"<\/div><div  id='customer-"+n.FeedbackCode+"' class='cite'>"+n.LoadFirstName+"  "+n.HowLongAgo.Key+" "+n.HowLongAgo.Value+"<\/div><\/div><\/a><\/div>"}function escapeHtml(n){"use strict";return n.replace(/[\"&<>]/g,function(n){return{'"':"&quot;","&":"&amp;","<":"&lt;",">":"&gt;"}[n]})}function prePendFreewallFeedback(n,t){var h=n.container.selector,i,c,r,u,f,e;if(t.length>0){i=new Date;c=i.getMonth().length+1===1?i.getMonth()+1:"0"+(i.getMonth()+1);lastSearchTimestamp=i.getDate()+"/"+c+"/"+i.getFullYear()+" "+i.getHours()+":"+i.getMinutes()+":"+i.getSeconds();var o="",s=!1,l=$(h+" .col-sm-4").length;if(l==0)for(lastFeedbackItem=t[0],r=0;r<t.length;r++)o+=appendWallCommentHtml(t[r]),s=!0;else for(u=t.length-1;u>=0;u--)f=t[u],parseInt(f.FeedbackCode)>parseInt(lastFeedbackItem.FeedbackCode)&&(o+=appendWallCommentHtml(f),lastFeedbackItem=f,s=!0);s&&(n.prepend(o),e=0,$(h+" .col-sm-4").each(function(){var n=escapeHtml(lastFeedbackItem.Notes);e==0?$(this).show():e<9?$(this).show():$(this).remove();e++}))}}function startDynamicWallTimer(){$(function(){var n=setInterval(function(){loadYouiWallPositiveFeedbackAPI(feedbacksPerPage,loadDynamicWallFeedSuccess)},3e4)})}function loadDynamicWallFeedSuccess(n){try{prePendFreewallFeedback(freewallFeedback,n)}catch(t){console.warn("loadDynamicWallFeedSuccess",t)}}function OperationalHours(){var t=function(){$("#department-container-new").length&&getOperationHoursAPI(n)},n=function(n){var i=jQuery.parseJSON(n),f,t,u,r;for($("#department-container-new").html(""),$("#tzDescription-new").html(""),$("#tzDescription-new").append(i[0].TimeZone),f=12/i.length,t=0;t<i.length;t++){var e="department-wrapper-"+(t+1),o="#department-container-new ."+e,s=i[t].Version.indexOf("Nz")>=0?"NZ Services":i[t].Version;for($("#department-container-new").append("<div class='"+e+" department-wrapper col-sm-"+f+"'><\/div>"),$(o).append("<div class='department'><div class='name'>"+s+"<\/div><\/div>"),u=i[t].Hours,r=0;r<u.length;r++)$(o).append("<div class='hours'>"+u[r]+"<\/div>")}};return{showBusinessHours:t,getHoursComplete:n}}function PostiveFeedbackWidget(n,t,i,r,u){var f=this;f.satWidgetAu=n;f.satWidgetNz=t;f.wallCountTotalElement=r;f.wallScorePercAu=i;f.isMobileDevice=u;f.addCommas=function(n){n+="";for(var i=n.split("."),t=i[0],u=i.length>1?"."+i[1]:"",r=/(\d+)(\d{3})/;r.test(t);)t=t.replace(r,"$1,$2");return t+u};f.getFormattedWallCountTotal=function(n){return f.addCommas(n>100?Math.floor(n/100)*100:n)};f.updateWallCountTotal=function(n){var t=f.getFormattedWallCountTotal(n);f.wallCountTotalElement.html(t)};f.loadPostiveFeedbackGrid=function(n){for(var i,t=n.length-1;t>=0;t--)i=n[t],$("#postiveFeedback"+(t+1)+"_href").attr("href","/wall?feedbackCode="+i.FeedbackCode),$("#postiveFeedback"+(t+1)+"_quote").html(f.getFeedbackNotes(i.Notes)),$("#postiveFeedback"+(t+1)+"_cite").html(i.LoadFirstName+"  "+i.HowLongAgo.Key+" "+i.HowLongAgo.Value)};f.getFeedbackNotes=function(n){return n.length<100?n:n.substr(0,n.lastIndexOf(" ",97))+"..."};f.applyCirclifulOnMyStat=function(){f.satWidgetAu.circliful()};f.loadSatisfaction=function(n){f.updateWallCountTotal(n.WallTotal);var t=n.ComplimentPercentage+"<sup>%<\/sup>",i=n.ComplimentPercentage;f.satWidgetNz.length&&f.satWidgetNz.html(t);f.satWidgetAu.length&&!f.isMobileDevice&&(f.satWidgetAu.attr("data-text",t),f.wallScorePercAu.html(t),f.satWidgetAu.attr("data-percent",i),f.satWidgetAu.attr("data-part",i),f.applyCirclifulOnMyStat())}}function showCountryRedirectModal(){logFlashEventAPI("divCountryRedirectModal_show");$("#divCountryRedirectModal").removeClass("display-none")}function hideCountryRedirectModal(){$("#divCountryRedirectModal").addClass("display-none")}var showDebugLogs,postiveFeedbackWidget,youi,lastFeedbackItem,freewallFeedback,feedbacksPerPage;(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=!0;youi=youi||{};youi.state=function(){}();$(document).ready(function(){if(webInitAPI(webInitComplete),$(".video-modal").length>0&&(console.log("found video modal"),$(".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();$("#CountryRedirectRequired").val()=="True"&&showCountryRedirectModal()});var width=$(window).width(),height=$(window).height(),isMobile=!1;feedbacksPerPage=6