/* Minification failed. Returning unminified contents.
(3684,45-46): run-time error JS1195: Expected expression: >
(3684,83-84): run-time error JS1004: Expected ';': )
(3689,4-5): run-time error JS1002: Syntax error: }
(3692,33-34): run-time error JS1195: Expected expression: )
(3692,35-36): run-time error JS1004: Expected ';': {
(3802,6-7): run-time error JS1195: Expected expression: )
(3806,42-43): run-time error JS1004: Expected ';': {
(3819,98-99): run-time error JS1195: Expected expression: .
 */
;(function () {
	'use strict';

	/**
	 * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
	 *
	 * @codingstandard ftlabs-jsv2
	 * @copyright The Financial Times Limited [All Rights Reserved]
	 * @license MIT License (see LICENSE.txt)
	 */

	/*jslint browser:true, node:true*/
	/*global define, Event, Node*/


	/**
	 * Instantiate fast-clicking listeners on the specified layer.
	 *
	 * @constructor
	 * @param {Element} layer The layer to listen on
	 * @param {Object} [options={}] The options to override the defaults
	 */
	function FastClick(layer, options) {
		var oldOnClick;

		options = options || {};

		/**
		 * Whether a click is currently being tracked.
		 *
		 * @type boolean
		 */
		this.trackingClick = false;


		/**
		 * Timestamp for when click tracking started.
		 *
		 * @type number
		 */
		this.trackingClickStart = 0;


		/**
		 * The element being tracked for a click.
		 *
		 * @type EventTarget
		 */
		this.targetElement = null;


		/**
		 * X-coordinate of touch start event.
		 *
		 * @type number
		 */
		this.touchStartX = 0;


		/**
		 * Y-coordinate of touch start event.
		 *
		 * @type number
		 */
		this.touchStartY = 0;


		/**
		 * ID of the last touch, retrieved from Touch.identifier.
		 *
		 * @type number
		 */
		this.lastTouchIdentifier = 0;


		/**
		 * Touchmove boundary, beyond which a click will be cancelled.
		 *
		 * @type number
		 */
		this.touchBoundary = options.touchBoundary || 10;


		/**
		 * The FastClick layer.
		 *
		 * @type Element
		 */
		this.layer = layer;

		/**
		 * The minimum time between tap(touchstart and touchend) events
		 *
		 * @type number
		 */
		this.tapDelay = options.tapDelay || 200;

		/**
		 * The maximum time for a tap
		 *
		 * @type number
		 */
		this.tapTimeout = options.tapTimeout || 700;

		if (FastClick.notNeeded(layer)) {
			return;
		}

		// Some old versions of Android don't have Function.prototype.bind
		function bind(method, context) {
			return function() { return method.apply(context, arguments); };
		}


		var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'];
		var context = this;
		for (var i = 0, l = methods.length; i < l; i++) {
			context[methods[i]] = bind(context[methods[i]], context);
		}

		// Set up event handlers as required
		if (deviceIsAndroid) {
			layer.addEventListener('mouseover', this.onMouse, true);
			layer.addEventListener('mousedown', this.onMouse, true);
			layer.addEventListener('mouseup', this.onMouse, true);
		}

		layer.addEventListener('click', this.onClick, true);
		layer.addEventListener('touchstart', this.onTouchStart, false);
		layer.addEventListener('touchmove', this.onTouchMove, false);
		layer.addEventListener('touchend', this.onTouchEnd, false);
		layer.addEventListener('touchcancel', this.onTouchCancel, false);

		// Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
		// which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick
		// layer when they are cancelled.
		if (!Event.prototype.stopImmediatePropagation) {
			layer.removeEventListener = function(type, callback, capture) {
				var rmv = Node.prototype.removeEventListener;
				if (type === 'click') {
					rmv.call(layer, type, callback.hijacked || callback, capture);
				} else {
					rmv.call(layer, type, callback, capture);
				}
			};

			layer.addEventListener = function(type, callback, capture) {
				var adv = Node.prototype.addEventListener;
				if (type === 'click') {
					adv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) {
						if (!event.propagationStopped) {
							callback(event);
						}
					}), capture);
				} else {
					adv.call(layer, type, callback, capture);
				}
			};
		}

		// If a handler is already declared in the element's onclick attribute, it will be fired before
		// FastClick's onClick handler. Fix this by pulling out the user-defined handler function and
		// adding it as listener.
		if (typeof layer.onclick === 'function') {

			// Android browser on at least 3.2 requires a new reference to the function in layer.onclick
			// - the old one won't work if passed to addEventListener directly.
			oldOnClick = layer.onclick;
			layer.addEventListener('click', function(event) {
				oldOnClick(event);
			}, false);
			layer.onclick = null;
		}
	}

	/**
	* Windows Phone 8.1 fakes user agent string to look like Android and iPhone.
	*
	* @type boolean
	*/
	var deviceIsWindowsPhone = navigator.userAgent.indexOf("Windows Phone") >= 0;

	/**
	 * Android requires exceptions.
	 *
	 * @type boolean
	 */
	var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0 && !deviceIsWindowsPhone;


	/**
	 * iOS requires exceptions.
	 *
	 * @type boolean
	 */
	var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent) && !deviceIsWindowsPhone;


	/**
	 * iOS 4 requires an exception for select elements.
	 *
	 * @type boolean
	 */
	var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent);


	/**
	 * iOS 6.0-7.* requires the target element to be manually derived
	 *
	 * @type boolean
	 */
	var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS [6-7]_\d/).test(navigator.userAgent);

	/**
	 * BlackBerry requires exceptions.
	 *
	 * @type boolean
	 */
	var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0;

	/**
	 * Determine whether a given element requires a native click.
	 *
	 * @param {EventTarget|Element} target Target DOM element
	 * @returns {boolean} Returns true if the element needs a native click
	 */
	FastClick.prototype.needsClick = function(target) {
		switch (target.nodeName.toLowerCase()) {

		// Don't send a synthetic click to disabled inputs (issue #62)
		case 'button':
		case 'select':
		case 'textarea':
			if (target.disabled) {
				return true;
			}

			break;
		case 'input':

			// File inputs need real clicks on iOS 6 due to a browser bug (issue #68)
			if ((deviceIsIOS && target.type === 'file') || target.disabled) {
				return true;
			}

			break;
		case 'label':
		case 'iframe': // iOS8 homescreen apps can prevent events bubbling into frames
		case 'video':
			return true;
		}

		return (/\bneedsclick\b/).test(target.className);
	};


	/**
	 * Determine whether a given element requires a call to focus to simulate click into element.
	 *
	 * @param {EventTarget|Element} target Target DOM element
	 * @returns {boolean} Returns true if the element requires a call to focus to simulate native click.
	 */
	FastClick.prototype.needsFocus = function(target) {
		switch (target.nodeName.toLowerCase()) {
		case 'textarea':
			return true;
		case 'select':
			return !deviceIsAndroid;
		case 'input':
			switch (target.type) {
			case 'button':
			case 'checkbox':
			case 'file':
			case 'image':
			case 'radio':
			case 'submit':
				return false;
			}

			// No point in attempting to focus disabled inputs
			return !target.disabled && !target.readOnly;
		default:
			return (/\bneedsfocus\b/).test(target.className);
		}
	};


	/**
	 * Send a click event to the specified element.
	 *
	 * @param {EventTarget|Element} targetElement
	 * @param {Event} event
	 */
	FastClick.prototype.sendClick = function(targetElement, event) {
		var clickEvent, touch;

		// On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24)
		if (document.activeElement && document.activeElement !== targetElement) {
			document.activeElement.blur();
		}

		touch = event.changedTouches[0];

		// Synthesise a click event, with an extra attribute so it can be tracked
		clickEvent = document.createEvent('MouseEvents');
		clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
		clickEvent.forwardedTouchEvent = true;
		targetElement.dispatchEvent(clickEvent);
	};

	FastClick.prototype.determineEventType = function(targetElement) {

		//Issue #159: Android Chrome Select Box does not open with a synthetic click event
		if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {
			return 'mousedown';
		}

		return 'click';
	};


	/**
	 * @param {EventTarget|Element} targetElement
	 */
	FastClick.prototype.focus = function(targetElement) {
		var length;

		// Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
		if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') {
			length = targetElement.value.length;
			targetElement.setSelectionRange(length, length);
		} else {
			targetElement.focus();
		}
	};


	/**
	 * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it.
	 *
	 * @param {EventTarget|Element} targetElement
	 */
	FastClick.prototype.updateScrollParent = function(targetElement) {
		var scrollParent, parentElement;

		scrollParent = targetElement.fastClickScrollParent;

		// Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the
		// target element was moved to another parent.
		if (!scrollParent || !scrollParent.contains(targetElement)) {
			parentElement = targetElement;
			do {
				if (parentElement.scrollHeight > parentElement.offsetHeight) {
					scrollParent = parentElement;
					targetElement.fastClickScrollParent = parentElement;
					break;
				}

				parentElement = parentElement.parentElement;
			} while (parentElement);
		}

		// Always update the scroll top tracker if possible.
		if (scrollParent) {
			scrollParent.fastClickLastScrollTop = scrollParent.scrollTop;
		}
	};


	/**
	 * @param {EventTarget} targetElement
	 * @returns {Element|EventTarget}
	 */
	FastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) {

		// On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node.
		if (eventTarget.nodeType === Node.TEXT_NODE) {
			return eventTarget.parentNode;
		}

		return eventTarget;
	};


	/**
	 * On touch start, record the position and scroll offset.
	 *
	 * @param {Event} event
	 * @returns {boolean}
	 */
	FastClick.prototype.onTouchStart = function(event) {
		var targetElement, touch, selection;

		// Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111).
		if (event.targetTouches.length > 1) {
			return true;
		}

		targetElement = this.getTargetElementFromEventTarget(event.target);
		touch = event.targetTouches[0];

		if (deviceIsIOS) {

			// Only trusted events will deselect text on iOS (issue #49)
			selection = window.getSelection();
			if (selection.rangeCount && !selection.isCollapsed) {
				return true;
			}

			if (!deviceIsIOS4) {

				// Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):
				// when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched
				// with the same identifier as the touch event that previously triggered the click that triggered the alert.
				// Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
				// immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
				// Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,
				// which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,
				// random integers, it's safe to to continue if the identifier is 0 here.
				if (touch.identifier && touch.identifier === this.lastTouchIdentifier) {
					event.preventDefault();
					return false;
				}

				this.lastTouchIdentifier = touch.identifier;

				// If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and:
				// 1) the user does a fling scroll on the scrollable layer
				// 2) the user stops the fling scroll with another tap
				// then the event.target of the last 'touchend' event will be the element that was under the user's finger
				// when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check
				// is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42).
				this.updateScrollParent(targetElement);
			}
		}

		this.trackingClick = true;
		this.trackingClickStart = event.timeStamp;
		this.targetElement = targetElement;

		this.touchStartX = touch.pageX;
		this.touchStartY = touch.pageY;

		// Prevent phantom clicks on fast double-tap (issue #36)
		if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
			event.preventDefault();
		}

		return true;
	};


	/**
	 * Based on a touchmove event object, check whether the touch has moved past a boundary since it started.
	 *
	 * @param {Event} event
	 * @returns {boolean}
	 */
	FastClick.prototype.touchHasMoved = function(event) {
		var touch = event.changedTouches[0], boundary = this.touchBoundary;

		if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {
			return true;
		}

		return false;
	};


	/**
	 * Update the last position.
	 *
	 * @param {Event} event
	 * @returns {boolean}
	 */
	FastClick.prototype.onTouchMove = function(event) {
		if (!this.trackingClick) {
			return true;
		}

		// If the touch has moved, cancel the click tracking
		if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {
			this.trackingClick = false;
			this.targetElement = null;
		}

		return true;
	};


	/**
	 * Attempt to find the labelled control for the given label element.
	 *
	 * @param {EventTarget|HTMLLabelElement} labelElement
	 * @returns {Element|null}
	 */
	FastClick.prototype.findControl = function(labelElement) {

		// Fast path for newer browsers supporting the HTML5 control attribute
		if (labelElement.control !== undefined) {
			return labelElement.control;
		}

		// All browsers under test that support touch events also support the HTML5 htmlFor attribute
		if (labelElement.htmlFor) {
			return document.getElementById(labelElement.htmlFor);
		}

		// If no for attribute exists, attempt to retrieve the first labellable descendant element
		// the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label
		return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');
	};


	/**
	 * On touch end, determine whether to send a click event at once.
	 *
	 * @param {Event} event
	 * @returns {boolean}
	 */
	FastClick.prototype.onTouchEnd = function(event) {
		var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement;

		if (!this.trackingClick) {
			return true;
		}

		// Prevent phantom clicks on fast double-tap (issue #36)
		if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
			this.cancelNextClick = true;
			return true;
		}

		if ((event.timeStamp - this.trackingClickStart) > this.tapTimeout) {
			return true;
		}

		// Reset to prevent wrong click cancel on input (issue #156).
		this.cancelNextClick = false;

		this.lastClickTime = event.timeStamp;

		trackingClickStart = this.trackingClickStart;
		this.trackingClick = false;
		this.trackingClickStart = 0;

		// On some iOS devices, the targetElement supplied with the event is invalid if the layer
		// is performing a transition or scroll, and has to be re-detected manually. Note that
		// for this to function correctly, it must be called *after* the event target is checked!
		// See issue #57; also filed as rdar://13048589 .
		if (deviceIsIOSWithBadTarget) {
			touch = event.changedTouches[0];

			// In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null
			targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;
			targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent;
		}

		targetTagName = targetElement.tagName.toLowerCase();
		if (targetTagName === 'label') {
			forElement = this.findControl(targetElement);
			if (forElement) {
				this.focus(targetElement);
				if (deviceIsAndroid) {
					return false;
				}

				targetElement = forElement;
			}
		} else if (this.needsFocus(targetElement)) {

			// Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
			// Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
			if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) {
				this.targetElement = null;
				return false;
			}

			this.focus(targetElement);
			this.sendClick(targetElement, event);

			// Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.
			// Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others)
			if (!deviceIsIOS || targetTagName !== 'select') {
				this.targetElement = null;
				event.preventDefault();
			}

			return false;
		}

		if (deviceIsIOS && !deviceIsIOS4) {

			// Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled
			// and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42).
			scrollParent = targetElement.fastClickScrollParent;
			if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) {
				return true;
			}
		}

		// Prevent the actual click from going though - unless the target node is marked as requiring
		// real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted.
		if (!this.needsClick(targetElement)) {
			event.preventDefault();
			this.sendClick(targetElement, event);
		}

		return false;
	};


	/**
	 * On touch cancel, stop tracking the click.
	 *
	 * @returns {void}
	 */
	FastClick.prototype.onTouchCancel = function() {
		this.trackingClick = false;
		this.targetElement = null;
	};


	/**
	 * Determine mouse events which should be permitted.
	 *
	 * @param {Event} event
	 * @returns {boolean}
	 */
	FastClick.prototype.onMouse = function(event) {

		// If a target element was never set (because a touch event was never fired) allow the event
		if (!this.targetElement) {
			return true;
		}

		if (event.forwardedTouchEvent) {
			return true;
		}

		// Programmatically generated events targeting a specific element should be permitted
		if (!event.cancelable) {
			return true;
		}

		// Derive and check the target element to see whether the mouse event needs to be permitted;
		// unless explicitly enabled, prevent non-touch click events from triggering actions,
		// to prevent ghost/doubleclicks.
		if (!this.needsClick(this.targetElement) || this.cancelNextClick) {

			// Prevent any user-added listeners declared on FastClick element from being fired.
			if (event.stopImmediatePropagation) {
				event.stopImmediatePropagation();
			} else {

				// Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
				event.propagationStopped = true;
			}

			// Cancel the event
			event.stopPropagation();
			event.preventDefault();

			return false;
		}

		// If the mouse event is permitted, return true for the action to go through.
		return true;
	};


	/**
	 * On actual clicks, determine whether this is a touch-generated click, a click action occurring
	 * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or
	 * an actual click which should be permitted.
	 *
	 * @param {Event} event
	 * @returns {boolean}
	 */
	FastClick.prototype.onClick = function(event) {
		var permitted;

		// It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.
		if (this.trackingClick) {
			this.targetElement = null;
			this.trackingClick = false;
			return true;
		}

		// Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.
		if (event.target.type === 'submit' && event.detail === 0) {
			return true;
		}

		permitted = this.onMouse(event);

		// Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.
		if (!permitted) {
			this.targetElement = null;
		}

		// If clicks are permitted, return true for the action to go through.
		return permitted;
	};


	/**
	 * Remove all FastClick's event listeners.
	 *
	 * @returns {void}
	 */
	FastClick.prototype.destroy = function() {
		var layer = this.layer;

		if (deviceIsAndroid) {
			layer.removeEventListener('mouseover', this.onMouse, true);
			layer.removeEventListener('mousedown', this.onMouse, true);
			layer.removeEventListener('mouseup', this.onMouse, true);
		}

		layer.removeEventListener('click', this.onClick, true);
		layer.removeEventListener('touchstart', this.onTouchStart, false);
		layer.removeEventListener('touchmove', this.onTouchMove, false);
		layer.removeEventListener('touchend', this.onTouchEnd, false);
		layer.removeEventListener('touchcancel', this.onTouchCancel, false);
	};


	/**
	 * Check whether FastClick is needed.
	 *
	 * @param {Element} layer The layer to listen on
	 */
	FastClick.notNeeded = function(layer) {
		var metaViewport;
		var chromeVersion;
		var blackberryVersion;
		var firefoxVersion;

		// Devices that don't support touch don't need FastClick
		if (typeof window.ontouchstart === 'undefined') {
			return true;
		}

		// Chrome version - zero for other browsers
		chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];

		if (chromeVersion) {

			if (deviceIsAndroid) {
				metaViewport = document.querySelector('meta[name=viewport]');

				if (metaViewport) {
					// Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)
					if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
						return true;
					}
					// Chrome 32 and above with width=device-width or less don't need FastClick
					if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) {
						return true;
					}
				}

			// Chrome desktop doesn't need FastClick (issue #15)
			} else {
				return true;
			}
		}

		if (deviceIsBlackBerry10) {
			blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/);

			// BlackBerry 10.3+ does not require Fastclick library.
			// https://github.com/ftlabs/fastclick/issues/251
			if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) {
				metaViewport = document.querySelector('meta[name=viewport]');

				if (metaViewport) {
					// user-scalable=no eliminates click delay.
					if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
						return true;
					}
					// width=device-width (or less than device-width) eliminates click delay.
					if (document.documentElement.scrollWidth <= window.outerWidth) {
						return true;
					}
				}
			}
		}

		// IE10 with -ms-touch-action: none or manipulation, which disables double-tap-to-zoom (issue #97)
		if (layer.style.msTouchAction === 'none' || layer.style.touchAction === 'manipulation') {
			return true;
		}

		// Firefox version - zero for other browsers
		firefoxVersion = +(/Firefox\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];

		if (firefoxVersion >= 27) {
			// Firefox 27+ does not have tap delay if the content is not zoomable - https://bugzilla.mozilla.org/show_bug.cgi?id=922896

			metaViewport = document.querySelector('meta[name=viewport]');
			if (metaViewport && (metaViewport.content.indexOf('user-scalable=no') !== -1 || document.documentElement.scrollWidth <= window.outerWidth)) {
				return true;
			}
		}

		// IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version
		// http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx
		if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') {
			return true;
		}

		return false;
	};


	/**
	 * Factory method for creating a FastClick object
	 *
	 * @param {Element} layer The layer to listen on
	 * @param {Object} [options={}] The options to override the defaults
	 */
	FastClick.attach = function(layer, options) {
		return new FastClick(layer, options);
	};


	if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {

		// AMD. Register as an anonymous module.
		define(function() {
			return FastClick;
		});
	} else if (typeof module !== 'undefined' && module.exports) {
		module.exports = FastClick.attach;
		module.exports.FastClick = FastClick;
	} else {
		window.FastClick = FastClick;
	}
}());
;
/* Modernizr 2.8.3 (Custom Build) | MIT & BSD
 * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-printshiv-mq-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load
 */
