/* Minification failed. Returning unminified contents.
(3668,23-24): run-time error JS1300: Strict-mode does not allow assignment to undefined variables: $
(1725,5-19): run-time error JS1300: Strict-mode does not allow assignment to undefined variables: anchorSelector
 */
"use strict";

// add ScrollReveal to window
window.sr = ScrollReveal({
  reset: true,
  mobile: false,
  container: $('html')[0]
});
(function ($) {
  /*
   *	Add easeInOutQuad easing to jquery
   */
  $.extend($.easing, {
    easeInOutQuad: function easeInOutQuad(x, t, b, c, d) {
      if ((t /= d / 2) < 1) {
        return c / 2 * t * t + b;
      } else {
        return -c / 2 * (--t * (t - 2) - 1) + b;
      }
    }
  });
  window.slideToggleOpts = {
    duration: 350,
    easing: 'swing'
  };
})(jQuery);

/*
	console.log() polyfill
 */
(function () {
  var w = typeof window === 'undefined' ? this : window;
  w.console = w.console || {
    log: function log() {}
  };
})();

/*
 *	Prevent multiple function calls, useful on window resize events
 */
function debounce(func, wait, immediate) {
  var timeout;
  return function () {
    var context = this;
    var args = arguments;
    var later = function later() {
      timeout = null;
      if (!immediate) func.apply(context, args);
    };
    var callNow = immediate && !timeout;
    clearTimeout(timeout);
    timeout = setTimeout(later, wait);
    if (callNow) func.apply(context, args);
  };
}

/*
    Throttle function
*/
function throttle(fn, threshhold, scope) {
  threshhold || (threshhold = 250);
  var last;
  var deferTimer;
  return function () {
    var context = scope || this;
    var now = +new Date();
    var args = arguments;
    if (last && now < last + threshhold) {
      // hold on to it
      clearTimeout(deferTimer);
      deferTimer = setTimeout(function () {
        last = now;
        fn.apply(context, args);
      }, threshhold + last - now);
    } else {
      last = now;
      fn.apply(context, args);
    }
  };
}

/**
 * Function to return the pixel width of the browser scrollbar
 *
 * @returns integer
 */
function getScrollbarWidth() {
  var inner = document.createElement('p');
  inner.style.width = "100%";
  inner.style.height = "200px";
  var outer = document.createElement('div');
  outer.style.position = "absolute";
  outer.style.top = "0px";
  outer.style.left = "0px";
  outer.style.visibility = "hidden";
  outer.style.width = "200px";
  outer.style.height = "150px";
  outer.style.overflow = "hidden";
  outer.appendChild(inner);
  document.body.appendChild(outer);
  var w1 = inner.offsetWidth;
  outer.style.overflow = 'scroll';
  var w2 = inner.offsetWidth;
  if (w1 == w2) {
    w2 = outer.clientWidth;
  }
  document.body.removeChild(outer);
  return w1 - w2;
}
window.jsUtilities = window.jsUtilities || {};
(function ($, jsUtilities) {
  jsUtilities.getUrlParameters = function () {
    return location.search.substring(1).split("&").reduce(function (result, value) {
      var parts = value.split('=');
      if (parts[0]) result[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
      return result;
    }, {});
  };
})(jQuery, window.jsUtilities);
"use strict";

/*
	Default Media queries - Should match exactly with the media queries in '_config-utilities.scss'
 */
var mq = {
  lg: '(min-width: 1200px)',
  md: '(min-width: 992px)',
  mdMax: '(max-width: 991px)',
  sm: '(min-width: 768px)',
  xs: '(max-width: 767px)',
  xxs: '(max-width: 500px)',
  xxxs: '(max-width: 359px)'
};
window.mq = mq;
"use strict";

/*
	Function to hide/show responsive elements
 */

function skipLinks() {
  var links = $('.skip-links a');
  function removeFocus() {
    $(this).removeAttr('tabindex');
  }
  function applyFocus() {
    var target = $(this).attr('href');
    $(target).attr('tabindex', '-1').focus();
    $(target).one('blur', removeFocus);
  }
  links.on('click', applyFocus);
}
"use strict";

/*
	Adding click functionality for mobile menu buttons
 */
function menuMobile() {
  var btnMenu = $('.site-header_menu-mob-nav');
  var body = $('body');
  var viewport = $('.page-viewport');
  var btnClose = $('.nav-close-mob, .site-header_close-btn');
  var primaryNav = $('.site-header_nav');
  var aClass = 'active';
  var oClass = 'open';
  var oNavClass = 'primary-nav-open';
  var $campaignNavLinks = $('.primary-nav_list-campaign ul li > a');
  $campaignNavLinks.on('click', closeMenu);
  function openMenu() {
    body.addClass(oNavClass);
  }
  function closeMenu() {
    body.removeClass(oNavClass);
  }
  function toggleMenu(e) {
    e.preventDefault();
    if (window.matchMedia(mq.mdMax).matches) {
      if (body.hasClass(oNavClass)) {
        closeMenu();
      } else {
        openMenu();
      }
      $(this).toggleClass(aClass);
    }
  }
  function closeMenuBtn(e) {
    e.preventDefault();
    if (window.matchMedia(mq.mdMax).matches) {
      btnMenu.removeClass(aClass);
      closeMenu();
    }
  }
  function initFunctions() {
    btnMenu.on('click', toggleMenu);
    btnClose.on('click', closeMenuBtn);
  }
  initFunctions();
}
"use strict";

/*
	Functionality for primary nav on desktop - the mega menu
 */
function calcMegaPos() {
  var nav = $(this);
  var navWidth = nav.outerWidth();
  var navPos = nav.offset();
  var navLeft = navPos.left;
  var navRight = navPos.left + navWidth;
  function eachMega() {
    var thisMega = $(this);
    if (window.matchMedia(mq.mdMax).matches) {
      thisMega.removeAttr('style');
    } else if (window.matchMedia(mq.md).matches) {
      var parent = $('.primary-nav_list');
      var parentNeg = parseInt(parent.css('left'));
      var selfWidth = thisMega.outerWidth();
      var listItem = thisMega.closest('li');
      var liLeft = listItem.position().left;
      var newLeft = 0;
      parentNeg = isNaN(parentNeg) ? 0 : parentNeg;
      if (navLeft + liLeft + selfWidth + parentNeg < navRight) {
        newLeft = liLeft;
      } else {
        newLeft = navWidth - selfWidth - parentNeg;
      }
      thisMega.css({
        left: newLeft
      });
    }
  }
  $('.primary-mega').each(eachMega);
}
"use strict";

function primaryMega() {
  var pNavs = $('.primary-nav_list-overflow');

  // initialize the megamenu
  pNavs.accessibleMegaMenu({
    /* unique ID's are required to indicate aria-owns, aria-controls and aria-labelledby */
    uuidPrefix: 'primary-mega',
    /* css class used to define the megamenu styling */
    menuClass: '',
    /* css class for a top-level navigation item in the megamenu */
    topNavItemClass: 'primary-nav_top-item',
    /* css class for a megamenu panel */
    panelClass: 'primary-mega',
    /* css class for a group of items within a megamenu panel */
    panelGroupClass: 'primary-mega_col',
    /* css class for the hover state */
    hoverClass: 'hover',
    /* css class for the focus state */
    focusClass: 'focus',
    /* css class for the open state */
    openClass: 'open',
    mqMobile: mq.mdMax
  });
  pNavs.each(calcMegaPos);
  $(window).on('resize', throttle(function () {
    pNavs.each(calcMegaPos);
  }, 100));
}
"use strict";

function locationMega() {
  var lNavs = $('.location-nav_list-overflow');

  // initialize the megamenu
  lNavs.accessibleMegaMenu({
    /* unique ID's are required to indicate aria-owns, aria-controls and aria-labelledby */
    uuidPrefix: 'location-mega',
    /* css class used to define the megamenu styling */
    menuClass: '',
    /* css class for a top-level navigation item in the megamenu */
    topNavItemClass: 'location-nav_top-item',
    /* css class for a megamenu panel */
    panelClass: 'location-mega',
    /* css class for a group of items within a megamenu panel */
    panelGroupClass: 'location-mega_col',
    /* css class for the hover state */
    hoverClass: 'hover',
    /* css class for the focus state */
    focusClass: 'focus',
    /* css class for the open state */
    openClass: 'open',
    mqMobile: mq.mdMax
  });
}
"use strict";

/*
	Functionality for primary nav on mobile
 */
function primaryNavMobile() {
  var cLevel = '.primary-mega';
  var cBtn = '.xs-nav-acc-btn';
  var cBackBtns = '.xs-nav-back-btn';
  var cShow = 'xs-show-level';
  var dataLev = 'data-xs-level';
  var levels = $(cLevel);
  var btns = $(cBtn);
  var body = $('.primary-nav_list');
  var backBtns = body.find(cBackBtns);
  function bpCheck() {
    if (window.matchMedia(mq.md).matches) {
      body.removeAttr('style');
    } else if (window.matchMedia(mq.mdMax).matches) {
      reShow();
    }
  }
  function backLevel(e) {
    e.preventDefault();
    var self = $(this);
    var currentLev = parseInt($(this).closest('.primary-nav_list').attr(dataLev));
    var thisLev = self.closest(cLevel);
    var upperLev = thisLev.parents(cLevel);
    thisLev.removeClass(cShow);
    $(this).closest('.primary-nav_list').attr('data-xs-level', currentLev - 1);
    if (upperLev.length > 0) {
      $(this).closest('.primary-nav_list').height(upperLev.outerHeight());
    } else {
      $(this).closest('.primary-nav_list').height('');
      $(this).closest('.primary-nav_list').outerHeight(body.outerHeight());
    }
  }
  function reShow() {
    var level = $(cLevel + '.xs-show-level').last();
    $(this).closest('.primary-nav_list').height(level.outerHeight());
  }
  function showLevel(e) {
    e.preventDefault();
    var self = $(this);
    var nextLevel = self.closest('li').find('> ' + cLevel);
    var upperLevs = self.parentsUntil(body, 'li');
    if (nextLevel && upperLevs) {
      nextLevel.addClass(cShow);
      //body.attr(dataLev, parseInt(upperLevs.length));
      //body.height(nextLevel.outerHeight());
      $(this).closest('.primary-nav_list').attr(dataLev, parseInt(upperLevs.length));
      $(this).closest('.primary-nav_list').height(nextLevel.outerHeight());
    }
  }
  btns.on('click', showLevel);
  backBtns.on('click', backLevel);
  $(window).on('resize', throttle(function () {
    bpCheck();
  }, 100));
  if (window.matchMedia(mq.mdMax).matches) {
    //body.outerHeight(body.outerHeight());
    body.each(function () {
      $(this).outerHeight($(this).outerHeight());
    });
  }
}
"use strict";

// Responsive Column Based Carousels
function carousels() {
  var smData = 'data-slider-sm';
  var smSel = '[' + smData + ']';
  var mdData = 'data-slider-md';
  var mdSel = '[' + mdData + ']';
  var allData = 'data-slider';
  var allSel = '[' + allData + ']';
  function getOpts(self, attr) {
    var opts = self.attr(attr);
    var optsParsed;
    if (opts === '') {
      optsParsed = {};
    } else {
      optsParsed = JSON.parse(opts);
    }
    var optsCombined = $.extend({
      items: 1,
      center: true,
      dots: false,
      nav: true,
      loop: true,
      infinite: true,
      navText: ['<span class="visuallyhidden">Previous</span><span class="fa fa-angle-left"></span>', '<span class="visuallyhidden">Next</span><span class="fa fa-angle-right"></span>']
    }, optsParsed);
    return optsCombined;
  }
  function addSm() {
    var self = $(this);
    var sliderOpts = getOpts(self, smData);
    enquire.register(mq.xs, {
      setup: function setup() {
        if (window.matchMedia(mq.xs).matches) {
          self.owlCarousel(sliderOpts);
          self.addClass('owl-carousel');
        }
      },
      match: function match() {
        self.owlCarousel(sliderOpts);
        self.addClass('owl-carousel');
      },
      unmatch: function unmatch() {
        self.trigger('destroy.owl.carousel');
        self.removeClass('owl-carousel');
      }
    });
  }
  function addMd() {
    var self = $(this);
    var sliderOpts = getOpts(self, mdData);
    enquire.register(mq.smxs, {
      setup: function setup() {
        if (window.matchMedia(mq.sm).matches) {
          self.owlCarousel(sliderOpts);
          self.addClass('owl-carousel');
        }
      },
      match: function match() {
        self.owlCarousel(sliderOpts);
        self.addClass('owl-carousel');
      },
      unmatch: function unmatch() {
        self.trigger('destroy.owl.carousel');
        self.removeClass('owl-carousel');
      }
    });
  }
  function addAll() {
    var self = $(this);
    var sliderOpts = getOpts(self, allData);
    $(self).owlCarousel(sliderOpts);
    self.addClass('owl-carousel');
  }
  $(smSel).each(addSm);
  $(mdSel).each(addMd);
  $(allSel).each(addAll);
}
"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
// Extends OwlCarousel functionality and settings
var owlCarouselHero = function owlCarouselHero() {
  var items = [];
  var $oc = $('[data-carousel-hero]');
  $oc.each(function () {
    items = new OwlCarouselItem($(this));
  });
};

// for each instance of the carousel
var OwlCarouselItem = function OwlCarouselItem($el) {
  if ($el) {
    this._$el = $el;
    if (this._$el.length > 0) {
      this._init();
    }
  }
};
OwlCarouselItem.prototype = {
  _init: function _init() {
    // attribute to hide hero on mobile
    this._hideBelow = this._$el.data('hide-below-width');
    // fix issue with number not being numeric
    if (!$.isNumeric(this._hideBelow)) {
      if (this._hideBelow != null) {
        this._hideBelow = this._hideBelow.match(/\d/g).join("");
      }
    }
    this._isActive = false;
    this._isConfig = false;
    this._isShowing = false;
    this.__resize = $.proxy(this._resize, this);
    // update positioning on resize
    window.addEventListener('resize', this.__resize);
    window.addEventListener('orientationchange', this.__resize);
    this._resize();
  },
  _config: function _config() {
    // only configure once
    if (!this._isConfig) {
      this._int = 0;
      this._$items = $('> *', this._$el);
      if (this._$items.length > 0) {
        var showControls = this._$items.length > 1,
          self = this,
          settings = this._$el.data('carousel-hero');
        this.__loading = $.proxy(this._loading, this);
        this.__loadComplete = $.proxy(this._loadComplete, this);
        this.__loadError = $.proxy(this._loadError, this);
        this.__resizeUpdate = $.proxy(this._resizeUpdate, this);
        // default carousel settings
        this._defaults = {
          items: 1,
          autoplay: true,
          autoplayTimeout: 5000,
          autoplayHoverPause: true,
          autoHeight: false,
          loop: true,
          dots: showControls,
          nav: showControls,
          mouseDrag: showControls,
          touchDrag: showControls,
          autoplaySpeed: 1000,
          animateIn: 'fadeIn',
          animateOut: 'fadeOut',
          // callbacks
          onInitialized: $.proxy(this._update, this)
        };

        // custom settings data attribute settings

        if (_typeof(settings) === 'object') {
          for (var item in settings) {
            this._defaults[item] = settings[item] == "true" ? true : settings[item] == "false" ? false : parseInt(settings[item]);
          }
        }
        this._$el.on('loading', this.__loading);
        this._$el.on('load_complete', this.__loadComplete);
        this._$el.on('load_error', this.__loadError);
        this._$el.on('cancel', this.__cancel);
        // 
        this._$el.owlCarousel(this._defaults);
        //
        this._$dots = $('.owl-dots', this._$el);
        this._$nav = $('.owl-nav', this._$el);

        // sets up responsive images for carousel
        this._$imgs = $('[data-responsive-img]', this._$el);
        this._imgItems = [];
        this._$imgs.each(function () {
          var $item = $(this);
          $item.on('loading', self.__loading);
          $item.on('load_complete', self.__loadComplete);
          self._imgItems = new ResponsiveImgItem($item);
        });
      }
      this._isConfig = true;
    }
  },
  // accessibility functionality 
  _update: function _update() {
    var $items = $('.owl-item', this._$el);
    // make individual items focusable
    $items.attr('aria-selected', 'false').attr('tabindex', '0');
    this._$el.attr('tabindex', '0');

    // on when an item has focus, let screen readers know it is active
    $items.on('focus', function () {
      $items.attr('aria-selected', 'false');
      $(this).attr('aria-selected', 'true');
    });

    // show instructions to keyboard users when the carousel is focused
    $('.owl-wrapper-outer', this._$el).append('');
  },
  _cancel: function _cancel() {},
  _loading: function _loading() {
    // Empty
  },
  _loadComplete: function _loadComplete() {
    this._resize();
  },
  _loadError: function _loadError() {
    // Empty
  },
  _resize: function _resize() {
    if (this._hideBelow != undefined) {
      if (this.getInnerWidth() <= this._hideBelow) {
        if (this._isActive) {
          this._isActive = false;
          this.hide();
        }
      } else {
        if (!this._isActive) {
          this._isActive = true;
          if (!this._isConfig) {
            this._config();
          }
          this.show();
        }
      }
    } else {
      if (!this._isActive) {
        this._isActive = true;
        if (!this._isConfig) {
          this._config();
        }
        this.show();
      }
    }
    if (this._isActive) {
      clearTimeout(this._int);
      this._int = setTimeout(this.__resizeUpdate, 250);
    }
  },
  _resizeUpdate: function _resizeUpdate() {
    clearTimeout(this._int);
    var w = this.getInnerWidth(),
      top = this._$el.height(),
      d = 0,
      $imgs = $('.slide__img', this._$el);
    if (w < 1024) {
      if (this._$dots.length > 0) {
        top = $imgs.first().height();
      }
    } else {
      // if image is bigger in height than carousel
      var h = this._$el.height(),
        imgH = $imgs.first().height();
      if (imgH > h) {
        d = (this._$el.height() - $('.slide__img', this._$el).first().height()) / 2;
      }
    }

    // image centered
    $('.slide__img', this._$el).css({
      '-webkit-transform': 'translateY(' + (d > 0 ? 0 : d) + 'px)',
      'transform': 'translateY(' + (d > 0 ? 0 : d) + 'px)'
    });

    // dots below image
    this._$dots.css({
      top: top
    });
    this._$nav.css({
      top: top / 2
    });
  },
  getInnerWidth: function getInnerWidth() {
    return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  },
  show: function show() {
    if (!this._isShowing) {
      this._isShowing = true;
      this._$el.show();
    }
  },
  hide: function hide() {
    if (this._isShowing) {
      this._isShowing = false;
      this._$el.hide();
    }
  }
};
"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
// Extends Owl Carousel Controls for multi items in view 
var owlCarouselMulti = function owlCarouselMulti() {
  var items = [];
  var $oc = $('[data-carousel-multi]');
  if (navigator.geolocation) {
    var reorder = $oc.filter('[data-reorder="geolocation"]');
    if (reorder.length > 0) {
      reorder.each(function (i, e) {
        navigator.geolocation.getCurrentPosition(function (position) {
          var getDistanceFromLatLonInKm = function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) {
            var R = 6371; // Radius of the earth in km
            var dLat = deg2rad(lat2 - lat1); // deg2rad below
            var dLon = deg2rad(lon2 - lon1);
            var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
            var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
            var d = R * c; // Distance in km
            return d;
          };
          var deg2rad = function deg2rad(deg) {
            return deg * (Math.PI / 180);
          };
          var distanceTo = function distanceTo(from, to) {
            return getDistanceFromLatLonInKm(from.latitude, from.longitude, to.latitude, to.longitude);
          };
          var getCoord = function getCoord(elem) {
            return {
              latitude: elem.getAttribute("data-latitude"),
              longitude: elem.getAttribute("data-longitude")
            };
          };
          var res = $(e.children).sort(function (a, b) {
            var coordA = getCoord(a);
            var coordB = getCoord(b);
            var distA = distanceTo(position.coords, coordA);
            var distB = distanceTo(position.coords, coordB);
            return distA - distB;
          });
          res.appendTo(e);
          items = new OwlCarouselItemMulti($(e));
        }, function () {
          items = new OwlCarouselItemMulti($(e));
        });
      });
    }

    // Fix bug where some card-containers are not displayed
    if ($oc.length != reorder.length) {
      $oc.each(function () {
        if (!$(this).is("[data-reorder='geolocation']")) {
          items = new OwlCarouselItemMulti($(this));
        }
      });
    }
  } else {
    $oc.each(function () {
      items = new OwlCarouselItemMulti($(this));
    });
  }
};

