﻿function hideSiteAlert() {
  if ($('.site-alert').length) {
    $('.site-alert').hide();

    $('body').removeClass('has-alert');
  }
}

$(function () {
  // check if user has already clicked site wide modal off
  if (readCookie("hideSiteAlert") == "1") {
    // cookie exists; hide the modal
    hideSiteAlert();
  }
  else {
    // if site alert is on, add class to body element
    if ($('.site-alert').length) {
      $('body').addClass('has-alert');
    }
  }

  // set site alert click handler to close it (the 'X')
  $('.site-alert').click(function (e) {
    $(this).fadeOut();

    $('body').removeClass('has-alert');
    $(this).removeClass("d-flex");

    createCookie("hideSiteAlert", "1");
  });
});
