setTimeout(function(){window.location="/mygov/content/html/session-expired.html";},1740000);function priorityLookup(levelName){switch(levelName){case"high":return 1;case"medium":return 2;case"low":return 3;default:return 4;}}function compareDates(firstDate,secondDate){firstDate=new Date(firstDate);secondDate=new Date(secondDate);return firstDate<secondDate?1:-1;}function getTopAlert(entries){var sortedAlerts=entries.sort(function(firstEntry,secondEntry){if(priorityLookup(firstEntry.priority)===priorityLookup(secondEntry.priority)){return compareDates(firstEntry.modified,secondEntry.modified);}return priorityLookup(firstEntry.priority)>priorityLookup(secondEntry.priority)?1:-1;});return sortedAlerts[0];}function getTopBroadcast(entries){var sortedBroadcasts=entries.sort(function(firstEntry,secondEntry){return compareDates(firstEntry.modified,secondEntry.modified);});return sortedBroadcasts[0];}function displayBroadcast(alert){if(alert&&alert.body){$(".emergency-text").html(alert.body);$(".emergency-text").find("a").attr("target","_blank");$(".emergency-information").css({height:"auto",padding:"17px 5px"});}}$(document).ready(function(){var url=$("#govcms-endpoint").val();var clientId=$("#govcms-client-id").val();var apiVersion=$("#govcms-api-version").val();if(url&&clientId&&apiVersion){fetch(url,{headers:{"x-caas-client-id":clientId,"x-caas-version":apiVersion,"Cache-Control":"no-cache"}}).then(function(resp){return resp.json();}).then(function(data){if(data&&data.broadcasts){displayBroadcast(getTopBroadcast(data.broadcasts));}});}});