;



window.Modernizr = (function( window, document, undefined ) {

    var version = '2.8.3',

    Modernizr = {},

    enableClasses = true,

    docElement = document.documentElement,

    mod = 'modernizr',
    modElem = document.createElement(mod),
    mStyle = modElem.style,

    inputElem  = document.createElement('input')  ,

    smile = ':)',

    toString = {}.toString,

    prefixes = ' -webkit- -moz- -o- -ms- '.split(' '),



    omPrefixes = 'Webkit Moz O ms',

    cssomPrefixes = omPrefixes.split(' '),

    domPrefixes = omPrefixes.toLowerCase().split(' '),

    ns = {'svg': 'http://www.w3.org/2000/svg'},

    tests = {},
    inputs = {},
    attrs = {},

    classes = [],

    slice = classes.slice,

    featureName, 


    injectElementWithStyles = function( rule, callback, nodes, testnames ) {

      var style, ret, node, docOverflow,
          div = document.createElement('div'),
                body = document.body,
                fakeBody = body || document.createElement('body');

      if ( parseInt(nodes, 10) ) {
                      while ( nodes-- ) {
              node = document.createElement('div');
              node.id = testnames ? testnames[nodes] : mod + (nodes + 1);
              div.appendChild(node);
          }
      }

                style = ['&#173;','<style id="s', mod, '">', rule, '</style>'].join('');
      div.id = mod;
          (body ? div : fakeBody).innerHTML += style;
      fakeBody.appendChild(div);
      if ( !body ) {
                fakeBody.style.background = '';
                fakeBody.style.overflow = 'hidden';
          docOverflow = docElement.style.overflow;
          docElement.style.overflow = 'hidden';
          docElement.appendChild(fakeBody);
      }

      ret = callback(div, rule);
        if ( !body ) {
          fakeBody.parentNode.removeChild(fakeBody);
          docElement.style.overflow = docOverflow;
      } else {
          div.parentNode.removeChild(div);
      }

      return !!ret;

    },

    testMediaQuery = function( mq ) {

      var matchMedia = window.matchMedia || window.msMatchMedia;
      if ( matchMedia ) {
        return matchMedia(mq) && matchMedia(mq).matches || false;
      }

      var bool;

      injectElementWithStyles('@media ' + mq + ' { #' + mod + ' { position: absolute; } }', function( node ) {
        bool = (window.getComputedStyle ?
                  getComputedStyle(node, null) :
                  node.currentStyle)['position'] == 'absolute';
      });

      return bool;

     },
 

    isEventSupported = (function() {

      var TAGNAMES = {
        'select': 'input', 'change': 'input',
        'submit': 'form', 'reset': 'form',
        'error': 'img', 'load': 'img', 'abort': 'img'
      };

      function isEventSupported( eventName, element ) {

        element = element || document.createElement(TAGNAMES[eventName] || 'div');
        eventName = 'on' + eventName;

            var isSupported = eventName in element;

        if ( !isSupported ) {
                if ( !element.setAttribute ) {
            element = document.createElement('div');
          }
          if ( element.setAttribute && element.removeAttribute ) {
            element.setAttribute(eventName, '');
            isSupported = is(element[eventName], 'function');

                    if ( !is(element[eventName], 'undefined') ) {
              element[eventName] = undefined;
            }
            element.removeAttribute(eventName);
          }
        }

        element = null;
        return isSupported;
      }
      return isEventSupported;
    })(),


    _hasOwnProperty = ({}).hasOwnProperty, hasOwnProp;

    if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {
      hasOwnProp = function (object, property) {
        return _hasOwnProperty.call(object, property);
      };
    }
    else {
      hasOwnProp = function (object, property) { 
        return ((property in object) && is(object.constructor.prototype[property], 'undefined'));
      };
    }


    if (!Function.prototype.bind) {
      Function.prototype.bind = function bind(that) {

        var target = this;

        if (typeof target != "function") {
            throw new TypeError();
        }

        var args = slice.call(arguments, 1),
            bound = function () {

            if (this instanceof bound) {

              var F = function(){};
              F.prototype = target.prototype;
              var self = new F();

              var result = target.apply(
                  self,
                  args.concat(slice.call(arguments))
              );
              if (Object(result) === result) {
                  return result;
              }
              return self;

            } else {

              return target.apply(
                  that,
                  args.concat(slice.call(arguments))
              );

            }

        };

        return bound;
      };
    }

    function setCss( str ) {
        mStyle.cssText = str;
    }

    function setCssAll( str1, str2 ) {
        return setCss(prefixes.join(str1 + ';') + ( str2 || '' ));
    }

    function is( obj, type ) {
        return typeof obj === type;
    }

    function contains( str, substr ) {
        return !!~('' + str).indexOf(substr);
    }

    function testProps( props, prefixed ) {
        for ( var i in props ) {
            var prop = props[i];
            if ( !contains(prop, "-") && mStyle[prop] !== undefined ) {
                return prefixed == 'pfx' ? prop : true;
            }
        }
        return false;
    }

    function testDOMProps( props, obj, elem ) {
        for ( var i in props ) {
            var item = obj[props[i]];
            if ( item !== undefined) {

                            if (elem === false) return props[i];

                            if (is(item, 'function')){
                                return item.bind(elem || obj);
                }

                            return item;
            }
        }
        return false;
    }

    function testPropsAll( prop, prefixed, elem ) {

        var ucProp  = prop.charAt(0).toUpperCase() + prop.slice(1),
            props   = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' ');

            if(is(prefixed, "string") || is(prefixed, "undefined")) {
          return testProps(props, prefixed);

            } else {
          props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' ');
          return testDOMProps(props, prefixed, elem);
        }
    }    tests['flexbox'] = function() {
      return testPropsAll('flexWrap');
    };    tests['canvas'] = function() {
        var elem = document.createElement('canvas');
        return !!(elem.getContext && elem.getContext('2d'));
    };

    tests['canvastext'] = function() {
        return !!(Modernizr['canvas'] && is(document.createElement('canvas').getContext('2d').fillText, 'function'));
    };



    tests['webgl'] = function() {
        return !!window.WebGLRenderingContext;
    };


    tests['touch'] = function() {
        var bool;

        if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
          bool = true;
        } else {
          injectElementWithStyles(['@media (',prefixes.join('touch-enabled),('),mod,')','{#modernizr{top:9px;position:absolute}}'].join(''), function( node ) {
            bool = node.offsetTop === 9;
          });
        }

        return bool;
    };



    tests['geolocation'] = function() {
        return 'geolocation' in navigator;
    };


    tests['postmessage'] = function() {
      return !!window.postMessage;
    };


    tests['websqldatabase'] = function() {
      return !!window.openDatabase;
    };

    tests['indexedDB'] = function() {
      return !!testPropsAll("indexedDB", window);
    };

    tests['hashchange'] = function() {
      return isEventSupported('hashchange', window) && (document.documentMode === undefined || document.documentMode > 7);
    };

    tests['history'] = function() {
      return !!(window.history && history.pushState);
    };

    tests['draganddrop'] = function() {
        var div = document.createElement('div');
        return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div);
    };

    tests['websockets'] = function() {
        return 'WebSocket' in window || 'MozWebSocket' in window;
    };


    tests['rgba'] = function() {
        setCss('background-color:rgba(150,255,150,.5)');

        return contains(mStyle.backgroundColor, 'rgba');
    };

    tests['hsla'] = function() {
            setCss('background-color:hsla(120,40%,100%,.5)');

        return contains(mStyle.backgroundColor, 'rgba') || contains(mStyle.backgroundColor, 'hsla');
    };

    tests['multiplebgs'] = function() {
                setCss('background:url(https://),url(https://),red url(https://)');

            return (/(url\s*\(.*?){3}/).test(mStyle.background);
    };    tests['backgroundsize'] = function() {
        return testPropsAll('backgroundSize');
    };

    tests['borderimage'] = function() {
        return testPropsAll('borderImage');
    };



    tests['borderradius'] = function() {
        return testPropsAll('borderRadius');
    };

    tests['boxshadow'] = function() {
        return testPropsAll('boxShadow');
    };

    tests['textshadow'] = function() {
        return document.createElement('div').style.textShadow === '';
    };


    tests['opacity'] = function() {
                setCssAll('opacity:.55');

                    return (/^0.55$/).test(mStyle.opacity);
    };


    tests['cssanimations'] = function() {
        return testPropsAll('animationName');
    };


    tests['csscolumns'] = function() {
        return testPropsAll('columnCount');
    };


    tests['cssgradients'] = function() {
        var str1 = 'background-image:',
            str2 = 'gradient(linear,left top,right bottom,from(#9f9),to(white));',
            str3 = 'linear-gradient(left top,#9f9, white);';

        setCss(
                       (str1 + '-webkit- '.split(' ').join(str2 + str1) +
                       prefixes.join(str3 + str1)).slice(0, -str1.length)
        );

        return contains(mStyle.backgroundImage, 'gradient');
    };


    tests['cssreflections'] = function() {
        return testPropsAll('boxReflect');
    };


    tests['csstransforms'] = function() {
        return !!testPropsAll('transform');
    };


    tests['csstransforms3d'] = function() {

        var ret = !!testPropsAll('perspective');

                        if ( ret && 'webkitPerspective' in docElement.style ) {

                      injectElementWithStyles('@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}', function( node, rule ) {
            ret = node.offsetLeft === 9 && node.offsetHeight === 3;
          });
        }
        return ret;
    };


    tests['csstransitions'] = function() {
        return testPropsAll('transition');
    };



    tests['fontface'] = function() {
        var bool;

        injectElementWithStyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) {
          var style = document.getElementById('smodernizr'),
              sheet = style.sheet || style.styleSheet,
              cssText = sheet ? (sheet.cssRules && sheet.cssRules[0] ? sheet.cssRules[0].cssText : sheet.cssText || '') : '';

          bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0;
        });

        return bool;
    };

    tests['generatedcontent'] = function() {
        var bool;

        injectElementWithStyles(['#',mod,'{font:0/0 a}#',mod,':after{content:"',smile,'";visibility:hidden;font:3px/1 a}'].join(''), function( node ) {
          bool = node.offsetHeight >= 3;
        });

        return bool;
    };
    tests['video'] = function() {
        var elem = document.createElement('video'),
            bool = false;

            try {
            if ( bool = !!elem.canPlayType ) {
                bool      = new Boolean(bool);
                bool.ogg  = elem.canPlayType('video/ogg; codecs="theora"')      .replace(/^no$/,'');

                            bool.h264 = elem.canPlayType('video/mp4; codecs="avc1.42E01E"') .replace(/^no$/,'');

                bool.webm = elem.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,'');
            }

        } catch(e) { }

        return bool;
    };

    tests['audio'] = function() {
        var elem = document.createElement('audio'),
            bool = false;

        try {
            if ( bool = !!elem.canPlayType ) {
                bool      = new Boolean(bool);
                bool.ogg  = elem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,'');
                bool.mp3  = elem.canPlayType('audio/mpeg;')               .replace(/^no$/,'');

                                                    bool.wav  = elem.canPlayType('audio/wav; codecs="1"')     .replace(/^no$/,'');
                bool.m4a  = ( elem.canPlayType('audio/x-m4a;')            ||
                              elem.canPlayType('audio/aac;'))             .replace(/^no$/,'');
            }
        } catch(e) { }

        return bool;
    };


    tests['localstorage'] = function() {
        try {
            localStorage.setItem(mod, mod);
            localStorage.removeItem(mod);
            return true;
        } catch(e) {
            return false;
        }
    };

    tests['sessionstorage'] = function() {
        try {
            sessionStorage.setItem(mod, mod);
            sessionStorage.removeItem(mod);
            return true;
        } catch(e) {
            return false;
        }
    };


    tests['webworkers'] = function() {
        return !!window.Worker;
    };


    tests['applicationcache'] = function() {
        return !!window.applicationCache;
    };


    tests['svg'] = function() {
        return !!document.createElementNS && !!document.createElementNS(ns.svg, 'svg').createSVGRect;
    };

    tests['inlinesvg'] = function() {
      var div = document.createElement('div');
      div.innerHTML = '<svg/>';
      return (div.firstChild && div.firstChild.namespaceURI) == ns.svg;
    };

    tests['smil'] = function() {
        return !!document.createElementNS && /SVGAnimate/.test(toString.call(document.createElementNS(ns.svg, 'animate')));
    };


    tests['svgclippaths'] = function() {
        return !!document.createElementNS && /SVGClipPath/.test(toString.call(document.createElementNS(ns.svg, 'clipPath')));
    };

    function webforms() {
                                            Modernizr['input'] = (function( props ) {
            for ( var i = 0, len = props.length; i < len; i++ ) {
                attrs[ props[i] ] = !!(props[i] in inputElem);
            }
            if (attrs.list){
                                  attrs.list = !!(document.createElement('datalist') && window.HTMLDataListElement);
            }
            return attrs;
        })('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' '));
                            Modernizr['inputtypes'] = (function(props) {

            for ( var i = 0, bool, inputElemType, defaultView, len = props.length; i < len; i++ ) {

                inputElem.setAttribute('type', inputElemType = props[i]);
                bool = inputElem.type !== 'text';

                                                    if ( bool ) {

                    inputElem.value         = smile;
                    inputElem.style.cssText = 'position:absolute;visibility:hidden;';

                    if ( /^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined ) {

                      docElement.appendChild(inputElem);
                      defaultView = document.defaultView;

                                        bool =  defaultView.getComputedStyle &&
                              defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' &&
                                                                                  (inputElem.offsetHeight !== 0);

                      docElement.removeChild(inputElem);

                    } else if ( /^(search|tel)$/.test(inputElemType) ){
                                                                                    } else if ( /^(url|email)$/.test(inputElemType) ) {
                                        bool = inputElem.checkValidity && inputElem.checkValidity() === false;

                    } else {
                                        bool = inputElem.value != smile;
                    }
                }

                inputs[ props[i] ] = !!bool;
            }
            return inputs;
        })('search tel url email datetime date month week time datetime-local number range color'.split(' '));
        }
    for ( var feature in tests ) {
        if ( hasOwnProp(tests, feature) ) {
                                    featureName  = feature.toLowerCase();
            Modernizr[featureName] = tests[feature]();

            classes.push((Modernizr[featureName] ? '' : 'no-') + featureName);
        }
    }

    Modernizr.input || webforms();


     Modernizr.addTest = function ( feature, test ) {
       if ( typeof feature == 'object' ) {
         for ( var key in feature ) {
           if ( hasOwnProp( feature, key ) ) {
             Modernizr.addTest( key, feature[ key ] );
           }
         }
       } else {

         feature = feature.toLowerCase();

         if ( Modernizr[feature] !== undefined ) {
                                              return Modernizr;
         }

         test = typeof test == 'function' ? test() : test;

         if (typeof enableClasses !== "undefined" && enableClasses) {
           docElement.className += ' ' + (test ? '' : 'no-') + feature;
         }
         Modernizr[feature] = test;

       }

       return Modernizr; 
     };


    setCss('');
    modElem = inputElem = null;


    Modernizr._version      = version;

    Modernizr._prefixes     = prefixes;
    Modernizr._domPrefixes  = domPrefixes;
    Modernizr._cssomPrefixes  = cssomPrefixes;

    Modernizr.mq            = testMediaQuery;

    Modernizr.hasEvent      = isEventSupported;

    Modernizr.testProp      = function(prop){
        return testProps([prop]);
    };

    Modernizr.testAllProps  = testPropsAll;


    Modernizr.testStyles    = injectElementWithStyles;
    Modernizr.prefixed      = function(prop, obj, elem){
      if(!obj) {
        return testPropsAll(prop, 'pfx');
      } else {
            return testPropsAll(prop, obj, elem);
      }
    };


    docElement.className = docElement.className.replace(/(^|\s)no-js(\s|$)/, '$1$2') +

                                                    (enableClasses ? ' js ' + classes.join(' ') : '');

    return Modernizr;

})(this, this.document);
/**
* @preserve HTML5 Shiv prev3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
;(function(window, document) {
/*jshint evil:true */
  /** version */
  var version = '3.7.0';

  /** Preset options */
  var options = window.html5 || {};

  /** Used to skip problem elements */
  var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;

  /** Not all elements can be cloned in IE **/
  var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i;

  /** Detect whether the browser supports default html5 styles */
  var supportsHtml5Styles;

  /** Name of the expando, to work with multiple documents or to re-shiv one document */
  var expando = '_html5shiv';

  /** The id for the the documents expando */
  var expanID = 0;

  /** Cached data for each document */
  var expandoData = {};

  /** Detect whether the browser supports unknown elements */
  var supportsUnknownElements;

  (function() {
    try {
        var a = document.createElement('a');
        a.innerHTML = '<xyz></xyz>';
        //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles
        supportsHtml5Styles = ('hidden' in a);

        supportsUnknownElements = a.childNodes.length == 1 || (function() {
          // assign a false positive if unable to shiv
          (document.createElement)('a');
          var frag = document.createDocumentFragment();
          return (
            typeof frag.cloneNode == 'undefined' ||
            typeof frag.createDocumentFragment == 'undefined' ||
            typeof frag.createElement == 'undefined'
          );
        }());
    } catch(e) {
      // assign a false positive if detection fails => unable to shiv
      supportsHtml5Styles = true;
      supportsUnknownElements = true;
    }

  }());

  /*--------------------------------------------------------------------------*/

  /**
   * Creates a style sheet with the given CSS text and adds it to the document.
   * @private
   * @param {Document} ownerDocument The document.
   * @param {String} cssText The CSS text.
   * @returns {StyleSheet} The style element.
   */
  function addStyleSheet(ownerDocument, cssText) {
    var p = ownerDocument.createElement('p'),
        parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;

    p.innerHTML = 'x<style>' + cssText + '</style>';
    return parent.insertBefore(p.lastChild, parent.firstChild);
  }

  /**
   * Returns the value of `html5.elements` as an array.
   * @private
   * @returns {Array} An array of shived element node names.
   */
  function getElements() {
    var elements = html5.elements;
    return typeof elements == 'string' ? elements.split(' ') : elements;
  }

    /**
   * Returns the data associated to the given document
   * @private
   * @param {Document} ownerDocument The document.
   * @returns {Object} An object of data.
   */
  function getExpandoData(ownerDocument) {
    var data = expandoData[ownerDocument[expando]];
    if (!data) {
        data = {};
        expanID++;
        ownerDocument[expando] = expanID;
        expandoData[expanID] = data;
    }
    return data;
  }

  /**
   * returns a shived element for the given nodeName and document
   * @memberOf html5
   * @param {String} nodeName name of the element
   * @param {Document} ownerDocument The context document.
   * @returns {Object} The shived element.
   */
  function createElement(nodeName, ownerDocument, data){
    if (!ownerDocument) {
        ownerDocument = document;
    }
    if(supportsUnknownElements){
        return ownerDocument.createElement(nodeName);
    }
    if (!data) {
        data = getExpandoData(ownerDocument);
    }
    var node;

    if (data.cache[nodeName]) {
        node = data.cache[nodeName].cloneNode();
    } else if (saveClones.test(nodeName)) {
        node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
    } else {
        node = data.createElem(nodeName);
    }

    // Avoid adding some elements to fragments in IE < 9 because
    // * Attributes like `name` or `type` cannot be set/changed once an element
    //   is inserted into a document/fragment
    // * Link elements with `src` attributes that are inaccessible, as with
    //   a 403 response, will cause the tab/window to crash
    // * Script elements appended to fragments will execute when their `src`
    //   or `text` property is set
    return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node;
  }

  /**
   * returns a shived DocumentFragment for the given document
   * @memberOf html5
   * @param {Document} ownerDocument The context document.
   * @returns {Object} The shived DocumentFragment.
   */
  function createDocumentFragment(ownerDocument, data){
    if (!ownerDocument) {
        ownerDocument = document;
    }
    if(supportsUnknownElements){
        return ownerDocument.createDocumentFragment();
    }
    data = data || getExpandoData(ownerDocument);
    var clone = data.frag.cloneNode(),
        i = 0,
        elems = getElements(),
        l = elems.length;
    for(;i<l;i++){
        clone.createElement(elems[i]);
    }
    return clone;
  }

  /**
   * Shivs the `createElement` and `createDocumentFragment` methods of the document.
   * @private
   * @param {Document|DocumentFragment} ownerDocument The document.
   * @param {Object} data of the document.
   */
  function shivMethods(ownerDocument, data) {
    if (!data.cache) {
        data.cache = {};
        data.createElem = ownerDocument.createElement;
        data.createFrag = ownerDocument.createDocumentFragment;
        data.frag = data.createFrag();
    }


    ownerDocument.createElement = function(nodeName) {
      //abort shiv
      if (!html5.shivMethods) {
          return data.createElem(nodeName);
      }
      return createElement(nodeName, ownerDocument, data);
    };

    ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
      'var n=f.cloneNode(),c=n.createElement;' +
      'h.shivMethods&&(' +
        // unroll the `createElement` calls
        getElements().join().replace(/\w+/g, function(nodeName) {
          data.createElem(nodeName);
          data.frag.createElement(nodeName);
          return 'c("' + nodeName + '")';
        }) +
      ');return n}'
    )(html5, data.frag);
  }

  /*--------------------------------------------------------------------------*/

  /**
   * Shivs the given document.
   * @memberOf html5
   * @param {Document} ownerDocument The document to shiv.
   * @returns {Document} The shived document.
   */
  function shivDocument(ownerDocument) {
    if (!ownerDocument) {
        ownerDocument = document;
    }
    var data = getExpandoData(ownerDocument);

    if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
      data.hasCSS = !!addStyleSheet(ownerDocument,
        // corrects block display not defined in IE6/7/8/9
        'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +
        // adds styling not present in IE6/7/8/9
        'mark{background:#FF0;color:#000}' +
        // hides non-rendered elements
        'template{display:none}'
      );
    }
    if (!supportsUnknownElements) {
      shivMethods(ownerDocument, data);
    }
    return ownerDocument;
  }

  /*--------------------------------------------------------------------------*/

  /**
   * The `html5` object is exposed so that more elements can be shived and
   * existing shiving can be detected on iframes.
   * @type Object
   * @example
   *
   * // options can be changed before the script is included
   * html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false };
   */
  var html5 = {

    /**
     * An array or space separated string of node names of the elements to shiv.
     * @memberOf html5
     * @type Array|String
     */
    'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video',

    /**
     * current version of html5shiv
     */
    'version': version,

    /**
     * A flag to indicate that the HTML5 style sheet should be inserted.
     * @memberOf html5
     * @type Boolean
     */
    'shivCSS': (options.shivCSS !== false),

    /**
     * Is equal to true if a browser supports creating unknown/HTML5 elements
     * @memberOf html5
     * @type boolean
     */
    'supportsUnknownElements': supportsUnknownElements,

    /**
     * A flag to indicate that the document's `createElement` and `createDocumentFragment`
     * methods should be overwritten.
     * @memberOf html5
     * @type Boolean
     */
    'shivMethods': (options.shivMethods !== false),

    /**
     * A string to describe the type of `html5` object ("default" or "default print").
     * @memberOf html5
     * @type String
     */
    'type': 'default',

    // shivs the document according to the specified `html5` object options
    'shivDocument': shivDocument,

    //creates a shived element
    createElement: createElement,

    //creates a shived documentFragment
    createDocumentFragment: createDocumentFragment
  };

  /*--------------------------------------------------------------------------*/

  // expose html5
  window.html5 = html5;

  // shiv the document
  shivDocument(document);

  /*------------------------------- Print Shiv -------------------------------*/

  /** Used to filter media types */
  var reMedia = /^$|\b(?:all|print)\b/;

  /** Used to namespace printable elements */
  var shivNamespace = 'html5shiv';

  /** Detect whether the browser supports shivable style sheets */
  var supportsShivableSheets = !supportsUnknownElements && (function() {
    // assign a false negative if unable to shiv
    var docEl = document.documentElement;
    return !(
      typeof document.namespaces == 'undefined' ||
      typeof document.parentWindow == 'undefined' ||
      typeof docEl.applyElement == 'undefined' ||
      typeof docEl.removeNode == 'undefined' ||
      typeof window.attachEvent == 'undefined'
    );
  }());

  /*--------------------------------------------------------------------------*/

  /**
   * Wraps all HTML5 elements in the given document with printable elements.
   * (eg. the "header" element is wrapped with the "html5shiv:header" element)
   * @private
   * @param {Document} ownerDocument The document.
   * @returns {Array} An array wrappers added.
   */
  function addWrappers(ownerDocument) {
    var node,
        nodes = ownerDocument.getElementsByTagName('*'),
        index = nodes.length,
        reElements = RegExp('^(?:' + getElements().join('|') + ')$', 'i'),
        result = [];

    while (index--) {
      node = nodes[index];
      if (reElements.test(node.nodeName)) {
        result.push(node.applyElement(createWrapper(node)));
      }
    }
    return result;
  }

  /**
   * Creates a printable wrapper for the given element.
   * @private
   * @param {Element} element The element.
   * @returns {Element} The wrapper.
   */
  function createWrapper(element) {
    var node,
        nodes = element.attributes,
        index = nodes.length,
        wrapper = element.ownerDocument.createElement(shivNamespace + ':' + element.nodeName);

    // copy element attributes to the wrapper
    while (index--) {
      node = nodes[index];
      node.specified && wrapper.setAttribute(node.nodeName, node.nodeValue);
    }
    // copy element styles to the wrapper
    wrapper.style.cssText = element.style.cssText;
    return wrapper;
  }

  /**
   * Shivs the given CSS text.
   * (eg. header{} becomes html5shiv\:header{})
   * @private
   * @param {String} cssText The CSS text to shiv.
   * @returns {String} The shived CSS text.
   */
  function shivCssText(cssText) {
    var pair,
        parts = cssText.split('{'),
        index = parts.length,
        reElements = RegExp('(^|[\\s,>+~])(' + getElements().join('|') + ')(?=[[\\s,>+~#.:]|$)', 'gi'),
        replacement = '$1' + shivNamespace + '\\:$2';

    while (index--) {
      pair = parts[index] = parts[index].split('}');
      pair[pair.length - 1] = pair[pair.length - 1].replace(reElements, replacement);
      parts[index] = pair.join('}');
    }
    return parts.join('{');
  }

  /**
   * Removes the given wrappers, leaving the original elements.
   * @private
   * @params {Array} wrappers An array of printable wrappers.
   */
  function removeWrappers(wrappers) {
    var index = wrappers.length;
    while (index--) {
      wrappers[index].removeNode();
    }
  }

  /*--------------------------------------------------------------------------*/

  /**
   * Shivs the given document for print.
   * @memberOf html5
   * @param {Document} ownerDocument The document to shiv.
   * @returns {Document} The shived document.
   */
  function shivPrint(ownerDocument) {
    var shivedSheet,
        wrappers,
        data = getExpandoData(ownerDocument),
        namespaces = ownerDocument.namespaces,
        ownerWindow = ownerDocument.parentWindow;

    if (!supportsShivableSheets || ownerDocument.printShived) {
      return ownerDocument;
    }
    if (typeof namespaces[shivNamespace] == 'undefined') {
      namespaces.add(shivNamespace);
    }

    function removeSheet() {
      clearTimeout(data._removeSheetTimer);
      if (shivedSheet) {
          shivedSheet.removeNode(true);
      }
      shivedSheet= null;
    }

    ownerWindow.attachEvent('onbeforeprint', function() {

      removeSheet();

      var imports,
          length,
          sheet,
          collection = ownerDocument.styleSheets,
          cssText = [],
          index = collection.length,
          sheets = Array(index);

      // convert styleSheets collection to an array
      while (index--) {
        sheets[index] = collection[index];
      }
      // concat all style sheet CSS text
      while ((sheet = sheets.pop())) {
        // IE does not enforce a same origin policy for external style sheets...
        // but has trouble with some dynamically created stylesheets
        if (!sheet.disabled && reMedia.test(sheet.media)) {

          try {
            imports = sheet.imports;
            length = imports.length;
          } catch(er){
            length = 0;
          }

          for (index = 0; index < length; index++) {
            sheets.push(imports[index]);
          }

          try {
            cssText.push(sheet.cssText);
          } catch(er){}
        }
      }

      // wrap all HTML5 elements with printable elements and add the shived style sheet
      cssText = shivCssText(cssText.reverse().join(''));
      wrappers = addWrappers(ownerDocument);
      shivedSheet = addStyleSheet(ownerDocument, cssText);

    });

    ownerWindow.attachEvent('onafterprint', function() {
      // remove wrappers, leaving the original elements, and remove the shived style sheet
      removeWrappers(wrappers);
      clearTimeout(data._removeSheetTimer);
      data._removeSheetTimer = setTimeout(removeSheet, 500);
    });

    ownerDocument.printShived = true;
    return ownerDocument;
  }

  /*--------------------------------------------------------------------------*/

  // expose API
  html5.type += ' print';
  html5.shivPrint = shivPrint;

  // shiv for print
  shivPrint(document);

}(this, document));
/*yepnope1.5.4|WTFPL*/
(function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i<a.length;i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&&h(j,l);else Object(a)===a&&h(a,l)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}})(this,document);
Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0));};
;;
(function(n){function h(n,t){var r=n.find(".dd-option-value[value= '"+t+"']").parents("li").prevAll().length;i(n,r)}function i(n,t){var r=n.data("ddslick"),e=n.find(".dd-selected"),s=e.siblings(".dd-selected-value"),l=n.find(".dd-options"),a=e.siblings(".dd-pointer"),o=n.find(".dd-option").eq(t),h=o.closest("li"),u=r.settings,i=r.settings.data[t];n.find(".dd-option").removeClass("dd-option-selected");o.addClass("dd-option-selected");r.selectedIndex=t;r.selectedItem=h;r.selectedData=i;u.showSelectedHTML?e.html((i.imageSrc?'<img class="dd-selected-image'+(u.imagePosition=="right"?" dd-image-right":"")+'" src="'+i.imageSrc+'" />':"")+(i.text?'<label class="dd-selected-text">'+i.text+"<\/label>":"")+(i.description?'<small class="dd-selected-description dd-desc'+(u.truncateDescription?" dd-selected-description-truncated":"")+'" >'+i.description+"<\/small>":"")):e.html(i.text);s.val(i.value);r.original.val(i.value);n.data("ddslick",r);f(n);c(n);typeof u.onSelected=="function"&&u.onSelected.call(this,r)}function u(t){var i=t.find(".dd-select"),r=i.siblings(".dd-options"),u=i.find(".dd-pointer"),f=r.is(":visible");n(".dd-click-off-close").not(r).slideUp(50);n(".dd-pointer").removeClass("dd-pointer-up");i.removeClass("dd-open");f?(r.slideUp("fast"),u.removeClass("dd-pointer-up"),i.removeClass("dd-open")):(i.addClass("dd-open"),r.slideDown("fast"),u.addClass("dd-pointer-up"));l(t)}function f(n){n.find(".dd-select").removeClass("dd-open");n.find(".dd-options").slideUp(50);n.find(".dd-pointer").removeClass("dd-pointer-up").removeClass("dd-pointer-up")}function c(n){var t=n.find(".dd-select").css("height"),i=n.find(".dd-selected-description"),r=n.find(".dd-selected-image");i.length<=0&&r.length>0&&n.find(".dd-selected-text").css("lineHeight",t)}function l(t){t.find(".dd-option").each(function(){var i=n(this),r=i.css("height"),u=i.find(".dd-option-description"),f=t.find(".dd-option-image");u.length<=0&&f.length>0&&i.find(".dd-option-text").css("lineHeight",r)})}n.fn.ddslick=function(i){if(t[i])return t[i].apply(this,Array.prototype.slice.call(arguments,1));if(typeof i!="object"&&i)n.error("Method "+i+" does not exists.");else return t.init.apply(this,arguments)};var t={},r={data:[],keepJSONItemsOnTop:!1,width:260,height:null,background:"#eee",selectText:"",defaultSelectedIndex:null,truncateDescription:!0,imagePosition:"left",showSelectedHTML:!0,clickOffToClose:!0,embedCSS:!0,onSelected:function(){}},e='<div class="dd-select"><input class="dd-selected-value" type="hidden" /><a class="dd-selected"><\/a><span class="dd-pointer dd-pointer-down"><\/span><\/div>',o='<ul class="dd-options"><\/ul>',s='<style id="css-ddslick" type="text/css">.dd-select{ border-radius:2px; border:solid 1px #ccc; position:relative; cursor:pointer;}.dd-desc { color:#aaa; display:block; overflow: hidden; font-weight:normal; line-height: 1.4em; }.dd-selected{ overflow:hidden; display:block; padding:10px; font-weight:bold;}.dd-pointer{ width:0; height:0; position:absolute; right:10px; top:50%; margin-top:-3px;}.dd-pointer-down{ border:solid 5px transparent; border-top:solid 5px #000; }.dd-pointer-up{border:solid 5px transparent !important; border-bottom:solid 5px #000 !important; margin-top:-8px;}.dd-options{ border:solid 1px #ccc; border-top:none; list-style:none; box-shadow:0px 1px 5px #ddd; display:none; position:absolute; z-index:2000; margin:0; padding:0;background:#fff; overflow:auto;}.dd-option{ padding:10px; display:block; border-bottom:solid 1px #ddd; overflow:hidden; text-decoration:none; color:#333; cursor:pointer;-webkit-transition: all 0.25s ease-in-out; -moz-transition: all 0.25s ease-in-out;-o-transition: all 0.25s ease-in-out;-ms-transition: all 0.25s ease-in-out; }.dd-options > li:last-child > .dd-option{ border-bottom:none;}.dd-option:hover{ background:#f3f3f3; color:#000;}.dd-selected-description-truncated { text-overflow: ellipsis; white-space:nowrap; }.dd-option-selected { background:#f6f6f6; }.dd-option-image, .dd-selected-image { vertical-align:middle; float:left; margin-right:5px; max-width:64px;}.dd-image-right { float:right; margin-right:15px; margin-left:5px;}.dd-container{ position:relative;}​ .dd-selected-text { font-weight:bold}​<\/style>';t.init=function(t){var f=n.extend({},r,t);return n("#css-ddslick").length<=0&&f.embedCSS&&n(s).appendTo("head"),this.each(function(){var f=n.extend({},r,t),s=n(this),p=s.data("ddslick"),w,l,a,h,c,v,y;if(!p){h=[];w=f.data;s.find("option").each(function(){var t=n(this),i=t.data();h.push({text:n.trim(t.text()),value:t.val(),selected:t.is(":selected"),description:i.description,imageSrc:i.imagesrc})});f.keepJSONItemsOnTop?n.merge(f.data,h):f.data=n.merge(h,f.data);l=s;a=n("<div>").attr("id",s.attr("id")+"-dd-placeholder");s.replaceWith(a);s=a;s.addClass("dd-container").append(e).append(o);s.find("input.dd-selected-value").attr("id",n(l).attr("id")).attr("name",n(l).attr("name"));h=s.find(".dd-select");c=s.find(".dd-options");c.css({width:f.width});h.css({width:f.width,background:f.background});s.css({width:f.width});f.height!=null&&c.css({height:f.height,overflow:"auto"});n.each(f.data,function(n,t){t.selected&&(f.defaultSelectedIndex=n);c.append('<li><a class="dd-option">'+(t.value?' <input class="dd-option-value" type="hidden" value="'+t.value+'" />':"")+(t.imageSrc?' <img class="dd-option-image'+(f.imagePosition=="right"?" dd-image-right":"")+'" src="'+t.imageSrc+'" />':"")+(t.text?' <label class="dd-option-text">'+t.text+"<\/label>":"")+(t.description?' <small class="dd-option-description dd-desc">'+t.description+"<\/small>":"")+"<\/a><\/li>")});v={settings:f,original:l,selectedIndex:-1,selectedItem:null,selectedData:null};s.data("ddslick",v);f.selectText.length>0&&f.defaultSelectedIndex==null?s.find(".dd-selected").html(f.selectText):(y=f.defaultSelectedIndex!=null&&f.defaultSelectedIndex>=0&&f.defaultSelectedIndex<f.data.length?f.defaultSelectedIndex:0,i(s,y));s.find(".dd-select").on("click.ddslick",function(){u(s)});s.find(".dd-option").on("click.ddslick",function(){i(s,n(this).closest("li").index())});if(f.clickOffToClose){c.addClass("dd-click-off-close");s.on("click.ddslick",function(n){n.stopPropagation()});n("body").on("click",function(){n(".dd-open").removeClass("dd-open");n(".dd-click-off-close").slideUp(50).siblings(".dd-select").find(".dd-pointer").removeClass("dd-pointer-up")})}}})};t.select=function(t){return this.each(function(){t.index!==undefined&&i(n(this),t.index);t.id&&h(n(this),t.id)})};t.open=function(){return this.each(function(){var t=n(this),i=t.data("ddslick");i&&u(t)})};t.close=function(){return this.each(function(){var t=n(this),i=t.data("ddslick");i&&f(t)})};t.destroy=function(){return this.each(function(){var t=n(this),i=t.data("ddslick"),r;i&&(r=i.original,t.removeData("ddslick").unbind(".ddslick").replaceWith(r))})}})(jQuery);
//# sourceMappingURL=jquery.ddslick.min.js.map
;
// ###################################
// COVINGTON - JS                    
// ###################################



