function onWindowResize(n){var t=$(window).width(),i=$(window).height();$(window).resize(function(){var r=$(window).width(),u=$(window).height();(r!==t||u!==i)&&(t=r,i=u,n())})}function getScripts(n,t){var i=0;n.forEach(function(r){$.getScript(r,function(){++i==n.length&&typeof t=="function"&&t()})})}function htmlDecode(n){return $("<textarea/>").html(n).text()}function htmlEncode(n){return $("<textarea/>").text(n).html()}function hideScrollbar(n,t){var i=n.outerWidth(!0);$(".stream",n).width(i+t)}function showNarrow(n){n.outerWidth(!0)<320?$(".twitter-timeline",n).addClass("env-narrow"):$(".twitter-timeline",n).removeClass("env-narrow")}function setStreamHeight(n,t){var i,r,u,f,e;t==!1?(i=0,$(".timeline-header",n).is(":visible")&&(i=$(".timeline-header",n).outerHeight(!0)),r=0,$(".timeline-footer",n).is(":visible")&&(r=$(".timeline-footer",n).outerHeight(!0)),u=n.outerHeight(!0),f=u-(i+r),$(".stream",n).height(f)):(e=$(".h-feed",n).outerHeight(!0),$(".stream",n).height(e))}function updateFeed(){$(".twitter_feed").each(function(){var n=$(this),t=!1,i=!1,r=-2;$(".twitter-timeline",n).hasClass("var-static")&&(t=!0);i=$(".twitter-timeline",n).data("show-scrollbar");t===!1&&i==="False"&&(r=16);hideScrollbar(n,r);showNarrow(n);setStreamHeight(n,t)})}function checkNotEmptyInput(){$("#search").attr("disabled",$.trim($("#q").val())=="")}function addTwitterHashTags(){var n=$('meta[name="twitter:hashtags"]').attr("content");n!=null&&n.length>0&&($("#hlCsTwitter").attr("href",$("#hlCsTwitter").attr("href")+"&amp;hashtags="+n),$("#hlCsTwitterSm").attr("href",$("#hlCsTwitter").attr("href")))}function addWhatsAppShare(){var n=$('meta[name="description"]').attr("content")!=null?$('meta[name="description"]').attr("content"):"",t="whatsapp://send?text="+encodeURIComponent(n+" - "+window.location);$("#hlCsWhatsAppSm").attr("href",t)}function textResizeDetection(){TextResizeDetector.TARGET_ELEMENT_ID="mainContainerFrame";TextResizeDetector.USER_INIT_FUNC=init}function onFontResize(n,t){var i=t[0].iSize;i>threshold?loadCSS("/css/bootstrap-accessibility-firefox.css"):$("link[href='/css/bootstrap-accessibility-firefox.css']").remove()}function init(){var n=TextResizeDetector.addEventListener(onFontResize,null);n>threshold?loadCSS("/css/bootstrap-accessibility-firefox.css"):$("link[href='/css/bootstrap-accessibility-firefox.css']").remove()}function checkSearchHasValue(){return $.trim($("#q").val())==""?($("#support-message").text("Please type a query into the search box."),$("#searchpanel #q").focus(),!1):!0}function applyFocusVisiblePolyfill(n){function f(n){return n&&n!==document&&n.nodeName!=="HTML"&&n.nodeName!=="BODY"&&"classList"in n&&"contains"in n.classList?!0:!1}function c(n){var i=n.type,t=n.tagName;return t=="INPUT"&&h[i]&&!n.readOnly?!0:t=="TEXTAREA"&&!n.readOnly?!0:n.isContentEditable?!0:!1}function o(n){n.classList.contains("focus-visible")||(n.classList.add("focus-visible"),n.setAttribute("data-focus-visible-added",""))}function l(n){n.hasAttribute("data-focus-visible-added")&&(n.classList.remove("focus-visible"),n.removeAttribute("data-focus-visible-added"))}function a(t){t.metaKey||t.altKey||t.ctrlKey||(f(n.activeElement)&&o(n.activeElement),i=!0)}function e(){i=!1}function v(n){f(n.target)&&(i||c(n.target))&&o(n.target)}function y(n){f(n.target)&&(n.target.classList.contains("focus-visible")||n.target.hasAttribute("data-focus-visible-added"))&&(r=!0,window.clearTimeout(u),u=window.setTimeout(function(){r=!1;window.clearTimeout(u)},100),l(n.target))}function p(){document.visibilityState=="hidden"&&(r&&(i=!0),s())}function s(){document.addEventListener("mousemove",t);document.addEventListener("mousedown",t);document.addEventListener("mouseup",t);document.addEventListener("pointermove",t);document.addEventListener("pointerdown",t);document.addEventListener("pointerup",t);document.addEventListener("touchmove",t);document.addEventListener("touchstart",t);document.addEventListener("touchend",t)}function w(){document.removeEventListener("mousemove",t);document.removeEventListener("mousedown",t);document.removeEventListener("mouseup",t);document.removeEventListener("pointermove",t);document.removeEventListener("pointerdown",t);document.removeEventListener("pointerup",t);document.removeEventListener("touchmove",t);document.removeEventListener("touchstart",t);document.removeEventListener("touchend",t)}function t(n){n.target.nodeName&&n.target.nodeName.toLowerCase()==="html"||(i=!1,w())}var i=!0,r=!1,u=null,h={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};document.addEventListener("keydown",a,!0);document.addEventListener("mousedown",e,!0);document.addEventListener("pointerdown",e,!0);document.addEventListener("touchstart",e,!0);document.addEventListener("visibilitychange",p,!0);s();n.addEventListener("focus",v,!0);n.addEventListener("blur",y,!0);n.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&n.host?n.host.setAttribute("data-js-focus-visible",""):n.nodeType===Node.DOCUMENT_NODE&&document.documentElement.classList.add("js-focus-visible")}var threshold,RESPONSIVEUI,event;loadCSS=function(n){var t=$("<link>");$("head").append(t);t.attr({rel:"stylesheet",type:"text/css",href:n})};updateFeed();$("a",".twitter_feed").click(function(){$(this).attr("target","_blank")});TextResizeDetector=function(){function h(){window.clearInterval(i);i=null}function f(){i||(i=window.setInterval("TextResizeDetector.detect()",o))}function c(){var i=TextResizeDetector.getSize(),n,f;if(i!==t)for(n=0;n<r.length;n++)aListnr=r[n],f={iBase:u,iDelta:t!=-1?i-t+"px":"0px",iSize:t=i},aListnr.obj?aListnr.fn.apply(aListnr.obj,["textSizeChanged",[f]]):aListnr.fn("textSizeChanged",[f]);return t}var n=null,o=200,i=null,t=-1,u=-1,r=[],s=function(){n=document.createElement("span");n.id="textResizeControl";n.innerHTML="&nbsp;";n.style.position="absolute";n.style.left="-9999px";var i=document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID);i&&i.insertBefore(n,i.firstChild);u=t=TextResizeDetector.getSize()},e=function(){TextResizeDetector.onAvailableCount_i||(TextResizeDetector.onAvailableCount_i=0);document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID)?(TextResizeDetector.init(),TextResizeDetector.USER_INIT_FUNC&&TextResizeDetector.USER_INIT_FUNC(),TextResizeDetector.onAvailableCount_i=null):TextResizeDetector.onAvailableCount_i<600&&(TextResizeDetector.onAvailableCount_i++,setTimeout(e,200))};return setTimeout(e,500),{init:function(){s();f()},addEventListener:function(n,t){return r[r.length]={fn:n,obj:t},u},detect:function(){return c()},getSize:function(){return n.offsetHeight},stopDetector:function(){return h()},startDetector:function(){return f()}}}();TextResizeDetector.TARGET_ELEMENT_ID="doc";TextResizeDetector.USER_INIT_FUNC=null;$(window).ready(function(){addWhatsAppShare();addTwitterHashTags();textResizeDetection()});threshold=24;$(document).ready(function(){$(".scrollToTop > img").click(function(){$("html, body").animate({scrollTop:0},800)});$(".scrollToTop").bind("keydown",function(n){var t=n.keyCode?n.keyCode:n.which;t===13&&($("html, body").animate({scrollTop:0},800),$("#skip-to-content").focus())})});RESPONSIVEUI={},function(n){RESPONSIVEUI.responsiveTabs=function(){var i=n(".responsive-tabs"),t,r;i.hasClass("responsive-tabs--enabled")||(i.addClass("responsive-tabs--enabled"),t=1,i.each(function(){var i=n(this),c,h,f,r,e,o,s,u;n(i).hasClass("full")?(c=i[0].getAttribute("data-multi"),h=i[0].getAttribute("data-panel")):f=1;i.children(":header").addClass("responsive-tabs__heading");i.children("div").addClass("responsive-tabs__panel");(h==="true"||f===1)&&(r=i.find(".responsive-tabs__panel--active"),r.length||(r=i.find(".responsive-tabs__panel").first().addClass("responsive-tabs__panel--active")));h==="true"||f===1?i.hasClass("full")&&(r=i.find(".responsive-tabs__heading--active"),r.length||(r=i.find(".responsive-tabs__heading").first().addClass("responsive-tabs__heading--active"))):i.hasClass("full")&&(r=i.find(".responsive-tabs__heading--active"),r.length||r.addClass("responsive-tabs__panel--closed-accordion-only"));i.find(".responsive-tabs__panel").not(".responsive-tabs__panel--active").hide().attr("aria-hidden","true");r.attr("aria-hidden","false");i.hasClass("full")||r.addClass("responsive-tabs__panel--closed-accordion-only");e=n("<div/>",{"class":"responsive-tabs-wrapper"});i.wrap(e);o=0;i.find(".responsive-tabs__panel").each(function(){var t=n(this).height();t>o&&(o=t)});s=n("<ul/>",{"class":"responsive-tabs__list",role:"tablist"});u=1;i.find(".responsive-tabs__heading").each(function(){var r=n(this),h=n(this).next(),l,v,a;r.attr("tabindex",0);l=r.text().replace(/\W+/g,"-").toLowerCase();v=l.nthIndexOf("-",5);v>-1&&(l=l.substring(0,v));r.addClass(l);a=n("<li/>",{"class":"responsive-tabs__list__item "+l,id:"tablist"+t+"-tab"+u,"aria-controls":"tablist"+t+"-panel"+u,role:"tab",tabindex:0,text:r.text(),keydown:function(n){n.keyCode===13&&a.click()},click:function(){e.css("height",o);i.find(".responsive-tabs__panel--closed-accordion-only").removeClass("responsive-tabs__panel--closed-accordion-only");i.find(".responsive-tabs__panel--active").toggle().removeClass("responsive-tabs__panel--active").attr("aria-hidden","true").prev().removeClass("responsive-tabs__heading--active");h.toggle().addClass("responsive-tabs__panel--active").attr("aria-hidden","false");r.addClass("responsive-tabs__heading--active");s.find(".responsive-tabs__list__item--active").removeClass("responsive-tabs__list__item--active");a.addClass("responsive-tabs__list__item--active");e.css("height","auto")}});h.attr({role:"tabpanel","aria-labelledby":a.attr("id"),id:"tablist"+t+"-panel"+u});h.hasClass("responsive-tabs__panel--active")&&a.addClass("responsive-tabs__list__item--active");s.append(a);r.keydown(function(n){n.keyCode===13&&r.click()});r.click(function(){var e,t,o,s,l,a,u;i.find(".responsive-tabs__panel--closed-accordion-only").removeClass("responsive-tabs__panel--closed-accordion-only");r.hasClass("responsive-tabs__heading--active")?(h.removeClass("responsive-tabs__panel--active").slideToggle(function(){n(this).addClass("responsive-tabs__panel--closed-accordion-only")}),r.removeClass("responsive-tabs__heading--active")):(t=i.find(".responsive-tabs__heading--active"),t.length&&(e=t.offset().top),(c==="false"||f===1)&&(i.find(".responsive-tabs__panel--active").slideToggle().removeClass("responsive-tabs__panel--active").prev().removeClass("responsive-tabs__heading--active"),i.find(".responsive-tabs__panel").hide().attr("aria-hidden","true")),h.slideToggle().addClass("responsive-tabs__panel--active").attr("aria-hidden","false"),r.addClass("responsive-tabs__heading--active"),o=i.find(".responsive-tabs__list__item--active"),o.removeClass("responsive-tabs__list__item--active"),s=h.attr("id"),l=s.replace("panel","tab"),n("#"+l).addClass("responsive-tabs__list__item--active"),a=i.offset().top,u=r.offset().top-15,e<u&&n("html, body").animate({scrollTop:a},0).animate({scrollTop:u},400))});u++});i.prepend(s);t++}),r="."+window.location.href.replace(/^.*?(#|$)/,""),r.length>1&&n(r,".responsive-tabs").filter(":visible").trigger("click"))};String.prototype.nthIndexOf=function(n,t){for(var i=-1;t--&&i++<this.length;)if(i=this.indexOf(n,i),i<0)break;return i}}(jQuery);RESPONSIVEUI.responsiveTabs(),function(n,t,i){function e(n){return n}function o(n){return s(decodeURIComponent(n.replace(f," ")))}function s(n){return n.indexOf('"')===0&&(n=n.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\")),n}function u(n){return r.json?JSON.parse(n):n}var f=/\+/g,r=n.cookie=function(f,s,h){var v,l,c,w;if(s!==i)return h=n.extend({},r.defaults,h),s===null&&(h.expires=-1),typeof h.expires=="number"&&(v=h.expires,l=h.expires=new Date,l.setDate(l.getDate()+v)),s=r.json?JSON.stringify(s):String(s),t.cookie=[encodeURIComponent(f),"=",r.raw?s:encodeURIComponent(s),h.expires?"; expires="+h.expires.toUTCString():"",h.path?"; path="+h.path:"",h.domain?"; domain="+h.domain:"",h.secure?"; secure":""].join("");var y=r.raw?e:o,p=t.cookie.split("; "),a=f?null:{};for(c=0,w=p.length;c<w;c++){var b=p[c].split("="),k=y(b.shift()),d=y(b.join("="));if(f&&f===k){a=u(d);break}f||(a[k]=u(d))}return a};r.defaults={};n.removeCookie=function(t,i){return n.cookie(t)!==null?(n.cookie(t,null,i),!0):!1}}(jQuery,document),function(n){n.cookieCuttr=function(t){var s={cookieCutter:!1,cookieCutterDeclineOnly:!1,cookieAnalytics:!0,cookieDeclineButton:!1,cookieAcceptButton:!0,cookieResetButton:!1,cookieOverlayEnabled:!1,cookiePolicyLink:"/privacy-policy/",cookieMessage:'We use cookies on this website, you can <a href="{{cookiePolicyLink}}" title="read about our cookies">read about them here<\/a>. To use the website as intended please...',cookieAnalyticsMessage:"We use cookies, just to track visits to our website, we store no personal details.",cookieErrorMessage:"We're sorry, this feature places cookies in your browser and has been disabled. <br>To continue using this functionality, please",cookieWhatAreTheyLink:"http://www.allaboutcookies.org/",cookieDisable:"",cookieExpires:365,cookieAcceptButtonText:"ACCEPT COOKIES",cookieDeclineButtonText:"DECLINE COOKIES",cookieResetButtonText:"RESET COOKIES FOR THIS WEBSITE",cookieWhatAreLinkText:"What are cookies?",cookieNotificationLocationBottom:!1,cookiePolicyPage:!1,cookiePolicyPageMessage:"Please read the information below and then choose from the following options",cookieDiscreetLink:!1,cookieDiscreetReset:!1,cookieDiscreetLinkText:"Cookies?",cookieDiscreetPosition:"topleft",cookieNoMessage:!1,cookieDomain:""},t=n.extend(s,t),ht=s.cookieMessage.replace("{{cookiePolicyLink}}",s.cookiePolicyLink),c,e,o,r,u,l;s.cookieMessage='We use cookies on this website, you can <a href="'+s.cookiePolicyLink+'" title="read about our cookies">read about them here<\/a>. To use the website as intended please...';var d=t.cookiePolicyLink,g=t.cookieCutter,nt=t.cookieCutterDeclineOnly,tt=t.cookieAnalytics,ct=t.cookieDeclineButton,lt=t.cookieAcceptButton,l=t.cookieResetButton,at=t.cookieOverlayEnabled,pt=t.cookiePolicyLink,it=ht,rt=t.cookieAnalyticsMessage,ut=t.cookieErrorMessage,ft=t.cookieDisable,et=t.cookieWhatAreTheyLink,p=t.cookieExpires,h=t.cookieAcceptButtonText,w=t.cookieDeclineButtonText,f=t.cookieResetButtonText,ot=t.cookieWhatAreLinkText,b=t.cookieNotificationLocationBottom,a=t.cookiePolicyPage,st=t.cookiePolicyPageMessage,v=t.cookieDiscreetLink,vt=t.cookieDiscreetReset,y=t.cookieDiscreetLinkText,i=t.cookieDiscreetPosition,yt=t.cookieNoMessage,k=n.cookie("cc_cookie_accept")=="cc_cookie_accept";n.cookieAccepted=function(){return k};c=n.cookie("cc_cookie_decline")=="cc_cookie_decline";n.cookieDeclined=function(){return c};e=lt?' <a href="#accept" class="cc-cookie-accept">'+h+"<\/a> ":"";o=ct?' <a href="#decline" class="cc-cookie-decline">'+w+"<\/a> ":"";r=at?"cc-overlay":"";u=b||i=="bottomright"||i=="bottomleft"?!0:!1;k||c?l&&vt?(u?n("body").append('<div class="cc-cookies cc-discreet"><a class="cc-cookie-reset" href="#" title="'+f+'">'+f+"<\/a><\/div>"):n("body").prepend('<div class="cc-cookies cc-discreet"><a class="cc-cookie-reset" href="#" title="'+f+'">'+f+"<\/a><\/div>"),i=="topleft"&&(n("div.cc-cookies").css("top","0"),n("div.cc-cookies").css("left","0")),i=="topright"&&(n("div.cc-cookies").css("top","0"),n("div.cc-cookies").css("right","0")),i=="bottomleft"&&(n("div.cc-cookies").css("bottom","0"),n("div.cc-cookies").css("left","0")),i=="bottomright"&&(n("div.cc-cookies").css("bottom","0"),n("div.cc-cookies").css("right","0"))):l?u?n("body").append('<div class="cc-cookies"><a href="#" class="cc-cookie-reset">'+f+"<\/a><\/div>"):n("body").prepend('<div class="cc-cookies"><a href="#" class="cc-cookie-reset">'+f+"<\/a><\/div>"):l="":(yt&&!a||(v&&!a?(u?n("body").append('<div class="cc-cookies cc-discreet"><a href="'+d+'" title="'+y+'">'+y+"<\/a><\/div>"):n("body").prepend('<div class="cc-cookies cc-discreet"><a href="'+d+'" title="'+y+'">'+y+"<\/a><\/div>"),i=="topleft"&&(n("div.cc-cookies").css("top","0"),n("div.cc-cookies").css("left","0")),i=="topright"&&(n("div.cc-cookies").css("top","0"),n("div.cc-cookies").css("right","0")),i=="bottomleft"&&(n("div.cc-cookies").css("bottom","0"),n("div.cc-cookies").css("left","0")),i=="bottomright"&&(n("div.cc-cookies").css("bottom","0"),n("div.cc-cookies").css("right","0"))):tt&&(u?n("body").append('<div class="cc-cookies '+r+'">'+rt+e+o+'<a href="'+et+'" title="Visit All about cookies (External link)">'+ot+"<\/a><\/div>"):n("body").prepend('<div class="cc-cookies '+r+'">'+rt+e+o+'<a href="'+et+'" title="Visit All about cookies (External link)">'+ot+"<\/a><\/div>"))),a?u?n("body").append('<div class="cc-cookies '+r+'">'+st+'  <a href="#accept" class="cc-cookie-accept">'+h+'<\/a>  <a href="#decline" class="cc-cookie-decline">'+w+"<\/a> <\/div>"):n("body").prepend('<div class="cc-cookies '+r+'">'+st+'  <a href="#accept" class="cc-cookie-accept">'+h+'<\/a>  <a href="#decline" class="cc-cookie-decline">'+w+"<\/a> <\/div>"):tt||v||(u?n("body").append('<div class="cc-cookies '+r+'">'+it+e+o+"<\/div>"):n("body").prepend('<div class="cc-cookies '+r+'"><div class="container">'+it+e+o+"<\/div><\/div>")));g&&!nt&&(c||!k)&&n(ft).html('<div class="cc-cookies-error">'+ut+' <a href="#accept" class="cc-cookie-accept">'+h+"<\/a> <\/div>");g&&nt&&c&&n(ft).html('<div class="cc-cookies-error">'+ut+' <a href="#accept" class="cc-cookie-accept">'+h+"<\/a> <\/div>");b&&!v&&(n("div.cc-cookies").css("top","auto"),n("div.cc-cookies").css("bottom","0"));b&&v&&a&&(n("div.cc-cookies").css("top","auto"),n("div.cc-cookies").css("bottom","0"));n(".cc-cookie-accept, .cc-cookie-decline").click(function(i){i.preventDefault();n(this).is("[href$=#decline]")?(n.cookie("cc_cookie_accept",null,{path:"/"}),n.cookie("cc_cookie_decline","cc_cookie_decline",{expires:p,path:"/"}),t.cookieDomain&&(n.cookie("__utma",null,{domain:"."+t.cookieDomain,path:"/"}),n.cookie("__utmb",null,{domain:"."+t.cookieDomain,path:"/"}),n.cookie("__utmc",null,{domain:"."+t.cookieDomain,path:"/"}),n.cookie("__utmz",null,{domain:"."+t.cookieDomain,path:"/"}))):(n.cookie("cc_cookie_decline",null,{path:"/"}),n.cookie("cc_cookie_accept","cc_cookie_accept",{expires:p,path:"/"}));n(".cc-cookies").fadeOut(function(){})});n("a.cc-cookie-reset").click(function(t){t.preventDefault();n.cookie("cc_cookie_accept",null,{path:"/"});n.cookie("cc_cookie_decline",null,{path:"/"});n(".cc-cookies").fadeOut(function(){location.reload()})});n(".cc-cookies-error a.cc-cookie-accept").click(function(t){t.preventDefault();n.cookie("cc_cookie_accept","cc_cookie_accept",{expires:p,path:"/"});n.cookie("cc_cookie_decline",null,{path:"/"});location.reload()})}}(jQuery);$(document).ready(function(){$.cookieCuttr({cookieAnalytics:!1,cookieMessage:'<div class="cc-text">By continuing to use this site, you are agreeing to our <a href="{{cookiePolicyLink}}">use of cookies<\/a>. If you do not want to see this message again, click continue.<\/div>',cookiePolicyLink:"/pages/cookies.aspx",cookieAcceptButtonText:"Continue"})});window.applyFocusVisiblePolyfill=applyFocusVisiblePolyfill;try{event=new CustomEvent("focus-visible-polyfill-ready")}catch(error){event=document.createEvent("CustomEvent");event.initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(event);applyFocusVisiblePolyfill(document);var chatbotInactivityTimer,chatWindowOpen=!1,chatbotState="INIT",CHATBOT_SESSION_ID_DURATION=33e5,CHATBOT_INACTIVITY_DURATION=1e4,CHATBOT_TYPING_DELAY=500,CHATBOT_CLOSE_WINDOW_DELAY=2e3,CHATBOT_PING_WAITING_TIME=500,CHATBOT_SESSION_MESSAGE_DURATION=1500,CHATBOT_MAX_SESSION_ID_TRIES=5;$(document).ready(function(){function kt(){chatWindowOpen=!0;clearTimeout(chatbotInactivityTimer);$("#chatbot-window").fadeIn();$("#chatbot-user-input").focus()}function y(){chatWindowOpen=!1;bt();$("#chatbot-window").fadeOut()}function p(){$("#chatbot-welcome").fadeIn()}function o(){$("#chatbot-welcome").hide()}function w(){$("#chatbot-button").css("opacity",1);o()}function i(){$("#chatbot-button").css("opacity",0)}function s(n){document.getElementById("chatbot-alert").innerHTML=n;$("#chatbot-alert").show()}function h(){$("#chatbot-alert").hide()}function b(n){n?$("#chatbot-new-session-alert").text("Your session will start shortly"):$("#chatbot-new-session-alert").text("Your session has expired. A new one will start shortly.");$("#chatbot-new-session-alert").show()}function c(){$("#chatbot-new-session-alert").hide()}function dt(){$("#chatbot-typing-indicator").show()}function l(){$("#chatbot-typing-indicator").hide()}function k(n){n||(chatbotState="IDLE");y();w();o()}function gt(n){$("#chatbot-user-input").attr("placeholder",n)}function r(){$("#chatbot-user-input").attr("disabled",!0);$("#chatbot-user-input").addClass("disabled")}function u(){$("#chatbot-user-input").attr("disabled",!1);$("#chatbot-user-input").attr("placeholder","Reply to the System Agent");$("#chatbot-user-input").removeClass("disabled")}function f(){$("#chatbot-message-container").scrollTop($("#chatbot-message-container")[0].scrollHeight)}function ni(){$(".chatbot-window .option-item").addClass("disabled");$(".chatbot-window .option-item").removeAttr("onclick")}function d(){kt();i();u();chatbotState==="INIT"&&yt().then(function(){chatbotState="ACTIVE"})}function g(n){var i=n.dataset.chatbotLink||!1,t=n.href||"",r=/\?q=\d+&c=\d+/gm.test(t),u=t.indexOf("/pages/")!==-1;(i||r||u)&&(ai(),chatbotState="ACTIVE")}function ti(n){var t=/\[\[[A-Za-z0-9._\-:|/@?&=\s\\]*]]/gm;return t.test(n)?n.replace(t,function(n){var r;n=n.replace("[[","");n=n.replace("]]","");var t=n.split("|"),u=t[0].trim(),i=t[1].trim();return u==="link"?(r=t[2].trim(),'<a href="'+r+'" data-chatbot-link="true">'+i+"<\/a>"):'<span class="content-span">'+i+"<\/span>"}):n}function ii(n){var t=n.split("\n"),i=[];return t.forEach(function(n,r){var f=ti(n),u=document.createElement("p");u.classList.add("bot-paragraph");u.innerHTML=f;r===t.length-1&&u.classList.add("last-paragraph");i.push(u)}),i}function ri(n){var t=document.createElement("ul");return t.classList.add("bot-list"),n.forEach(function(n){var u=n.label||"",e=n.value||"",r=document.createElement("li"),i,f;r.classList.add("bot-list-item");i=document.createElement("a");f="selectOption('"+u+"', '"+e+"')";i.classList.add("option-item");i.setAttribute("onclick",f);i.setAttribute("tabindex","0");i.innerHTML=u;r.appendChild(i);t.appendChild(r)}),t}function ui(n){var t=document.createElement("div");return t.classList.add("message"),t.classList.add("chatbot-content"),t.classList.add(n),t.setAttribute("tabindex","0"),t}function fi(n,t,i){var u=document.createElement("p"),o,f,r,s,e;for(u.setAttribute("tabindex","0"),o=["rating",t,n,i].join("__"),u.setAttribute("id",o),u.setAttribute("tabindex","0"),u.innerHTML="Rate this answer:",f=0;f<5;f++)r=document.createElement("i"),r.setAttribute("tabindex","0"),r.classList.add("fa"),r.classList.add("fa-star-o"),r.classList.add("star-temp"),s="star-rating_"+i+"_"+f,r.setAttribute("id",s),f===0&&(r.style.marginLeft="5px"),u.appendChild(r);return e=document.createElement("div"),e.classList.add("answer-rating"),e.classList.add("chatbot-content"),e.appendChild(u),e}function ei(n,t){var u=a(t),f=u+" - Session ID: "+n,r=document.createElement("p"),i;return r.innerHTML=f,r.classList.add("session-id-divider"),i=document.createElement("div"),i.classList.add("chatbot-content"),i.appendChild(r),i}function nt(n,t){var u="#"+n,r,i;for($(n).empty(),$(u).text("Your rating:"),r=0;r<t;r++)i=document.createElement("i"),i.classList.add("fa"),i.classList.add("fa-star"),r===0&&(i.style.marginLeft="5px"),$(u).append(i)}function oi(n){var t="#"+n;$(n).empty();$(t).text("Your rating could not be submitted")}function a(n){var i,t,r;return i=n?new Date(n):new Date,t=i.getMinutes(),r=i.getHours()+":"+(t<10?"0"+t:t),r}function si(){var t=document.createElement("div");t.classList.add("chatbot-title");t.classList.add("chatbot-content");t.innerHTML="SP Energy Networks System Agent";n(t)}function hi(t){var i=document.createElement("div"),r=a(t);i.classList.add("chatbot-time");i.classList.add("chatbot-content");i.classList.add("col-12");i.innerHTML=r;n(i)}function ci(t,i,r){var u=fi(t,i,r);n(u)}function n(n){var t=document.getElementById("chatbot-message-container"),i=document.getElementById("chatbot-alert");document.getElementById("chatbot-message-container")&&t.insertBefore(n,i)}function li(){window.localStorage.setItem("clear","true")}function ai(){window.localStorage.setItem("link","true")}function vi(n){var t=lt();t.push(n);window.localStorage.setItem("messageHistory",JSON.stringify(t))}function yi(n){window.localStorage.setItem("newMessageGroup",JSON.stringify(n))}function tt(){window.localStorage.setItem("ping","false")}function pi(){window.localStorage.setItem("ping","true")}function wi(n,t){var i={id:n,timestamp:t};window.localStorage.setItem("sessionId",JSON.stringify(i))}function bi(){var n=Date.now();window.localStorage.setItem("timestamp",n)}function ki(n,t){var i={id:n,rating:t};window.localStorage.setItem("rating",JSON.stringify(i))}function di(){var n=lt();n.forEach(function(n){t(n,!1)});f()}function gi(){window.localStorage.removeItem("clear")}function it(){window.localStorage.removeItem("link")}function rt(){window.localStorage.removeItem("messageHistory")}function nr(){window.localStorage.removeItem("newMessageGroup")}function ut(){window.localStorage.removeItem("ping")}function tr(){window.localStorage.removeItem("rating")}function ft(){window.localStorage.removeItem("sessionId")}function et(){window.localStorage.removeItem("timestamp")}function ot(){return window.localStorage.getItem("link")==="true"}function st(){return window.localStorage.getItem("ping")==="true"}function ht(){try{var n=window.localStorage.getItem("sessionId");return JSON.parse(n)}catch(t){return{}}}function ct(){var n=ht();return n?n.id:""}function ir(){var n=ht();if(n)return n.timestamp}function rr(){var n=window.localStorage.getItem("timestamp");return n!==""&&n&&n!==undefined?parseInt(n):0}function lt(){var n=window.localStorage.getItem("messageHistory");return JSON.parse(n)||[]}function e(n,t){rt();ft();et();it();tr();$(".chatbot-window .chatbot-content").remove();h();k(!0);n||li();(!n||t)&&setTimeout(function(){gi()},CHATBOT_PING_WAITING_TIME);wt().then(function(){}).fail(function(){i()});chatbotState="INIT"}function ur(n,t){var i="My choice: "+n;vt(t,i)}function fr(n,t){var i=t.split("__"),r=i[1],u=i[2],f={sessionId:r,rating:n,nodeId:u};vr(f).then(function(){nt(t,n);ki(t,n)}).fail(function(){oi(t);console.log("local catch")})}function at(n){var i=/<[^\s]*\s+[^\s]*=[^>]*>|<\/[^\s]*>/g,r=/[<>="`\\]|\('|\("|\(`|'\)|"\)|`\)/g,u,t;return n=n.replace(i,""),n=n.replace(r,""),u=$("<p><\/p").text(n),t=$(u).text(),t=t.replace(i,""),t.replace(r,"")}function vt(n,i){var u=n,r=i;r||(r=u);u=at(u);r=at(r);var f=[{outputs:[{responseType:"text",text:r}],userDefined:{}}],e=Date.now(),o={origin:"user",messages:f,timestamp:e};t(o,!0);yt().then(function(){return cr(u,!1)}).then(function(){return!1})}function t(t,i){var o=t.messages||[],r=t.origin,u=t.sessionId||"",f=t.timestamp,e;o.forEach(function(n){n.outputs.length>0&&er(n,r,u,f)});r==="system"&&(v(),e=ei(u,f),n(e));i&&(yi(t),vi(t),setTimeout(function(){nr()},CHATBOT_PING_WAITING_TIME))}function er(t,i,r,o){function l(t,r){var l=t.responseType||"",y=t.text,p=t.text,a=t.options||[],v,h,c;l==="text"||i==="user"?p&&u():l==="option"&&gt("Choose an option or type a question");v=ii(y);h=null;a&&(h=ri(a));c=ui(i);v.forEach(function(n){c.appendChild(n)});h&&c.appendChild(h);n(c);i==="user"&&hi(o);r===0&&f();s.endOfConversation&&setTimeout(function(){e()},CHATBOT_CLOSE_WINDOW_DELAY)}var h=t.outputs,c=t.nodeId,s=t.userDefined;ni();i==="bot"&&si();h.forEach(l);i==="bot"&&s.ratingEnabled&&ci(c,r,o)}function or(){var n=rr(),t=Date.now(),i=t-n;return i>CHATBOT_SESSION_ID_DURATION}function v(){var n=ct(),t=ir(),i=a(t);document.getElementById("chatbot-session-id").innerHTML=i+" - Session ID: "+n}function sr(n){var t=$.Deferred();return setTimeout(function(){t.resolve()},n),t.promise()}function yt(){var t=or(),n;return t?(n=!0,chatbotState!=="INIT"?(n=!1,b(n),f()):chatbotState==="INIT"&&b(n),sr(CHATBOT_SESSION_MESSAGE_DURATION).then(function(){return hr()})):$.when()}function pt(n,i){var r,e,o;if(n){h();var s=n.dialogNodes,f=n.sessionId,r=Date.now();i&&(r=Date.now(),wi(f,r),v(),e={origin:"system",sessionId:f,timestamp:r},t(e,!0));o={origin:"bot",messages:s,sessionId:f,timestamp:r};setTimeout(function(){return l(),t(o,!0),bi(),u(),$("#chatbot-user-input").focus(),!1},CHATBOT_TYPING_DELAY)}}function hr(){return lr().then(function(n){pt(n,!0);c()})}function cr(n,t,i){$("#chatbot-user-input").val("");r();dt();f();var u=ct(),e={message:n,sessionId:u,firstSession:t};return ar(e).then(function(n){pt(n,i)})}function lr(){return $.ajax({type:"GET",headers:{"Content-Type":"application/json"},contentType:"application/json; charset=utf-8",url:"/WebServices/chatbot.asmx/GetSessionId",dataType:"json"}).then(function(n){if(n.HasError)return $.Deferred().reject();var t=JSON.parse(n.Result);return t.isError?$.Deferred().reject():$.Deferred().resolve(t)}).fail(function(){c();r();s("Your session could not be initiated. Please close the window and retry.")})}function wt(){return $.ajax({type:"GET",headers:{"Content-Type":"application/json"},contentType:"application/json; charset=utf-8",url:"/WebServices/chatbot.asmx/GetHeartbeat",dataType:"json"}).then(function(n){return n.HasError?$.Deferred().reject():$.Deferred().resolve()}).fail(function(){r();s("Could not reach the server to check availibility.")})}function ar(n){return $.ajax({type:"POST",headers:{"Content-Type":"application/json"},contentType:"application/json; charset=utf-8",url:"/WebServices/chatbot.asmx/PostMessage",data:JSON.stringify(n),dataType:"json"}).then(function(n){if(n.HasError)return $.Deferred().reject();var t=JSON.parse(n.Result);return t.isError?$.Deferred().reject():$.Deferred().resolve(t)}).fail(function(){l();u();s("Something wrong happened while sending your message. Please close the window and retry.")})}function vr(n){return $.ajax({type:"POST",headers:{"Content-Type":"application/json"},contentType:"application/json; charset=utf-8",url:"/WebServices/chatbot.asmx/PostRating",data:JSON.stringify(n),dataType:"json"}).then(function(n){if(n.HasError)return $.Deferred().reject();var t=JSON.parse(n.Result);return t.isError?$.Deferred().reject():$.Deferred().resolve()})}function bt(){function t(){p()}function n(){chatWindowOpen||(clearTimeout(chatbotInactivityTimer),chatbotInactivityTimer=setTimeout(t,CHATBOT_INACTIVITY_DURATION))}window.onload=n;document.onmousemove=n;document.onkeypress=n;n()}function yr(){chatbotState="INIT";y();i();h();l();r();c();var n=ot();it();tt();setTimeout(function(){var t=st();ut();wt().then(function(){w();bt();n||t?(v(),d(),di()):(rt(),et(),ft())}).fail(function(){i()})},CHATBOT_PING_WAITING_TIME)}$("#chatbot-user-input").keypress(function(n){var r=n.keyCode===13&&!n.shiftKey,i,t;if(r){if(i=document.getElementById("chatbot-user-input").value,t=i.trim(),t===""){n.preventDefault();return}t=i.replace(/(\r\n|\r|\n|\s\s+)/gm,function(){return" "});t=t.trim();vt(t,null)}});$("#chatbot-avatar").mouseenter(function(){p()}).mouseleave(function(){o()});$("#chatbot-avatar").bind("click",function(){d()});$(window).on("beforeunload",function(){var n=ot();tt();setTimeout(function(){var t=st();ut();n||t||e(!0,!0)},CHATBOT_PING_WAITING_TIME)});$(window).on("storage",function(n){var h=window.document.hasFocus(),i,r,f,u,o,s;h||(i=n.originalEvent,r=i.key,r==="clear"?i.newValue&&e(!0):r==="link"?i.newValue&&(chatbotState="ACTIVE"):r==="newMessageGroup"?(f=JSON.parse(i.newValue),f&&t(f,!1)):r==="ping"?i.newValue&&pi():r==="rating"&&(u=JSON.parse(i.newValue),u&&(o=u.id,s=u.rating,nt(o,s))))});$(document).on("click",'a[data-chatbot-link="true"]',function(n){var t=n.target;return g(t),!0});$(document).on("contextmenu",'a[data-chatbot-link="true"]',function(n){var t=n.target;return g(t),!0});$(document).on("mouseover",".fa-star-o.star-temp",function(n){for(var f=n.target,e=f.getAttribute("id"),i=e.split("_"),o=i[0],s=i[1],h=parseInt(i[2]),u,r,t=0;t<=h;t++)u=[o,s,t].join("_"),r=document.getElementById(u),r.classList.remove("fa-star-o"),r.classList.add("fa-star")});$(document).on("mouseleave",".fa-star.star-temp",function(n){for(var f=n.target,e=f.getAttribute("id"),r=e.split("_"),o=r[0],s=r[1],u,i,t=0;t<5;t++)u=[o,s,t].join("_"),i=document.getElementById(u),i.classList.remove("fa-star"),i.classList.add("fa-star-o")});$(document).on("click",".star-temp",function(n){var t=n.target,i=t.parentElement.getAttribute("id"),r=t.getAttribute("id"),u=r.split("_"),f=parseInt(u[2]),e=f+1,o="#"+i;$(o).text("Your rating is being submitted...");setTimeout(function(){fr(e,i)},CHATBOT_TYPING_DELAY)});window.clearChat=e;window.minimiseChatWindow=k;window.selectOption=ur;yr()})