(function(){"use strict";angular.module("karinourish-brandsite",["uiServices","accordion","modal","contact","ourstory","karinourish-responsive-table","subnav","duScroll","quoteSlideShow","country-detection"]).directive("cemail",function(){return{restrict:"A",require:"ngModel",link:function(n,t,i,r){function u(n){if(!n)return!0;var t=/^[_A-Za-z0-9-+]+(.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(.[A-Za-z0-9]+)*(.[A-Za-z]{2,})$/;return t.exec(n)!==null}function f(n){return r.$setValidity("cemail",u(n)),u?n:undefined}r.$parsers.unshift(f)}}})})(),function(){"use strict";angular.module("common-service",[]).directive("scrollToTop",function(){return{restrict:"A",link:function(n,t){alert("clicked");t.on("click",function(n){n.preventDefault()})}}})}(),function(){"use strict";angular.module("country-detection",["LocalStorageModule"]).config(["localStorageServiceProvider",function(n){n.setPrefix("k").setStorageCookie(0,"/")}]).controller("CountryDetectionCtrl",["$http","$scope","$modal","$attrs","localStorageService",function(n,t,i,r,u){function f(n,r,f){t.destCountry=n,t.currCountry=r,t.countryUrl=f.indexOf("http")===0?f:"http://"+f,i.open({templateUrl:"country-detection-modal.html",scope:t}),u.cookie.set("countryshown",!0)}if(u.cookie.isSupported&&!u.cookie.get("countryshown")){var e=r.countrycode,o=r.nzurl,s=r.auurl;n.get("//ipinfo.io/json").success(function(n){n.country!=e&&(n.country=="NZ"?f("Australia","New Zealand",o):n.country=="AU"&&f("New Zealand","Australia",s))})}}])}(),function(){angular.module("quoteSlideShow",[]).controller("slideShowCtrl",["$scope","$timeout",function(n,t){function e(){n.currentIndex=0,n.selectedId="slide-0"}var i,u,f,r;e(),u=document.querySelector("#slides").children,f=u.length,n.animateSlideshow=!0,r=function(){i=t(function(){n.next(),i=t(r,5e3)},1e3)},n.animateSlideshow&&r(),n.next=function(){n.currentIndex<f-1?n.currentIndex++:n.currentIndex=0,n.selectedId="slide-"+n.currentIndex},n.select=function(t){n.currentIndex=t,n.selectedId="slide-"+t},n.$on("$destroy",function(){t.cancel(i)})}]).directive("activeSlide",function(){return{link:function(n,t){angular.element(t.parent()[0].firstElementChild).addClass("active");t.on("click",function(){t.parent().children().removeClass("active"),t.addClass("active")})}}})}(),function(){angular.module("accordion",["ui.bootstrap.collapse"]).directive("accordionGroup",function(){return{restrict:"EA",scope:{collapseOthers:"=",recordHistory:"="},controller:["$scope","$location",function(n,t){var i=[];this.addGroup=function(n){i.push(n)},this.hideGroups=function(t){if(n.collapseOthers)for(var r=0;r<i.length;r++)i[r]!=t&&(i[r].open=!1)},this.isAccordionOpenParameter=function(n){return t.search()[n]?t.search()[n]===!0:undefined},this.setAccordionOpenParameter=function(i){n.recordHistory&&(t.search(i,!t.search()[i]),t.replace())},this.getAccordionParamsLength=function(){return Object.keys(t.search()).length}}]}}).directive("accordion",["$compile",function(n){return{restrict:"EA",scope:{initiallyOpen:"="},require:"^accordionGroup",link:function(t,i,r,u){n(i.contents())(t.$new()),u.isAccordionOpenParameter(r.id)!==undefined?t.open=u.isAccordionOpenParameter(r.id)===!0:t.initiallyOpen&&u.getAccordionParamsLength()<1?(t.open=!0,u.setAccordionOpenParameter(r.id)):t.open=!1,t.toggleAccordion=function(){u.hideGroups(t),t.open=!t.open,u.setAccordionOpenParameter(r.id)},u.addGroup(t)}}}])}(),angular.module("ui.bootstrap.collapse",[]).directive("collapse",["$animate",function(n){return{link:function(t,i,r){function u(){i.removeClass("collapse").addClass("collapsing"),n.addClass(i,"in",{to:{height:i[0].scrollHeight+"px"}}).then(f)}function f(){i.removeClass("collapsing"),i.css({height:"auto"})}function e(){i.css({height:i[0].scrollHeight+"px"}).removeClass("collapse").addClass("collapsing"),n.removeClass(i,"in",{to:{height:"0"}}).then(o)}function o(){i.css({height:"0"}),i.removeClass("collapsing"),i.addClass("collapse")}t.$watch(r.collapse,function(n){n?e():u()})}}}]),function(){angular.module("contact",["ui.bootstrap.position","ui.bootstrap.dateparser","ui.bootstrap.tpls","ui.bootstrap.datepicker"]).factory("httpFormDataTransform",function(){return function(n){var i=[],t;for(t in n)i.push(encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return i.join("&")}}).service("contactService",["$http","httpFormDataTransform",function(n,t){return{Submit:function(i){return n({method:"POST",url:"/umbraco/surface/ContactForm/Send",headers:{"Content-Type":"application/x-www-form-urlencoded"},transformRequest:t,data:i})}}}]).controller("contactController",["$scope","$modal","contactService",function(n,t){n.openModal=function(){t.open({templateUrl:"contact-modal.html"})}}]).run(["$compile","$rootScope",function(n,t){var i=angular.element(document.querySelector('a[href$="#livechat"]'));if(i)i.on("click",function(i){return lpElm=angular.element(document.querySelector('span[data-lp-event="click"]')),compiled=n(lpElm)(t),compiled.triggerHandler("click"),i.preventDefault(),!1})}]).controller("breastIsBestController",["$scope","$modal",function(n,t){n.openModal=function(){window.scrollTo(0,0),t.open({templateUrl:"breast-is-best-modal.html"})}}]).controller("contactformController",["$scope","$modal","contactService",function(n,t,i){function r(t,i){n.isSubmitting=!1,n.submitted=t,n.resultMessage=i,document.querySelector(".modal").scrollTop=0,u()}function u(){setTimeout(function(){t.close()},8e3)}n.isSubmitting=!1,n.submitted=!1,n.resultMessage="",n.openModal=function(){t.open({templateUrl:"contact-modal.html"})},n.submitForm=function(t){n.isSubmitting=!0,i.Submit(t).then(function(n){r(!0,n.data)},function(n){r(!1,n.data)})}}]).service("leaveSiteService",function(){var n={urlTarget:"urlString",urlTitle:"urlTitle"};return{setObject:function(t){n=t},getEventLinkObject:function(){return n}}}).controller("ExternalLinksController",["$scope","$modal","$timeout",function(n,t){n.openModalLeaveSite=function(i,r){i.preventDefault(),n.linkUrl=i.target.href,n.linkCaption=i.currentTarget.innerText.trim(),t.open({templateUrl:r,scope:n})},n.closeModalLeaveSite=function(){t.close()},n.leaveSiteExternalLink=function(i){i.preventDefault(),t.close(),window.open(n.linkUrl,"_blank")}}]).controller("FooterLinksController",["$scope","$modal","$timeout",function(n,t){n.openModalLeaveSite=function(i){i.preventDefault(),n.linkUrl=i.target.href,n.linkCaption=i.currentTarget.innerText.trim(),t.open({templateUrl:"accept-leaving-site-modal.html",scope:n})},n.closeModalLeaveSite=function(){t.close()},n.leaveSiteExternalLink=function(i){i.preventDefault(),t.close(),window.open(n.linkUrl,"_blank")}}]).controller("gentlePromiseController",["$scope","$document",function(n,t){n.doSurvey=function(){n.showSurvey=!0,t.scrollTopAnimated(0)}}]).service("gentlePromiseService",["$http","httpFormDataTransform","$q","baseSiteUrl",function(n,t,i,r){function u(n,t){var r=i.defer();return setTimeout(function(){n.submit(t,function(n){n?n.data&&n.data.duplicateFields&&n.data.duplicateFields[0]=="emailAddress"?r.reject("duplicate_email"):r.reject("submission_error"):r.resolve("submission_succeed")})},5e3),r.promise}return{submitSurvey:function(n){return!input||!input.campaigns[0]?i.defer().promise:u(input.campaigns[0],n)},sendConfirmation:function(i){return n({method:"POST",url:r+"/umbraco/surface/gentlepromiseform/confirm",headers:{"Content-Type":"application/x-www-form-urlencoded"},transformRequest:t,data:i})}}}]).directive("autoNext",function(){return{require:["^form"],restrict:"A",link:function(n,t,i){function f(n){var t=n[0].nextElementSibling;if(t)return t}var u=parseInt(i.maxlength);t.on("keyup",function(){if(t.val().length==u){var i=f(t);i&&i.focus()}})}}}).controller("gentlePromiseFormController",["$scope","$document","gentlePromiseService","$attrs",function(n,t,i,r){function e(n){angular.forEach(n.$error,function(n){angular.forEach(n,function(n){n.$setTouched()})})}function o(){var t=n.form.firstName||"",i=n.form.lastName||"";n.form.bankChequeName=t+" "+i}function u(t,i,r,u,f){n.showPart1=t,n.showPart2=i,n.showPart3=r,n.showSubmissionInProgress=u,n.showConfirmation=f}function c(t){n.submissionFailed=!1,n.submissionSucceeded=!1,n.submissionSubmitted=!0,u(!1,!1,!1,!0,!1),i.submitSurvey(t).then(function(){l(t)},function(t){switch(t){case"duplicate_email":u(!0,!1,!1,!1,!1);break;case"submission_error":n.submissionFailed=!0,u(!1,!1,!1,!1,!0);return}})}function l(t){i.sendConfirmation(t).then(function(){n.submissionSucceeded=!0,console.log("survey submission completed")},function(){n.submissionFailed=!0,console.log("survey submission failed")}).then(function(){u(!1,!1,!1,!1,!0)})}var s=r.states||"",h=r.products||"",f=r.country||"";n.states=s.split(","),n.form={},n.form.communicationOptIn=!0,n.form.country=f,n.products=h.split(","),n.showPart1=!0,n.showPart2=!1,n.showPart3=!1,n.showSubmissionInProgress=!1,n.showConfirmation=!1,n.dateFormat="dd-MM-yyyy",n.form.purchaseDate=null,n.form.purchaseDateOpened=!1,n.dateOptions={formatYear:"yyyy","max-mode":"month","show-weeks":!1,startingDay:1,maxDate:new Date(2016,11,31)},n.dateOptions.minDate=f==="Australia"?new Date(2015,2,1):new Date(2015,5,1),n.openPurchaseDate=function(t){t.preventDefault(),t.stopPropagation(),n.form.purchaseDateOpened=!0},n.proceed=function(i){switch(i){case"part1":u(!0,!1,!1,!1,!1);break;case"part2":e(n.GentlePromiseFormPart1),n.GentlePromiseFormPart1.$valid&&u(!1,!0,!1,!1,!1);break;case"part3":e(n.GentlePromiseFormPart2),n.GentlePromiseFormPart2.$valid&&(n.form.purchaseAmount=n.form.purchaseAmountDollars+"."+n.form.purchaseAmountCents,u(!1,!1,!0,!1,!1));break;case"confirm":c(n.form)}t.scrollTopAnimated(0)},n.$watch("form.firstName",function(){o()}),n.$watch("form.lastName",function(){o()})}])}(),function(){angular.module("modal",[]).provider("$modal",function(){return{$get:["$document","$compile","$rootScope",function(n,t,i){var u={},r;return u.open=function(u){var f=n.find("body").eq(0),e=u.scope||i.$new(!0),o=angular.element('<div class="modal-close" ng-click="close()"><i class="icon icon-cancel"><\/i><\/div><div class="modal" modal><div class="modal-bg" ng-click="close()"><\/div><div class="modal-inner" template-url="'+u.templateUrl+'" modal-content><\/div><\/div>');r=t(o)(e),f.append(r),f.addClass("no-scroll"),setTimeout(function(){r.addClass("visible")},30)},u.close=function(){r.removeClass("visible"),setTimeout(function(){r.remove();var t=n.find("body").eq(0);t.removeClass("no-scroll")},420)},u}]}}).controller("ModalController",["$scope","$modal",function(n,t){n.close=function(){t.close()}}]).service("DisclaimerService",["$http",function(n){return{accept:function(){return n.post("/umbraco/surface/disclaimer/accept")}}}]).controller("DisclaimerModalController",["$scope","$document","DisclaimerService",function(n,t,i){var r=angular.element(document.getElementById("disclaimer"));n.accept=function(){i.accept().then(function(){r.removeClass("visible"),setTimeout(function(){r.remove();var n=t.find("body").eq(0);n.removeClass("no-scroll")},420)},function(){})}}]).directive("modal",function(){return{controller:"ModalController"}}).directive("modalContent",function(){return{transclude:!0,templateUrl:function(n,t){return t.templateUrl}}})}(),function(){angular.module("ourstory",[]).controller("ourstory",["$scope",function(n){n.timelineOpen=!1,n.openTimeline=function(){n.timelineOpen=!0}}])}(),function(){angular.module("subnav",[]).controller("Subnav",["$scope","$window","$location","$element","$compile",function(n,t,i,r){function e(i){var u=20,f=Math.floor(r[0].getBoundingClientRect().top+t.pageYOffset),e=t.pageYOffset>f-u?Math.floor(r[0].getBoundingClientRect().left):0,o=Math.floor(r[0].offsetWidth)-16;n.left=e,n.width=o,n.stickyChildStyles={left:e+"px",width:o+"px"},i&&n.$apply(),r[t.pageYOffset>f-u?"addClass":"removeClass"]("fixed")}var f=[];n.width=0,n.left=0,e(!1),angular.element(t).bind("scroll",function(){e(!0)}),angular.element(t).bind("resize",function(){e(!0)}),this.addItem=function(n){f.push(n)},this.resetItems=function(){for(var n=0;n<f.length;n++)f[n].removeClass("active")}}]).directive("subnav",["$compile",function(){return{restrict:"C",controller:"Subnav"}}]).directive("subnavItem",["$compile","anchorSmoothScroll",function(n,t){return{restrict:"A",require:"^subnav",link:function(i,r,u,f){n(r.contents())(i.$new()),i.goToElement=function(n,i){f.resetItems(),angular.element(i.target).parent().addClass("active"),t.scrollTo(n,10)},f.addItem(r)}}}])}(),function(){for(var n,u=function(){},t=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],i=t.length,r=window.console=window.console||{};i--;)n=t[i],r[n]||(r[n]=u)}(),function(){angular.module("karinourish-responsive-table",["uiServices"]).controller("ResponsiveTableCtrl",["$scope",function(){function o(n){return Array.prototype.map.call(n,function(n){return n.innerHTML})}function u(n){r=n,t.selectedRowHeader=i[n],t.responsiveRows=f.map(function(t,i){var r=e[n].querySelector("td:nth-child("+(i+2)+")");return{header:t,value:r.innerHTML}}),t.hasPrevRow=n>0,t.hasNextRow=n<i.length-1}var t=this,f,i,e,r=-1;this.analyseTableElements=function(n){var r=n[0],s=angular.element(r.querySelector("caption"));t.caption=s.html(),f=o(r.querySelectorAll("tr:first-child > *:not(:first-child)")),i=o(r.querySelectorAll("tr:not(:first-child) > *:first-child")),e=r.querySelectorAll("tr:not(:first-child)"),u(0)},this.incrementIndex=function(n){n==-1&&t.hasPrevRow&&u(r-1),n==1&&t.hasNextRow&&u(r+1)}}]).directive("table",["$compile","kariBreakpointService",function(){return{scope:!0,controllerAs:"vm",controller:"ResponsiveTableCtrl",restrict:"E",link:function(n,t,i,r){i.tableNotResponsive||(r.analyseTableElements(t),t.append('<thead class="hidden-desktop" responsive-table-controls><\/thead><tbody class="hidden-desktop" responsive-table><\/tbody>'))}}}]).directive("responsiveTable",["$compile",function(n){return{require:"^table",restrict:"AE",link:function(t,i){var u='<tr ng-repeat="row in vm.responsiveRows"><th ng-bind="row.header"><\/th><td ng-bind="row.value"><\/td><\/tr>',f=n(u)(t);i.append(f)}}}]).directive("responsiveTableControls",["$compile",function(n){return{require:"^table",restrict:"AE",link:function(t,i){var u='<tr><td colspan="2"><a href ng-click="vm.incrementIndex(-1)" class="inactive" ng-class="{\'inactive\':!vm.hasPrevRow}"><\/a><div><p ng-bind="::vm.caption"><\/p><h3 ng-bind="vm.selectedRowHeader"><\/h3><\/div><a href ng-click="vm.incrementIndex(1)" ng-class="{\'inactive\':!vm.hasNextRow}"><\/a><\/td><\/tr>',f=n(u)(t);i.append(f)}}}])}(),function(){"use strict";angular.module("uiServices",[]).run(["$window","kariBreakpointService",function(n,t){var i=angular.element(n);i.on("resize",function(){t.updateBreakpoint(i[0].innerWidth)});t.updateBreakpoint(i[0].innerWidth)}]).factory("kariBreakpointService",["$rootScope",function(n){function i(n){return n>960?"desktop":n>767?"tablet":"mobile"}var t;return{updateBreakpoint:function(r){var f=t,u=i(r);u!=f&&n.$apply(function(){n.$broadcast("gygMediaBreakpointChanged",u,f),t=u})},getBreakpoint:function(){return t}}}]).controller("navCtrl",["$scope",function(n){n.navOpen=!1,n.searchOpen=!1,n.isSearchPage=!1,document.querySelector(".page-search")&&(n.isSearchPage=!0),n.toggleNav=function(t){t!="menu"||n.navOpen?t!="search"||n.searchOpen?(n.searchOpen=!1,n.navOpen=!1):(n.searchOpen=!0,n.navOpen=!1):(n.searchOpen=!1,n.navOpen=!0)}}]).controller("search",["$scope",function(n){function t(){n.searchTerm&&(window.location.href="/search?query="+window.encodeURIComponent(n.searchTerm))}n.open=!1,n.style="",n.toggleOrSearch=function(){n.disableSearch||(n.style==="open"?t():n.style="open")},n.doSearch=function(){t()}}]).service("anchorSmoothScroll",function(){this.scrollTo=function(n,t){function l(){return self.pageYOffset?self.pageYOffset:document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop?document.body.scrollTop:0}function a(n){for(var r=document.getElementById(n),u=r.offsetTop,i=r;i.offsetParent&&i.offsetParent!=document.body;)i=i.offsetParent,u+=i.offsetTop;return u-(t?t:0)}var r=l(),i=a(n),s=i>r?i-r:r-i,e,h,c;if(s<100){scrollTo(0,i);return}e=Math.round(s/100),e>=20&&(e=20);var f=Math.round(s/25),u=i>r?r+f:r-f,o=0;if(i>r){for(h=r;h<i;h+=f)setTimeout("window.scrollTo(0, "+u+")",o*e),u+=f,u>i&&(u=i),o++;return}for(c=r;c>i;c-=f)setTimeout("window.scrollTo(0, "+u+")",o*e),u-=f,u<i&&(u=i),o++}})}()