//22-03-17

// Adds Font Awesome Bullets to quicklinks
function FontAwesomeQuicklinksBullets() {
  try {
    $('.quicklinks > ul').addClass('fa-ul');
    $('.quicklinks > ul > li').prepend('<span class="fa-li"><i class="fas fa-diamond"></i></span>'
    );
  }
  catch (error) {
    console.log('Quicklinks font awesome bullets did not work');
  }
}

$(document).ready(sitewideincludes);

// Loads quicklinks from the quicklinks page into .quicklinks
function sitewideincludes() {
  try {
    $('.quicklinks').load('Quicklinks/index.html #container ul', function () {
      FontAwesomeQuicklinksBullets();
    });
  }
  catch (ex) {
    console.log('Quicklinks missing.');
  }
}

// Removes empty anchors from the footer
let footerEmptyLinks = $("footer a[href|=''], footer a[href|='tel:'], footer a[href*='tel:<catapultcms Name=']");
let socialBarEmptyLinks = $(".social-buttons a[href|='']");
$(footerEmptyLinks).remove();
$(socialBarEmptyLinks).remove();

if (ElementEmptyCheck($('.social-bar .social-buttons > a'))) {
  $('.social-bar').remove();
}

let contactDivs = $('.footer-contact .footer-phone div');

$(contactDivs).each(function () {
  if ($(this).text().trim() === '' || $(this).text().trim() === '(fax)') {
    $(this).remove();
  }
});

// Adds empty-element class to the footer tagline if it is empty
ElementEmptyCheck('.tagline');

// Add empty-element class if (fax) exists in footer-phone with nothing else
let footerPhoneDivs = $('.footer-phone > div');

$(footerPhoneDivs).each(function () {
  if ($(this).text().trim() === '(fax)') {
    $(this).addClass('empty-element');
  }
});

try {
  if (typeof useNonDiscriminationDropup !== 'undefined' && useNonDiscriminationDropup) {
    $('.non-discrimination-link').hide();
  }
  else {
    $('.non-discrimination-dropup').hide();
  }
}

catch (error) {
  console.log(error);
}
