!function(e,t){"use strict";function n(t,s,i){"undefined"==typeof e(t).eq(0).data(s)?(e(t).eq(0).data(s,!0),i()):setTimeout(function(){n(t,s,i)},50)}t.Initdocs={Nav:function(){function t(){s=e(".js_header_nav"),enquire.register("screen and (max-width: 570px)",{match:function(){e(".js_header_button").on("click",n)},unmatch:function(){e(".js_header_button").off("click")},deferSetup:!0})}function n(t){t.preventDefault();var n=e(this);if(n.hasClass("is_selected"))n.removeClass("is_selected"),s.removeClass("header_has_search_expanded header_has_menu_expanded");else{var i=n.hasClass("iconf-search")?"search":"menu",a="search"===i?"header_has_search_expanded":"header_has_menu_expanded",o="search"===i?"header_has_menu_expanded":"header_has_search_expanded";s.find(".is_selected").removeClass("is_selected"),n.addClass("is_selected"),s.addClass(a).removeClass(o)}}var s;return{init:t}}(),SearchBlock:function(){function t(){e(document).on("focus",".search_block",function(){e(this).addClass("search_block_has_focus")}),e(document).on("blur",".search_block",function(){e(this).removeClass("search_block_has_focus")})}return{init:t}}(),Equalisation:function(){function t(){enquire.register("screen and (min-width: 480px) and (max-width: 639px)",{match:function(){n(".js_equalise_is_landing .list_item","equalise",function(){e(".js_equalise_is_landing .list_item").evenSteven({columns:2,resize:!0})})},unmatch:function(){e(".js_equalise_is_landing .list_item").eq(0).removeData("equalise"),e(".js_equalise_is_landing .list_item").evenSteven("destroy")},deferSetup:!0}),enquire.register("screen and (min-width: 640px)",{match:function(){e(".js_equalise_is_level_2 .list_item").evenSteven({columns:2,resize:!0}),n(".js_equalise_is_landing .list_item","equalise",function(){e(".js_equalise_is_landing .list_item").evenSteven({columns:2,resize:!0})})},unmatch:function(){e(".js_equalise_is_level_2 .list_item").evenSteven("destroy"),e(".js_equalise_is_landing .list_item").evenSteven("destroy"),e(".js_equalise_is_landing .list_item").eq(0).removeData("equalise")},deferSetup:!0})}return{init:t}}(),SubNav:function(){function n(){y=e(".js_grid"),g=e("#js_subnav"),b=g.find(".js_subnav_list"),q=e("#js_page_content").find("h2"),j=e(".js_subnav_container"),g.length&&(q.length<2?g.css({visibility:"hidden",height:"1px",overflow:"hidden"}):(f(),v(),setTimeout(a,500),s()))}function s(){enquire.register("screen and (min-width: 960px)",{match:function(){u(),c(),i(),r(),p(),h(),o()},unmatch:function(){l(),_()},deferSetup:!0})}function i(){var e=j.offset().top,n=e<t.scrollY,s=n?"add":"remove";if(y[s+"Class"]("subnav_is_fixed"),n){var i=20,a=20,o=g.outerHeight(),r=o+i>w-(C+a),l=r&&t.scrollY+w>=document.body.scrollHeight-(C+a);y[(l?"add":"remove")+"Class"]("subnav_is_stuck_to_bottom")}}function a(){var e=g.find('a[href="#'+d().attr("id")+'"]'),t=g.find(".js_is_current");t.removeClass(x+" js_is_current"),e.addClass(x+" js_is_current")}function o(){var e=b.find(".js_is_current");if(e.length){var t=g.find('a[href="#'+d().attr("id")+'"]');e!==t&&(e.removeClass(x+" js_is_current"),t.addClass(x+" js_is_current"))}}function r(){g.css("width",j.width()+"px")}function l(){g.attr("style",""),y.removeClass("subnav_is_fixed")}function c(){w=e(t).height()}function u(){e(t).on("scroll",e.throttle(100,function(){i(),o()})),e(t).on("resize",e.throttle(200,function(){c(),h()}))}function h(){q.each(function(n){var s=e(this);t.headingPositions[n]=s.offset().top-parseInt(s.css("marginTop"),10)})}function d(){for(var n,s=e(t).scrollTop(),i=t.headingPositions,a=0,o=i.length;o>a&&"undefined"==typeof n;a++)i[a]>s&&(n=Math.max(a-1,0));return"number"==typeof n?q.eq(n):q.eq(i.length-1)}function _(){e(t).off("scroll")}function f(){q.each(function(){this.id=m(e(this).text())})}function m(e){return e.toLowerCase().replace(/[^a-zA-Z0-9\s\-]/gi,"").replace(/\s/g,"-")}function p(){C=e(".footer").outerHeight()+20}function v(){var t="",n=!0;q.each(function(){var s=e(this),i=s.text();t+='<li class="grid_item one_whole s_one_half l_one_whole"><a href="#'+m(i)+'" class="js_link subnav_link">'+i+"</a></li>",n=!1}),b.append(t)}var g,b,q,j,y,x="subnav_link_is_current",C=0,w=0;return t.setInterval(function(){h(),o()},2e3),t.headingPositions=[],{init:n}}(),SlideItems:function(){function n(n){if("#"===n.substr(0,1)){var s=e(n);if(s.length>0&&t.history&&t.history.pushState)return t.history.pushState(null,null,n),e("html,body").animate({scrollTop:1+(s.offset().top-parseInt(s.css("marginTop"),10))},1e3),!1}}function s(){e(document).on("click",".js_link",function(){n(e(this).attr("href"))}),t.location.hash&&e(t).on("load",function(){n(t.location.hash)})}return{init:s}}()};var s=!0;e(document).ready(function(){var n,i=e("#search"),a=i.val(),o=e("#search_results"),r=e("#results"),l=e("#no-results"),c=e("#page_content"),u=e("h1",o),h=e(".search-results",o),d=!1;s&&(r.css({minHeight:e(">.wrapper",c).height()}),s=!1),i.parents("form").eq(0).on("submit",function(e){return e.preventDefault(),!1}),i.on("keyup",e.throttle(200,function(){var s=i.val(),_=e("<div/>").text(s).html();(s!=a||d)&&(d=!1,a=s,"undefined"!=typeof n&&"function"==typeof n.abort&&n.abort(),0===s.length?(o.hide(),c.show()):(c.hide(),h.html(""),o.show(),u.html('Searching for &#8220;<span class="highlight">'+_+"</span>&#8221;"),u.append('<img src="https://s3.amazonaws.com/helpjuice_production/uploads/upload/image/1856/14890/ajax-loader.gif" class="search-activity-indicator" />'),n=e.get("/search",{query:s}).done(function(n){var s,i,a;if(u.html(""),0===n.length)u.html('Sorry, we found <span class="highlight">0</span> results for &#8220;<span class="highlight">'+_+"</span>&#8221;"),r.addClass("hidden"),l.removeClass("hidden"),e(t).trigger("resize");else{r.removeClass("hidden"),l.addClass("hidden"),u.html('Search results for &#8220;<span class="highlight">'+_+"</span>&#8221;");for(var o=0,c=n.length;c>o;o++)s=n[o].question,console.log(n[o].question),i=e('<li class="list_item"><h2 class="list_heading text_impact"><a></a></h2><p class="list_content"></p></li>'),a=e("a",i),a.text(s.name),a.attr("href",s.url),e("p",i).text(s.long_answer_sample.substr(0,220)+"..."),h.append(i)}e("body").hasClass("landing_page")&&e(t).width()>=570&&e("html,body").animate({scrollTop:0},1400)}).fail(function(e){404===e.status&&(d=!0,t.setTimeout(function(){i.trigger("keyup")},250))})))})),null!==location.hash.match("#search_query")&&(i.val(decodeURIComponent(location.hash.split("=")[1])),i.trigger("keyup"))})}(jQuery,window),Initdocs.SearchBlock.init(),Initdocs.SubNav.init(),Initdocs.Equalisation.init(),Initdocs.Nav.init(),Initdocs.SlideItems.init(),$(function(){$("input").blur()}),$(document).ready(function(){function e(e){return e.toLowerCase().replace(/[^a-zA-Z0-9\s\-]/gi,"").replace(/\s/g,"-")}$(".article-body h1").each(function(t){var n=e($(this).text());$(this).attr("id",n),$(".article-body h1").length>2&&(0==t&&$("#table-of-contents").append("<h3>In this article</h3>"),$("#table-of-contents").append("<li><a href='#"+n+"'>"+$(this).html()+"</a></li>"))})});