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/magis-giving-pack/inc/css/gift-tracker-style.css?v=1.24.40';head.appendChild(link);link.onload = function () {var countdown = '01/01/2024 00:00:00';var oatrackerMarkup = '<div class="oa-tracker-embed-wrapper red"><div class="oa-tracker-countdown-wrapper"><div class="oa-tracker-countdown-heading" aria-label="Small Countdown"><span>Time to Give</span></div><div class="oa-tracker-countdown-svg"><svg width="11px" height="11px" viewBox="0 0 11 11" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g transform="translate(-673.000000, -25.000000)"><g transform="translate(1.000000, 0.000000)"><g transform="translate(575.000000, 6.000000)"><polygon transform="translate(102.094035, 24.500000) rotate(90.000000) translate(-102.094035, -24.500000) " points="102.094035 19.5 107.594035 29.5 96.5940348 29.5"></polygon></g></g></g></g></svg></div><div class="oa-tracker-countdown" aria-label="Small Countdown"><span id="oa-tracker-ticker" style="white-space:nowrap;"></span></div></div></div>';var giftsGoal = '0';var giftStat = '0';var element = document.getElementById('oa-embed-tracker');element.insertAdjacentHTML('beforebegin', '<div class="clearfix"></div>');element.innerHTML = oatrackerMarkup;// progress bar functionality
var progressTracker = document.querySelector(
  '.oa-tracker-progress-tracker-wrapper .oa-tracker-progress-heading',
)

// If progress bar functionality is active
if (progressTracker) {
  var progressTrackerFitContent = document.querySelector(
    '.oa-tracker-progress-tracker-wrapper .oa-tracker-progress-hidden-heading',
  )
  //If it isn't "undefined" and it isn't "null", then it exists.
  if (
    typeof progressTrackerFitContent != 'undefined' &&
    progressTrackerFitContent != null
  ) {
    var progressTrackerFitContentWidth =
      progressTrackerFitContent.getBoundingClientRect().width
  }

  var countdownContainer = document.querySelector(
    '.oa-tracker-progress-tracker-wrapper .oa-tracker-countdown',
  )
  var triangle = document.querySelector(
    '.oa-tracker-progress-tracker-wrapper .oa-tracker-triangle-right',
  )
  var trackerContent = document.querySelector(
    '.oa-tracker-progress-tracker-wrapper .oa-tracker-progress-heading span',
  )
  var viewportWidth = window.innerWidth || document.documentElement.clientWidth
  var addClass = function (event) {
    // function to end transition
    document
      .querySelector('.oa-tracker-progress-tracker-wrapper')
      .classList.add('preload')
  }

  // Set width of progress bar by calculate difference from giftstat and giftgoal
  function getCurrentState() {
    var fullPercentageWidth =
      ((window.innerWidth -
        countdownContainer.getBoundingClientRect().width -
        20) /
        window.innerWidth) *
      100
    var currentState = giftsGoal - giftStat
    var progressPercentage =
      ((giftStat / giftsGoal) *
        100 *
        (window.innerWidth -
          countdownContainer.getBoundingClientRect().width -
          20)) /
      window.innerWidth

    if (currentState <= 0) {
      progressTracker.style.width = fullPercentageWidth + '%'
    } else {
      // set progressTracker width to tracker with default content

      if (
        progressPercentage == 0 ||
        (progressPercentage * window.innerWidth) / 100 <
          progressTrackerFitContentWidth
      ) {
        progressTracker.style.width = progressTrackerFitContentWidth + 'px'
        addClass()
      } else {
        progressTracker.style.width = progressPercentage + '%'
      }
    }
    // if transition is canceled or ended, add preload to end width transition
    progressTracker.addEventListener('transitioncancel', addClass, false)
    progressTracker.addEventListener('transitionend', addClass, false)
  }

  // Find height of progress bar and set the height of triangle
  function drawTriangle() {
    var trackerHeight = progressTracker.getBoundingClientRect().height
    triangle.style.borderBottomWidth = trackerHeight / 2 + 'px'
    triangle.style.borderTopWidth = trackerHeight / 2 + 'px'
    triangle.style.borderLeftColor = '#D50032'
  }

  // set initial width of progress tracker
  progressTracker.style.width =
    progressTracker.getBoundingClientRect().width + 'px'

  if (viewportWidth >= 768) {
    drawTriangle()

    setTimeout(function () {
      getCurrentState()
    }, 1000)
  } else {
    addClass()
    progressTracker.style.width = 'auto'
  }

  window.addEventListener('resize', function () {
    var viewportWidth =
      window.innerWidth || document.documentElement.clientWidth
    if (viewportWidth >= 768) {
      getCurrentState()
      drawTriangle()
    } else {
      progressTracker.style.width = 'auto'
    }
  })
}

// 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(' ')
  }
}
};