// for each instance of the carousel
var OwlCarouselItemMulti = function OwlCarouselItemMulti($el) {
  OwlCarouselItem.call(this, $el);
};
OwlCarouselItemMulti.prototype = new OwlCarouselItem();

// Extend Owl Carousel item 
OwlCarouselItemMulti.prototype._init = function () {
  //this._$el = $el;      
  this._int = 0;
  this._$items = $('> *', this._$el);
  // padding around the stage
  this._padding = {
    top: 15,
    bottom: 15,
    left: 35,
    right: 35
  };
  this._int = 0;
  this.__resize = $.proxy(this._resize, this);
  this.__resizeUpdate = $.proxy(this._resizeUpdate, this);
  if (this._$items.length > 1) {
    var numItems = this._$items.length,
      loop = numItems > 3,
      nav = numItems > 3,
      dots = numItems > 3,
      settings = this._$el.data('carousel-multi');

    // default carousel settings
    this._defaults = {
      items: 3,
      autoplay: false,
      //true,
      autoplayTimeout: 5000,
      autoHeight: false,
      loop: loop,
      dots: dots,
      nav: nav,
      autoplaySpeed: 500,
      responsiveClass: true,
      responsive: {
        0: {
          items: 1,
          nav: true
        },
        480: {
          items: 2,
          nav: true
        },
        992: {
          items: 3
        }
      },
      // callbacks
      onInitialized: $.proxy(this._update, this)
    };

    // custom settings data attribute settings
    if (_typeof(settings) === 'object') {
      for (var item in settings) {
        this._defaults[item] = settings[item];
      }
    }
    this._$el.owlCarousel(this._defaults);
    this._$stage = $('.owl-stage', this._$el);
    this._$stageOuter = $('.owl-stage-outer', this._$el);

    // update positioning on resize
    window.addEventListener('resize', this.__resize);
    window.addEventListener('orientationchange', this.__resize);
    this._resize();
  }
};

// Extend Owl Carousel item 
OwlCarouselItemMulti.prototype._resizeUpdate = function () {
  clearTimeout(this._int);
  if (this._$stageOuter.length > 0) {
    var h = this._$stage.height() + this._padding.top + this._padding.bottom;
    this._$stageOuter.height(h);
  }
};
"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
// Load images depending on screen width, used in owlCarouselHero
var ResponsiveImgItem = function ResponsiveImgItem($el) {
  this._$el = $el;
  if (this._$el.length > 0) {
    this._init();
  }
};
ResponsiveImgItem.prototype = {
  _init: function _init() {
    this._data = this._$el.data('responsive-img'); // json data 
    if (_typeof(this._data) === 'object') {
      this._index = 0;
      this._isComplete = false;
      this._imgWidth = 0;
      this._imgHeight = 0;
      this._start();
    }
  },
  _start: function _start() {
    this.__resize = this._resize.bind(this);
    window.addEventListener('resize', this.__resize);
    window.addEventListener('orientationchange', this.__resize);
    this._resize();
  },
  cancel: function cancel() {
    window.removeEventListener('resize', this.__resize);
    window.removeEventListener('orientationchange', this.__resize);
    this._$el.trigger('cancel', {
      target: this
    });
  },
  _complete: function _complete() {
    this.cancel();
  },
  _resize: function _resize() {
    var w = this.getInnerWidth(),
      url = '',
      i = 0;
    for (var item in this._data) {
      if (w >= parseInt(item)) {
        url = this._data[item];
        i++;
      }
    }
    // Only load larger images, not smaller on resize
    if (i > this._index) {
      if (url.length > 0) {
        this._url = url;
        this._load();
      }
      this._index = i;
      // if loaded largest image then completed task
      if (this._index === this._length) {
        this._complete();
      }
    }
  },
  // apply image to img src attribute
  _setSrc: function _setSrc() {
    if (this._$el.length > 0) {
      this._$el.attr('src', this._url);
    }
  },
  // load the image into cache
  _load: function _load() {
    // load image into cache ready 
    this._img = new Image();
    this._img.addEventListener('load', this._loadComplete.bind(this), false);
    this._img.addEventListener('error', this._loadError.bind(this), false);
    this._img.src = this._url;
    // set the image source
    this._setSrc(this._url);
    //
    this._$el.trigger('loading', {
      target: this
    });
  },
  // image load complete
  _loadComplete: function _loadComplete(e) {
    this._img = null; // clear memory
    this._$el.trigger('load_complete', {
      target: this
    });
  },
  // image load error
  _loadError: function _loadError(e) {
    this._img = null; // clear memory
    this._$el.trigger('load_error', {
      target: this
    });
  },
  getInnerWidth: function getInnerWidth() {
    return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  }
};
"use strict";

// Deals with the querystring path
var MultiSelectFilterPath = function MultiSelectFilterPath(model) {
  this._model = model;
  this._location = window.location.hash;
};
MultiSelectFilterPath.prototype = {
  init: function init() {
    this.type = 'path';
    this._hasItems = false;
    if (window.location.hash) {
      if (window.location.hash.indexOf('topics')) {
        this._hasItems = true;
        this._model.onChange({
          target: this
        });
      }
    }
    window.addEventListener("hashchange", $.proxy(this._onHashChange, this), false);
  },
  hasItems: function hasItems() {
    return this._hasItems;
  },
  getItems: function getItems() {
    var str = unescape(window.location.hash);
    return str.slice(1, str.length).split('+');
  },
  update: function update() {
    var items = this._model.items(),
      querystring = '';
    if (items.length > 0) {
      for (var i = 0; i < items.length; i++) {
        querystring += items[i].label;
        if (i != items.length - 1) {
          querystring += '+';
        }
      }
    }
    window.location.hash = querystring;
  },
  _onHashChange: function _onHashChange(e) {
    e.preventDefault();
  }
};
"use strict";

