var Alerts=function(){function n(){var n=this;this.cycleTimeForAllAlerts=0;this.$alertsBox=$("#alertsBox");this.$alertsBoxBody=this.$alertsBox.find("ul");this.forceAlertRefresh=function(){n.getAlerts(n.updateAlerts,n.updateGlobalEmergencyPopup)};this.getAlerts=function(n,t){var i=Cookies.get("_culture")?Cookies.get("_culture"):"";$.ajax({url:"/Alert/GetUpdatedAlerts?lang="+i,dataType:"json"}).done(function(i){i.alerts&&n(i.alerts);i.emergencyAlertHash!==0?($(".emergencyPopupNotification").show(),$("footer").addClass("pad45"),Cookies.get("emergencyPopup")!=i.emergencyAlertHash&&(Cookies.set("emergencyPopup",i.emergencyAlertHash,{expires:365,path:"/"}),t())):($("footer").removeClass("pad45"),$(".emergencyPopupNotification").hide(),Cookies.remove("emergencyPopup",{path:"/"}))})};this.updateAlerts=function(t){var f=n.$alertsBox.data("easyTicker"),i,u;if(f&&f.stop(),i=n,n.$alertsBoxBody.empty(),t.length>0)if(resources.UseAlertBellIcon!="true"){var e=0,o=Cookies.get("_culture"),s=Cookies.get("_region")?Cookies.get("_region"):"ALL",r=o!=null?o.toLowerCase():"en";r=r.indexOf("-")==-1?r:r.split("-")[0];u='""';$.each(t,function(){var n,t;(!this.filterRegions||s=="ALL"||this.regions.indexOf(s)>=0)&&(r==="fr"?n=this.messages.messageLang2:r==="es"&&(n=this.messages.messageLang3),n=n!=null&&n.message!=""?n:this.messages.messageLang1,t=n.message,t&&(u=this.highImportance?"highImportanceAlert":"",resources.FloodgateAlertBarAsLink==="true"?i.$alertsBoxBody.append('<li id="alertsLi'+e+'" data-type="'+u+'"><a href="/List/Alerts">'+t+"<\/a><\/li>"):i.$alertsBoxBody.append('<li id="alertsLi'+e+'" data-type="'+u+'">'+t+"<\/li>")),e++)});n.splitLongAlerts();n.cycleTimeForAllAlerts=i.$alertsBoxBody[0].childElementCount*globalVars.tickerInterval;n.cycleTimeForAllAlerts>n.currentFetchAlertsFreqTime&&(clearInterval(n.fetchAlertsInterval),n.currentFetchAlertsFreqTime=n.cycleTimeForAllAlerts+1e3,n.fetchAlertsInterval=setInterval(function(){n.forceAlertRefresh()},n.currentFetchAlertsFreqTime));$("#emptyAlertLi").remove();i.toggleAlertColor();i.$alertsBoxBody.children().length>1&&f?f.start():i.$alertsBoxBody.append('<li id="emptyAlertLi">&nbsp;<\/li>')}else $(".alertIcon").attr("title",resources.Alerts),$(".alertIcon .dot").show();else resources.UseAlertBellIcon!="true"?(i.$alertsBoxBody.append('<li id="emptyAlertLi">&nbsp;<\/li>'),i.toggleAlertColor()):($(".alertIcon").attr("title",resources.NoAlert),$(".alertIcon .dot").hide())};this.updateGlobalEmergencyPopup=function(){var t=Cookies.get("_culture")?Cookies.get("_culture"):"";$.ajax({url:"/Alert/GetEmergencyAlert?lang="+t,dataType:"json"}).done(function(t){$(".emergencyPopupNotification").attr("data-alert",t.content);t.content.length>0&&$(".modal.in").length==0&&n.showPopup(t.content)})};this.showPopup=function(n){bootbox.dialog({title:'<i style="padding-right: 5px;" class="far fa-exclamation-triangle"><\/i> '+resources.EmergencyAlertPopUp.toUpperCase(),onEscape:!0,className:"emergencyAlertModal",message:n})};this.toggleAlertColor=function(){n.$alertsBoxBody.children().first().data("type")=="highImportanceAlert"?$(".scrollRow").addClass("highImportanceAlert"):$(".scrollRow").removeClass("highImportanceAlert")};this.startEasyTicker()}return n.prototype.splitLongAlerts=function(){var n=this;this.$alertsBoxBody.children().each(function(t){var e=n.$alertsBox.get(0).clientHeight,o=$(this).attr("data-type"),s=$(this).text(),f="",h=s.split(" "),r=[],i="",u=0;h.forEach(function(n){i+=i?" "+n:n;$(".tempAlert").html(i);var t=$(".tempAlert").height()>e;t&&(i=i.substring(0,i.lastIndexOf(" ")),r.push({key:u,value:i}),i=n,u++)});r.push({key:u,value:i});r.forEach(function(n){n.value.length>0&&(f+='<li id="alertsLi'+t+"_"+n.key+'" data-type="'+o+'">'+n.value+"<\/li>")});$(this).replaceWith(replaceUrlsWithLinks(f))})},n.prototype.hashCode=function(n){for(var t=0,i=0;i<n.length;i++)t=~~((t<<5)-t+n.charCodeAt(i));return t},n.prototype.startEasyTicker=function(){$(".siteWideAlerts").easyTicker({direction:"up",easing:"swing",speed:"slow",interval:globalVars.tickerInterval,height:"auto",visible:1,mousePause:1,controls:{up:"",down:"",toggle:"",playText:"Play",stopText:"Stop"}});$(".siteWideAlerts").on("contentChanged",this.toggleAlertColor)},n}();$(document).ready(function(){var n=new Alerts;n.forceAlertRefresh();n.currentFetchAlertsFreqTime=resources.AlertRefreshInterval?parseInt(resources.AlertRefreshInterval):6e4;n.fetchAlertsInterval=setInterval(function(){n.forceAlertRefresh()},n.currentFetchAlertsFreqTime);$(".emergencyPopupNotification").on("click",function(){$(".emergencyPopupNotification").attr("data-alert")?n.showPopup($(".emergencyPopupNotification").attr("data-alert")):n.updateGlobalEmergencyPopup()});$(window).on("regionChanged orientationchange",function(){n.forceAlertRefresh()})})