var App = App || {}; App.WebRoot = '/Content'; App.CurrentZip = $.cookie(".REGION"); App.CTElectricLanding = '/CG/AcctInfo/AccountInformation'; App.CTGasLanding = '/CG/AcctInfo/AccountInformation'; App.Storm='OFF'; App.ContinueToSite='OFF'; App.StormLanding='stormnh'; App.ContinueToSiteUrl=''; App.Domain='eversource.com'; App.init = function () { if (window.location.pathname.toLowerCase() === App.WebRoot.toLowerCase() || window.location.pathname.toLowerCase() === App.WebRoot.toLowerCase() + "/") { var region = JSON.parse($.cookie('.REGION') || '{"ZipCode" : null}'); if (region.ZipCode) { if(App.Storm=="ON") { window.location.replace("/Content/Storms/"+App.StormLanding); } else { window.location.replace(region.Root); } } } } App.getSegmentByZipCode = function (zipCode, callback) { var params = { zipCode: zipCode }; var wcfServiceUrl = App.WebRoot + "/Personalization/Service/PersonalizationService.svc/"; $.ajax({ cache: false, url: wcfServiceUrl + "SetRegion", type: "post", contentType: 'application/json; charset=utf-8', data: JSON.stringify(params), dataType: "json", success: callback, error: function (XMLHttpRequest, textStatus, errorThrown) { if (window.console && window.console.log) console.log(XMLHttpRequest.responseText); } }); } App.skipZipCode = function () { var wcfServiceUrl = App.WebRoot + "/Personalization/Service/PersonalizationService.svc/"; if( App.Storm == "OFF" || App.ContinueToSite=="ON" || App.CombinedCheck=="False") { $.ajax({ cache: false, url: wcfServiceUrl + "SkipRegion", type: "post", contentType: 'application/json; charset=utf-8', dataType: "json", success: function (data, textStatus, jqXHR) { window.location = data.Result.Root; }, error: function (XMLHttpRequest, textStatus, errorThrown) { if (window.console && window.console.log) console.log(XMLHttpRequest.responseText); } }); } else if (App.Storm == "ON" & App.ContinueToSite=="OFF") { window.location.replace("/Content/Storms/"+App.StormLanding); } } App.getUser = function (callback) { var wcfServiceUrl = App.WebRoot + "/Personalization/Service/PersonalizationService.svc/"; $.ajax({ cache: false, url: wcfServiceUrl + "GetUser", type: "post", contentType: 'application/json; charset=utf-8', dataType: "json", success: callback, error: function (XMLHttpRequest, textStatus, errorThrown) { if (window.console && window.console.log) console.log(XMLHttpRequest.responseText); } }); } App.getUserFirstName = function (callback) { var wcfServiceUrl = App.WebRoot + "/Personalization/Service/PersonalizationService.svc/"; $.ajax({ cache: false, url: wcfServiceUrl + "GetUserFirstName", type: "post", contentType: 'application/json; charset=utf-8', dataType: "json", success: callback, error: function (XMLHttpRequest, textStatus, errorThrown) { if (window.console && window.console.log) console.log(XMLHttpRequest.responseText); } }); } App.checkForRedirect = function(pathAndQuery) { var wcfServiceUrl = App.WebRoot + "/Personalization/Service/PersonalizationService.svc/"; var params = { pathAndQuery: pathAndQuery }; if( App.Storm == "OFF" || App.ContinueToSite=="ON" || App.CombinedCheck=="False") { $.ajax({ cache: false, url: wcfServiceUrl + "CheckForRedirect", type: "post", contentType: 'application/json; charset=utf-8', data: JSON.stringify(params), dataType: "json", success: function (data, textStatus, jqXHR) { if (data.Status == "Success" && data.Message == "Redirect") { window.location.replace(data.Result); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { if (window.console && window.console.log) console.log(XMLHttpRequest.responseText); } }); } else if (App.Storm == "ON" & App.ContinueToSite=="OFF") { window.location.replace("/Content/Storms/" + App.StormLanding); } } App.init(); $("#Header_Continue,.storm-eversource-logo").click(function(event) { event.preventDefault(); document.cookie=".ContinueToSite=ON; path=/"; window.location="/Content/" + App.ContinueToSiteUrl; }); var popupStatus = 0; function loadPopup() { if (popupStatus == 0) { $("#backgroundPopup").css({ "opacity": "0.7" }); $("#backgroundPopup").fadeIn("fast"); popupStatus = 1; $("#popupContact").css("visibility", "visible"); } } function disablePopup() { if (popupStatus == 1) { $("#backgroundPopup").fadeOut("fast"); $("#popupContact").css("visibility", "hidden"); popupStatus = 0; } } function centerPopup() { var windowWidth = document.documentElement.clientWidth; var windowHeight = document.documentElement.clientHeight; var popupHeight = $("#popupContact").height(); var popupWidth = $("#popupContact").width(); $("#backgroundPopup").css({ "height": windowHeight }); } function loadPopupInitial() { centerPopup(); loadPopup(); } $("#popupContactClose").click(function () { disablePopup(); }); $("#backgroundPopup").click(function () { disablePopup(); }); $(document).keyup(function (e) { if (e.keyCode == 27 && popupStatus == 1) { disablePopup(); } });