// Checkbox View
var MultiSelectFilterOptions = function MultiSelectFilterOptions($el, model) {
  this._model = model;
  this._$el = $el;
};
MultiSelectFilterOptions.prototype = {
  init: function init() {
    if (this._$el.length > 0) {
      this.type = 'options';
      // proxy
      this.__onChange = $.proxy(this._onChange, this);

      // apply button (optional)
      this._$applyFiltersBtn = $('#c-search-filter-button');
      // 
      this._$checkBoxes = $('input[type="checkbox"]', this._$el);
      // All checkbox
      this._$all = $('input[name*="all"], input[name*="All"]', this._el);

      // check if any checkboxes are ticked on page load
      var items = this.getSelectedItems();
      if (items.length > 0) {
        this._model.onChange({
          target: this
        });
      }
      this.categoryFilterSubmit();
      this.start();
    }
  },
  start: function start() {
    this._$checkBoxes.on('change', this.__onChange);
  },
  cancel: function cancel() {
    this._$checkBoxes.off('change', this.__onChange);
  },
  toggleCategoryColors: function toggleCategoryColors($element, isChecked) {
    if (isChecked) {
      $element.addClass("active");
    }
  },
  toggleCategoryAndTriggerSubmit: function toggleCategoryAndTriggerSubmit($element, colorsFunc, doCheck, doSubmit) {
    var $categoryElement = $("#" + $element.attr("id").replace("value-", ""));
    var isChecked = $categoryElement.prop("checked");
    $categoryElement.prop("checked", doCheck);
    if (colorsFunc) colorsFunc($element, isChecked);
    if (doSubmit) {
      var $submitter = $('.c-loc-form_submit');
      $submitter.trigger("click");
    }
  },
  categoryFilterSubmit: function categoryFilterSubmit() {
    var $categoryElements = $(".category-clicker");
    var toggleCategoryFunc = this.toggleCategoryAndTriggerSubmit;
    var colorsFunc = this.toggleCategoryColors;
    $categoryElements.on("click", function () {
      $categoryElements.each(function () {
        toggleCategoryFunc($(this), colorsFunc, false, false);
      });
      toggleCategoryFunc($(this), colorsFunc, true, true);
    });
    var count = 0;
    $categoryElements.each(function () {
      if ($(this).children("input").is(":checked")) {
        colorsFunc($(this), true);
        count++;
      }
    });
    if (count === 0) {
      colorsFunc($("#value-all"), true);
    }
    $("#value-all").on("click", function () {
      $categoryElements.each(function () {
        toggleCategoryFunc($(this), null, false, false);
      });
      toggleCategoryFunc($(this), colorsFunc);
    });
  },
  // Returns array of items from the checkbox list
  getSelectedItems: function getSelectedItems() {
    var $selected = $('input[type="checkbox"]:checked', this._$el),
      items = [];
    // collect all selected checkboxes
    $selected.each(function (index) {
      var $checkbox = $(this),
        id = $checkbox.attr('id'),
        name = $checkbox.attr('name'),
        label = $('+label', $checkbox).text();
      if (!/all/ig.test(id) && id !== "all") {
        // add to the array
        items.push({
          id: id,
          name: name,
          label: label
        });
      }
    });
    return items;
  },
  // Checks items and returns checked items by there label text
  checkItemsByLabels: function checkItemsByLabels(a) {
    var items = [];
    if (a.length > 0) {
      // unselect all option
      this._$all.prop('checked', false);
      // collect all checkboxes
      this._$checkBoxes.each(function (index) {
        var $checkbox = $(this),
          id = $checkbox.attr('id'),
          name = $checkbox.attr('name'),
          label = $('+label', $checkbox).text();

        // check if checkbox should be selected
        for (var i = 0; i < a.length; i++) {
          if (a[i] == label) {
            $checkbox.prop('checked', true);
            if (!/all/ig.test(id)) {
              // add to the array
              items.push({
                id: id,
                name: name,
                label: label
              });
            }
          }
        }
      });
    }
    return items;
  },
  update: function update() {
    var items = this._model.items();
    this._render(items);
  },
  _onChange: function _onChange(e) {
    e.preventDefault();
    // check if this is the all options and is checked
    var $el = $(e.currentTarget),
      id = $el.attr('id');
    if (/all/ig.test(id)) {
      if ($el.prop('checked')) {
        this._selectAll();
      }
    } else {
      if (this._$all.length > 0) {
        this._$all.prop('checked', false);
      }
    }

    // select all if no items  selected
    var items = this.getSelectedItems();
    if (items.length === 0) {
      this._$all.prop('checked', true);
    }

    // update the model
    this._model.onChange({
      target: this
    });
  },
  // select only the all option
  _selectAll: function _selectAll() {
    this._$checkBoxes.each(function (index) {
      if (index > 0) {
        var $checkbox = $(this);
        $checkbox.prop('checked', false);
      }
    });
  },
  _render: function _render(items) {
    // show tooltip if apply button
    if (this._$applyFiltersBtn.length > 0) {
      if (!this._$applyFiltersBtn.hasClass('is-active')) {
        this._$applyFiltersBtn.addClass('is-active');
        this._$applyFiltersBtn.attr('disabled', false);
        this._$applyFiltersBtn.tooltipster('open');
      }
    }
    // uncheck all checkboxes
    this._$checkBoxes.each(function (index) {
      var $checkbox = $(this);
      $checkbox.prop('checked', false);
    });

    // update checked boxes from items list
    if (items.length > 0) {
      for (var i = 0; i < items.length; i++) {
        $('#' + items[i].id, this._$el).prop('checked', true);
      }
    } else {
      // if no checkboxes selected default to all
      this._$all.prop('checked', true);
    }
  }
};
"use strict";

// Deals with the toggle button number data
var MultiSelectFilterToggle = function MultiSelectFilterToggle(model) {
  // Toggle Filter button on mobile
  var $btn = $('.c-acc-5_btn');
  if ($btn) {
    this._$el = $btn;
    if (model && model._defaults && model._defaults.buttonLabel) {
      this._label = model._defaults.buttonLabel;
    } else {
      this._label = 'Filter blog by topic';
    }
  } else {
    this._$el = $('.c-search-filters-toggle');
    this._label = 'Filter';
  }
  this._isRunning = false;
  if (this._$el.length > 0) {
    this._model = model;
    this._init();
  }
};
MultiSelectFilterToggle.prototype = {
  _init: function _init() {
    this._isRunning = true;
  },
  update: function update() {
    if (this._isRunning) {
      var items = this._model.items();
      this._render(items);
    }
  },
  _render: function _render(items) {
    var str = this._label;
    if (items.length > 0) {
      str = this._label + (items.length > 1 ? 's (' + items.length + ')' : ' (' + items.length + ')');
    }
    // check if all is selected 
    if (items.length == 0) {
      var $checkbox = $('[data-multi-select-filter] input[name*="all"]:checked');
      if ($checkbox.length > 0) {
        str = this._label + 's (All)';
      }
    }
    $('span:first-child', this._$el).text(str);
  }
};
"use strict";

// View for the removable filter capsules
var MultiSelectFilterCapsules = function MultiSelectFilterCapsules(model) {
  this._model = model;
  this._$el = $('[data-multi-select-filter-capsules]');
  if (this._$el.length > 0) {
    this._init();
  }
};
MultiSelectFilterCapsules.prototype = {
  _init: function _init() {
    this.type = 'capsules';
    this.__onItemRemoveHandler = $.proxy(this._onItemRemoveHandler, this);
  },
  cancel: function cancel() {
    $('a', this._$el).off('click', this.__onItemRemoveHandler);
    this._render([]);
  },
  update: function update() {
    var items = this._model.items();
    this._render(items);
  },
  // handler for close item
  _onItemRemoveHandler: function _onItemRemoveHandler(e) {
    e.preventDefault();
    var $item = $(e.target);
    if ($item.length > 0) {
      var val = $item.data('value');
      this._model.removeItem(val);
    }
    this._model.onChange({
      target: this
    });
  },
  _listen: function _listen() {
    $('a', this._$el).on('click', this.__onItemRemoveHandler);
  },
  _render: function _render(items) {
    var html = '';
    if (items.length > 0) {
      if (!this._$el.hasClass('is-active')) {
        this._$el.addClass('is-active');
      }
      html = '<ul>';
      for (var i = 0; i < items.length; i++) {
        html += '<li>';
        html += '<div class="c-filter-capsule">' + items[i].label + '<a href="#" class="c-filter-capsule_remove" data-value="' + items[i].id + '">Remove filter ' + items[i].label + '</a></span>';
        html += '</li>';
      }
      html += '</ul>';
    } else {
      if (this._$el.hasClass('is-active')) {
        this._$el.removeClass('is-active');
      }
    }
    this._$el.html(html);
    this._listen();
  }
};
"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
/*  For multiple select items in accordion dropdown (See blog page, and search results)

    Settings  (set with data attriute in the HTML)
        changeUrls      :Boolean - If set true changes to url hash according to the selected checkbox
        showCapsules    :Boolean - If set true shows the capsules below the search input box
        hideBelowWidth  :Number - If set the capules will be hidding below that screen width
        buttonLabel     :String - If set the button will use this text
*/
var MultiSelectFilter = function MultiSelectFilter() {
  this._$el = $('[data-multi-select-filter]');
  if (this._$el.length > 0) {
    this._init();
  }
};
MultiSelectFilter.prototype = {
  _init: function _init() {
    this._isConfig = false;
    this._isRunning = false;
    this.__resize = $.proxy(this._resize, this);
    this._defaults = {
      changeUrls: true,
      showCapsules: true,
      hideBelowWidth: 768,
      buttonLabel: ''
    };

    // Custom overrides 
    var settings = this._$el.data('multi-select-filter');
    if (_typeof(settings) === 'object') {
      for (var item in settings) {
        if (item === 'buttonLabel') {
          this._defaults[item] = settings[item];
        } else {
          this._defaults[item] = settings[item] == "true" ? true : settings[item] == "false" ? false : parseInt(settings[item]);
        }
      }
    }
    this._items = [];
    // filter list view (capsules)
    this._multiSelectFilterCapsules = new MultiSelectFilterCapsules(this);

    // updates the url path
    this._multiSelectFilterPath = new MultiSelectFilterPath(this);

    // udates the filter toggle number of selected items
    this._multiSelectFilterToggle = new MultiSelectFilterToggle(this);

    // checkbox options view (dropdown)
    this._multiSelectFilterOptions = new MultiSelectFilterOptions(this._$el, this);
    this._multiSelectFilterOptions.init();
    // init path urls
    if (this._defaults.changeUrls) {
      this._multiSelectFilterPath.init();
    }
    this.__resizeUpdate = $.proxy(this._resizeUpdate, this);
    window.addEventListener('resize', this.__resize);
    window.addEventListener('orientationchange', this.__resize);
    this._resize();
  },
  el: function el() {
    return this._$el;
  },
  // Start functionlity
  start: function start() {
    if (!this._isRunning) {
      this._isRunning = true;
      this._items = this._multiSelectFilterOptions.getSelectedItems();
      if (this._defaults.showCapsules) {
        this._multiSelectFilterCapsules.update();
      }
    }
  },
  // Cancel functionailty
  cancel: function cancel() {
    if (this._isRunning) {
      this._isRunning = false;
      this._multiSelectFilterCapsules.cancel();
    }
  },
  // returns the item list
  items: function items() {
    return this._items;
  },
  // On user input make changes
  onChange: function onChange(e) {
    switch (e.target.type) {
      case 'path':
        if (this._defaults.changeUrls) {
          this._items = this._multiSelectFilterOptions.checkItemsByLabels(this._multiSelectFilterPath.getItems());
          if (this._isRunning && this._defaults.showCapsules) {
            this._multiSelectFilterCapsules.update();
          }
        }
        break;
      case 'options':
        // update item list from checkbox list
        this._items = this._multiSelectFilterOptions.getSelectedItems();
        if (this._isRunning && this._defaults.showCapsules) {
          this._multiSelectFilterCapsules.update();
        }
        if (this._isRunning && this._defaults.changeUrls) {
          this._multiSelectFilterPath.update();
        }
        break;
      case 'capsules':
        this._update();
        break;
      default:
    }
    // update the number in the filter toggle text
    this._multiSelectFilterToggle.update();
    this._$el.trigger('change', {
      target: this
    });
  },
  // remove an item from the list
  removeItem: function removeItem(id) {
    for (var i = 0; i < this._items.length; i++) {
      if (this._items[i].id == id) {
        this._items.splice(i, 1);
      }
    }
  },
  // Update views
  _update: function _update() {
    this._multiSelectFilterOptions.update();
    this._multiSelectFilterCapsules.update();
    if (this._isRunning && this._defaults.changeUrls) {
      this._multiSelectFilterPath.update();
    }
    this._items = this._multiSelectFilterOptions.getSelectedItems();
  },
  _resize: function _resize() {
    if (this.getInnerWidth() >= this._defaults.hideBelowWidth) {
      this.start();
    } else {
      this.cancel();
    }
  },
  getInnerWidth: function getInnerWidth() {
    return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  }
};
"use strict";

// Deals with the blog data
var BlogData = function BlogData(model) {
  this._$el = $('[data-blog-results]');
  this._$template = $("#blog-results-template").html();
  if (this._$el.length > 0 && this._$template.length > 0) {
    this._init();
  }
};
BlogData.prototype = {
  update: function update(items) {
    if (!this._$el.hasClass('is-loading')) {
      this._$el.addClass('is-loading');
    }
    this._isLoading = true;
    this._setData(items);
  },
  _setData: function _setData(items) {
    if (this._items !== items) {
      this._items = items;
      // put topics into a string
      this._categories = '';
      for (var i = 0; i < items.length; i++) {
        this._categories += $('#' + items[i].id).data('category-id');
        if (i != items.length - 1) {
          this._categories += '|'; // delimiter
        }
      }

      this._getData();
    }
  },
  _init: function _init() {
    Handlebars.registerHelper('splitLabel', function (title) {
      var t = title.split('|');
      return t[0];
    });

    // url for ajax requests  
    //this._url = 'data/blog.json';
    this._url = [location.protocol, "//", location.host, location.pathname, location.search].join("");
    this._isLoading = false;
    this._hasError = false;
    this.__pageClick = $.proxy(this._pageClick, this);
    this.__success = $.proxy(this._success, this);
    this.__error = $.proxy(this._error, this);

    // Compile the template data into a function
    this._templateScript = Handlebars.compile(this._$template);
    // page number 'hidden field, crouching page number'
    this._pageNumber = "1";
    // default data
    this._data = {
      Location: 'all',
      Topic: ['All'],
      Start: 0,
      End: 10
    };
    this._getData();
  },
  // gets the data 
  _getData: function _getData() {
    if ($("#AuthorId").length) {
      this._getBlogsByAuthor();
    } else {
      this._getBlogs();
    }
  },
  _getBlogs: function _getBlogs() {
    var postData = {
      scController: "NewsMedia",
      scAction: "GetBlogResults",
      __RequestVerificationToken: $('[name=__RequestVerificationToken]').val(),
      topicFilters: this._categories,
      // GetTopicFilters(),
      pageNumber: this._pageNumber,
      renderingItemId: $("#RenderingItemId").val(),
      locationFilterId: $("#LocationFilterId").val(),
      resultsType: $("#ResultsType").val()
    };
    $.ajax({
      url: this._url,
      type: "POST",
      traditional: true,
      data: postData,
      context: this,
      success: this.__success,
      error: this.__error
    });
  },
  _getBlogsByAuthor: function _getBlogsByAuthor() {
    var postData = {
      scController: "NewsMedia",
      scAction: "GetPostResultsByAuthor",
      __RequestVerificationToken: $('[name=__RequestVerificationToken]').val(),
      authorId: $("#AuthorId").val(),
      pageNumber: this._pageNumber,
      renderingItemId: $("#RenderingItemId").val(),
      locationFilterId: $("#LocationFilterId").val()
    };
    $.ajax({
      url: this._url,
      type: "POST",
      traditional: true,
      data: postData,
      context: this,
      success: this.__success,
      error: this.__error
    });
  },
  _success: function _success(data) {
    this._hasError = false;
    this._complete();
    if (data.Pager) {
      data.Pager.Enabled = false;
      if (data.Pager.TotalPages > 1) {
        data.Pager.Enabled = true;
      }
    }
    this._render(data);
  },
  _error: function _error(data) {
    this._hasError = true;
    this._complete();
    this._render(data);
    console.warn("error", data);
  },
  _complete: function _complete() {
    this._isLoading = false;
    if (this._$el.hasClass('is-loading')) {
      this._$el.removeClass('is-loading');
    }
  },
  // Renders the handle bars
  _render: function _render(data) {
    var html = '';
    if (this._hasError) {
      html = '<p class="error-msg">Server error please try again later.</p>';
    } else {
      html = this._templateScript(data);
    }
    this._$el.html(html);
    this._bind();
  },
  // bind events 
  _bind: function _bind() {
    this._$pageButtons = $('.c-pagination a').on('click', this.__pageClick);
  },
  // pagination click sets the page number
  _pageClick: function _pageClick(e) {
    e.preventDefault();
    var href = $(e.currentTarget).attr('href'),
      n = href.slice(1, href.length);
    this._pageNumber = n ? n : '1';
    this._getData();
  }
};
"use strict";