/* #################### CLOSE EVERYTHING #################### */
function closeEverything(){
   // header
   closeNavPopup();
   closeNavItemPopup();
   closeSearchPopup();
   // closeSubscribePopup();
   $('body').removeClass('email-modal-open');
}



/* #################### ESC KEY PRESS #################### */
$(document).keyup(function(e) {
   if (e.keyCode == 27) {
      closeEverything();
   }
});


// history tracking is disabled by Coveo search, and Coveo overrides native JS history events. Using this to track actively clicked links
window.app = {
    hash: {
        recentlyClickedHash: '',
        clickedAtTime: null,
        setRecentlyClickedHash: function(hash){
            window.app.hash.recentlyClickedHash = hash;
            window.app.hash.clickedAtTime = Date.now();
        },
        getRecentlyClickedHash: function(){
            return {
                clickedHash: window.app.hash.recentlyClickedHash,
                clickedTime: window.app.hash.clickedAtTime
            };
        },
        clearRecentlyClickedHash: function(){
            window.app.hash.recentlyClickedHash = null;
            window.app.hash.clickedAtTime = null;
        }
    }
}

/* #################### ANCHOR LINK EASING #################### */
$(function() {
   $('a[href*="#"]:not([href="#"])').click(function() {
      if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
         var hashParts = this.hash.split("&");
         var hash = hashParts[0];
         var continueExecuting = false;
         if(hashParts.length > 1){
             continueExecuting = true;
         }
         var target = $(hash);
         target = target.length ? target : $('[name=' + hash.slice(1) +']');
         if (target.length) {
            // set hash location - event.preventDefault is called elsewhere, preventing href location from appending in URLs
            window.app.hash.setRecentlyClickedHash(hash);
            
            // find search interface that may be a subitem of the linked dom element - if it exists, jump to it to ensure that it lazy-loads
            var searchInterface = target.find(".CoveoSearchInterface:not(.coveo-after-initialization)");

            target = searchInterface && searchInterface.length ? searchInterface : target;

            $('html, body').animate({
               scrollTop: target.offset().top
            }, 500);
            return continueExecuting;
         }
      }
   });
});



