document.addEventListener('DOMContentLoaded', function(event) {var head = document.head;var link = document.createElement('link');link.type = 'text/css';link.rel = 'stylesheet';link.href = 'https://giving.georgetown.edu/wp-content/plugins/oa-gutenberg/inc/css/lightbox-style.css?v=1.24.40';head.appendChild(link);link.onload = function () {var el = document.querySelector('body');var oaLightboxMarkup = '<div tableindex="0" class="oa-lightbox-wrapper one-btn bg-gu-blue btn-pantone199 " role="complementary" aria-label="Special Announcement"><div class="oa-lightbox-container"><div class="oa-lightbox-header-wrapper"><h2 tabindex="-1" id="oa-lightbox-heading" class="oa-lightbox-header">Your gift before midnight tonight will help us reach our 1,789-gift goal!</h2><h4 class="oa-lightbox-subheader">Show your support now and make a difference for our students.</h4></div><div class="oa-lightbox-button-wrapper"><div class="oa-lightbox-buttons-container"><a class="oa-lightbox-button" href="https://givingtuesday.georgetown.edu/?unit=0&dids=29.8.42.337.118.49.50.144&utm_source=dglbc&utm_medium=referral&utm_campaign=webgt22&appealcode=23UN003993">Give Now</a></div><p class="oa-lightbox-disclaimer"></p></div></div><div class="oa-lightbox-close-container"><div class="oa-lightbox-close-button" tabindex="0" role="button" aria-pressed="false" aria-label="Close Announcement"><span>&#10005;</span></button></div></div>';var countdown = '';var cookieName = 'oa_lightbox-giving-tuesday-2022-giving-control-day-of';var cookieExpDays = '0.0416667';var postStatus = 'publish';if(!el.classList.contains('error404') && !el.classList.contains('password-protected') && postStatus == 'publish') {el.insertAdjacentHTML('afterbegin', oaLightboxMarkup);var cookiePresent = getCookie(cookieName)
var container = document.querySelector('.oa-lightbox-wrapper')
var countdownContainer = document.querySelector(
  '.oa-tracker-countdown-wrapper .oa-tracker-countdown',
)

if (cookiePresent !== 'true') {
  // Check that the cookie isn't set ensuring user hasn't yet seen/closed out of the lightbox
  document.body.classList.remove('oa-lightbox-not-exist')
  document.body.classList.add('oa-lightbox-exist')

  container.classList.add('active')
  container.style.height = 'auto'

  let height = container.clientHeight + 'px'

  container.style.height = '0px'

  setTimeout(function () {
    container.style.height = height
  }, 0)
  document.getElementById('oa-lightbox-heading').focus()
}

document
  .querySelector('.oa-lightbox-close-button')
  .addEventListener('click', function (event) {
    event.preventDefault()

    setTimeout(function () {
      document.body.classList.remove('oa-lightbox-exist')
      document.body.classList.add('oa-lightbox-not-exist')
    }, 500)

    // Set cookie when user closes lightbox
    var d = new Date()
    var expDays = cookieExpDays
    d.setTime(d.getTime() + expDays * 24 * 60 * 60 * 1000)
    var expires = ' expires=' + d.toUTCString()
    document.cookie = cookieName + '=true;' + expires + ';path=/'

    container.style.height = '0px'

    container.addEventListener(
      'transitionend',
      function () {
        container.classList.remove('active')
      },
      {
        once: true,
      },
    )
  })

function getCookie(cname) {
  var name = cname + '='
  var ca = document.cookie.split(';')
  for (var i = 0; i < ca.length; i++) {
    var c = ca[i]
    while (c.charAt(0) == ' ') {
      c = c.substring(1)
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length)
    }
  }
  return ''
}

// Countdown functionality
if (countdown != '') {
  var future = new Date(countdown)
  setInterval(updateTime, 1000)
  updateTime()
} else {
  // empty
}

function updateTime() {
  var diff

  // Get the local time of a Eastern timezone
  today = new Date()
  easternTime = new Date(
    today.toLocaleString('en-US', { timeZone: 'America/New_York' }),
  )

  diff = Math.floor((future.getTime() - easternTime.getTime()) / 1000)
  return (document.getElementById('oa-tracker-ticker').innerHTML =
    countUtil(diff))
}

function countUtil(t) {
  var days, hours, minutes, seconds
  days = Math.floor(t / 86400)
  if (days < 10) days = '0' + days
  if (isNaN(days)) days = '00'
  t -= days * 86400
  hours = Math.floor(t / 3600) % 24
  if (hours < 10) hours = '0' + hours
  if (isNaN(hours)) hours = '00'
  t -= hours * 3600
  minutes = Math.floor(t / 60) % 60
  if (minutes < 10) minutes = '0' + minutes
  if (isNaN(minutes)) minutes = '00'
  t -= minutes * 60
  seconds = t % 60
  if (seconds < 10) seconds = '0' + seconds
  if (isNaN(seconds)) seconds = '00'

  if (days !== '00') {
    return [
      '<span>' + days + 'D :',
      hours + 'H :',
      minutes + 'M :',
      seconds + 'S</span>',
    ].join(' ')
  } else {
    return [
      '<span>' + hours + 'H :',
      minutes + 'M :',
      seconds + 'S</span>',
    ].join(' ')
  }
}
/*!
 * The Final Countdown for jQuery v2.1.0 (http://hilios.github.io/jQuery.countdown/)
 * Copyright (c) 2015 Edson Hilios
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
(function(factory) {
    "use strict";
    if (typeof define === "function" && define.amd) {
        define([ "jquery" ], factory);
    } else {
        factory(jQuery);
    }
})(function($) {
    "use strict";
    var instances = [], matchers = [], defaultOptions = {
        precision: 100,
        elapse: false
    };
    matchers.push(/^[0-9]*$/.source);
    matchers.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
    matchers.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
    matchers = new RegExp(matchers.join("|"));
    function parseDateString(dateString) {
        if (dateString instanceof Date) {
            return dateString;
        }
        if (String(dateString).match(matchers)) {
            if (String(dateString).match(/^[0-9]*$/)) {
                dateString = Number(dateString);
            }
            if (String(dateString).match(/\-/)) {
                dateString = String(dateString).replace(/\-/g, "/");
            }
            return new Date(dateString);
        } else {
            throw new Error("Couldn't cast `" + dateString + "` to a date object.");
        }
    }
    var DIRECTIVE_KEY_MAP = {
        Y: "years",
        m: "months",
        n: "daysToMonth",
        w: "weeks",
        d: "daysToWeek",
        D: "totalDays",
        H: "hours",
        M: "minutes",
        S: "seconds"
    };
    function escapedRegExp(str) {
        var sanitize = str.toString().replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
        return new RegExp(sanitize);
    }
    function strftime(offsetObject) {
        return function(format) {
            var directives = format.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);
            if (directives) {
                for (var i = 0, len = directives.length; i < len; ++i) {
                    var directive = directives[i].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/), regexp = escapedRegExp(directive[0]), modifier = directive[1] || "", plural = directive[3] || "", value = null;
                    directive = directive[2];
                    if (DIRECTIVE_KEY_MAP.hasOwnProperty(directive)) {
                        value = DIRECTIVE_KEY_MAP[directive];
                        value = Number(offsetObject[value]);
                    }
                    if (value !== null) {
                        if (modifier === "!") {
                            value = pluralize(plural, value);
                        }
                        if (modifier === "") {
                            if (value < 10) {
                                value = "0" + value.toString();
                            }
                        }
                        format = format.replace(regexp, value.toString());
                    }
                }
            }
            format = format.replace(/%%/, "%");
            return format;
        };
    }
    function pluralize(format, count) {
        var plural = "s", singular = "";
        if (format) {
            format = format.replace(/(:|;|\s)/gi, "").split(/\,/);
            if (format.length === 1) {
                plural = format[0];
            } else {
                singular = format[0];
                plural = format[1];
            }
        }
        if (Math.abs(count) === 1) {
            return singular;
        } else {
            return plural;
        }
    }
    var Countdown = function(el, finalDate, options) {
        this.el = el;
        this.$el = $(el);
        this.interval = null;
        this.offset = {};
        this.options = $.extend({}, defaultOptions);
        this.instanceNumber = instances.length;
        instances.push(this);
        this.$el.data("countdown-instance", this.instanceNumber);
        if (options) {
            if (typeof options === "function") {
                this.$el.on("update.countdown", options);
                this.$el.on("stoped.countdown", options);
                this.$el.on("finish.countdown", options);
            } else {
                this.options = $.extend({}, defaultOptions, options);
            }
        }
        this.setFinalDate(finalDate);
        this.start();
    };
    $.extend(Countdown.prototype, {
        start: function() {
            if (this.interval !== null) {
                clearInterval(this.interval);
            }
            var self = this;
            this.update();
            this.interval = setInterval(function() {
                self.update.call(self);
            }, this.options.precision);
        },
        stop: function() {
            clearInterval(this.interval);
            this.interval = null;
            this.dispatchEvent("stoped");
        },
        toggle: function() {
            if (this.interval) {
                this.stop();
            } else {
                this.start();
            }
        },
        pause: function() {
            this.stop();
        },
        resume: function() {
            this.start();
        },
        remove: function() {
            this.stop.call(this);
            instances[this.instanceNumber] = null;
            delete this.$el.data().countdownInstance;
        },
        setFinalDate: function(value) {
            this.finalDate = parseDateString(value);
        },
        update: function() {
            if (this.$el.closest("html").length === 0) {
                this.remove();
                return;
            }
            var hasEventsAttached = $._data(this.el, "events") !== undefined, now = new Date(), newTotalSecsLeft;
            newTotalSecsLeft = this.finalDate.getTime() - now.getTime();
            newTotalSecsLeft = Math.ceil(newTotalSecsLeft / 1e3);
            newTotalSecsLeft = !this.options.elapse && newTotalSecsLeft < 0 ? 0 : Math.abs(newTotalSecsLeft);
            if (this.totalSecsLeft === newTotalSecsLeft || !hasEventsAttached) {
                return;
            } else {
                this.totalSecsLeft = newTotalSecsLeft;
            }
            this.elapsed = now >= this.finalDate;
            this.offset = {
                seconds: this.totalSecsLeft % 60,
                minutes: Math.floor(this.totalSecsLeft / 60) % 60,
                hours: Math.floor(this.totalSecsLeft / 60 / 60) % 24,
                days: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
                daysToWeek: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
                daysToMonth: Math.floor(this.totalSecsLeft / 60 / 60 / 24 % 30.4368),
                totalDays: Math.floor(this.totalSecsLeft / 60 / 60 / 24),
                weeks: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7),
                months: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 30.4368),
                years: Math.abs(this.finalDate.getFullYear() - now.getFullYear())
            };
            if (!this.options.elapse && this.totalSecsLeft === 0) {
                this.stop();
                this.dispatchEvent("finish");
            } else {
                this.dispatchEvent("update");
            }
        },
        dispatchEvent: function(eventName) {
            var event = $.Event(eventName + ".countdown");
            event.finalDate = this.finalDate;
            event.elapsed = this.elapsed;
            event.offset = $.extend({}, this.offset);
            event.strftime = strftime(this.offset);
            this.$el.trigger(event);
        }
    });
    $.fn.countdown = function() {
        var argumentsArray = Array.prototype.slice.call(arguments, 0);
        return this.each(function() {
            var instanceNumber = $(this).data("countdown-instance");
            if (instanceNumber !== undefined) {
                var instance = instances[instanceNumber], method = argumentsArray[0];
                if (Countdown.prototype.hasOwnProperty(method)) {
                    instance[method].apply(instance, argumentsArray.slice(1));
                } else if (String(method).match(/^[$A-Z_][0-9A-Z_$]*$/i) === null) {
                    instance.setFinalDate.call(instance, method);
                    instance.start();
                } else {
                    $.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi, method));
                }
            } else {
                new Countdown(this, argumentsArray[0], argumentsArray[1]);
            }
        });
    };
    // Style for small tracker
    $(function(){
      $('.sm-countdown[data-countdown]').each(function() {
        var $this = $(this), finalDate = moment.tz($(this).data('countdown'), 'America/New_York');

        $this.countdown(finalDate.toDate(), function(event) {

          if(event.offset.totalDays <= 0){
            $this.html(event.strftime('<span>%HH : %MM : %SS</span>'))
          }
          else{
            $this.html(event.strftime('<span>%DD : %HH : %MM : %SS</span>'))
          }
        }).on('finish.countdown', function() {
        });
      });
      // Style for jumbo tracker
      $('.jumbo-countdown[data-countdown]').each(function() {
        var $this = $(this), finalDate = moment.tz($(this).data('countdown'), 'America/New_York');
        $this.countdown(finalDate.toDate(), function(event) {

          if(event.offset.totalDays <= 0){
            $this.html(event.strftime('<div class ="box"><span class ="stat">%H</span><span class ="stat-subtitle">Hours</span></div>' +
                                      '<div class ="box"><span class ="stat">%M</span><span class ="stat-subtitle">Minutes</span></div>' +
                                      '<div class ="box"><span class ="stat">%S</span><span class ="stat-subtitle">Seconds</span></div>'))
          }
          else{
            $this.html(event.strftime('<div class ="box"><span class ="stat">%D</span><span class ="stat-subtitle">Days</span></div>' +
                                      '<div class ="box"><span class ="stat">%H</span><span class ="stat-subtitle">Hours</span></div>' +
                                      '<div class ="box"><span class ="stat">%M</span><span class ="stat-subtitle">Minutes</span></div>' +
                                      '<div class ="box"><span class ="stat">%S</span><span class ="stat-subtitle">Seconds</span></div>'))

          }
        }).on('finish.countdown', function() {
        });
      });
    });

});
}};});