// Deals with the blog featured card
var BlogFeatured = function BlogFeatured() {
  this._$el = $('.c-featured-card-container');
  if (this._$el.length > 0) {
    this._init();
  }
};
BlogFeatured.prototype = {
  _init: function _init() {
    this._isInit = true;
    this._$checkboxes = $('[data-multi-select-filter] input[type="checkbox"]');
    this._$all = $('[data-multi-select-filter] input[name*="all"], [data-multi-select-filter] input[name*="All"]');
    if (this._$checkboxes.length > 0 && this._$all.length > 0) {
      this.__onChange = $.proxy(this._onChange, this);
      this._$checkboxes.on('change', this.__onChange);
      this.update();
    }
  },
  _onChange: function _onChange() {
    this.update();
  },
  update: function update() {
    if (this._isInit) {
      if (this._$all.prop('checked')) {
        this._$el.show();
      } else {
        this._$el.hide();
      }
    }
  }
};
"use strict";

// Deals with the (media)Event data
var MediaEventData = function MediaEventData(model) {
  this._$el = $('#event-results'); // container div in EventSearch
  if (this._$el.length > 0) {
    this._init();
  }
};
MediaEventData.prototype = {
  update: function update(items) {
    if (!this._$el.hasClass('is-loading')) {
      this._$el.addClass('is-loading');
    }
    this._isLoading = true;
    this._setData(items);
  },
  _setData: function _setData(items) {
    if (this._items !== items) {
      this._items = items;
      // put topics into a string
      this._topics = '';
      for (var i = 0; i < items.length; i++) {
        this._topics += $('#' + items[i].id).data('topic-id');
        if (i != items.length - 1) {
          this._topics += '|'; // delimiter
        }
      }
      //this._getData();
    }
  },

  _init: function _init() {
    // url for ajax requests  
    //this._url = 'data/blog.json';
    this._url = [location.protocol, "//", location.host, location.pathname, location.search].join("");
    this._isLoading = false;
    this._hasError = false;
    this.__success = $.proxy(this._success, this);
    this.__error = $.proxy(this._error, this);
    this.__pageClick = $.proxy(this._pageClick, this);
    this.__getData = $.proxy(this._getData, this);

    // page number 'hidden field, crouching page number'
    this._pageNumber = "1";
    // default data
    //this._data = { 
    //    Location:'all',
    //    Topic:['All'],
    //    Start:0,
    //    End:10
    //}
    this._bind(); //this._getData();

    //bind the Search Event button (reset pageNumber when starting a new search)
    this._$startSearch = $('#mediaevents-search-btn').on('click', {
      pageNumber: "1"
    }, this.__getData);

    //bind the sortBy button (reset pageNumber too)
    this._$startSort = $('#sortBy').on('change', {
      pageNumber: "1"
    }, this.__getData);

    //css for event-location dropdownlist so it looks similar to event-topic
    $('#eventLocState').find("~.default-select > .default-select_inner").addClass('c-acc-5_btn');
  },
  // gets the data 
  _getData: function _getData(event) {
    if (event && event.data && event.data.pageNumber) {
      this._pageNumber = event.data.pageNumber;
    }
    this._getEvents();
  },
  _getEvents: function _getEvents() {
    var postData = {
      scController: "NewsMedia",
      scAction: "GetEventResults",
      __RequestVerificationToken: $('[name=__RequestVerificationToken]').val(),
      pageNumber: this._pageNumber,
      topicFilters: this._topics,
      eventLocationState: $("#eventLocState").val(),
      eventWebinarOnly: $("#eventWebinarOnly").is(':checked'),
      sortBy: $("#sortBy").find(":selected").val(),
      renderingItemId: $("#RenderingItemId").val(),
      locationFilterId: $("#LocationFilterId").val()
    };
    $.ajax({
      url: this._url,
      type: "POST",
      traditional: true,
      data: postData,
      context: this,
      success: this.__success,
      error: this.__error
    });
  },
  _success: function _success(data) {
    this._hasError = false;

    //Note: Review the use of innerHtml!
    //$('#event-results').html(data).promise().done(function () { masonryGrid(); });
    document.getElementById('event-results').innerHTML = data;
    //Update masonryGrid -- this is stupid, but there is no page-event raised for when innerHtml is loaded, and using just setTimeout or promise didn't always work
    var counter = 0;
    var found = false;
    var test1 = setInterval(function () {
      found = $('.searchEventLoaded');
      counter++;
      if (found || counter > 5) {
        clearInterval(test1);
        masonryGrid();
      }
    }, 100);
    this._complete();
    this._bind();
  },
  _error: function _error(data) {
    this._hasError = true;
    this._complete();
    this._bind();
    console.warn("error", data);
    var html = '<p class="error-msg">Server error please try again later.</p>';
    document.getElementById('event-results').innerHTML = html;
  },
  _complete: function _complete() {
    this._isLoading = false;
    if (this._$el.hasClass('is-loading')) {
      this._$el.removeClass('is-loading');
    }
  },
  // bind events 
  _bind: function _bind() {
    this._$pageButtons = $('.c-pagination a').on('click', this.__pageClick);
  },
  // pagination click sets the page number
  _pageClick: function _pageClick(e) {
    e.preventDefault();
    var href = $(e.currentTarget).attr('href'),
      n = href.slice(1, href.length);
    this._pageNumber = n ? n : '1';
    this._getData();
  }
};
"use strict";

/*
    If the fragment identifier is specified in the url, find the specified element.
    Returns null if the element is not found.
*/
function findNamedAnchorElement() {
  var hash = window.location.hash;
  if (hash) {
    anchorSelector = decodeURIComponent(hash); // [SJOGSR-133]

    // find element by id
    var anchorEl = $(anchorSelector);
    if (anchorEl.length) return anchorEl;

    // find element by name
    anchorEl = $("[name='" + anchorSelector.substring(1) + "']");
    if (anchorEl.length) return anchorEl;
  }
  return null;
}
function accordions() {
  var accData = 'data-accordion';
  var accContainerSel = '[' + accData + ']';
  var open = 'is-open';
  function addAcc() {
    var self = $(this);
    var selectors = self.attr(accData).split(',');
    var acc = selectors[0].trim();
    var accBtn = selectors[1].trim();
    var accBody = selectors[2].trim();
    var closeOnBlur = false;
    if (acc === '.c-acc-5') {
      closeOnBlur = $(self).data('multi-select') ? true : true;
    }
    if (self.attr(accData) && self.hasClass(acc.substr(1))) {
      individualAcc(self, accBtn, accBody, closeOnBlur);
    } else {
      $(acc, self).each(function () {
        individualAcc(this, accBtn, accBody, closeOnBlur);
      });
    }
  }
  function individualAcc(acc, accBtn, accBody, closeOnBlur) {
    var thisBtn = $(accBtn, acc);
    var thisBody = $(accBody, acc);
    var isOpen = true;
    if ($(acc).hasClass(open)) {
      thisBtn.attr('aria-expanded', true);
    } else {
      thisBtn.attr('aria-expanded', false);
    }
    thisBody.attr('id', 'some-name-' + thisBody.index());
    thisBtn.on('click', function (e) {
      e.preventDefault();
      isOpen = !isOpen;
      if (!$(acc).hasClass(open)) {
        var siblings = $(acc).siblings('.' + open).removeClass(open).find(accBody);
        if (siblings.length) {
          siblings.slideUp($.extend({
            complete: toggleThisSlide
          }, slideToggleOpts));
        } else {
          toggleThisSlide();
        }
      } else {
        toggleThisSlide();
      }
    });
    function toggleThisSlide() {
      var $acc = $(acc);
      $acc.toggleClass(open);
      if ($acc.hasClass(open)) {
        thisBtn.attr('aria-expanded', true);
      } else {
        thisBtn.attr('aria-expanded', false);
      }
      thisBody.stop().slideToggle($.extend({
        complete: function complete() {
          var $acc = $(acc);
          if ($acc.length > 0) {
            var offsetTop = $acc.offset().top;
            if (offsetTop < $('body').scrollTop() || offsetTop > $('body').scrollTop() + $(window).height()) {
              $('body').animate({
                scrollTop: offsetTop + 20
              }, 350);
            }
          }
        }
      }, slideToggleOpts));
    }
    function closeThisAcc() {
      $(acc).removeClass(open);
      $(acc).attr('aria-expanded', false);
      thisBody.stop().slideUp(slideToggleOpts);
      isOpen = false;
    }
    if (closeOnBlur) {
      $(document).on('click', function (e) {
        if (isOpen) {
          if ($(e.target).is(thisBtn[0]) || $(e.target).is(thisBody[0]) || $(e.target).closest(accBtn).length || $(e.target).closest(accBody).length) {
            // stay open
          } else {
            closeThisAcc();
          }
        }
      });

      // Close the accordion after a checkbox is selected. This should only apply to '.c-acc-5' accordions
      //$('[type="checkbox"]', thisBody).on('change', function() {
      //    closeThisAcc();
      //});
    }

    if (!$(acc).hasClass(open)) {
      thisBody.hide();
      isOpen = false;
    }
  }
  $(accContainerSel).each(addAcc);

  // SJOGSR-85 Show more/Show less
  $('.acc-showmore-state').change(function () {
    var accCommonAncestor = this.closest('.c-tab_body');
    var showMoreToggleTabs = $('.acc-toggle-showmore', accCommonAncestor);
    if (this.checked) {
      showMoreToggleTabs.removeClass('acc-collapse-tab');
    } else {
      showMoreToggleTabs.addClass('acc-collapse-tab');
    }
  });

  // SJOGSR-119 Anchor link to an open accordion
  var anchorEl = findNamedAnchorElement();
  if (anchorEl != null) {
    // If this anchorEl is inside an accordion-tab, find that tab and expand it (accordion tabs are initially collapsed)
    var accTab = anchorEl.closest('.c-acc-1');
    if (accTab) {
      var tabBtn = $('.c-acc-1_btn', accTab);
      if (tabBtn) tabBtn.trigger('click');
    }
  }
}
"use strict";

function tabs() {
  var tabData = 'data-tabs';
  var tabContainerSel = '[' + tabData + ']';
  var open = 'is-open';
  var cNotLoaded = 'tabs-not-loaded';
  function addTab() {
    var self = $(this);
    var selectors = self.attr(tabData).split(',');
    var tabBtn = selectors[0].trim();
    var tabBody = selectors[1].trim();
    individualTab(self, tabBtn, tabBody);
    self.removeClass(cNotLoaded);
  }
  function updateMegas() {
    $('.primary-nav_list-overflow').each(function () {
      var hiddenParents = $(this).parents(':hidden');
      if (!hiddenParents.length) {
        $(this).each(calcMegaPos);
      }
    });
  }
  function individualTab(tab, tabBtns, tabBodies) {
    var openTab = $(tabBtns + '.' + open, tab);
    tabBodies = $(tabBodies, tab);
    tabBtns = $(tabBtns, tab);
    if (tabBtns[0].tagName.toLowerCase() !== 'a') {
      tabBtns = tabBtns.find('a');
    }
    function tabBtnClick(e) {
      e.preventDefault();
      var self = $(this);
      var target = self.attr('href');
      if ($(target).is(':hidden')) {
        var index = $(target).index();
        var navX = 0;
        var thisOverflow = $(target).find('.primary-nav_list-overflow');
        tabBtns.removeClass(open);
        self.addClass(open);
        if (self.attr("id") == "sht-btn-1") {
          $("#header_search_isfullsite").attr("value", false);
          var placeholder = $("#header_search_placeholder").attr("value");
          $("#site-header_search").attr("placeholder", placeholder);
        } else if (self.attr("id") == "sht-btn-2") {
          $("#header_search_isfullsite").attr("value", true);
          var placeholder = "Search St John Of God Health Care";
          $("#site-header_search").attr("placeholder", placeholder);
        }
        tabBodies.hide();
        if (thisOverflow.length) {
          if (index === 0) {
            navX = -100;
          } else if (index === 1) {
            navX = 100;
          }
          new TweenMax(thisOverflow[0], 0, {
            opacity: 0,
            x: navX
          });
          new TweenMax.fromTo(thisOverflow[0], 1, {
            opacity: 0,
            x: navX
          }, {
            opacity: 1,
            x: 0,
            delay: 0.2,
            ease: Power3.easeOut
          });
        }
        $(target).show({
          duration: 0,
          complete: function complete() {
            window.gridInstances.forEach(function (instance) {
              instance.update();
            });
          }
        });
        var x = $(document).scrollLeft();
        var y = $(document).scrollTop();
        $(target).attr('tabindex', '0').focus(function () {
          //window.scrollTo(x, y); //todo: not scrolling to top of tab
        });
        $(target).one('blur', function () {
          $(target).removeAttr('tabindex');
        });
        updateMegas();
      }
    }
    tabBtns.on('click', tabBtnClick);
    tabBodies.on('focus', function (e) {
      e.preventDefault();
    });
    tabBodies.hide();
    if (openTab.length) {
      $(openTab.attr('href')).show();
    } else {
      tabBtns.first().addClass(open);
      tabBodies.first().show();
    }
  }
  var $priNav_overflow = $('.primary-nav_list-overflow');
  if ($priNav_overflow.length > 0) {
    new TweenMax.fromTo($priNav_overflow[0], 0.7, {
      opacity: 0,
      y: -8
    }, {
      opacity: 1,
      y: 0,
      delay: 0.5,
      ease: Power1.easeOut
    });
  }
  $(tabContainerSel).each(addTab);
}
"use strict";