// #################### CUSTOM SELECT (SUMO) ####################
$(document).ready(function() {
   $('.custom-select').SumoSelect();
});



// #################### HEADER ####################
// ########## SCROLL POSITIONING ##########
function headerScrollPosResize(){
	// on page load/resize
	var headerHeight = $('header').innerHeight();
	var headerHeightDouble = headerHeight * 2;
	var prevScrollAmount = $(window).scrollTop();
	if (prevScrollAmount >= headerHeight) {
		// scroll 1 header height = opaque
		$('body').addClass('scrolled-header-height');
	} else {
		// default top of page styling = transparent
		$('body').removeClass('scrolled-header-height');
	}
	// on page scroll
   $(window).scroll(function(event){
      var scrollAmount = $(window).scrollTop();
      if (scrollAmount > prevScrollAmount) { // scroll down
      	if (scrollAmount >= 50 && scrollAmount < 250) { // (scrollAmount >= headerHeight && scrollAmount < headerHeightDouble)
         	// scroll 1 header height = visible/opaque
         	$('body').addClass('scrolled-header-height');
         	$('body').removeClass('scrolled-header-hidden');
         } else if (scrollAmount >= 100) { // (scrollAmount >= headerHeightDouble)
         	// scroll 2 header heights = hidden/opaque
         	$('body').addClass('scrolled-header-hidden');
         }
      } else { // scroll up
      	if (scrollAmount > 50) { // (scrollAmount > headerHeight)
	         // scroll up a bit lower on page = visible/opaque
	         $('body').removeClass('scrolled-header-hidden');
	      } else {
	      	// scroll less than header height = visible/transparent
	      	$('body').removeClass('scrolled-header-height');
	      	$('body').removeClass('scrolled-header-hidden');
	      }
      }
      // closing adjustments
      prevScrollAmount = scrollAmount;
   });
}
$(window).on('load resize',function(){
   headerScrollPosResize();
});


// ########## HEADER CLOSE FUNCTIONS ##########
function closeNavPopup(){
   $('body').removeClass('nav-open');
}

function closeNavItemPopup(){
   $('.header__main___nav__item').removeClass('header__main___nav__item--open');
}

function closeSearchPopup(){
   $('body').removeClass('scroll-disabled');
   $('.header__main__right__controls__search').removeClass('header__main__right__controls__search--open');
}

// function closeSubscribePopup(){
//    $('body').removeClass('scroll-disabled');
//    $('header').removeClass('header--subscribe-popup-open');
// }


// ########## OPEN/CLOSE MOBILE NAV ##########
$('.header__main__right__controls__hamburger').click(function() {
   closeSearchPopup();
   // closeSubscribePopup();
   $('body').addClass('nav-open');
});

$('.header__main__right__popup__close').click(function() {
   closeNavPopup();
   closeNavItemPopup();
});


// ########## OPEN/CLOSE SECONDARY/TERTIARY NAV ##########
$('.header__main___nav__item__trigger').click(function() {
   closeSearchPopup();
   // closeSubscribePopup();
   if (window.innerWidth >= 1180) {
      if ($(this).closest('.header__main___nav__item').hasClass('header__main___nav__item--open')) {
         closeNavItemPopup();
         closeNavPopup();
      } else {
         closeNavItemPopup();
         $('body').addClass('nav-open');
         $(this).closest('.header__main___nav__item').addClass('header__main___nav__item--open');
      }
   } else {
      $(this).closest('.header__main___nav__item').addClass('header__main___nav__item--open');
   }
});

$('.header__main__right__popup__back').click(function() {
   $(this).closest('.header__main___nav__item').removeClass('header__main___nav__item--open');
});


// ########## SEARCH POPUP OPEN/CLOSE ##########
$('.header__main__right__controls__search__trigger').click(function() {
   closeNavPopup();
   closeNavItemPopup();
   // closeSubscribePopup();
   if (window.innerWidth >= 1180) {
      $(this).closest('.header__main__right__controls__search').toggleClass('header__main__right__controls__search--open');

      if ($(this).closest('.header__main__right__controls__search').hasClass('header__main__right__controls__search--open')) {
         $('body').addClass('nav-open');
      } else {
         closeNavPopup();
      }
   } else {
      $('body').addClass('scroll-disabled');
      $(this).closest('.header__main__right__controls__search').addClass('header__main__right__controls__search--open');
   }
});

$('.header__main__right__controls__search__popup__close').click(function() {
   closeSearchPopup();
});


// ########## DESKTOP HEADER CLOSE ##########
$('.desktop-header-close').click(function() {
   closeNavPopup();
   closeNavItemPopup();
   closeSearchPopup();
});


// ########## SUBSCRIBE POPUP OPEN/CLOSE ##########
// $('.header__subscribe-popup-trigger').click(function() {
//    if (window.innerWidth >= 1180) {
//       closeNavPopup();
//       closeNavItemPopup();
//       closeSearchPopup();
//       $('header').toggleClass('header--subscribe-popup-open');
//    } else {
//       $('header').addClass('header--subscribe-popup-open');
//    }
//    if (window.innerWidth < 1180) {
//       $('body').addClass('scroll-disabled');
//    }
// });

// $('.header__subscribe-popup__content__close').click(function() {
//    closeSubscribePopup();
// });


// ########## MOUSE LEAVE HEADER ##########
// $('header').mouseleave(function() {
//    if (window.innerWidth >= 1180) {
//       closeEverything();
//    }
// });


/* ########## SEARCH PREDICTIVE RESULTS ########## */
// $('.header__main__right__popup__professionals-search__search-bar input').focus(function() {
//    $(this).closest('.header__main__right__popup__professionals-search__search-bar').addClass('header__main__right__popup__professionals-search__search-bar--open');
// });
// $('.header__main__right__popup__professionals-search__search-bar input').blur(function() {
//    $(this).closest('.header__main__right__popup__professionals-search__search-bar').removeClass('header__main__right__popup__professionals-search__search-bar--open');
// });

// $('.search-bar input').focus(function() {
//    $(this).closest('.search-bar').addClass('search-bar--open');
// });
// $('.search-bar input').blur(function() {
//    $(this).closest('.search-bar').removeClass('search-bar--open');
// });



// #################### CUSTOM SELECT - LINKS ####################
$('.custom-select-links__trigger').click(function() {
   $(this).closest('.custom-select-links').toggleClass('custom-select-links--open');
});

$('.custom-select-links__dropdown li').click(function() {
   var selectedItem = $(this).text();
   $(this).closest('.custom-select-links').removeClass('custom-select-links--open');
   $(this).closest('.custom-select-links').find('.custom-select-links__trigger').text(selectedItem);
});



// #################### CUSTOM SELECT - LINKS - MOBILE BUTTON ####################
$('.custom-select-links-mobile-button__trigger').click(function() {
   $(this).closest('.custom-select-links-mobile-button').toggleClass('custom-select-links-mobile-button--open');
});