function secondaryNav() {
  var navSel = '.secondary-nav';
  if ($(navSel).length) {
    var fixedContainer = $('[data-sticky-container]');
    var fixedNav = $('.secondary-nav', fixedContainer);
    var stickyVerticalOffset = 40;
    var tBtn = $('.nav-toggle_btn');
    var navList = $(navSel + '_list');
    var navUl = navList.find('> ul');
    var navTop = $(navSel + '_title, ' + navSel + '_logo');
    var bScrollUp = $(navSel + '_scroll-up');
    var bScrollDown = $(navSel + '_scroll-down');
    var panningOffset = 120;
    var wHeight = 0;
    var topHeight = 0;
    var ulHeight = 0;
    var sticky = new Sticky(navSel);
    var tBtnClick = function tBtnClick(e) {
      e.preventDefault();
      function toggleCbs() {
        recalcSecNavHeight();
        sticky.update();
      }
      if (window.matchMedia(mq.sm).matches) {
        var self = $(this);
        var item = self.closest('li');
        var body = item.find('> .sub-level');
        if (item.hasClass('is-open')) {
          TweenLite.to(body, 0.2, {
            height: 0,
            onComplete: toggleCbs
          });
          item.removeClass('is-open');
        } else {
          TweenLite.set(body, {
            height: 'auto'
          });
          TweenLite.from(body, 0.2, {
            height: 0,
            onComplete: toggleCbs
          });
          item.addClass('is-open');
        }
      }
    };
    var recalcSecNavHeight = function recalcSecNavHeight() {
      if (window.matchMedia(mq.sm).matches) {
        var listTop = Math.abs(parseInt(navUl.data('top'))) || 0;
        wHeight = $(window).height() - stickyVerticalOffset * 2;
        topHeight = 0;
        ulHeight = navUl.outerHeight();
        navTop.each(function () {
          topHeight += $(this).outerHeight();
        });
        var listHeight = wHeight - topHeight;
        navList.css('max-height', listHeight);
        if (listHeight < ulHeight) {
          navList.addClass('-show-scroll-down');
        } else {
          navList.removeClass('-show-scroll-down');
        }
        if (listTop > 0 && ulHeight <= listHeight) {
          doScrollTo(0);
          navList.removeClass('-show-scroll-up');
          navList.removeClass('-show-scroll-down');
        } else if (listTop > 0 && ulHeight > listHeight) {
          var maxTop = Math.abs(listHeight - ulHeight);
          if (listTop > maxTop) {
            doScrollTo(-maxTop);
            navList.addClass('-show-scroll-up');
            navList.removeClass('-show-scroll-down');
          }
        }
        adjustContainer();
      }
    };
    var doScrollTo = function doScrollTo(pos) {
      new TweenMax(navUl[0], 0.7, {
        y: pos
      });
      navUl.data('top', pos);
    };
    var doScrollUp = function doScrollUp() {
      var newTop = 0;
      var listHeight = navList.height();
      var currentTop = Math.abs(parseInt(navUl.data('top'))) || 0;
      if (ulHeight > listHeight) {
        if (currentTop - listHeight + panningOffset < 0) {
          // out of scroll space, go to top
          doScrollTo(0);
          navList.removeClass('-show-scroll-up');
          navList.addClass('-show-scroll-down');
        } else {
          // still have scroll space, do full scroll
          doScrollTo(-(currentTop - (listHeight - panningOffset)));
          navList.addClass('-show-scroll-up');
        }
      }
    };
    var doScrollDown = function doScrollDown() {
      var newTop = 0;
      var listHeight = navList.height();
      var currentTop = Math.abs(parseInt(navUl.data('top'))) || 0;
      var temp = Math.floor(listHeight * 2);
      if (ulHeight > listHeight) {
        if (temp + currentTop - panningOffset > ulHeight) {
          // out of scroll space, go to bottom
          doScrollTo(-(ulHeight - listHeight));
          navList.addClass('-show-scroll-up');
          navList.removeClass('-show-scroll-down');
        } else {
          // still have scroll space, do full scroll
          doScrollTo(-(currentTop + (listHeight - panningOffset)));
          navList.addClass('-show-scroll-up');
        }
      }
    };
    var adjustContainer = function adjustContainer() {
      if (fixedNav.length) {
        fixedContainer.css('min-height', '');
        var navHeight = fixedNav.outerHeight();
        var mainMargin = parseInt($('.site-main').css('margin-top'));
        fixedContainer.css('min-height', navHeight + mainMargin + 20);
      }
    };
    $('.sub-level', navUl).each(function () {
      if ($(this).closest('li').hasClass('is-open') || $('.is-active', this).length) {
        TweenLite.set(this, {
          height: 'auto'
        });
      } else {
        TweenLite.set(this, {
          height: 0
        });
      }
    });
    bScrollUp.on('mousedown', doScrollUp);
    bScrollDown.on('mousedown', doScrollDown);
    tBtn.on('click', tBtnClick);
    recalcSecNavHeight();
    $(window).on('resize', debounce(function () {
      recalcSecNavHeight();
    }, 80));
  }
}
"use strict";

function readMorePlus() {
  var readData = 'data-readmore-plus';
  var readContainerSel = '[' + readData + ']';
  function addReadMore() {
    var self = $(this);
    var optsAttr = self.attr(readData);
    var opts = JSON.parse(optsAttr);
    var optsCombined = $.extend({
      speed: 75,
      collapsedHeight: 100,
      moreLink: '<span class="read-plus"><a href="#">Read more<span class="fa fa-plus"></span></a></span>',
      lessLink: '<div class="read-plus"><a href="#">Read less<span class="fa fa-minus"></span></a></div>'
    }, opts);
    self.readmore(optsCombined);
  }
  $(readContainerSel).each(addReadMore);
}
function readMore() {
  var readData = 'data-xs-readmore';
  var readContainerSel = '[' + readData + ']';
  function addReadMore() {
    var self = $(this);
    var optsAttr = self.attr(readData);
    var opts = JSON.parse(optsAttr);
    var optsCombined = $.extend({
      speed: 75,
      collapsedHeight: 100,
      moreLink: '<div class="text-right"><a href="#">Read more<span class="fa fa-chevron-down"></span></a></div>',
      lessLink: '<div class="text-right"><a href="#">Read less<span class="fa fa-chevron-up"></span></a></div>'
    }, opts);
    enquire.register("screen and (mq.xs)", {
      setup: function setup() {
        if (window.matchMedia(mq.xs).matches) {
          self.readmore(optsCombined);
        } else {
          self.readmore('destroy');
        }
      },
      match: function match() {
        self.readmore(optsCombined);
      },
      unmatch: function unmatch() {
        self.readmore('destroy');
      }
    });
  }
  $(readContainerSel).each(addReadMore);
}
"use strict";

function heroHeaderBlurBg() {
  var heroEl = $('.c-hero');
  var heroImg = $('.c-hero_img', heroEl);
  var headerEl = $('.site-header');
  var headerImg = $('.header-hero-img', headerEl);
  function bpCheck() {
    var breadCrumbsEl = $('.c-page-crumbs');
    var headerHeight = headerEl.outerHeight();
    var breadCrumbsHeight = breadCrumbsEl.outerHeight() || 0;
    heroImg.css({
      'top': -headerHeight + 'px'
    });
    var heroHeight = heroImg.outerHeight();
    headerImg.height(heroHeight);
    if (breadCrumbsEl.length && window.matchMedia(mq.sm).matches) {
      heroEl.css({
        'margin-top': -breadCrumbsHeight + 'px',
        'padding-top': breadCrumbsHeight + 'px'
      });
    } else if (window.matchMedia(mq.xs).matches) {
      heroEl.css({
        'margin-top': '',
        'padding-top': ''
      });
    }
  }
  if (heroImg.length || headerImg.length) {
    bpCheck();
    $(window).on('resize', throttle(function () {
      bpCheck();
    }, 100));
    // jquery can't add clases to svg elements 
    // https://stackoverflow.com/questions/8638621/jquery-svg-why-cant-i-addclass
    var $elements = $('.header-hero-img');
    $elements.each(function () {
      var el = $(this)[0];
      if (el.classList) {
        el.classList.add('fade-in'); // breaks ie11
      } else {
        $(this).attr('class', 'header-hero-img fade-in'); // ie11 fallback
      }
    });
  }
}
"use strict";

function numberLineAnimation() {
  var svgEls = $('.c-number_circle-line');
  if (svgEls.length == 0) return;
  var vivusObjs = [];

  // $.cssNumber.strokeDashoffset = true;
  // $.cssNumber.strokeDasharray = true;

  function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
    var angleInRadians = angleInDegrees * Math.PI / 180.0;
    var x = centerX + radius * Math.cos(angleInRadians);
    var y = centerY + radius * Math.sin(angleInRadians);
    return {
      x: x,
      y: y
    };
  }
  function drawCircle(x, y, radius, startAngle, endAngle) {
    var start = polarToCartesian(x, y, radius, endAngle);
    var end = polarToCartesian(x, y, radius, startAngle);
    var arcSweep = endAngle - startAngle <= 180 ? "0" : "1";
    var d = ["M", start.x, start.y, "A", radius, radius, 0, arcSweep, 0, end.x, end.y].join(" ");
    return d;
  }
  function addStyle() {
    var svg = $(this);
    var circle = svg.find('[class="percent-circle"]');
    var semiCircle = svg.find('[class="percent-semicircle"]');
    var percentage = parseInt(svg.data('percentage'));
    var percentContainer = $('.c-number.-percent');
    if (percentage === 100) {
      // show full circle
      circle.removeClass('hidden');
      semiCircle.remove();
    } else {
      // draw semi circle
      semiCircle.removeClass('hidden');
      circle.remove();
      var pathRadius = 360 / 100 * percentage;
      semiCircle.attr('d', drawCircle(112, 112, 102, 0, pathRadius));
    }

    // bug in ie11 with path.getTotalLength()
    // https://stackoverflow.com/questions/43198953/does-path-gettotallength-no-longer-work-anymore-for-text-svg
    var isIE = document.body.style.msTouchAction !== undefined;
    if (!isIE) {
      vivusObjs.push(new Vivus(svg[0], {
        type: 'async',
        duration: 100,
        animTimingFunction: Vivus.EASE
      }));
    }
    function addSr() {
      if (!percentContainer.length) {
        return;
      }
      // debugger;
      sr.reveal(percentContainer[0], {
        beforeReveal: function beforeReveal() {
          for (var i in vivusObjs) {
            vivusObjs[i].play();
          }
        },
        afterReset: function afterReset() {
          for (var i in vivusObjs) {
            vivusObjs[i].reset();
          }
        }
      }, 100);
    }
    function bpCheck() {
      var smSliderParent = svg.parents('[data-slider-sm]');
      if (window.matchMedia(mq.sm).matches) {
        // addSr();
      } else {
        if (!smSliderParent.length) {
          // addSr();
        } else {
          for (var i in vivusObjs) {
            vivusObjs[i].play();
          }
        }
      }
    }
    bpCheck();

    // $(window).on('resize', debounce(function () {
    //  bpCheck();
    // }, 100));
  }

  svgEls.each(addStyle);
}
"use strict";

function countToAnimation() {
  // if (!window.requestAnimationFrame) {
  //  return;
  // }
  var countAttr = 'data-count-to';
  var options = {
    easingFn: function easingFn(t, b, c, d) {
      var ts = (t /= d) * t;
      var tc = ts * t;
      return b + c * (1.77635683940025e-15 * tc * ts + 0.999999999999998 * tc + -3 * ts + 3 * t);
    }
  };
  function addCount() {
    var self = $(this);
    var value = parseInt(self.data('count-to'));
    var countObj = new CountUp(self[0], 0, value, 0, 2, options);

    // var smSliderParent = self.parents('[data-slider-sm]');

    function addSr() {
      sr.reveal(self[0], {
        beforeReveal: function beforeReveal() {
          countObj.start();
        },
        afterReset: function afterReset() {
          countObj.reset();
        }
      }, 100);
    }
    function bpCheck() {
      // var smSliderParent = self.parents('[data-slider-sm]');
      if (window.matchMedia(mq.sm).matches) {
        // addSr();
      }
      countObj.start();
    }
    bpCheck();

    // $(window).on('resize', debounce(function () {
    //  bpCheck();
    // }, 100));
  }

  $('[' + countAttr + ']').each(addCount);
}
"use strict";

function customSelects() {
  var cDef = 'default-select';
  $('select').each(function () {
    $(this).customSelect({
      customClass: cDef
    });
  });
}
"use strict";

function panelBlurBg() {
  var cPanel = '.c-panel';
  var panelImg = $(cPanel + '_svg');
  function bpCheck(self, thisPanel) {
    if (window.matchMedia(mq.xs).matches) {
      self.removeAttr('style');
      var panelHeight = thisPanel.outerHeight();
      var panelWidth = thisPanel.outerWidth();
      var panelPos = thisPanel.offset();
      var imgPos = self.offset();
      self.css({
        'top': panelPos.top - imgPos.top + 'px',
        'left': panelPos.left - imgPos.left + 'px',
        'height': panelHeight + 'px',
        'width': panelWidth + 'px'
      });
    } else {
      self.removeAttr('style');
    }
  }
  function addWatch() {
    var self = $(this);
    var thisPanel = self.parents(cPanel);
    bpCheck(self, thisPanel);
    $(window).on('resize', throttle(function () {
      bpCheck(self, thisPanel);
    }, 100));
  }
  panelImg.each(addWatch);
}
"use strict";

(function ($) {
  var modalDimissKeyBase = 'popupAlertDismissed-';
  function popupAlertShow() {
    $(".popup-alert .info-modal").each(function () {
      var id = $(this).attr("id");
      if (!sessionStorage.getItem(modalDimissKeyBase + id)) {
        $(this).closest(".info-modal-container").css("display", "flex").hide().fadeIn(500);
      }
    });
  }
  function popupAlertDismiss(event) {
    var $this = $(event.target);
    var id = $this.closest(".info-modal").attr("id");
    sessionStorage.setItem(modalDimissKeyBase + id, true);
    $(this).closest(".info-modal-container").fadeOut(500);
  }
  if ($('.popup-alert').length) {
    $('.popup-alert .info-modal__dismiss').on('click', popupAlertDismiss);
    popupAlertShow();
  }
})(jQuery);
"use strict";

function inputClear() {
  var container = $('.has-input-clear');
  var cShowClear = 'show-clear';
  function bindFunctions(btn) {
    var input = btn.parent().find('input');
    var thisCont = btn.parent();
    input = thisCont.find('input'); // wth is going on here..

    var media = input[0].classList.contains('media');
    if (media === true) {
      btn.addClass('media');
    }
    var hiddenInput = thisCont.attr('data-hidden') || [];
    if (hiddenInput.length) {
      // if hidden attribute selector exists, select with jquery
      hiddenInput = $(hiddenInput);
    }
    function checkInput() {
      var val = input.val();
      if (val === '') {
        thisCont.removeClass(cShowClear);
      } else {
        thisCont.addClass(cShowClear);
      }
    }
    function clearClick(e) {
      e.preventDefault();
      input.val('');
      thisCont.removeClass(cShowClear);
      if (hiddenInput.length) {
        hiddenInput.val('');
      }
    }
    input.on('keyup', checkInput);
    btn.on('click', clearClick);
    checkInput();
  }
  function addBtn() {
    var newBtn = $('<button class="js-input-clear"><i class="fa fa-times" aria-hidden="true"></i><span class="visuallyhidden">Clear input</span></button>').appendTo(this);
    bindFunctions(newBtn);
  }
  container.each(addBtn);
}
"use strict";

function tooltips() {
  var ttItems = $('.js-tooltip-click');
  if (ttItems.length) {
    $('.js-tooltip-click').on('click', function (e) {
      e.preventDefault();
    }).tooltipster({
      trigger: 'click',
      theme: 'tooltipster-noir'
    });
  }
}
"use strict";

var panZoomMap;
function mapLists() {
  var lists = $('.c-map-list');
  var llAttr = 'data-latlng';
  var imgAttr = 'data-img';
  var cBtnActive = '-is-active';
  var showImage = '-show-img';
  var mapCallbacks = [];
  function sBtnHtml(bClass, text, fa) {
    return '<button type="button" class="' + bClass + '"><span class="visuallyhidden">' + text + '</span><i class="fa ' + fa + '" aria-hidden="true"></i></button>';
  }
  function eachList() {
    var container = $(this);
    var slider = $('.c-map-list_slider-wrap', container);
    var mapWrap = $('.c-map-list_map-wrap', container);
    var mapSel = $('.c-map-list_map-object', container);
    var mapImg = $('.c-map-list_map-img', container);
    var mapPanZoomContainer = $('.c-map-list_map-img', container);
    var mapObj;
    var marker;
    var mapStyles = {
      styles: [{
        "featureType": "landscape",
        "elementType": "geometry.fill",
        "stylers": [{
          "color": "#b5dbdb"
        }]
      }, {
        "featureType": "landscape.man_made",
        "elementType": "geometry.fill",
        "stylers": [{
          "color": "#fff5ea"
        }]
      }, {
        "featureType": "landscape.natural",
        "elementType": "geometry.fill",
        "stylers": [{
          "color": "#ffe2d5"
        }]
      }, {
        "featureType": "poi",
        "elementType": "geometry.fill",
        "stylers": [{
          "color": "#ffc9ae"
        }]
      }, {
        "featureType": "poi.park",
        "elementType": "geometry.fill",
        "stylers": [{
          "color": "#c8dfd9"
        }]
      }, {
        "featureType": "road",
        "elementType": "geometry.fill",
        "stylers": [{
          "color": "#ffc977"
        }]
      }, {
        "featureType": "road.local",
        "elementType": "geometry.fill",
        "stylers": [{
          "color": "#ffffff"
        }]
      }]
    };
    var mapOptions = {
      zoom: 13
    };
    var btns = $('[' + llAttr + '], [' + imgAttr + ']', slider);
    function mapUpdate(coords) {
      var newLatlng = new google.maps.LatLng(coords[0], coords[1]);
      mapObj.panTo(newLatlng);
      marker.setPosition(newLatlng);
    }
    function mapChangeClick(e) {
      var self = $(this);
      var latlng = self.attr(llAttr);
      var mapSrc = self.attr(imgAttr);
      btns.removeClass(cBtnActive);
      self.addClass(cBtnActive);
      if (panZoomMap != undefined) {
        panZoomMap.destroy();
        panZoomMap = undefined;
        $('#svgBuildingMap').remove();
        $('.printbtn-bldgmap').remove();
      }
      if (latlng) {
        mapWrap.removeClass(showImage);
        mapUpdate(latlng.split(',').map(Number));
        $('[' + llAttr + '].' + cBtnActive, slider).attr('data-latlng', latlng);
      } else if (mapSrc) {
        mapWrap.addClass(showImage);

        // Print button
        var printTrigger = document.createElement('div');
        printTrigger.setAttribute('class', 'printbtn-bldgmap hidden-sm-down');
        printTrigger.addEventListener("click", function () {
          printImage(mapSrc);
        });
        var printText = document.createTextNode("PRINT");
        printTrigger.appendChild(printText);
        mapPanZoomContainer.append(printTrigger);

        // Create svg element (id=svgBuildingMap)
        var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
        svg.setAttributeNS(null, "id", "svgBuildingMap");
        svg.setAttributeNS(null, 'class', 'c-map-list_map-svg-image');
        // Use svg's image (id=imageBuildingMap)
        var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
        img.setAttributeNS(null, 'height', '100%');
        img.setAttributeNS(null, 'width', '100%');
        img.setAttributeNS('http://www.w3.org/1999/xlink', 'href', mapSrc);
        img.setAttributeNS(null, 'x', '0');
        img.setAttributeNS(null, 'y', '0');
        img.setAttributeNS(null, 'visibility', 'visible');
        img.setAttributeNS(null, 'id', 'imageBuildingMap');
        svg.appendChild(img);
        // Put svg element into mapPanZoomContainer
        mapPanZoomContainer.append(svg);
        // Event handler to pan and zoom
        panZoomMap = svgPanZoom('#svgBuildingMap', {
          zoomEnabled: true,
          controlIconsEnabled: true
        });
      }
      e.preventDefault();
    }
    function printImage(imagePath) {
      var width = $(window).width() * 0.9;
      var height = $(window).height() * 0.9;
      var content = '<!DOCTYPE html>' + '<html>' + '<head><title></title></head>' + '<body onload="window.focus(); window.print(); window.close();">' + '<img src="' + imagePath + '" style="width: 100%;" />' + '</body>' + '</html>';
      var options = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=" + width + ",height=" + height;
      var printWindow = window.open('', 'print', options);
      printWindow.document.open();
      printWindow.document.write(content);
      printWindow.document.close();
      printWindow.focus();
    }
    function mapListInit() {
      var selMap = $('[' + llAttr + '].' + cBtnActive, slider);
      var selLatLng = selMap.attr(llAttr);
      if (selLatLng) {
        selLatLng = selLatLng.split(',').map(Number);
      } else {
        var mapLL = mapSel.attr(llAttr);
        if (mapLL) {
          selLatLng = mapLL.split(',').map(Number);
        }
      }
      mapOptions.center = new google.maps.LatLng(selLatLng[0], selLatLng[1]);
      mapOptions.styles = mapStyles.styles;
      mapObj = new google.maps.Map(mapSel[0], mapOptions);
      marker = new google.maps.Marker({
        position: mapOptions.center,
        map: mapObj
      });
    }
    function runMapCallbacks() {
      window.loadingGMaps = false;
      for (var i = 0; i < mapCallbacks.length; i++) {
        mapCallbacks[i]();
      }
    }
    window.mapListInit = mapListInit;
    if (slider.length) {
      var slideDefaults = {
        autoplay: false,
        arrows: true,
        dots: false,
        slidesToShow: 3,
        centerPadding: "100px",
        draggable: true,
        infinite: false,
        swipe: true,
        touchMove: true,
        speed: 400,
        useTransform: true,
        cssEase: 'cubic-bezier(.26,.85,.46,.99)'
      };
      if (slider.parents('.-has-slider').length) {
        slider.slick($.extend({}, slideDefaults, {
          vertical: true,
          verticalSwiping: true,
          prevArrow: sBtnHtml('slick-prev', 'Previous', 'fa-chevron-up'),
          nextArrow: sBtnHtml('slick-next', 'Next', 'fa-chevron-down')
        }));
      } else if (slider.parents('.-has-hor-slider').length) {
        slider.slick($.extend({}, slideDefaults, {
          prevArrow: sBtnHtml('slick-prev', 'Previous', 'fa-chevron-left'),
          nextArrow: sBtnHtml('slick-next', 'Next', 'fa-chevron-right')
        }));
      }
    }
    btns.on('click', mapChangeClick);
    if (typeof google === 'undefined') {
      if (typeof window.loadingGMaps === 'undefined') {
        window.loadingGMaps = true;
        $.ajax({
          url: 'https://maps.googleapis.com/maps/api/js?key=AIzaSyBtjXxY3lXFhqKDPABdqMHSHnaSyfAQPzU',
          dataType: "script",
          success: runMapCallbacks
        });
        mapCallbacks.push(mapListInit);
      } else if (window.loadingGMaps === true) {
        mapCallbacks.push(mapListInit);
      }
    } else {
      mapListInit();
    }
  }
  lists.each(eachList);
}
"use strict";

function dirBox() {
  var form = $('.c-dir-search');
  function urlBuilder(start, dest) {
    var url = 'https://maps.google.com?';
    if (start !== '') {
      url += 'saddr=' + start;
    } else {
      url += 'saddr=Current+Location';
    }
    url += '&daddr=' + dest;
    return url;
  }
  function formSubmit(e) {
    var dest = $(this).attr('data-latlng');
    var start = $(this).find('.c-dir-search_input').val();
    var url = urlBuilder(start, dest);
    var win = window.open(url, '_blank');
    if (win) {
      //Browser has allowed it to be opened
      win.focus();
    } else {
      //Browser has blocked it
      alert('Please allow popups for this website.');
    }
    e.preventDefault();
  }
  form.on('submit', formSubmit);
}
"use strict";

function masonryGrid() {
  var dataSel = 'data-masonry';
  var selector = '[' + dataSel + ']';
  window.gridInstances = [];
  function addMasonry() {
    var self = this;
    var grid = UIkit.grid(self, {
      gutter: 15
    });

    // enquire.register(mq.xs, {
    //  setup: function () {
    //      if (window.matchMedia(mq.xs).matches) {
    //          self.owlCarousel(sliderOpts);
    //          self.addClass('owl-carousel');
    //      }
    //  },
    //  match: function () {
    //      self.owlCarousel(sliderOpts);
    //      self.addClass('owl-carousel');
    //  },
    //  unmatch: function () {
    //      self.trigger('destroy.owl.carousel');
    //      self.removeClass('owl-carousel');
    //  }
    // });

    window.gridInstances.push(grid);
  }
  $(selector).each(addMasonry);
}
"use strict";

function checkToggleAll() {
  var sel = 'data-toggle-name';
  function addToggle() {
    var toggle = $(this);
    var name = toggle.attr(sel);
    var otherChecks = $('[type="checkbox"][name="' + name + '"]').not(toggle[0]);
    toggle.on('change', function () {
      if (this.checked) {
        otherChecks.prop('checked', false);
      }
    });
    otherChecks.on('change', function () {
      if (this.checked) {
        toggle.prop('checked', false);
      }
    });
    initCheck(toggle, otherChecks);
  }
  function initCheck(toggle, others) {
    var allShouldBeChecked = true;
    others.each(function () {
      if (this.checked) {
        allShouldBeChecked = false;
        toggle.prop('checked', allShouldBeChecked);
      }
    });
  }
  $('[' + sel + ']').each(addToggle);
}
"use strict";

function alerts() {
  function closeAlert(e) {
    e.preventDefault();
    $(this).closest('.alert').fadeOut();
  }
  $('.alert .close').on('click', closeAlert);
}
"use strict";

function checkHash() {
  var hash = window.location.hash;
  if (hash.indexOf('#tab') !== -1) {
    // if it's a tab, then select it
    $('a[href="' + hash + '"]').click();
  } else {
    var h = $(window.location.hash);
    if (h.length) {
      var top = Math.round(h.offset().top);
      $('html, body').animate({
        scrollTop: top
      }, 700, 'swing', function () {});
    }
  }
}
"use strict";

function serviceIndex() {
  var pathArray = window.location.pathname.split('/'),
    sl = window.location.search,
    hash = sl.substring(sl.lastIndexOf('Letter=') + 1),
    $azNavBar = $('nav.c-bar-az');
  if (hash.length && $azNavBar.length) {
    $('html, body').animate({
      scrollTop: $azNavBar.offset().top
    }, 700, 'swing', function () {});
  }
}
"use strict";

function setNavLabel() {
  var navItem = $('.primary-nav_top-item a');
  var tabNavItem = $('.sht-panel-1 .primary-nav_top-item');
  var lhn = $('.secondary-nav_list li a');
  var path = window.location.pathname;
  var parentItemPath = path.substr(0, path.lastIndexOf("/"));
  var currentItemPath = path;
  function navActiveState() {
    var $this = $(this);
    var navitemLink = $this.attr('href');
    var trimmedLink = navitemLink.replace('/', "");
    var isMicrositeHeader = $this.hasClass('microsite-home');
    if (currentItemPath === navitemLink) {
      $this.addClass('active-parent');
    } else if (parentItemPath === navitemLink && !isMicrositeHeader) {
      $this.addClass('active-parent');
    } else if (path.split('/')[1] === trimmedLink && !isMicrositeHeader) {
      $this.addClass('active-parent');
    }
  }
  navItem.each(navActiveState);
  tabNavItem.each(navActiveState);
  lhn.each(navActiveState);
}
"use strict";

// Uses in the campaign pages for anchor navigation (smooth scrolling)
function pageScroll() {
  // thanks - https://css-tricks.com/snippets/jquery/smooth-scrolling/
  // Select all links with hashes
  $('a[href*="#"]')
  // Remove links that don't actually link to anything
  .not('[href="#"]').not('[href="#0"]').click(function (event) {
    // On-page links
    if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
      // Figure out element to scroll to
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
      // Does a scroll target exist?
      if (target.length) {
        // Only prevent default if animation is actually gonna happen
        event.preventDefault();
        $('html, body').animate({
          scrollTop: target.offset().top
        }, 750, function () {
          // Callback after animation
          // Must change focus!
          var $target = $(target);
          $target.focus();
          if ($target.is(":focus")) {
            // Checking if the target was focused
            return false;
          } else {
            $target.attr('tabindex', '-1'); // Adding tabindex for elements not focusable
            $target.focus(); // Set focus again
          }
        });
      }
    }
  });
}
"use strict";