$('.custom-select-links-mobile-button__dropdown li').click(function() {
   var selectedItem = $(this).text();
   $(this).closest('.custom-select-links-mobile-button').removeClass('custom-select-links-mobile-button--open');
   $(this).closest('.custom-select-links-mobile-button').find('.custom-select-links-mobile-button__trigger').text(selectedItem);
});




// #################### FOOTER - BACK TO TOP ####################
$('.footer__back-to-top').click(function() {
   $('html,body').animate({scrollTop: 0}, 300);
});



// #################### HERO ####################
window.covHeroInitFunc = function () {

      // ########## PARALLAX ##########
      $(this).parallax({speed: 0.5});


      // ########## SLIDERS ##########
      $('.hero__slider-image').on('init', function () {
         $(this).css({opacity: '1', visibility: 'visible'});
      });

      $('.hero__slider-text').on('init', function () {
         $(this).css({opacity: '1', visibility: 'visible'});
      });


      if ($(this).hasClass('hero--internal')) {
         
         $('.hero__slider-image').slick({
            arrows: true,
            dots: true,
            infinite: true,
            autoplay: true,
            autoplaySpeed: 5000,
            draggable: false,
            slidesToShow: 1,
            slidesToScroll: 1,
            fade: false,
            asNavFor: '',
            asNavFor: '.hero__slider-text, .hero__slider-background'
         });

         $('.hero__slider-text').slick({
            arrows: true,
            dots: true,
            infinite: true,
            autoplay: true,
            autoplaySpeed: 5000,
            draggable: false,
            slidesToShow: 1,
            slidesToScroll: 1,
            fade: true,
            asNavFor: '.hero__slider-image, .hero__slider-background',
            responsive: [
               {
                  breakpoint: 992,
                  settings: {
                     arrows: false,
                     dots: false
                  }
               }
            ]
         });

         $('.hero__slider-background').slick({
            arrows: false,
            dots: false,
            infinite: true,
            autoplay: true,
            autoplaySpeed: 5000,
            draggable: false,
            slidesToShow: 1,
            slidesToScroll: 1,
            fade: true,
            asNavFor: '.hero__slider-text, .hero__slider-image'
         });

      } else {

         $('.hero__slider-image').slick({
            arrows: true,
            dots: true,
            infinite: true,
            autoplay: true,
            autoplaySpeed: 5000,
            draggable: false,
            slidesToShow: 1,
            slidesToScroll: 1,
            fade: false,
            asNavFor: '.hero__slider-text',
            responsive: [
               {
                  breakpoint: 992,
                  settings: {
                     dots: false
                  }
               }
            ]
         });

         $('.hero__slider-text').slick({
            arrows: false,
            dots: false,
            infinite: true,
            autoplay: true,
            autoplaySpeed: 5000,
            draggable: false,
            slidesToShow: 1,
            slidesToScroll: 1,
            fade: true,
            asNavFor: '.hero__slider-image'
         });

      }

   }

$(document).ready(function(){
   $('.hero--slider').each(window.covHeroInitFunc);

   $('.hero__slider-text, .hero__slider-image').on('mouseenter', function(){
      $('.hero__slider-text, .hero__slider-image').slick('slickPause');
   });
   $('.hero__slider-text, .hero__slider-image').on('mouseleave', function(){
      $('.hero__slider-text, .hero__slider-image').slick('slickPlay');
   });
});



// #################### EMAIL MODAL ####################
$('.hero__content__email__modal-trigger').click(function(e) {
   $('body').addClass('email-modal-open');
    e.preventDefault();

    var anchorTrigger = $(this).attr('href');

    if (!anchorTrigger) {
        anchorTrigger = $(this).find('a').attr('href');
    }

    $('#emailModalInput').attr('value', anchorTrigger);

    return false;
});

$('#emailModalAccept').click(function() {
    window.location.href = $('#emailModalInput').attr('value');
});

$('.email-modal .bttn, .email-modal__shade').click(function() {
   $('body').removeClass('email-modal-open');
});



// #################### TABS THREE UP ####################
$('.tabs-three-up__desktop-trigger li, .tabs-three-up__main__mobile-trigger').click(function() {
   var tabClicked = $(this).attr('data-tabSelection');
   
   if (window.innerWidth >= 992) {
      $('.tabs-three-up__desktop-trigger li').removeClass('tabs-three-up__desktop-trigger__current-tab');
      $('.tabs-three-up__main > li').removeClass('tabs-three-up__main__current-tab');
      $('.tabs-three-up__desktop-trigger li').each(function() {
         if ($(this).attr('data-tabSelection') === tabClicked) {
            $(this).addClass('tabs-three-up__desktop-trigger__current-tab');
         } else {
            $(this).removeClass('tabs-three-up__desktop-trigger__current-tab');
         }
      });
      $('.tabs-three-up__main > li').each(function() {
         if ($(this).attr('data-tabContent') === tabClicked) {
            $(this).addClass('tabs-three-up__main__current-tab');
         } else {
            $(this).removeClass('tabs-three-up__main__current-tab');
         }
      });
   } else {
      if ($(this).parent().hasClass('tabs-three-up__main__current-tab')) {
         $('.tabs-three-up__desktop-trigger li').removeClass('tabs-three-up__desktop-trigger__current-tab');
         $('.tabs-three-up__main > li').removeClass('tabs-three-up__main__current-tab');
      } else {
         $('.tabs-three-up__desktop-trigger li').removeClass('tabs-three-up__desktop-trigger__current-tab');
         $('.tabs-three-up__main > li').removeClass('tabs-three-up__main__current-tab');
         $('.tabs-three-up__desktop-trigger li').each(function() {
            if ($(this).attr('data-tabSelection') === tabClicked) {
               $(this).addClass('tabs-three-up__desktop-trigger__current-tab');
            } else {
               $(this).removeClass('tabs-three-up__desktop-trigger__current-tab');
            }
         });

         $('.tabs-three-up__main > li').each(function() {
            if ($(this).attr('data-tabContent') === tabClicked) {
               $(this).addClass('tabs-three-up__main__current-tab');
            } else {
               $(this).removeClass('tabs-three-up__main__current-tab');
            }
         });
      }
   }
});

// $('.tabs-three-up__desktop-trigger li, .tabs-three-up__main__mobile-trigger').click(function() {
//    var tabClicked = $(this).attr('data-tabSelection');
//    $('.tabs-three-up__desktop-trigger li').removeClass('tabs-three-up__desktop-trigger__current-tab');
//    $('.tabs-three-up__main > li').removeClass('tabs-three-up__main__current-tab');
//    $('.tabs-three-up__desktop-trigger li').each(function() {
//       if ($(this).attr('data-tabSelection') === tabClicked) {
//          $(this).addClass('tabs-three-up__desktop-trigger__current-tab');
//       } else {
//          $(this).removeClass('tabs-three-up__desktop-trigger__current-tab');
//       }
//    });
//    $('.tabs-three-up__main > li').each(function() {
//       if ($(this).attr('data-tabContent') === tabClicked) {
//          $(this).addClass('tabs-three-up__main__current-tab');
//       } else {
//          $(this).removeClass('tabs-three-up__main__current-tab');
//       }
//    });
// });

$('.tabs-three-up__main__mobile-trigger').click(function() {
   var scrollAmmount = $(this).offset().top - 10;
   $('html,body').animate({scrollTop: scrollAmmount}, 0);
});



// #################### ACCORDION ####################
$('.accordion__trigger').click(function() {
   $(this).closest('.accordion').toggleClass('accordion--visible');
});




// #################### SEE MORE ####################
$('.bttn-small--see-more').click(function() {
   $(this).closest('.see-more').toggleClass('see-more--visible');
});



/* #################### STICKY SHARE LINKS #################### */
function stickyShareResponsive(){
   $('.share-links-wrapper').each(function () {
      var offsetHeight = ($(window).innerHeight() / 4);
      var controller = new ScrollMagic.Controller();
      var scene;
      var shareLinksDesktop = $('.share-links--desktop');

        if (shareLinksDesktop && !shareLinksDesktop.css("position") === "fixed") {
            scene = new ScrollMagic.Scene({triggerElement: '.share-links-trigger'})
                     .setPin('.share-links--desktop')
                     // .addIndicators({name: 'share links'})
                     .addTo(controller);
        }

        if (scene && offsetHeight) {
            scene.offset(offsetHeight);   
        }
   });
}
$(window).on('load resize',function(){
   stickyShareResponsive();
});



// #################### SECTION HEADING FILTER ####################
$('.section-heading__desktop-filters li, .section-heading .custom-select-links li').click(function() {
   var filterSelected = $(this).attr('data-sh-filter');

   $('.section-heading__desktop-filters li').each(function () {
      if ($(this).attr('data-sh-filter') == filterSelected) {
         $(this).addClass('section-heading__desktop-filters__selected');
      } else {
         $(this).removeClass('section-heading__desktop-filters__selected');
      }
   });

   $('.section-heading .custom-select-links__trigger').text(filterSelected);

   $('.section-heading .custom-select-links li').each(function () {
      if ($(this).attr('data-sh-filter') == filterSelected) {
         $(this).addClass('section-heading__desktop-filters__selected');
      } else {
         $(this).removeClass('section-heading__desktop-filters__selected');
      }
   });

   if (filterSelected == 'All') {   
      $('.section-heading-filter-items .col-12').each(function () {
         if ($(this).attr('data-sh-all') == 'All') {
            $(this).addClass('section-heading-filter-items__visible');
         } else {
            $(this).removeClass('section-heading-filter-items__visible');
         }
      });
   } else {
      $('.section-heading-filter-items .col-12').each(function () {
         if ($(this).attr('data-sh-item') == filterSelected && !$(this).attr('data-sh-all')) {
            $(this).addClass('section-heading-filter-items__visible');
         } else {
            $(this).removeClass('section-heading-filter-items__visible');
         }
      });
   }
});

$('.custom-select-links__dropdown li').click(function() {
   var selectedItem = $(this).text();
   $(this).closest('.custom-select-links').removeClass('custom-select-links--open');
   $(this).closest('.custom-select-links').find('.custom-select-links__trigger').text(selectedItem);
});



// #################### LANDING CARD CLICK STATE ####################
$('.landing-cards__card').click(function(event) {
    var url = $(this).attr('url');
    var clickedUrlLink = event && event.target && event.target.nodeName && event.target.nodeName.toLowerCase() === "a" && event.target.href ? 
        event.target.href : 
        "";
    if(!clickedUrlLink && url){
        window.location = url;
    }
    //$(this).find('.bttn').stopPropagation();
   
});



// #################### COOKIE NOTIFICATION ####################
$('.cookie-notification__close').click(function() {
   $('.cookie-notification').removeClass('cookie-notification--open');

    console.log($(this).parent());

    if ($(this).parent().attr("id") === "cookies-message") {
        var date = new Date();
        date.setDate(date.getDate() + (365 * 5));
        var expires = "expires=" + date.toGMTString();
        document.cookie = "cov.cookies=1; " + expires + "; path=/";
    }
});

function CookiesOk () {
    var cookies = document.cookie.split(";");

    for (var i = 0; i < cookies.length; i++) {
        var cookie = cookies[i];
        while (cookie.charAt(0) === ' ') cookie = cookie.substring(1, cookie.length)
        if (cookie.indexOf("cov.cookies") === 0) return true;
    }
    return false;
}

$(document).ready(function() {
   if (CookiesOk() === false) {
        $('.cookie-notification').addClass('cookie-notification--open');
    } else {
        $('.cookie-notification').removeClass('cookie-notification--open');
    }
});



// #################### HEADER ####################
$('.search-results-card__remove').click(function() {
   $(this).closest('.search-results-card--interactive').removeClass('search-results-card--interactive--removed');
});

var professionalsMenuTrigger = $('.professionals-menu');

if (professionalsMenuTrigger) {
    professionalsMenuTrigger.click(function () {
       var professionalsSearchInput = $('#professionalsSearch');

       if (professionalsSearchInput) {
         professionalsSearchInput.focus();
       }
    });
}

var practiceIndustryMenuTrigger = $('.practice-industry-menu');

if (practiceIndustryMenuTrigger) {
   practiceIndustryMenuTrigger.click(function () {
      var practiceIndustrySearchInput = $('#practicesIndustriesHeaderSearch');

      if (practiceIndustrySearchInput) {
         practiceIndustrySearchInput.focus();
      }
   });
}

var globalSearchMenuTrigger = $('.global-search-menu');

if (globalSearchMenuTrigger) {
   globalSearchMenuTrigger.click(function () {
      var globalSearchInput = $('header .CoveoSearchbox .magic-box-input input');

      if (globalSearchInput) {
         globalSearchInput.focus();
      }
   });
}


// #################### STICKY ACCORDION OPEN/CLOSE ####################
$('.sticky-accordion__trigger h2, .sticky-accordion__trigger__chevron').click(function() {
   $('.sticky-accordion').toggleClass('sticky-accordion--open');
});

$('.sticky-accordion__hide').click(function() {
   $('.sticky-accordion').addClass('sticky-accordion--hidden');
});

// jump to linked element (fixed header is blocking some of the referenced content)
$(function() {
    if(window.location.hash && window.location.hash.length){
        setTimeout(delayedFragmentTargetOffset, 500);
    }
});

function delayedFragmentTargetOffset(){
    var offset = $(':target').offset();
    if(offset){
        var scrollto = offset.top - $('header').height(); // minus fixed header height
        $('html, body').animate({scrollTop:scrollto}, 0);
    }
}
;

"use strict";
function GetDomain() {
    if (!window.location.origin) {
        // IE..
        return window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
    }
    else {
        // Non-IE..
        return window.location.origin;
    }
}

// string for pdf and word rep matters
var repIds = '';
var myAccentMap = { "ó": "o" };