// back to top button
function backToTop() {
  var $el = $('#back-to-top');
  if ($el.length > 0) {
    var $window = $(window),
      $footer = $('.site-footer'),
      nY = 0;
    $window.on('scroll resize orientationchange', function () {
      var n = $window.scrollTop(),
        dH = $(document).height(),
        yOffset = 65,
        fH = $footer.outerHeight(),
        wH = $window.height(),
        wY = n + $window.innerHeight(),
        fY = $footer.offset().top;
      if (n > 100 && !$el.hasClass('is-active')) {
        $el.addClass('is-active');
      } else if (n <= 100 && $el.hasClass('is-active')) {
        $el.removeClass('is-active');
      }

      // make sticky to footer                            
      if (wY - fY > 0) {
        $el.css({
          'position': 'absolute',
          '-webkit-transform': 'translateY(' + nY + 'px)',
          'transform': 'translateY(' + (dH - wH - (fH + yOffset)) + 'px)'
        });
      } else {
        nY = n;
        $el.css({
          'position': 'fixed',
          '-webkit-transform': 'none',
          'transform': 'none'
        });
      }
    });
    // scroll back to top
    $el.on('click', function (e) {
      e.preventDefault();
      $('html, body').animate({
        scrollTop: 0
      }, 750, function () {
        // complete
      });
    });
  }
}
"use strict";

function stickyNavHeight() {
  function setLeftNavHeight() {
    var contentCont = $('.site-main_content').height();
    var lhnHeight = $('.site-main_secondary-nav').height();
    if ($('.secondary-nav_list li').hasClass('is-open') && lhnHeight > contentCont) {
      $('.site-main_content').height(lhnHeight);
    } else {}
  }
  $(document).ready(debounce(function () {
    setLeftNavHeight();
  }, 100));
}
"use strict";

// Search results accordion filter accordion
function searchFilter() {
  var $accToggle = $('.c-search-filters-accordion-toggle'),
    $searchToggle = $('.c-search-filters-toggle'),
    $applyFiltersBtn = $('#c-search-filter-button');
  $applyFiltersBtn.tooltipster({
    contentCloning: true
  });

  // hide/show + Aria controls for Search results filter
  $accToggle.on('click', function () {
    var $parent = $(this).parent().parent();
    if ($parent.hasClass('is-open')) {
      // If already active, the item will be given an inactive state. 
      $parent.removeClass('is-open');
      $accToggle.attr('aria-expanded', 'false');
      $parent.find('.c-search-filters-options').stop(true, true).slideUp();
    } else {
      // Remove all the active classes + aria expanded from the other items
      $('.c-search-filters-list-item').removeClass('is-open');
      $accToggle.attr('aria-expanded', 'false');
      $('.c-search-filters-options').stop(true, true).slideUp();
      // Add active state and aria expanded value to current item
      $parent.addClass('is-open');
      $accToggle.attr('aria-expanded', 'true');
      $parent.find('.c-search-filters-options').slideDown();
    }
  });

  // hide/show + Aria controls for Search results filter
  $searchToggle.on('click', function () {
    var $parent = $(this).parent();
    if ($parent.hasClass('filter-is-open')) {
      // If already active, the item will be given an inactive state. 
      $parent.removeClass('filter-is-open');
      $searchToggle.attr('aria-expanded', 'false');
      $parent.find('.c-search-filter-wrap').stop(true, true).slideUp();
    } else {
      // Add active state and aria expanded value to current item
      $parent.addClass('filter-is-open');
      $searchToggle.attr('aria-expanded', 'true');
      $parent.find('.c-search-filter-wrap').stop(true, true).slideDown();
    }
  });

  // Apply disabled attrute if nothing is selectd
  $('.c-search-filters input').on('change', function () {
    if (!$applyFiltersBtn.hasClass('is-active')) {
      $applyFiltersBtn.addClass('is-active');
      $applyFiltersBtn.attr('disabled', false);
    }
    $applyFiltersBtn.tooltipster('open');
  });
}
"use strict";

// SJOGSR-101 Image gallery
$(document).on('click', '[data-toggle="lightbox"]', function (event) {
  event.preventDefault();
  $(this).ekkoLightbox({
    onShown: function onShown() {
      // Bug in IE with flex (https://github.com/ashleydw/lightbox/issues/277)
      var isIE = document.body.style.msTouchAction !== undefined;
      if (isIE) {
        $('.ekko-lightbox').addClass('iefix');
      }
    },
    leftArrow: "<span><span class='fa-stack fa-xs previmg-btn'><i class='fa fa-circle fa-stack-2x stack-1'></i><i class='fa fa-circle-thin fa-stack-2x stack-2'></i><i class='fa fa-angle-left fa-stack-1x stack-3'></i></span></span>",
    rightArrow: "<span><span class='fa-stack fa-xs nextimg-btn'><i class='fa fa-circle fa-stack-2x stack-1'></i><i class='fa fa-circle-thin fa-stack-2x stack-2'></i><i class='fa fa-angle-right fa-stack-1x stack-3'></i></span></span>"
  });
});
"use strict";

function fixedBottomBanner() {
  $('.fixed-bottom-banner > .close-banner').on('click', function () {
    $('.fixed-bottom-banner').removeClass('scrolled').addClass('banner-gone');
  });
  // Scroll up after the page is loaded
  $('.fixed-bottom-banner').addClass('scrolled');
}
"use strict";

function comparisonTable() {
  var tableRows = [];
  var $table = $(".comparison-table");
  // Early exit if comparison table is not on this page to prevent errors in page initalisation
  if (typeof $table === 'undefined') {
    return;
  }
  $table.owlCarousel({
    margin: 20,
    nav: true,
    dots: false,
    mouseDrag: true,
    stagePadding: 10,
    navText: ["<i class='fa fa-chevron-left'></i>", "<i class='fa fa-chevron-right'></i>"],
    responsive: {
      0: {
        items: 1,
        dots: true,
        stagePadding: 35
      },
      768: {
        items: 2
      }
    }
  }).on('resized.owl.carousel', function (event) {
    equaliseRows(tableRows);
  });
  comparisonTable_getRows(tableRows);
}
function comparisonTable_getRows(tableRows) {
  var $columns = $(".comparison-table__column");
  $columns.each(function (i) {
    var $rows = $(this).find(".comparison-table__row");
    $rows.each(function (n) {
      if (tableRows[n] == null) tableRows[n] = [$rows[n]];else tableRows[n].push($rows[n]);
    });
  });
  setTimeout(equaliseRows(tableRows), 0);
}
function equaliseRows(tableRows) {
  $(".comparison-table__row").removeAttr("style");
  $.each(tableRows, function (n, item) {
    var maxHeight = 0;
    $(item).each(function () {
      if ($(this).height() > maxHeight) maxHeight = $(this).height();
    });
    $(item).height(maxHeight);
  });
}
"use strict";

function blogSlider() {
  var $blogSlider = $(".c-blog-slider_list");
  $blogSlider.owlCarousel({
    margin: 30,
    loop: false,
    nav: false,
    responsive: {
      0: {
        items: 1,
        dots: true,
        stagePadding: 70,
        center: true
      },
      768: {
        items: 3,
        dots: false,
        stagePadding: 0,
        center: false
      }
    }
  });
}
"use strict";

function blogListPage() {
  $("#TopicSearchFilter").change(function () {
    $("#searchForm").submit();
  });
  $("#AllRadio").change(function () {
    $("#searchForm").submit();
  });
  $("#BlogRadio").change(function () {
    $("#searchForm").submit();
  });
  $("#PodRadio").change(function () {
    $("#searchForm").submit();
  });
}
"use strict";

// FAD Search more/fewer options
(function ($) {
  var $expandButton = $(".c-vmo-search_expand"),
    $morePanel = $(".c-vmo-search_more"),
    expanded = false;
  $expandButton.click(function () {
    expanded = !expanded;
    $(this).attr("aria-expanded", expanded);
    $(this).children("i").attr("class", expanded ? "fa fa-chevron-up" : "fa fa-chevron-down");
    $(this).children("span").text(expanded ? "Fewer options" : "More options");
    $morePanel.stop().slideToggle(300);
  });

  // Remove focus style on click
  function handleTab(e) {
    if (e.keyCode === 9) {
      $expandButton.removeClass('no-outline');
      $(window).off('keydown', handleTab);
      $(window).on('mousedown', handleMouseDown);
    }
  }
  function handleMouseDown(e) {
    if (e.pageX !== 0 && e.pageY !== 0) {
      $expandButton.addClass('no-outline');
      $(window).off('mousedown', handleMouseDown);
      $(window).on('keydown', handleTab);
    }
  }
  $(window).on('mousedown', handleMouseDown);
})(jQuery);

// Filter expand/contract
(function ($) {
  var $header = $(".c-vmo-filter_header"),
    $body = $(".c-vmo-filter_body");
  $header.click(function () {
    $(this).toggleClass("expanded");
    $(this).attr("aria-expanded", $(this).hasClass("expanded") ? "true" : "false");
    $body.stop().slideToggle(300, function () {
      if ($(this).is(':visible')) $(this).css('display', 'flex');
    });
  });
})(jQuery);

// Empty results
(function ($) {
  var $suggested = $(".c-vmo-suggested"),
    $elToHide = $(".c-vmo-results_empty > .suggested-" + ($suggested.length ? "false" : "true"));
  $elToHide.hide();
})(jQuery);

// Specialist profile sidebar accordions
(function ($) {
  var $accordions = $(".c-vmo-accordion");
  $accordions.each(function () {
    var $acc = $(this),
      $header = $acc.find(".c-vmo-accordion_header"),
      $body = $acc.find(".c-vmo-accordion_body");
    $header.click(function () {
      $acc.toggleClass("expanded");
      if ($acc.hasClass("expanded")) $body.hide().stop().slideDown(300);else $body.show().stop().slideUp(300);
    });
  });
})(jQuery);
(function ($) {
  var $bio = $(".c-vmo-profile_content"),
    $toggle = $(".c-vmo-profile_read-more"),
    excerptHeight = 200,
    expanded = true;
  if ($bio.length && $bio.outerHeight() > $(window).innerHeight() / 2 && $bio.outerHeight() > excerptHeight) {
    expanded = false;
    $toggle.show();
    $bio.css({
      height: excerptHeight
    });
    $bio.children().each(toggleChildrenAriaHidden);
  }
  $toggle.click(function () {
    var targetHeight;
    expanded = !expanded;
    if (expanded) {
      // Briefly reset css to get natural height
      targetHeight = $bio.css("height", "auto").outerHeight();
      $bio.css("height", excerptHeight);
      $toggle.addClass("expanded");
    } else {
      targetHeight = excerptHeight;
      $toggle.removeClass("expanded");
    }
    $bio.animate({
      "height": targetHeight
    }, 300);
    $bio.children().each(toggleChildrenAriaHidden);
  });
  function toggleChildrenAriaHidden() {
    var offsetFromBio = $(this).offset().top - $bio.offset().top;
    if (!expanded && offsetFromBio >= excerptHeight) $(this).attr("aria-hidden", "true").find("a").each(function () {
      var anchorOffsetFromBio = $(this).offset().top - $bio.offset().top;
      $(this).attr("tabindex", anchorOffsetFromBio >= 200 ? -1 : 0);
    });else $(this).attr("aria-hidden", "false").find("a").attr("tabindex", 0);
  }
})(jQuery);
"use strict";

var sjog = sjog || {};
sjog.fad = {};
(function ($, d, w, fad) {
  // selectors
  var specialtyEleName = "#vmo-specialty";
  var languageEleName = "#vmo-language";
  var nameEleName = "#vmo-name";
  var hospitalEleName = "#vmo-hospital";
  var genderEleName = "#vmo-gender";
  var locationsEleName = "#vmo-locations";
  var childrenEleName = "#vmo-children";
  var selfFundEleName = "#vmo-selffund";
  var telehealthEleName = "#vmo-telehealth";

  // query params
  var specialistNameQp = "SpecialistName";
  var divisionQp = "Division";
  var specialtyQp = "Specialty";
  var genderQp = "Gender";
  var languageQp = "Language";
  var postcodeOrSuburbQp = "PostcodeOrSuburb";
  var doesTreatChildrenQp = "DoesTreatChildren";
  var doesTelehealthQp = "DoesTelehealth";
  var doesTreatSelfFundQp = "DoesTreatSelfFund";
  var pageQp = "Page";
  var perPageQp = "PerPage";

  // global data store
  var dataStore;
  var perPage;
  var lookupsInput;
  function searchLookups(inputText, endpoint, awesomplete) {
    if (inputText.length === 0 || inputText === lookupsInput) {
      return;
    }
    $.ajax({
      type: 'POST',
      url: '/api/v1/fad/' + endpoint,
      data: JSON.stringify({
        Term: inputText
      }),
      success: function success(data) {
        lookupsInput = inputText;
        awesomplete.list = data;
        awesomplete.evaluate();
      },
      contentType: "application/json",
      dataType: 'json'
    });
  }
  function search(willResetPaging) {
    var inputData = getInputData(willResetPaging);
    if (JSON.stringify(inputData) === JSON.stringify(dataStore)) {
      return; // don't search when the input value is the same as the previous input value
    }

    $.ajax({
      type: 'POST',
      url: '/api/v1/fad/search',
      data: JSON.stringify(inputData),
      success: function success(data) {
        perPage = data.Inputs.PerPage;
        view(data);
        dataStore = getInputData(willResetPaging);
      },
      contentType: "application/json",
      dataType: 'json'
    });
  }
  function tokeniseTpl(tplName) {
    return $('script[data-template="' + tplName + '"]').text().split(/\$\{(.+?)\}/g);
  }
  function mapAndRender(tpl, data, willDisplay) {
    return tpl.map(render(data, willDisplay || false)).join('');
  }
  function mapViewToData($elem, tpl, data, willDisplay) {
    return $elem.empty().append(mapAndRender(tpl, data, willDisplay || false));
  }

  // Render the view template with results data
  // es5 no dependency templating inspired by https://stackoverflow.com/a/39065147 
  function view(data) {
    var $resultsList = $('.c-vmo-results_list');
    var $resultsDescription = $('.c-vmo-results_description');
    var $pagingWrapper = $('.c-vmo-results_paging-js');
    var $pagingServerSide = $('.c-search-list_foot.text-right');
    var $paging = $pagingWrapper.find('.c-pagination');
    var classHide = 'hide';
    $pagingServerSide.addClass(classHide);
    $pagingWrapper.removeClass(classHide);
    var $resultsDescriptionTpl = tokeniseTpl("resultsDescription");
    mapViewToData($resultsDescription, $resultsDescriptionTpl, data);

    // no results
    if (data.SearchResults.TotalResults === 0) {
      $resultsList.empty();
      $resultsList.addClass(classHide);
      $paging.empty();
      $paging.addClass(classHide);
      $(".c-vmo-results_empty").addClass('visible');
      return;
    }
    $(".c-vmo-results_empty").removeClass('visible');

    // results
    $resultsList.removeClass(classHide);
    var $itemTpl = tokeniseTpl("resultItem");
    $resultsList.empty().append(data.SearchResults.Results.map(function (item) {
      if (item.OverrideSpecialistTitle1 && item.OverrideSpecialistTitle1 !== "" || item.OverrideSpecialistTitle2 && item.OverrideSpecialistTitle2 !== "" || item.OverrideSpecialistTitle3 && item.OverrideSpecialistTitle3 !== "") {
        item["Specialties"] = [];
        if (item.OverrideSpecialistTitle1 && item.OverrideSpecialistTitle1 !== "") {
          item["Specialties"].push(item.OverrideSpecialistTitle1);
        }
        if (item.OverrideSpecialistTitle2 && item.OverrideSpecialistTitle2 !== "") {
          item["Specialties"].push(item.OverrideSpecialistTitle2);
        }
        if (item.OverrideSpecialistTitle3 && item.OverrideSpecialistTitle3 !== "") {
          item["Specialties"].push(item.OverrideSpecialistTitle3);
        }
      }
      return mapAndRender($itemTpl, item);
    }));

    // paging
    $paging.empty();
    if (data.SearchResults.Pager.TotalPages === 1) {
      $paging.addClass(classHide);
      return;
    }
    $paging.removeClass(classHide);
    var $fadPagingPreviousTpl = tokeniseTpl("fadPagingPrev");
    $paging.append(mapAndRender($fadPagingPreviousTpl, data.SearchResults.Pager.PreviousPage, data.SearchResults.Pager.HasPrev));
    var $fadPagingTpl = tokeniseTpl("fadPaging");
    $paging.append(data.SearchResults.Pager.Pages.map(function (item) {
      return mapAndRender($fadPagingTpl, item);
    }));
    var $fadPagingNextTpl = tokeniseTpl("fadPagingNext");
    $paging.append(mapAndRender($fadPagingNextTpl, data.SearchResults.Pager.NextPage, data.SearchResults.Pager.HasNext));
  }

  // replace the tokenised placeholders (every 2nd token) with data
  function render(props, willDisplay) {
    return function (token, i) {
      if (i % 2) {
        // convert array props to strings
        if (token === "Specialties" && props[token]) {
          props[token] = props[token].reduce(function (accumulator, currentValue) {
            return accumulator + "<li>" + currentValue.trim() + "</li>";
          }, "");
        }
        if (token === "Divisions" && props[token]) {
          props[token] = props[token].reduce(function (accumulator, currentValue) {
            return accumulator + "<li>" + currentValue.Name.trim() + "</li>";
          }, "");
        }

        // paging
        if (token === "IsActive") {
          props["IsActiveClass"] = props[token] ? "is-active" : "";
          props["IsActiveVisuallyHidden"] = props[token] ? "Current page" : "Go to page";
        }
        if (token === "Page") {
          props["PageUrl"] = getDestUrl(w.location.pathname, props[token]);
          props["PrevDisplay"] = willDisplay ? "inline-block" : "none";
          props["NextDisplay"] = willDisplay ? "inline-block" : "none";
        }
      }
      return i % 2 ? props[token] : token;
    };
  }
  function getInputData(willResetPaging) {
    var division = $(hospitalEleName).val();
    var gender = $(genderEleName).val();
    var page = getParameterByName(pageQp);
    page = page && page !== "null" ? page : 1;
    var dataObj = {
      SpecialistName: $(nameEleName).val(),
      Division: division !== 'Select a St John of God hospital' ? division : '',
      Gender: gender !== 'Select a gender' ? gender : '',
      Language: $(languageEleName).val(),
      Specialty: $(specialtyEleName).val(),
      PostcodeOrSuburb: $(locationsEleName).val(),
      DoesTreatChildren: $(childrenEleName).is(':checked'),
      DoesTelehealth: $(telehealthEleName).is(':checked'),
      DoesTreatSelfFund: $(selfFundEleName).is(':checked'),
      Page: willResetPaging ? 1 : page,
      PerPage: perPage || 25
    };
    return dataObj;
  }
  function getDestUrl(pathName, page) {
    var i = getInputData();
    var destUrl = pathName + '?' + specialistNameQp + '=' + i.SpecialistName + '&' + divisionQp + '=' + i.Division + '&' + specialtyQp + '=' + i.Specialty + '&' + genderQp + '=' + i.Gender + '&' + languageQp + '=' + i.Language + '&' + postcodeOrSuburbQp + '=' + i.PostcodeOrSuburb + '&' + doesTreatChildrenQp + '=' + i.DoesTreatChildren + '&' + doesTelehealthQp + '=' + i.DoesTelehealth + '&' + doesTreatSelfFundQp + '=' + i.DoesTreatSelfFund + '&' + pageQp + '=' + (page || i.Page) + '&' + perPageQp + '=' + i.PerPage;
    return destUrl;
  }
  function updateUrl(url) {
    if (w.history.pushState) {
      var newurl = url || w.location.protocol + "//" + w.location.host + getDestUrl(w.location.pathname);
      w.history.pushState({
        newurl: newurl
      }, '', newurl);
    }
  }
  function getParameterByName(name) {
    var match = RegExp('[?&]' + name + '=([^&]*)').exec(w.location.search);
    return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
  }
  function scrollToTop() {
    $('html, body').animate({
      scrollTop: $(".site-header").offset().top
    }, 300);

    // implementation in vmoSearch.js
    var $filterHeader = $('.c-vmo-filter_header');
    if ($filterHeader.hasClass("expanded")) {
      $filterHeader.trigger("click");
    }
  }
  function initGlobalFadSearch() {
    var awesompleteSpecialties = new Awesomplete(d.querySelector(specialtyEleName), {
      list: []
    });
    var awesompleteLanguages = new Awesomplete(d.querySelector(languageEleName), {
      list: []
    });
    $(specialtyEleName).on("keyup", debounce(function () {
      searchLookups($(this).val(), "SearchSpecialties", awesompleteSpecialties);
    }, 300));
    $(languageEleName).on("keyup", debounce(function () {
      searchLookups($(this).val(), "SearchLanguages", awesompleteLanguages);
    }, 300));
  }
  function initSearchLanding() {
    $('.c-vmo-search_submit').on('click', function () {
      w.location.href = getDestUrl(w.location.pathname + '/search-results');
    });
    $('.c-vmo-form').keypress(function (e) {
      var key = e.which;
      if (key === 13)
        // enter key
        {
          w.location.href = getDestUrl(w.location.pathname + '/search-results');
          scrollToTop();
        }
    });
  }
  function initSearchResults() {
    $('.c-vmo-filter_submit').on('click', function () {
      updateUrl();
      search(true);
      scrollToTop();
    });
    $('.c-vmo-filter').on("keypress", function (e) {
      var key = e.which;
      if (key === 13)
        // enter key
        {
          updateUrl();
          search(true);
          scrollToTop();
        }
    });
    $('.c-vmo-filter input:checkbox, .c-vmo-filter select').on("change", function () {
      updateUrl();
      search(true);
    });
    $('.c-vmo-filter ' + nameEleName).on("keyup", debounce(function (e) {
      var key = e.which;
      if (key !== 9 && key !== 10) {
        // enter, tab key
        updateUrl();
        search(true);
      }
    }, 300));
    $('.c-vmo-filter ' + locationsEleName).on("keyup", debounce(function () {
      if ($(this).val().length >= 4) {
        updateUrl();
        search(true);
      }
    }, 300));
    $('.c-vmo-filter ' + specialtyEleName + ', .c-vmo-filter ' + languageEleName).on("blur", function () {
      updateUrl();
      search(true);
    });

    // trigger search on history where the history event was invoked from code (event.state is not null)
    w.onpopstate = function (event) {
      if (event && event.state) {
        w.location.reload();
      }
    };
    d.querySelector(specialtyEleName).addEventListener('awesomplete-select', function (e) {
      $(this).val(e.text.value);
      updateUrl();
      search(true);
    });
    d.querySelector(languageEleName).addEventListener('awesomplete-select', function (e) {
      $(this).val(e.text.value);
      updateUrl();
      search(true);
    });
    $('.c-search-list_foot').on('click', ".c-pagination_item, .c-pagination_prev, .c-pagination_next", function (e) {
      e.preventDefault(0);
      updateUrl($(this).attr('href'));
      search(false);
      scrollToTop();
    });
  }
  fad.initFadSearchLanding = function () {
    initGlobalFadSearch();
    initSearchLanding();
  };
  fad.initFadSearchResults = function () {
    initGlobalFadSearch();
    initSearchResults();
  };
})(jQuery, document, window, sjog.fad);
"use strict";

function wffmHiddenUrlField() {
  $("*[data-wffm-hidden-url='true']").val(window.location.href);
}
"use strict";

function wffmGtmRegisterSubmission() {
  window.dataLayer = window.dataLayer || [];
  function gtag() {
    dataLayer.push(arguments);
  }
  gtag('js', new Date());
  gtag('config', 'G-W4YDC7X0DJ');
  $(document).ready(function () {
    var wffmForms = $("form[data-wffm]");
    wffmForms.each(function (i) {
      var el = $(this);
      if (el.find("*[data-wffm-submittogtm-hidden='true']").length) {
        var dataLayerModel = {
          form_id: el.attr("id"),
          form_embed_url: window.location.pathname,
          event: "Form Submission"
        };
        el.submit(function (e) {
          window.dataLayer.push(JSON.stringify(dataLayerModel));
        });
      }
    });
  });
}
"use strict";

window.jsNzSearch = window.jsNzSearch || {};
window.jsUtilities = window.jsUtilities || {};
(function ($, jsUtilities, jsNzSearch) {
  jsNzSearch.init = function () {
    var nzMain = $(".site-header_nz").siblings("main");
    if (!nzMain || !nzMain.length) {
      return;
    }
    $(".c-search-capsule.category-clicker").removeClass("active");
    var urlParameters = jsUtilities.getUrlParameters();
    if (!urlParameters["SelectedContentTypes"]) {
      $("#value-all").addClass("active");
    } else {
      $("#value-" + urlParameters["SelectedContentTypes"]).addClass("active");
    }
  };
  jsNzSearch.setContentType = function (id) {
    var urlParameters = jsUtilities.getUrlParameters();
    urlParameters["SelectedContentTypes"] = id || "";
    delete urlParameters["Page"];
    var queryStringParameters = [];
    for (var key in urlParameters) {
      if (urlParameters.hasOwnProperty(key)) {
        queryStringParameters.push(key + "=" + urlParameters[key]);
      }
    }
    window.location.href = location.pathname + "?" + queryStringParameters.join("&");
  };
  jsNzSearch.init();
})(jQuery, window.jsUtilities, window.jsNzSearch);
"use strict";

function imageLibrary() {
  function youtubeIDToURL(id) {
    return "https://www.youtube.com/watch?v=" + id;
  }
  function youtubeIDToEmbed(id) {
    return "<iframe src=\"https://www.youtube.com/embed/" + id + "?showinfo=0\" frameborder=\"0\" allowfullscreen></iframe>";
  }
  function vimeoIDToURL(id) {
    return "https://vimeo.com/" + id;
  }
  function vimeoIDToEmbed(id) {
    return "<iframe src=\"https://player.vimeo.com/video/" + id + "\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";
  }
  function copyStringToClipboard(incString) {
    var textarea = document.createElement("textarea");
    textarea.id = "copyTarget";
    textarea.value = incString;
    textarea.style = "top: 0; left: 0; position: fixed;";
    document.body.appendChild(textarea);
    textarea.focus();
    textarea.select();
    document.execCommand("copy");
    textarea.remove();
  }
  function getImageLibraryItemLeft(currentUsableID) {
    var currentIndex = imageLibraryItems.indexOf(currentUsableID);
    var nextIndex = (currentIndex - 1) % imageLibraryItems.length;
    console.log(imageLibraryItems);
    console.log(nextIndex);
    console.log(imageLibraryItems[nextIndex]);
    return imageLibraryItems[nextIndex];
  }
  function getImageLibraryItemRight(currentUsableID) {
    var currentIndex = imageLibraryItems.indexOf(currentUsableID);
    var nextIndex = (currentIndex + 1) % imageLibraryItems.length;
    console.log(imageLibraryItems);
    console.log(nextIndex);
    console.log(imageLibraryItems[nextIndex]);
    return imageLibraryItems[nextIndex];
  }
}
"use strict";

/*
	Document ready - init functions
 */
$(document).ready(function () {
  if (!Modernizr.svgfilters) {
    $('html').addClass('no-svgfilters');
  }
  // Fixes browserSync live proxy
  if ($ == undefined) $ = jQuery;
  skipLinks();
  menuMobile();
  primaryMega();
  // primaryNavMore();
  primaryNavMobile();
  locationMega();
  // modals();
  carousels();
  readMore();
  readMorePlus();
  secondaryNav();
  searchFilter();
  // secondaryNavMobile();
  heroHeaderBlurBg();
  numberLineAnimation(); // problem with this function in ie11 and edge (jquery sizzle) ?
  countToAnimation();
  tabs();
  customSelects();
  panelBlurBg();
  inputClear();
  tooltips();
  mapLists();
  dirBox();
  masonryGrid();
  checkToggleAll();
  accordions();
  alerts();
  //checkHash();
  setNavLabel();
  serviceIndex();
  stickyNavHeight();
  owlCarouselHero();
  owlCarouselMulti();
  pageScroll();
  backToTop();
  fixedBottomBanner();
  comparisonTable();
  blogSlider();
  blogListPage();
  imageLibrary();

  // WFFM
  wffmHiddenUrlField();
  wffmGtmRegisterSubmission();
  $('.c-video-container').fitVids();
  // Used on blog and carousel
  var multiSelectFilter = new MultiSelectFilter();

  // multiSelectFilter for the Blog filter
  if ($('.c-blog-filter').length) {
    var blogFeatured = new BlogFeatured(),
      blogData = new BlogData();
    blogData.update(multiSelectFilter.items());
    multiSelectFilter.el().on('change', function () {
      blogFeatured.update();
      blogData.update(multiSelectFilter.items());
    });
  }

  // multiSelectFilter for the Event filter
  if ($('.c-event-filter').length) {
    var mediaEventData = new MediaEventData();
    mediaEventData.update(multiSelectFilter.items());
    multiSelectFilter.el().on('change', function () {
      mediaEventData.update(multiSelectFilter.items());
    });
  }

  // populate blogs/podcasts by author
  if ($('.c-blog-author').length) {
    var blogData = new BlogData();
  }
});;