(function ($) {
    // Avoid `console` errors in browsers that lack a console.
    if (!(window.console && console.log)) {
        (function () {
            var noop = function () { };
            var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'markTimeline', 'table',

'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];
            var length = methods.length;
            var console = window.console = {};
            while (length--) {
                console[methods[length]] = noop;
            }
        }());
    }

    //String format stand-in
    if (!String.format) {
        String.format = function () {
            var s = arguments[0];
            for (var i = 0; i < arguments.length - 1; i++) {
                var reg = new RegExp("\\{" + i + "\\}", "gm");
                s = s.replace(reg, arguments[i + 1]);
            }

            return s;
        }
    }

    // Covington Namespace
    var Covington = {};

    /*
        Modernizr Loaders
     */
    Covington.Modernizr =
    {
        Init: function () {
            //Modernizr conditional loading
            //The script may be faulty
            Modernizr.load([
                {
                    test: Modernizr.csscolumns,
                    nope: ["/assets/js/plugins/css3-multicolumn/css3-multi-column.min.js"]
                }
            ]);
        }
    }


    Covington.Base =
    {
        Init: function () {
        }
    };


    /*
        Message box
    */
    Covington.Message =
    {
        Init: function () {
            if (Covington.Message.CookiesOk() === false) {
                $("#cookies-message").addClass("open");
            }

            //Close on click
            $("#message-binder").on("click", function () {
                $(this).removeClass("open");
            });

            $(".message > .fa").on("click", function () {
                $(this).parent().removeClass("open");

                if ($(this).parent().attr("id") === "cookies-message")
                    Covington.Message.SetCookies();
            });
        },

        CookiesOk: function () {
            var cookies = document.cookie.split(";");

            for (var i = 0; i < cookies.length; i++) {
                var cookie = cookies[i];
                while (cookie.charAt(0) === ' ') cookie = cookie.substring(1, cookie.length)
                if (cookie.indexOf("cov.cookies") === 0) return true;
            }
            return false;
        },

        SetCookies: function () {
            var date = new Date();
            date.setDate(date.getDate() + (365 * 5));
            var expires = "expires=" + date.toGMTString();
            document.cookie = "cov.cookies=1; " + expires + "; path=/";
        }
    };



    /*
        Mobile navigation controls
    */
    Covington.Navigation =
    {
        Init: function () {
            //Add click handlers for menu
            $("#nav-open").on("click", function (e) {
                e.preventDefault();
                e.stopPropagation();

                $("body").toggleClass("nav-expanded");
            });

            //Add close handler to both button & body shade
            $("#nav-close, #nav-shade").on("click", function (e) {
                e.preventDefault();
                e.stopPropagation();

                $("body").removeClass("nav-expanded");
            });
        },

        GetDomainAuthority: function () {
            return GetDomain();
        }
    };


    /*
        Mobile search controls
    */
    Covington.Search =
    {
        Init: function () {
            //Add click handlers to mobile-search
            $("#mobile-search-open, #mobile-search-close").on("click", function (e) {
                e.preventDefault();
                e.stopPropagation();

                $("body").toggleClass("search-open");
            });

            $('.navbar .search-input, .search-again .search-input').on("keypress", function (event) {
                var keycode = (event.keyCode ? event.keyCode : event.which);
                if (keycode === 13) {
                    event.preventDefault();
                    event.stopPropagation();
                    var $searchButton = $($(this).siblings(".btn-search"));
                    if ($searchButton.length === 0) {
                        $searchButton = $($(this).parent().siblings(".btn-search"));      // html markup may differ in this scenario, check for parent
                    }

                    Covington.Search.RedirectToSearch($searchButton[0].getAttribute("data-endpoint"), $searchButton[0].getAttribute("data-qs-key"), encodeURIComponent($(this).val()));
                }
            });

            $(".btn-search").on("click", function () {
                Covington.Search.RedirectToCoveoSearch($(this).attr("data-endpoint"), $(this).attr("data-qs-key"), Covington.Search.GetSearchValue());
            });

            $(".btn-pros-search").on("click", function () {
                Covington.Search.RedirectToCoveoSearch($(this).attr("data-endpoint"), $(this).attr("data-qs-key"), Covington.Search.GetLawyerSearchValue());
            });

            $(".search-popup-mobile").keydown(function (e) {
                if (e.keyCode == 13) {
                    var $searchButton = $("#popup-search-mobile-btn");

                    Covington.Search.RedirectToCoveoSearch($searchButton.attr("data-endpoint"), $searchButton.attr("data-qs-key"), Covington.Search.GetSearchValue());
                }
            });

            $(".search-popup-desktop").keydown(function (e) {
                if (e.keyCode == 13) {
                    var $searchButton = $("#popup-search-desktop-btn");

                    Covington.Search.RedirectToCoveoSearch($searchButton.attr("data-endpoint"), $searchButton.attr("data-qs-key"), Covington.Search.GetSearchValue());
                }
            });

            $("#professionalsSearch").keydown(function (e) {
                if (e.keyCode == 13) {
                    var $searchButton = $("#popup-pros-search-desktop-btn");

                    Covington.Search.RedirectToCoveoSearch($searchButton.attr("data-endpoint"), $searchButton.attr("data-qs-key"), Covington.Search.GetLawyerSearchValue());
                }
            });
        },

        RedirectToSearch: function (endpoint, querystringKey, term) {
            var currentDomain = Covington.Navigation.GetDomainAuthority();
            location.href = String.format("{0}{1}?{2}={3}", currentDomain, endpoint, querystringKey, term);
        },

        RedirectToCoveoSearch: function (endpoint, querystringKey, term) {
            var currentDomain = Covington.Navigation.GetDomainAuthority();
            location.href = String.format("{0}{1}#{2}={3}", currentDomain, endpoint, querystringKey, term); 
        },

        GetSearchValue: function () {
            var searchVal = $(this).siblings(".search-input").val();

            if (searchVal === undefined) {
                searchVal = $(this).siblings(".search-input-wrap").find(".search-input").val();
                //Handles redesigned global search functionality
                if (!searchVal || searchVal === undefined) {
                    searchVal = $(".search-popup-desktop").val();
                }

                if (!searchVal || searchVal === undefined) {
                    searchVal = $(".search-popup-mobile").val();
                }
            }
            
            return searchVal;
        },

        GetLawyerSearchValue: function () {
            var searchVal;

            if ($("#professionalsSearch")) {
                searchVal = $("#professionalsSearch").val();

                if (searchVal) {
                    return searchVal;
                }
            }
            
            return "";
        }
    };


    /*
        Widget/collapse
    */
    Covington.Widgets =
    {
        Init: function () {
            //Add toggles to widgets
            $(".widget-toggle").on("click", function (e) {
                if (window.innerWidth > 992) {
                    e.preventDefault();
                    e.stopPropagation();
                    return;
                }
            });

            //Close opened collapse elements on resize
            $(window).on("resize", function () {
                if (window.innerWidth > 992) {
                    $(".collapse").removeAttr("style");
                }
            });

            //Pass through clicks from header to more-arrows
            $(".widget-header-show-arrows h2").on("click", function (e) {
                $(this).siblings(".more-links").children(".more-link.show").click()
            })


            //jQuery('#morenews').on("click", function () {

            //    alert(jQuery(this).data('expanded'));
            //});

        }
    };


    /*
        Professionals/vCard widget
    */
    Covington.Vcard =
    {
        Init: function () {
            //Toggle professionals vcard-widget view
            $(".vcard-view-toggle").on("click", function (e) {
                e.preventDefault();
                e.stopPropagation();

                var $this = $(this);
                var $target = $($this.data("target"));

                var addClass = $this.data("add");
                var removeClass = $this.data("remove");

                if (typeof addClass !== "undefined")
                    $target.addClass(addClass);

                if (typeof removeClass !== "undefined")
                    $target.removeClass(removeClass);

                $(".vcard-view-toggle").removeClass("selected");
                $this.addClass("selected");
            });
        }
    };

    /*
        More Links
    */
    Covington.MoreLinks =
    {
        expandMoreLinks: function () {
            $(".collapse").collapse('show');
            $(".more-expand").removeClass("show");
            $(".more-contract").addClass("show");
        },

        getParameterByName: function (name) {
            var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
            return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
        },

        expandAllIndustries: function () {
            jQuery(".more-link.more-practices").on("click", function (e) {
                //Check for all expanded and all contracted
                if (jQuery(".more-expand.show").length === 4) {
                    jQuery(".more-all .more-close").removeClass("show");
                    jQuery(".more-all .more-open").addClass("show");
                }
                if (jQuery(".more-contract.show").length === 4) {
                    jQuery(".more-all .more-close").addClass("show");
                    jQuery(".more-all .more-open").removeClass("show");
                }
            });
        },

        vcardDetailExpand: function () {
            if (jQuery("#attorney-bio-more").length === 1) {
                jQuery(".more-link").on("click", function () {
                    if (jQuery(".body .more-contract.show").length === 0) {
                        jQuery(".body.more-expand").addClass("show");
                        jQuery(".body.more-contract").removeClass("show");
                    }
                    else if (jQuery(".body .more-expand.show").length === 0) {
                        jQuery(".body.more-contract").addClass("show");
                        jQuery(".body.more-expand").removeClass("show");
                    }
                });
            }
        },

        Init: function () {
            //Change styling for more-links on click
            $(".more-link").on("click", function (e) {
                $(this).removeClass("show");
                $(this).siblings(".more-link").addClass("show");
            });

            var expand = Covington.MoreLinks.getParameterByName('expand');
            if (expand === 1) Covington.MoreLinks.expandMoreLinks();

            Covington.MoreLinks.expandAllIndustries();
            Covington.MoreLinks.vcardDetailExpand();
        }
    };



    /*
        Add To Binder
    */



    /*
        Sidebar Filters
    */

    // * MOVED INTO /assets/js/covington/covington.searchfilter.js
    //Covington.Filters =
    //{
    //	Init: function() {
    //		//Sidebar-filter functionality
    //		$(".sidebar-search-filter").on("click", function (e) {
    //			e.preventDefault();
    //			e.stopPropagation();

    //			var $this = $(this);
    //			var $target = $($this.data("target"));

    //			if ($this.hasClass("selected"))
    //				return;

    //			$this.addClass("selected");
    //			$target.addClass("active");

    //			var closeButton = $("<span>").addClass("fa fa-times");
    //			var filterTag = $("<span>")
    //				.html($this.html())
    //				.addClass("sidebar-filter")
    //				.append(closeButton)
    //				.data("source", $this)
    //				.click(Covington.Filters.RemoveFilter);

    //			$target.append(filterTag);
    //		});
    //	},

    //	RemoveFilter: function (e) {
    //		e.preventDefault();
    //		e.stopPropagation();

    //		var $this = $(this);

    //		if ($this.siblings().length === 0)
    //			$this.parent().removeClass("active");

    //		$($this.data("source")).removeClass("selected");
    //		$this.remove();
    //	}
    //};


    /*
        Listing Items
    */
    Covington.Listing =
    {
        Init: function () {
            //Remove listing items
            $(".listing-remove").on("click", function () {
                var $item = $(this).parents(".listing-item");
                var $section = $item.parents(".widget");

                $item.remove();

                //Check for empty section
                if ($section.find(".listing-item").length === 0)
                    $section.remove();
            })
        }
    };



    /*
        FTimes Fastclick
    */
    Covington.Fastclick =
    {
        Init: function () {
            //Initialise fastclick.js on links
            //.min.js version:
            //Origami.fastclick("a")
            FastClick.attach(document.body);
        }
    };


    /*
        DDSlick <select> replacement for cross-browser styling
    */
    Covington.Ddslick =
    {
        Init: function () {
            //Initialise ddSlick
            $(".dd-slick").ddslick({
                background: "",
                height: "",
                width: "",
                onSelected: function (data) {
                    Covington.Ddslick.Default(data);

                    if ((data.original.attr("id") === "ddlSortOrder")) {
                        Covington.Ddslick.ChangeSortOrder(data);
                    }
                }
            });
            $("body").removeClass("no-js");
        },

        Default: function (data) {
            if (data.selectedIndex !== 0)
                $(data.selectedItem[0]).parents(".dd-container").addClass("selected")
            else
                $(data.selectedItem[0]).parents(".dd-container").removeClass("selected")
        },

        ChangeSortOrder: function (data) {
            covington.lawyersearch.redirectWithOrdering(data.selectedData.value);
        }
    };


    /*
        Twitter Typeahead styling
    */

    Covington.Typeahead =
    {
        Sources: {
            sitemap: ["About", "About Us", "Aerospace", "Africa", "Biographies", "Careers", "Contact Us", "Diversity", "Europe", "Excellence in Law", "Find a professional", "Firm Overview", "Global Reach", "Latin America",

"London", "Middle East", "New York", "News & Insights", "No Jurisdiction", "Offices", "Pro Bono", "Quango Law", "Regulatory & Government Affairs", "Seoul", "Zoning Ordinances"]
        },

        sitemapSearch: function () {

            if (jQuery('#sitemap-search .typeahead').length > 0) {
                jQuery.ajax({
                    url: Covington.Navigation.GetDomainAuthority() + '/services/typeahead.asmx/GetSitemap',
                    type: "POST",
                    cache: true,
                    contentType: "application/json; charset=utf-8",
                    data: "{}",
                    dataType: "json",
                    async: true,
                    success: function (data) {
                        //console.log('typeahead sitemap success');
                        var sitemapEntries = JSON.parse(data.d);
                        //console.log(sitemapEntries);
                        jQuery('#sitemap-search .typeahead').typeahead({
                            highlight: true,
                            hint: true,
                            minLength: 1,
                            limit: 20,
                        }, {
                            name: 'sitemapEntries',
                            source: Covington.Typeahead.SubstringMatcher(sitemapEntries)
                        });
                        //console.log('bound typeahead sitemap');
                    },
                    error: function (e) {
                        //console.log(e.message);
                        if (document.getElementById("json"))
                            document.getElementById("json").innerHTML = 'error';
                    }
                });
            }
        },

        loadPractices: function () {

            if (jQuery('#prefetch .typeahead').length > 0) {
                jQuery.ajax({
                    url: Covington.Navigation.GetDomainAuthority() + '/covapi/typeahead/GetPracticesAndIndustries',
                    type: "GET",
                    cache: true,
                    dataType: "json",
                    async: true,
                    success: function (data) {
                        var practices = JSON.parse(data);
                        jQuery('#prefetch .typeahead').typeahead({
                            highlight: true,
                            hint: true,
                            minLength: 1,
                            limit: 20
                        }, {
                            name: 'industries',
                            source: Covington.Typeahead.SubstringMatcher(practices)
                        });
                    },
                    error: function (e) {
                        document.getElementById("json").innerHTML = 'error';
                    }
                });
            }
        },

        loadBiographies: function () {

            var skipKey = true;
            if (jQuery('.lawyerprefetch .typeahead').length > 0) {


                $(document).on("keypress", function (event) {

                    if (event.keyCode == 8) {
                        skipKey = true
                    }
                    else {

                        skipKey = false;
                    }

                });

                var lawyerSearch = $('#TxtLawyerSearch.typeahead');

                if (lawyerSearch.length == 0) {
                    lawyerSearch = $('#professionalsSearch.typeahead');
                }

                lawyerSearch.bind('typeahead:render', function (ev, suggestion) {
                    var selector = ".tt-dataset.tt-dataset-0 > .tt-suggestion.tt-selectable";

                    if (jQuery(selector).length == 1) {
                        var result = jQuery('.tt-suggestion.tt-selectable')[0];
                        if (result != undefined && result != null) {
                            var input = jQuery("#TxtLawyerSearch");

                            if (input.length == 0) {
                                input = jQuery('#professionalsSearch');
                            }

                            console.log(skipKey)

                            if (result.innerText == input.val() || skipKey) {
                                //do nothing.. maybe something later..
                                skipKey = true;
                            }
                            else {
                                input.blur();
                                result.click();

                                var btn = undefined;

                                if ($('#professional_search button').length == 1) {
                                    btn = $('#professional_search button');
                                }
                                else if ($('.lawyer-search-submit.btn').length == 1) {
                                    btn = $('.lawyer-search-submit.btn');
                                }

                                if (btn !== undefined && btn.length > 0) {
                                    btn.focus();

                                }
                            }
                        }
                    }
                });

                jQuery.ajax({
                    url: Covington.Navigation.GetDomainAuthority() + '/covapi/typeahead/getbiographies',
                    type: "GET",
                    cache: true,
                    dataType: "json",
                    async: true,
                    success: function (data) {
                        var biographies = JSON.parse(data);
                        var charMap = {
                            "à": "a",
                            "á": "a",
                            "â": "a",
                            "é": "e",
                            "è": "e",
                            "ç": "c",
                            "ê": "e",
                            "ë": "e",
                            "É": "e",
                            "ï": "i",
                            "î": "i",
                            "í": "i",
                            "ì": "i",
                            "ô": "o",
                            "ö": "o",
                            "ó": "o",
                            "ò": "o",
                            "û": "u",
                            "ù": "u",
                            "ü": "u",
                            "ú": "u",
                            "ñ": "n",
                            "ý": "y",
                            "ã": "a",
                            "õ": "o",
                            "ä": "a",
                            "ÿ": "y"
                        };

                        var normalize = function (input) {
                            $.each(charMap, function (unnormalizedChar, normalizedChar) {
                                var regex = new RegExp(unnormalizedChar, 'gi');
                                input = input.replace(regex, normalizedChar);
                            });
                            return input;
                        };

                        var queryTokenizer = function (q) {
                            var normalized = normalize(q);
                            return Bloodhound.tokenizers.whitespace(normalized);
                        };

                        // prioritize matches at the beginning
                        var sorter = function (a, b) {
                            var lawyerSearch = $("#TxtLawyerSearch").val();

                            if (!lawyerSearch || lawyerSearch === undefined) {
                                lawyerSearch = $("#professionalsSearch").val();
                            }

                            var searchTerm = lawyerSearch.toLowerCase();
                            return a.value.toLowerCase().indexOf(searchTerm) - b.value.toLowerCase().indexOf(searchTerm);
                        }

                        var nombres = new Bloodhound({
                            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
                            queryTokenizer: queryTokenizer,
                            sorter: sorter,
                            local: $.map(biographies, function (name) {
                                // Normalize the name - use this for searching
                                var normalized = normalize(name);
                                return {
                                    value: normalized,
                                    // Include the original name - use this for display purposes
                                    displayValue: name
                                };
                            })
                        });

                        nombres.initialize();
                        var wasFocused = $('.lawyerprefetch .typeahead').is(":focus");
                        $('.lawyerprefetch .typeahead').typeahead({
                            minLength: 1,
                            hint: true,
                            highlight: true,
                            caseSensative: false

                        }, {
                            displayKey: 'displayValue',
                            source: nombres.ttAdapter()
                        });
                        if(wasFocused){
                            $('.lawyerprefetch .typeahead').trigger("focus");
                        }


                    },
                    error: function (e) {
                        //console.log(e);
                    }


                });
            }
        },

        //Custom string matcher for local typeahead implementation
        SubstringMatcher: function (strs) {
            return function findMatches(q, cb) {
                var matches, substrRegex;

                // an array that will be populated with substring matches
                matches = [];

                // regex used to determine if a string contains the substring `q`
                substrRegex = new RegExp(q, 'i');

                // iterate through the pool of strings and for any string that
                // contains the substring `q`, add it to the `matches` array
                $.each(strs, function (i, str) {
                    if (substrRegex.test(str)) {
                        matches.push(str);
                    }
                });

                cb(matches);
            };
        },
        Init: function () {
            Covington.Typeahead.loadPractices();
            Covington.Typeahead.loadBiographies();
            Covington.Typeahead.sitemapSearch();
        }
    };


    /*
        Modal/Popup functionality
    */
    Covington.Modal =
    {
        Init: function () {
            if (typeof Sitecore !== "undefined")
                return;

            $(".modal-open").on("click", function (e) {
                e.preventDefault();
                e.stopPropagation();

                var targetModal = $(this).attr("href");
                $(targetModal).addClass("in");
                $(document).on("keyup", Covington.Modal.ListenForEsc);
            });

            $(".close-modal").on("click", function (e) {
                e.preventDefault();
                e.stopPropagation();

                $(".modal.in").removeClass("in");
            });

            $(".modal").on("click", function (e) {
                if (e.target.className !== "modal in" && e.target.className !== "modal" && e.target.className !== "modal-video")
                    return

                var $this = $(this);
                $this.removeClass("in");

                //Pause video if playing
                playerInstance.pause(true);
            });
        },

        ListenForEsc: function (e) {
            if (e.keyCode) {
                $(document).off("keyup", Covington.Modal.ListenForEsc);
                $(".modal.in").click();
            }
        }
    };

    Covington.BacktoLinks =
        {
            Init:
                function () {
                    jQuery('a.back-link-hook').on('click', function () {
                        window.history.back();
                    });
                    //jQuery('a.back-link-hook').each(function () {
                    //    if (window.location.href != document.referrer) {
                    //        this.href = window.history.back();
                    //        jQuery(this).show();
                    //    }
                    //    else {
                    //        jQuery(this).hide();
                    //    }

                    //});
                }
        };


    Covington.RepMatters =
        {
            Init:
                function () {
                    var ua = window.navigator.userAgent;
                    var msie = ua.indexOf("MSIE ") > 0 || ua.indexOf("rv:11.0") > 0;
                    var reps = jQuery('[data-rep-id]');
                    if (reps.length > 0) {

                        for (var i = 0; i < reps.length; i++) {

                            //if (msie && i === 50) { for Internet Explorer, limit the number of rep matters to 50
                            //    break;
                            //}

                            if (i === 350) {//for other browsers, limit the number of rep matters to 350
                                break;
                            }

                            var id = jQuery(reps[i]).attr('data-rep-id')
                            if (id.length > 0) {
                                repIds += ((i !== 0) ? "|" : "") + id;
                            }
                        }
                    }
                }
        };

    /*
        Main code execution entry point
    */

   Covington.RecentlyViewed = {
       Professionals: {
           Descriptor: "Recently Viewed Lawyers",
           CssSelector: ".lawyer-info-attributes",
           LocalStorageKey: "recentlyViewedProfessionals",
           BuildFromDataAttributes: function(element) {
                return {
                    Id: element.dataset.id,
                    Url: element.dataset.url,
                    FullName: element.dataset.name,
                    Photo: element.dataset.photo,
                    LevelsDescription: element.dataset.levelsDescription,
                    LifestylePhoto: element.dataset.lifestylePhoto,
                    Phone1: element.dataset.phone1,
                    Phone2: element.dataset.phone2,
                    Email1: element.dataset.email1,
                    Email2: element.dataset.email2,
                    PrimaryOffice: element.dataset.primaryOffice,
                    OtherOffice: element.dataset.otherOffice
                };
           },
           MaxItems: 2
       },
       PracticeAndIndustries : {
           Descriptor: "Recently Viewed Practices and Industries",
           CssSelector: ".practice-industry-info-attributes",
           LocalStorageKey: "recentlyViewedPracticesIndustries",
           BuildFromDataAttributes: function(element) {
                return {
                    Id: element.dataset.id,
                    Url: element.dataset.url,
                    Name: element.dataset.name
                };
           },
           MaxItems: 3
       },
   }

   Covington.UpdateRecentlyViewed = function(recentlyViewedType){
        var itemsOnPage = []
        $(recentlyViewedType.CssSelector).each(function(index, element){
            var itemFromDom = recentlyViewedType.BuildFromDataAttributes(element);
            itemFromDom.ViewingTime = new Date().getTime();
            itemsOnPage.push(itemFromDom);
        });
       
        var previousRecentlyViewedJson = localStorage.getItem(recentlyViewedType.LocalStorageKey);
        var recentlyViewed = [];
        if(previousRecentlyViewedJson){
            try{
                var recentlyViewedParsed = JSON.parse(previousRecentlyViewedJson);
                if(Array.isArray(recentlyViewedParsed)){
                    recentlyViewed = recentlyViewedParsed;
                }
            }
            catch(error){
                console.log('Failed to deserialize ' + recentlyViewedType.Descriptor + ' ' + error.toString());
            }
        }
        recentlyViewed = recentlyViewed.concat(itemsOnPage);
        recentlyViewed = recentlyViewed.sort(function(item1, item2){
            return item2.ViewingTime - item1.ViewingTime;
        });

        var recentlyViewedDictionary = {}
        // remove duplicates by item id
        recentlyViewed.forEach((el, index) => recentlyViewedDictionary[el.Id] = el);

        recentlyViewed = Object.values(recentlyViewedDictionary);
        recentlyViewed = recentlyViewed.length > recentlyViewedType.MaxItems ? recentlyViewed.slice(0, recentlyViewedType.MaxItems) : recentlyViewed;
        localStorage.setItem(recentlyViewedType.LocalStorageKey, JSON.stringify(recentlyViewed));
   }


    $(document).ready(function () {
        if (typeof (Storage) !== "undefined") {
            Covington.UpdateRecentlyViewed(Covington.RecentlyViewed.Professionals);
            Covington.UpdateRecentlyViewed(Covington.RecentlyViewed.PracticeAndIndustries);
        }
        else {
            console.log("Local storage / recently viewed not supported.");
        }

        var position = covington.querystring.getParameterByName('sp');
        if (position > 0) {
            window.scrollBy(0, position);
        }

        $("a.prevent-default").on("click", function (e) {
            e.preventDefault();
        });

        if (jQuery('a[data-showall]').length == 0) {
            jQuery('#viewfullbio').remove();
        }
        else {
            jQuery('#viewfullbio').show()
        }

        if (jQuery('.appendQuery').length > 0) {
            jQuery('.appendQuery').each(function () {
                if (this.href != undefined && location.search !== undefined) {
                    if (location.search[0] === "?" && !location.search.indexOf("?action=search") === 0) {
                        this.href = this.href + "?action=search&" + location.search.substring(1);
                    }
                    else {
                        this.href = this.href + location.search;
                    }
                }
            });
        }

        //Call Frontend files first
        Covington.Modernizr.Init();

        //Hook up layout elements
        Covington.Base.Init();
        Covington.Message.Init();
        Covington.Navigation.Init();
        Covington.Search.Init();
        Covington.Widgets.Init();
        Covington.Vcard.Init();
        Covington.MoreLinks.Init();
        //Covington.AddToBinder.Init();
        //Covington.Filters.Init();
        Covington.Modal.Init();
        Covington.Listing.Init();
        Covington.RepMatters.Init();
        //Call external frameworks
        Covington.Fastclick.Init();
        Covington.Ddslick.Init();
        Covington.Typeahead.Init();
        Covington.BacktoLinks.Init();

        if (covington.querystring.getParameterByName("show") === "true") {
            Covington.MoreLinks.expandMoreLinks();
        }

        // Coveo Last Initial Search Fix
        jQuery(document).on('click', '.CoveoCovingtonLastInitialList a', function (initialClickEvent) {
            initialClickEvent.preventDefault();
            initialClickEvent.stopPropagation();
            initialClickEvent.stopImmediatePropagation();
            
            var lastInitialFacetElement = document.getElementById('coveoffdea020');
            var letter = $(this).data('letter');

            var lastInitialFacet = Coveo.get(lastInitialFacetElement);
            lastInitialFacet.reset();
            lastInitialFacet.selectValue(letter);

            var professionalsSearchInterface = document.getElementById('coveoe2d6f19f');
            Coveo.executeQuery(professionalsSearchInterface);
        });

        jQuery(".sidebar-item-collapse").on("click", function () {
        	$(this).toggleClass("no-border");
        });
        $('#alertsFrame').on('load', function () {
            $('html, body').animate({ scrollTop: 0 }, 'slow');
        });

        //add Google tracking code to all links with the class "tracked"
        var ext_links = $("a.tracked");
        [].forEach.call(ext_links, function (a) {
            a.addEventListener('click', function () {
                var url = a.href;
                ga('send', 'event', 'outbound', 'click', url);
            });
        });

		$("#onetrust-accept-btn-handler, #accept-recommended-btn-handler, .save-preference-btn-handler.onetrust-close-btn-handler").on("click", function(){
			$.ajax({
            url: '/api/sitecore/cookieconsent/getcookieconsent',
            type: 'GET',
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (result) {
            }
        });

		});

        CheckVisitor();
    });

})(jQuery);

function UpdateCounter(potential, total) {
    jQuery(potential).toggle();
    jQuery(total).toggle();
}

function CountRepAndNews() {
    console.log('Repmatters: ' + (jQuery('#matters-init .widget-subitem').length + jQuery('#matters-more .widget-subitem').length));
    console.log('News & Insights: ' + (jQuery('#news-init .widget-item').length + jQuery('#news-more .widget-item').length));
    return true;
}


function CheckVisitor() {
    var visitorId = document.cookie.match('(^|;)\\s*' + 'visitor_id955523' + '\\s*=\\s*([^;]+)')?.pop() || '';
    //console.log("Found visitorId", visitorId);

    if(visitorId != '') {
		jQuery.ajax({
            url: '/api/sitecore/visitoridsync/visitoridlookup?visitorid=' + visitorId,
            type: 'GET',
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (result) {
                if(window.dataLayer && result.ProspectID) {
                    dataLayer.push({"prospectid": result.ProspectID });
                }
                    
//                if(!result.ProspectID) {
//                    console.log("not a prospect");    
//                }
            }
        });
    }
}
;
var covington = covington || {};
covington.binder = covington.binder || {};
var bcn = "cov.binder";
var bcv = [];

covington.binder =
    {
        pdfEndpoint: "/services/pdf.asmx/GeneratePdf?ids={0}&langs={2}&filename={1}",
        mailpdfEndpoint: "/services/pdf.asmx/GeneratePdf?ids={0}%26langs={2}%26filename={1}",
        wordEndpoint: "/services/wordgenerator.asmx/GenerateWordDocument?id={0}&lang={1}",
        mailEndpoint: "mailto:?subject={0}&body={1}{2}",

        init: function () {
            if (covington.binder.readBinder() !== '') {
                bcv = JSON.parse(covington.binder.readBinder());
            }
        },

        utilEvents: function () {

            jQuery(".add-to-binder").on("click", function (e) {
                e.preventDefault();
                e.stopPropagation();

                jQuery(".add-to-binder.open").removeClass("open");
                jQuery(".atb-control-shade").addClass("show");
                jQuery(this).toggleClass("open");
            });

            jQuery(".atb-control-shade").on("click", function (e) {
                jQuery(this).removeClass("show");
                jQuery(".add-to-binder.open").removeClass("open");
            });
        },

        binderPdfClick: jQuery(".generate-pdf, .generate-mailto").on("click", function (e) {
            e.preventDefault();
            e.stopPropagation();

            //get page id
            var ids = this.getAttribute('data-id'),
                filename = this.getAttribute('data-filename'),
                lang = this.getAttribute('data-lang'),
                mailToSubject = this.getAttribute('data-mailto-subject'),
                pdfEndpoint = String.format(covington.binder.pdfEndpoint, ids, filename, lang),
                mailpdfEndpoint = String.format(covington.binder.mailpdfEndpoint, ids, filename, lang);

            if (jQuery(this).hasClass("generate-pdf")) {
                //console.log(pdfEndpoint);
                jQuery.redirectPost(pdfEndpoint, { reps: repIds });
            }
            else {
                var currentWindowLocation = window.location.origin;

                if (currentWindowLocation === undefined) {
                    currentWindowLocation = window.location.protocol + "//" + window.location.host;
                }
                location.href = String.format(covington.binder.mailEndpoint, mailToSubject, currentWindowLocation, mailpdfEndpoint);
            }
        }),

        binderWordClick: jQuery('a.generate-word').on('click', function (e) {
            e.preventDefault();
            e.stopPropagation();

            //get page id
            var id = this.getAttribute('data-id'),
                lang = this.getAttribute('data-lang'),
                endpoint = String.format(covington.binder.wordEndpoint, id, lang);

            if (jQuery(this).hasClass("generate-word")) {
                //console.log(endpoint);
                jQuery.redirectPost(endpoint, { reps: repIds });
            }

        }),

        addToBinder: jQuery(".addtobinder").on("click", function (e) {
            e.preventDefault();
            e.stopPropagation();

            //get page id
            var id = this.getAttribute('data-id'),
                lang = this.getAttribute('data-lang');

            //check if we have page id
            if (id !== null || id !== '') {

                if (covington.binder.readBinder() !== '') {
                    bcv = JSON.parse(covington.binder.readBinder());
                }

                if (JSON.stringify(bcv).indexOf(id) > -1) {
                    covington.binder.openMessage('#message-binder-failed');
                    return;
                }

                var binderItem = {
                    "id": id,
                    "lang": lang
                };

                //add id to array
                bcv.push(binderItem);

                if (bcv.length > 40) {
                    covington.binder.openMessage('#message-binder-full');
                    return;
                }

                //check if cookie is there
                if (covington.binder.checkBinder()) {

                    //update it with new ID
                    if (covington.binder.updateBinder(JSON.stringify(bcv))) {
                        covington.binder.openMessage('#message-binder');
                        covington.binder.updateBinderCount();
                        jQuery(".atb-pdf").hide();
                        jQuery(".atb-word").hide();
                    }
                    else {
                        covington.binder.openMessage('#message-binder-failed');
                    }
                }
                else {
                    //craete it with ID
                    if (covington.binder.createBinder(JSON.stringify(bcv))) {
                        covington.binder.openMessage('#message-binder');
                        covington.binder.updateBinderCount();
                        jQuery(".atb-pdf").hide();
                        jQuery(".atb-word").hide();
                    }
                    else {
                        covington.binder.openMessage('#message-binder-failed');
                    }
                }

                jQuery('.atb-control-shade').click();

            }
        }),

        checkBinder: function () {
            //check for cookie
            return document.cookie.indexOf(bcn) != -1;
        },

        updateBinder: function ($value) {

            //if value is already in cookie return false
            if (covington.binder.readBinder().indexOf($value) >= 0) {
                return false;
            }

            covington.binder.createBinder($value, 365);

            return true;
        },

        createBinder: function ($value, $expire) {

            document.cookie = bcn +
                '=' +
                $value +
                ';expires=' + new Date(new Date().setDate($expire)) +
                ';path=/';

            return true;
        },

        readBinder: function () {
            var name = bcn + '=';
            var ca = document.cookie.split(';');
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i];
                while (c.charAt(0) == ' ') c = c.substring(1);
                if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
            }
            return '';
        },

        removeItem: function ($item) {

            //refresh cookie to get tru value
            if (covington.binder.readBinder() !== '') {
                bcv = JSON.parse(covington.binder.readBinder());
            }
            else {
                return false;
            }

            if ($item == null || $item == '') {
                return false;
            }

            if (JSON.stringify(bcv).indexOf($item) > -1) {
                for (var i = 0; i < bcv.length; i++) {
                    if (bcv[i].id === $item) {
                        bcv.splice(i, 1);
                    }
                }

                covington.binder.updateBinder(JSON.stringify(bcv), 365);
            }

            covington.binder.updateBinderCount();

            //reload to correct binder mail link
            location.reload();
        },

        deleteBinder: function () {
            bcv = [];
            return covington.binder.createBinder(JSON.stringify(bcv), -1);
        },

        openMessage: function ($target) {
            if ($target === "#message-binder-failed") {
                jQuery('#message-binder').removeClass('open')
            }
            jQuery($target).addClass('open');
        },

        updateBinderCount: function () {
            jQuery('.binder-counter').each(function () {
                jQuery(this).html(bcv.length);
            });
        }
    }

jQuery.extend(
{
    redirectPost: function(location, args)
    {
        var form = jQuery("<form></form>");
        form.attr("method", "post");
        form.attr("action", location);

        jQuery.each(args, function (key, value) {
            var field = jQuery("<input></input>");

            field.attr("type", "hidden");
            field.attr("name", key);
            field.attr("value", value);

            form.append(field);
        });
        jQuery(form).appendTo("body").submit();
    }
});

jQuery(document).ready(function () {
    covington.binder.init();
    covington.binder.utilEvents();
});


;
var covington = covington || {};
covington.vcard = covington.vcard || {};

covington.vcard =
{
    endpoint: "{0}/services/vcard.asmx/GenerateVCard?id={1}",

    init: function () {
        jQuery(".vcard-download").on("click", function (e) {
            e.preventDefault();
            e.stopPropagation();
            covington.vcard.generateVCard(jQuery(this)[0].getAttribute("data-id"));
        });
    },

    generateVCard: function (id) {
        if (id !== "") {
            var currentDomain = GetDomain();
            location.href = String.format(this.endpoint,currentDomain, id);
        }
    }
}


jQuery(document).ready(function () {
    covington.vcard.init();
});
;
function SendContactMail(email, subject) {
    
    while (email.indexOf(".") != -1)
        email = email.replace(".", "%2E");
    var subj = '';
    if (subject != '')
        subj = '&subject=' + subject;
    var BaseOptions = 'width=400,height=330,status=no,scrollbars=yes,resizeable=yes';
    var win = window.open(GetDomain() + '/services/email.aspx?email=' + email + subj, '_new', BaseOptions);

}

function SendToContact() {
    return SendToUrl('/en/contact-us');
}

function ChangeButtonForLink() {
    var device = navigator.userAgent;
    if (device.indexOf("Android") !== -1)
    {
        jQuery("#btnSubmit").attr("style", "display:none");
        jQuery("#lnkSubmit").attr("style", "display:inline");
    }
}

function RedirectToContact(redirectLink) {
    opener.location.href = redirectLink;
    window.close();
}

jQuery(document).ready(ChangeButtonForLink);;
var covington = covington || {};
covington.querystring = covington.querystring || {};

covington.querystring =
{
    getParameterByName: function (name) {
        name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
            results = regex.exec(location.search);
        return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    },

    getQuerystringVariables: function () {
        var match,
    		pl = /\+/g,  // Regex for replacing addition symbol with a space
    		search = /([^&=]+)=?([^&]*)/g,
    		decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
    		query = window.location.search.substring(1);

        urlParams = {};
        while (match = search.exec(query))
            urlParams[decode(match[1])] = decode(match[2]);

        return urlParams;
    }
};
/* #################### INFO TILE ANIMATIONS #################### */
var controller = new ScrollMagic.Controller();
var offsetHeight = ($(window).innerHeight() / 4) * -1;


/* ########## BOUCE UP ########## */
$('.info-tile').each(function () {
    var infoTileTween = TweenMax.from($(this), 1, { marginTop: 120, opacity: 0, ease: Elastic.easeOut.config(1, 0.75) });
    var infoTileScene = new ScrollMagic.Scene({
        triggerElement: this
    })
        .setTween(infoTileTween)
        .addTo(controller);
    if (window.innerWidth >= 768) {
        infoTileScene.offset(offsetHeight);
    } else {
        infoTileScene.offset(offsetHeight - 200);
    }
});


/* ########## NUMBERS OPACITY ########## */
$('.info-tile').each(function () {
    var numbersImgTween = TweenMax.from($(this).find('.info-tile--trials__number, .info-tile--appeals__number, .info-tile--global50__number, .info-tile--fort100__number, .info-tile--billion-valuation__number, .info-tile--lawyers__number, .info-tile--dozens__number'), 1, { opacity: 0 });
    if (numbersImgTween) {
        var numbersImgScene = new ScrollMagic.Scene({
            triggerElement: this
        })
            .setTween(numbersImgTween)
            .addTo(controller);
        if (window.innerWidth <= 767) {
            numbersImgScene.offset(offsetHeight - 100);
        } else {
            numbersImgScene.offset(offsetHeight + 50);
        }
    }
});


/* ########## NUMBER COUNT UP ########## */
/* ########## TRIALS */
var infoTrials = $('.info-tile--trials');
if (infoTrials.length > 0) {
    var trials = new ScrollMagic.Scene({
        triggerElement: '.info-tile--trials'
    })
    .setTween(function count() {
        var counterOne = { var: 30 };
        TweenMax.to(counterOne, 2.5, {
            ease: Power3.easeOut,
            var: 50,
            delay: 0,
            onUpdate: function () {
                $('.info-tile--trials__number').html(Math.ceil(counterOne.var));
            }
        });
    })
    .addTo(controller);
    trials.offset(offsetHeight);
}

/* ########## APPEALS */
var infoAppeals = $('.info-tile--appeals');
if (infoAppeals.length > 0) {
    var appeals = new ScrollMagic.Scene({
        triggerElement: '.info-tile--appeals'
    })
    .setTween(function count() {
        var counterOne = { var: 45 };
        TweenMax.to(counterOne, 2.5, {
            ease: Power3.easeOut,
            var: 80,
            delay: 0,
            onUpdate: function () {
                $('.info-tile--appeals__number').html(Math.ceil(counterOne.var));
            }
        });
    })
    .addTo(controller);
    appeals.offset(offsetHeight);
}

/* ########## FT GLOBAL 50 */
var infoGlobal = $('.info-tile--global50');
if (infoGlobal.length > 0) {
    var global50 = new ScrollMagic.Scene({
        triggerElement: '.info-tile--global50'
    })
    .setTween(function count() {
        var counterOne = { var: 22 };
        TweenMax.to(counterOne, 2.5, {
            ease: Power3.easeOut,
            var: 35,
            delay: 0,
            onUpdate: function () {
                $('.info-tile--global50__number').html(Math.ceil(counterOne.var));
            }
        });
    })
    .addTo(controller);
    global50.offset(offsetHeight);
}

/* ########## FORTUNE 100 */
var infoFort100 = $('.info-tile--fort100');
if (infoFort100.length > 0) {
    var fort100 = new ScrollMagic.Scene({
        triggerElement: '.info-tile--fort100'
    })
    .setTween(function count() {
        var counterOne = { var: 30 };
        TweenMax.to(counterOne, 2.5, {
            ease: Power3.easeOut,
            var: 50,
            delay: 0,
            onUpdate: function () {
                $('.info-tile--fort100__number').html(Math.ceil(counterOne.var));
            }
        });
    })
    .addTo(controller);
    fort100.offset(offsetHeight);
}

/* ########## BILLION VALUATION */
var infoBillionValuation = $('.info-tile--billion-valuation');
if (infoBillionValuation.length > 0) {
    var billionValuation = new ScrollMagic.Scene({
        triggerElement: '.info-tile--billion-valuation'
    })
    .setTween(function count() {
        var counterOne = { var: 400 };
        TweenMax.to(counterOne, 2.5, {
            ease: Power3.easeOut,
            var: 500,
            delay: 0,
            onUpdate: function () {
                $('.info-tile--billion-valuation__number').html(Math.ceil(counterOne.var));
            }
        });
    })
    .addTo(controller);
    billionValuation.offset(offsetHeight);
}

/* ########## LAWYERS */
var infoLawyers = $('.info-tile--lawyers');
if (infoLawyers.length > 0) {
    var lawyers = new ScrollMagic.Scene({
        triggerElement: '.info-tile--lawyers'
    })
    .setTween(function count() {
        var counterOne = { var: 900 };
        TweenMax.to(counterOne, 2.5, {
            ease: Power3.easeOut,
            var: 1000,
            delay: 0,
            onUpdate: function () {
                $('.info-tile--lawyers__number').html(Math.ceil(counterOne.var));
            }
        });
    })
    .addTo(controller);
    lawyers.offset(offsetHeight);
}


/* ########## DOZENS OF PRACTICES */
var infoDozens = $('.info-tile--dozens');
if (infoDozens.length > 0) {
    var dozens = new ScrollMagic.Scene({
        triggerElement: '.info-tile--dozens'
    })
    .setTween(function count() {
        var counterOne = { var: 0 };
        TweenMax.to(counterOne, 2.5, {
            ease: Power3.easeOut,
            var: 1,
            delay: 0,
            onUpdate: function () {
                $('.info-tile--dozens__number').html(Math.ceil(counterOne.var));
            }
        });
    })
    .addTo(controller);
    dozens.offset(offsetHeight);
}
;
// ###################################
// COVINGTON - Social Share JS                    
// ###################################



/* #################### GENERATE PDF FUNCTIONALITY #################### */
console.log("Starting ajax query (social share) at " + Date.now());

function generatePdfMobile() {
    var generatePdfMobileLink = jQuery('#generatePdfMobile');

    generatePdf(generatePdfMobileLink);
}

function generatePdf(pdfLink) {
    var e = e || window.event;
    var targ = e.target || e.srcElement || e;
    if (targ.nodeType == 3) targ = targ.parentNode; // defeat Safari bug

    e.preventDefault();
    e.stopPropagation();    

    if (!pdfLink) {
        pdfLink = jQuery('#generatePdf');
    }    

    if (pdfLink) {
//        jQuery.redirectPost('/api/sitecore/pdf/generatepdf?ids=' + pdfLink.attr('data-id') + '&langs=' + pdfLink.attr('data-lang') + '&filename=' + pdfLink.attr('data-filename'), {});
        
        var pdfEndpoint = String.format("/services/pdf.asmx/GeneratePdf?ids={0}&langs={2}&filename={1}", pdfLink.attr('data-id'), pdfLink.attr('data-filename'), pdfLink.attr('data-lang'));

        jQuery.redirectPost(pdfEndpoint, { });
    }
}



/* #################### PRINT WINDOW FUNCTIONALITY #################### */
var currentOrigin = window.location.origin;

function openprintwindow() {
    var socialShareContentUrl = jQuery('#socialShareContentUrl');

    if (socialShareContentUrl) {
        var socialShareContentUrlValue = socialShareContentUrl.val();

        if (socialShareContentUrlValue) {
            var myPath = socialShareContentUrlValue + "?show=true",
                myChar = (location.href.indexOf('?') !== -1) ? '&' : '?',
                mywindow = window.open(myPath, 'printwindow', 'menubar=yes, location=yes, scrollbars=yes, width=800, height=600 onload=window.print()');

            if (navigator.userAgent.indexOf('Firefox') !== -1) {
                self.setTimeout('mywindow.print()', 1000);
            }
            else {
                mywindow.print();
            }
        }
    }    
}

jQuery(document).ready(function () {
    jQuery('.widge.social-item a').click(function (e) {
        $goalname = jQuery(this).data("goal-trigger");
        $goalURL = currentOrigin + "/-/media/images/goals/whitepixel?sc_trk=" + $goalname;
        jQuery.get($goalURL);
    });

    jQuery('.email a').click(function (e) {
        $goalname = jQuery(this).data("goal-trigger");
        $goalURL = currentOrigin + "/-/media/images/goals/whitepixel?sc_trk=" + $goalname;
        jQuery.get($goalURL);
    });

    jQuery('.print a').click(function (e) {
        $goalname = jQuery(this).data("goal-trigger");
        $goalURL = currentOrigin + "/-/media/images/goals/whitepixel?sc_trk=" + $goalname;
        jQuery.get($goalURL);
    });
});
;
jQuery(document).ready(function () {

    if (typeof (Storage) !== "undefined") {
        setInterval(getRecentlyViewedProfessionals(), 7200000);
        setInterval(getRecentlyViewedPractices(), 7200000);
    } else {
        console.log("RecentlyViewed not supported due to lack of localStorage support.");
    }

    function getRecentlyViewedPractices() {
        var previousRecentlyViewedJson = localStorage.getItem('recentlyViewedPracticesIndustries');
        var recentlyViewedPracticeIndustries = [];
        if(previousRecentlyViewedJson){
            try{
                var recentlyViewedParsed = JSON.parse(previousRecentlyViewedJson);
                if(Array.isArray(recentlyViewedParsed)){
                    recentlyViewedPracticeIndustries = recentlyViewedParsed;
                }
            }
            catch(error){
                console.log('Failed to deserialize recentlyViewedPracticesIndustries.' + error.toString());
            }
        }
        if(recentlyViewedPracticeIndustries.length) {
            $.each(recentlyViewedPracticeIndustries, function (index, item) {
                if (item.Name) {
                    var anchor = jQuery('<a>').text(item.Name);
                    anchor.attr('href', item.Url);

                    var listItem = jQuery('<li>');
                    listItem.append(anchor);

                    jQuery('#practice-industry-recently-viewed').append(listItem).show();
                    jQuery('#practice-industry-recently-viewed-title').show();
                    jQuery('#practice-industry-no-recently-viewed').hide();
                }
            });
        } else {
            jQuery('#practice-industry-no-recently-viewed').show();
            jQuery('#practice-industry-recently-viewed-title').hide();
            jQuery('#practice-industry-recently-viewed').hide();
        }
    }

    function getRecentlyViewedProfessionals() {
        
        var previousRecentlyViewedJson = localStorage.getItem('recentlyViewedProfessionals');
        var recentlyViewedProfessionals = [];
        if(previousRecentlyViewedJson){
            try{
                var recentlyViewedParsed = JSON.parse(previousRecentlyViewedJson);
                if(Array.isArray(recentlyViewedParsed)){
                    recentlyViewedProfessionals = recentlyViewedParsed;
                }
            }
            catch(error){
                console.log('Failed to deserialize recentlyViewedProfessionals.' + error.toString());
            }
        }

        if(recentlyViewedProfessionals && recentlyViewedProfessionals.length > 0) {
            $.each(recentlyViewedProfessionals, function (index, item) {
                var professionalLi = jQuery('<li>');


                var anchor = jQuery('<a>');
                anchor.addClass('header__main__right__popup__professionals__image');
                anchor.attr('href', item.Url);

                var image = jQuery('<img>');

                if (item.LifestylePhoto) {
                    image.attr('src', item.LifestylePhoto);
                }
                else if (item.Photo) {
                    image.attr('src', item.Photo);
                }

                anchor.append(image);
                professionalLi.append(anchor);

                var div = jQuery('<div>');
                div.addClass('header__main__right__popup__professionals__info');

                if (item.FullName) {
                    var h5 = jQuery('<h5>');
                    h5.addClass('bold-heading');

                    if (item.Url) {
                        var anchor = jQuery('<a>').text(item.FullName);
                        anchor.attr('href', item.Url);
                        h5.append(anchor);
                    }

                    div.append(h5);
                }

                var ul = jQuery('<ul>');
                ul.addClass('unlisted');

                if (item.Phone1) {
                    var telephoneNumberLi = jQuery('<li>');

                    var telephoneNumberAnchor = jQuery('<a>');
                    telephoneNumberAnchor.text(item.Phone1);
                    telephoneNumberAnchor.attr('href', 'tel:' + item.Phone1);

                    telephoneNumberLi.append(telephoneNumberAnchor);
                    ul.append(telephoneNumberLi);
                }

                if (item.Email1) {
                    var emailAddressLi = jQuery('<li>');

                    var emailAddressAnchor = jQuery('<a>');
                    emailAddressAnchor.text(item.Email1);
                    emailAddressAnchor.addClass('hero__content__email__modal-trigger');
                    emailAddressAnchor.attr('href', 'mailto:' + item.Email1);

                    emailAddressLi.append(emailAddressAnchor);
                    ul.append(emailAddressLi);
                }

                div.append(ul);
                professionalLi.append(div);

                jQuery('#professionals-recently-viewed').append(professionalLi);

                $('.hero__content__email__modal-trigger').click(function (e) {
                    $('body').addClass('email-modal-open');
                    e.preventDefault();

                    var anchorTrigger = $(this).attr('href');

                    if (!anchorTrigger) {
                        anchorTrigger = $(this).find('a').attr('href');
                    }

                    $('#emailModalInput').attr('value', anchorTrigger);

                    return false;
                });

                jQuery('#professionals-no-recently-viewed').remove();
            });
        }
        else {
            // handle error / no results
            jQuery('#professionals-recently-viewed-container').remove();
        }
    }
})
;
// ###################################
// COVINGTON - Outdated Browser JS                    
// ###################################

/* #################### IE REDIRECT FUNCTIONALITY #################### */
$(document).ready(function() {
    if(window.location.href.indexOf("outdated-browser") == -1) {
       localStorage.setItem('internetExplorerRedirect', '');
    }

    var internetExplorerRedirect = localStorage.getItem('internetExplorerRedirect');

    if (!internetExplorerRedirect) {
        var rv;

        if (navigator.appName == 'Microsoft Internet Explorer')
        {
            var ua = navigator.userAgent;
            var re = new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})");
            if (re.exec(ua) != null)
                rv = parseFloat( RegExp.$1 );
        }
        else if (navigator.appName == 'Netscape')
        {
            var ua = navigator.userAgent;
            var re  = new RegExp("Trident/.*rv:([0-9]{1,}[\\.0-9]{0,})");
            if (re.exec(ua) != null)
                rv = parseFloat( RegExp.$1 );
        }

        localStorage.setItem('internetExplorerRedirect', true);
    
        if (rv) {
            window.location.href = "/outdated-browser";
        }
    }
});

;
