/*!
 * enquire.js v2.1.2 - Awesome Media Queries in JavaScript
 * Copyright (c) 2014 Nick Williams - http://wicky.nillia.ms/enquire.js
 * License: MIT (http://www.opensource.org/licenses/mit-license.php)
 */

; (function (name, context, factory) {
    var matchMedia = window.matchMedia;

    if (typeof module !== 'undefined' && module.exports) {
        module.exports = factory(matchMedia);
    }
    else if (typeof define === 'function' && define.amd) {
        define(function () {
            return (context[name] = factory(matchMedia));
        });
    }
    else {
        context[name] = factory(matchMedia);
    }
}('enquire', this, function (matchMedia) {

    'use strict';

    /*jshint unused:false */
    /**
     * Helper function for iterating over a collection
     *
     * @param collection
     * @param fn
     */
    function each(collection, fn) {
        var i = 0,
            length = collection.length,
            cont;

        for (i; i < length; i++) {
            cont = fn(collection[i], i);
            if (cont === false) {
                break; //allow early exit
            }
        }
    }

    /**
     * Helper function for determining whether target object is an array
     *
     * @param target the object under test
     * @return {Boolean} true if array, false otherwise
     */
    function isArray(target) {
        return Object.prototype.toString.apply(target) === '[object Array]';
    }

    /**
     * Helper function for determining whether target object is a function
     *
     * @param target the object under test
     * @return {Boolean} true if function, false otherwise
     */
    function isFunction(target) {
        return typeof target === 'function';
    }

    /**
     * Delegate to handle a media query being matched and unmatched.
     *
     * @param {object} options
     * @param {function} options.match callback for when the media query is matched
     * @param {function} [options.unmatch] callback for when the media query is unmatched
     * @param {function} [options.setup] one-time callback triggered the first time a query is matched
     * @param {boolean} [options.deferSetup=false] should the setup callback be run immediately, rather than first time query is matched?
     * @constructor
     */
    function QueryHandler(options) {
        this.options = options;
        !options.deferSetup && this.setup();
    }
    QueryHandler.prototype = {

        /**
         * coordinates setup of the handler
         *
         * @function
         */
        setup: function () {
            if (this.options.setup) {
                this.options.setup();
            }
            this.initialised = true;
        },

        /**
         * coordinates setup and triggering of the handler
         *
         * @function
         */
        on: function () {
            !this.initialised && this.setup();
            this.options.match && this.options.match();
        },

        /**
         * coordinates the unmatch event for the handler
         *
         * @function
         */
        off: function () {
            this.options.unmatch && this.options.unmatch();
        },

        /**
         * called when a handler is to be destroyed.
         * delegates to the destroy or unmatch callbacks, depending on availability.
         *
         * @function
         */
        destroy: function () {
            this.options.destroy ? this.options.destroy() : this.off();
        },

        /**
         * determines equality by reference.
         * if object is supplied compare options, if function, compare match callback
         *
         * @function
         * @param {object || function} [target] the target for comparison
         */
        equals: function (target) {
            return this.options === target || this.options.match === target;
        }

    };
    /**
     * Represents a single media query, manages it's state and registered handlers for this query
     *
     * @constructor
     * @param {string} query the media query string
     * @param {boolean} [isUnconditional=false] whether the media query should run regardless of whether the conditions are met. Primarily for helping older browsers deal with mobile-first design
     */
    function MediaQuery(query, isUnconditional) {
        this.query = query;
        this.isUnconditional = isUnconditional;
        this.handlers = [];
        this.mql = matchMedia(query);

        var self = this;
        this.listener = function (mql) {
            self.mql = mql;
            self.assess();
        };
        this.mql.addListener(this.listener);
    }
    MediaQuery.prototype = {

        /**
         * add a handler for this query, triggering if already active
         *
         * @param {object} handler
         * @param {function} handler.match callback for when query is activated
         * @param {function} [handler.unmatch] callback for when query is deactivated
         * @param {function} [handler.setup] callback for immediate execution when a query handler is registered
         * @param {boolean} [handler.deferSetup=false] should the setup callback be deferred until the first time the handler is matched?
         */
        addHandler: function (handler) {
            var qh = new QueryHandler(handler);
            this.handlers.push(qh);

            this.matches() && qh.on();
        },

        /**
         * removes the given handler from the collection, and calls it's destroy methods
         * 
         * @param {object || function} handler the handler to remove
         */
        removeHandler: function (handler) {
            var handlers = this.handlers;
            each(handlers, function (h, i) {
                if (h.equals(handler)) {
                    h.destroy();
                    return !handlers.splice(i, 1); //remove from array and exit each early
                }
            });
        },

        /**
         * Determine whether the media query should be considered a match
         * 
         * @return {Boolean} true if media query can be considered a match, false otherwise
         */
        matches: function () {
            return this.mql.matches || this.isUnconditional;
        },

        /**
         * Clears all handlers and unbinds events
         */
        clear: function () {
            each(this.handlers, function (handler) {
                handler.destroy();
            });
            this.mql.removeListener(this.listener);
            this.handlers.length = 0; //clear array
        },

        /*
         * Assesses the query, turning on all handlers if it matches, turning them off if it doesn't match
         */
        assess: function () {
            var action = this.matches() ? 'on' : 'off';

            each(this.handlers, function (handler) {
                handler[action]();
            });
        }
    };
    /**
     * Allows for registration of query handlers.
     * Manages the query handler's state and is responsible for wiring up browser events
     *
     * @constructor
     */
    function MediaQueryDispatch() {
        if (!matchMedia) {
            throw new Error('matchMedia not present, legacy browsers require a polyfill');
        }

        this.queries = {};
        this.browserIsIncapable = !matchMedia('only all').matches;
    }

    MediaQueryDispatch.prototype = {

        /**
         * Registers a handler for the given media query
         *
         * @param {string} q the media query
         * @param {object || Array || Function} options either a single query handler object, a function, or an array of query handlers
         * @param {function} options.match fired when query matched
         * @param {function} [options.unmatch] fired when a query is no longer matched
         * @param {function} [options.setup] fired when handler first triggered
         * @param {boolean} [options.deferSetup=false] whether setup should be run immediately or deferred until query is first matched
         * @param {boolean} [shouldDegrade=false] whether this particular media query should always run on incapable browsers
         */
        register: function (q, options, shouldDegrade) {
            var queries = this.queries,
                isUnconditional = shouldDegrade && this.browserIsIncapable;

            if (!queries[q]) {
                queries[q] = new MediaQuery(q, isUnconditional);
            }

            //normalise to object in an array
            if (isFunction(options)) {
                options = { match: options };
            }
            if (!isArray(options)) {
                options = [options];
            }
            each(options, function (handler) {
                if (isFunction(handler)) {
                    handler = { match: handler };
                }
                queries[q].addHandler(handler);
            });

            return this;
        },

        /**
         * unregisters a query and all it's handlers, or a specific handler for a query
         *
         * @param {string} q the media query to target
         * @param {object || function} [handler] specific handler to unregister
         */
        unregister: function (q, handler) {
            var query = this.queries[q];

            if (query) {
                if (handler) {
                    query.removeHandler(handler);
                }
                else {
                    query.clear();
                    delete this.queries[q];
                }
            }

            return this;
        }
    };

    return new MediaQueryDispatch();

}));;
/*! LAB.js (LABjs :: Loading And Blocking JavaScript)
    v2.0.3 (c) Kyle Simpson
    MIT License
*/
(function (o) { var K = o.$LAB, y = "UseLocalXHR", z = "AlwaysPreserveOrder", u = "AllowDuplicates", A = "CacheBust", B = "BasePath", C = /^[^?#]*\//.exec(location.href)[0], D = /^\w+\:\/\/\/?[^\/]+/.exec(C)[0], i = document.head || document.getElementsByTagName("head"), L = (o.opera && Object.prototype.toString.call(o.opera) == "[object Opera]") || ("MozAppearance" in document.documentElement.style), q = document.createElement("script"), E = typeof q.preload == "boolean", r = E || (q.readyState && q.readyState == "uninitialized"), F = !r && q.async === true, M = !r && !F && !L; function G(a) { return Object.prototype.toString.call(a) == "[object Function]" } function H(a) { return Object.prototype.toString.call(a) == "[object Array]" } function N(a, c) { var b = /^\w+\:\/\//; if (/^\/\/\/?/.test(a)) { a = location.protocol + a } else if (!b.test(a) && a.charAt(0) != "/") { a = (c || "") + a } return b.test(a) ? a : ((a.charAt(0) == "/" ? D : C) + a) } function s(a, c) { for (var b in a) { if (a.hasOwnProperty(b)) { c[b] = a[b] } } return c } function O(a) { var c = false; for (var b = 0; b < a.scripts.length; b++) { if (a.scripts[b].ready && a.scripts[b].exec_trigger) { c = true; a.scripts[b].exec_trigger(); a.scripts[b].exec_trigger = null } } return c } function t(a, c, b, d) { a.onload = a.onreadystatechange = function () { if ((a.readyState && a.readyState != "complete" && a.readyState != "loaded") || c[b]) return; a.onload = a.onreadystatechange = null; d() } } function I(a) { a.ready = a.finished = true; for (var c = 0; c < a.finished_listeners.length; c++) { a.finished_listeners[c]() } a.ready_listeners = []; a.finished_listeners = [] } function P(d, f, e, g, h) { setTimeout(function () { var a, c = f.real_src, b; if ("item" in i) { if (!i[0]) { setTimeout(arguments.callee, 25); return } i = i[0] } a = document.createElement("script"); if (f.type) a.type = f.type; if (f.charset) a.charset = f.charset; if (h) { if (r) { e.elem = a; if (E) { a.preload = true; a.onpreload = g } else { a.onreadystatechange = function () { if (a.readyState == "loaded") g() } } a.src = c } else if (h && c.indexOf(D) == 0 && d[y]) { b = new XMLHttpRequest(); b.onreadystatechange = function () { if (b.readyState == 4) { b.onreadystatechange = function () { }; e.text = b.responseText + "\n//@ sourceURL=" + c; g() } }; b.open("GET", c); b.send() } else { a.type = "text/cache-script"; t(a, e, "ready", function () { i.removeChild(a); g() }); a.src = c; i.insertBefore(a, i.firstChild) } } else if (F) { a.async = false; t(a, e, "finished", g); a.src = c; i.insertBefore(a, i.firstChild) } else { t(a, e, "finished", g); a.src = c; i.insertBefore(a, i.firstChild) } }, 0) } function J() { var l = {}, Q = r || M, n = [], p = {}, m; l[y] = true; l[z] = false; l[u] = false; l[A] = false; l[B] = ""; function R(a, c, b) { var d; function f() { if (d != null) { d = null; I(b) } } if (p[c.src].finished) return; if (!a[u]) p[c.src].finished = true; d = b.elem || document.createElement("script"); if (c.type) d.type = c.type; if (c.charset) d.charset = c.charset; t(d, b, "finished", f); if (b.elem) { b.elem = null } else if (b.text) { d.onload = d.onreadystatechange = null; d.text = b.text } else { d.src = c.real_src } i.insertBefore(d, i.firstChild); if (b.text) { f() } } function S(c, b, d, f) { var e, g, h = function () { b.ready_cb(b, function () { R(c, b, e) }) }, j = function () { b.finished_cb(b, d) }; b.src = N(b.src, c[B]); b.real_src = b.src + (c[A] ? ((/\?.*$/.test(b.src) ? "&_" : "?_") + ~~(Math.random() * 1E9) + "=") : ""); if (!p[b.src]) p[b.src] = { items: [], finished: false }; g = p[b.src].items; if (c[u] || g.length == 0) { e = g[g.length] = { ready: false, finished: false, ready_listeners: [h], finished_listeners: [j] }; P(c, b, e, ((f) ? function () { e.ready = true; for (var a = 0; a < e.ready_listeners.length; a++) { e.ready_listeners[a]() } e.ready_listeners = [] } : function () { I(e) }), f) } else { e = g[0]; if (e.finished) { j() } else { e.finished_listeners.push(j) } } } function v() { var e, g = s(l, {}), h = [], j = 0, w = false, k; function T(a, c) { a.ready = true; a.exec_trigger = c; x() } function U(a, c) { a.ready = a.finished = true; a.exec_trigger = null; for (var b = 0; b < c.scripts.length; b++) { if (!c.scripts[b].finished) return } c.finished = true; x() } function x() { while (j < h.length) { if (G(h[j])) { try { h[j++]() } catch (err) { } continue } else if (!h[j].finished) { if (O(h[j])) continue; break } j++ } if (j == h.length) { w = false; k = false } } function V() { if (!k || !k.scripts) { h.push(k = { scripts: [], finished: true }) } } e = { script: function () { for (var f = 0; f < arguments.length; f++) { (function (a, c) { var b; if (!H(a)) { c = [a] } for (var d = 0; d < c.length; d++) { V(); a = c[d]; if (G(a)) a = a(); if (!a) continue; if (H(a)) { b = [].slice.call(a); b.unshift(d, 1);[].splice.apply(c, b); d--; continue } if (typeof a == "string") a = { src: a }; a = s(a, { ready: false, ready_cb: T, finished: false, finished_cb: U }); k.finished = false; k.scripts.push(a); S(g, a, k, (Q && w)); w = true; if (g[z]) e.wait() } })(arguments[f], arguments[f]) } return e }, wait: function () { if (arguments.length > 0) { for (var a = 0; a < arguments.length; a++) { h.push(arguments[a]) } k = h[h.length - 1] } else k = false; x(); return e } }; return { script: e.script, wait: e.wait, setOptions: function (a) { s(a, g); return e } } } m = { setGlobalDefaults: function (a) { s(a, l); return m }, setOptions: function () { return v().setOptions.apply(null, arguments) }, script: function () { return v().script.apply(null, arguments) }, wait: function () { return v().wait.apply(null, arguments) }, queueScript: function () { n[n.length] = { type: "script", args: [].slice.call(arguments) }; return m }, queueWait: function () { n[n.length] = { type: "wait", args: [].slice.call(arguments) }; return m }, runQueue: function () { var a = m, c = n.length, b = c, d; for (; --b >= 0;) { d = n.shift(); a = a[d.type].apply(null, d.args) } return a }, noConflict: function () { o.$LAB = K; return m }, sandbox: function () { return J() } }; return m } o.$LAB = J(); (function (a, c, b) { if (document.readyState == null && document[a]) { document.readyState = "loading"; document[a](c, b = function () { document.removeEventListener(c, b, false); document.readyState = "complete" }, false) } })("addEventListener", "DOMContentLoaded") })(this);;
"use strict";
/* dependency jQuery */

/*
 * jQuery outside events - v1.1 - 3/16/2010
 * http://benalman.com/projects/jquery-outside-events-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function ($, c, b) { $.map("click dblclick mousemove mousedown mouseup mouseover mouseout change select submit keydown keypress keyup".split(" "), function (d) { a(d) }); a("focusin", "focus" + b); a("focusout", "blur" + b); $.addOutsideEvent = a; function a(g, e) { e = e || g + b; var d = $(), h = g + "." + e + "-special-event"; $.event.special[e] = { setup: function () { d = d.add(this); if (d.length === 1) { $(c).bind(h, f) } }, teardown: function () { d = d.not(this); if (d.length === 0) { $(c).unbind(h) } }, add: function (i) { var j = i.handler; i.handler = function (l, k) { l.target = k; j.apply(this, arguments) } } }; function f(i) { $(d).each(function () { var j = $(this); if (this !== i.target && !j.has(i.target).length) { j.triggerHandler(e, [i.target]) } }) } } })(jQuery, document, "outside");

var gel = gel || {};

// Function to initialise a nav based on a selector, returns a ToggleNav class.
//
// ToggleNav contains a .nav jquery item with the following listenable events:
//      hamburgerToggled
//      hamburgerOpened
//      hamburgerClosed
//      dropdownToggled
//      dropdownOpened
//      dropdownClosed
gel.navIndex = gel.navIndex || 0;
gel.startToggleNav = function (selector, dropdowns) {

    // Make a new ToggleNav object to handle state and carry reusable functions
    var ToggleNav = function (selector, dropdowns) {
        this.index = gel.navIndex++;
        this.nav = $(selector);
        this.dropdowns = dropdowns ? this.nav.find(dropdowns) : null;
        this.button = "";
        this.cleanup(); 
        this.init();
    };

    //
    // Add function methods to ToggleNav
    //

    // Not sure this needs a separate function any longer. This may or may not be Fusion specific.
    ToggleNav.prototype.cleanup = function () {
        // Put gel-nav-collapse on the top level nav if we are toggling it
        this.nav.find(".gel-nav-toggle ~ nav").addClass("gel-nav-collapse");
    };

    // Called on creation
    ToggleNav.prototype.init = function () {
        var self = this;
        // Identify the toggle button(s)
        self.button = self.nav.find(".gel-nav-toggle:first");
        // Hook up the hamburger
        self.button
            .click(function (e) {
                self.hamburgerToggle(e);
            })
            .each(function (item) {
                // Set up the aria roles. The hamburger controls the whole nav.
                var uid = "nav_" + self.index + "_hamburgerlink_" + item;
                var subid = "nav_" + self.index + "_hamburgertarget_" + item;
                var subitem = self.nav.find(".gel-nav-main");
                $(this).attr("id", uid);
                $(this).attr("role", "button");
                $(this).attr("aria-controls", subid);
                $(this).attr("aria-hasPopup", "true");
                $(this).attr("aria-expanded", "false");
                subitem.attr("id", subid);
                //subitem.attr("role", subitem.attr("role") + " menu");
                subitem.attr("aria-expanded", "false");
                subitem.attr("aria-hidden", "true");
        })

        // Hook up the dropdowns
        if (self.dropdowns) {
            self.dropdowns
                .click(function (e) {
                    self.dropdownToggle(e);
                })
                .each(function (item) {
                    // Set up the aria roles. Each dropdown controls the ul child.
                    var uid = "nav_" + self.index + "_dropdownlink_" + item;
                    var subid = "nav_" + self.index + "_dropdowntarget_" + item;
                    var subitem = $(this).parent("li").children("ul");
                    $(this).addClass("gel-nav-dropdown-toggle");
                    $(this).attr("id", uid);
                    $(this).attr("aria-owns", subid);
                    $(this).attr("aria-controls", subid);
                    $(this).attr("aria-hasPopup", "true");
                    $(this).attr("aria-expanded", "false");
                    subitem.attr("id", subid);
                    subitem.attr("role", "group");
                    subitem.attr("aria-expanded", "false");
                    subitem.attr("aria-hidden", "true");
                    subitem.attr("aria-labelledby", uid);
                });
            // If a click reaches the body and we have the nav open, close it.
            self.nav.find(".gel-nav-main").bind("clickoutside", function (e) {
                // If we are toggling ourselves, we are not 'outside'
                if (e.target.id === self.button.attr("id")) {
                    return;
                }
                if (self.button.hasClass("opened") || self.nav.find(".gel-nav-opened").length) {
                    self.hamburgerToggle(e, true);
                    self.dropdownToggle(e, true);
                    return;
                }
            });
        }

        // If we have a navtitle but no gel-nav-categorylist, make one for mobile nav use.
        self.nav.find("li[data-navtitle]").has("ul").each(function () {
            var navtitle = $(this).data("navtitle");
            if (navtitle && $(this).find(".gel-nav-categorylist").length === 0) {
                $(this).children("a").prepend("<span class=\"gel-nav-categorylist\">" + navtitle + "</span>");
            }
        });

        // Hook up nav closing for same-page links
        self.nav.find("a[href*='#']:not([href$='#'])").click(function (e) {
            self.dropdownToggle(e, true, true);
            return true;
        })
    };

    // Event that triggers when the hamburger icon is clicked
    ToggleNav.prototype.hamburgerToggle = function (e, close) {
        if (e && e.preventDefault) {
            e.preventDefault();
        }
        // Toggling
        this.nav.trigger("hamburgerToggled");
        // Are we closing?
        var close = close || this.button.hasClass("opened");
        // If we are not closing, add the opened class.
        this.button.toggleClass("opened", !close);
        this.nav.find("nav").toggleClass("opened", !close);
        // Set aria roles to be in the closed/hidden state
        this.button.attr("aria-expanded", !close);
        this.nav.find(".gel-nav-main").attr("aria-expanded", !close);
        this.nav.find(".gel-nav-main").attr("aria-hidden", close);
        if (close) {
            this.nav.trigger("hamburgerClosed");
        } else {
            this.nav.trigger("hamburgerOpened");
        }
    };

    // Event that triggers when a top level list item containnig children is clicked
    ToggleNav.prototype.dropdownToggle = function (e, close, bubble) {
        if (e && e.preventDefault && !bubble) {
            e.preventDefault();
        }
        // Toggling
        this.nav.trigger("dropdownToggled");
        // Are we closing?
        var hitOtherToggle = false;
        // Did we hit a different toggle dropdown? if so we are not really closing.
        if (e && e.target) {
            hitOtherToggle = $(e.target).hasClass("gel-nav-dropdown-toggle") && !$(e.target).parent("li").hasClass("gel-nav-opened");
        }
        var close = close || !hitOtherToggle;
        // Clear the current opened dropdown
        this.nav.find(".gel-nav-opened, .gel-nav-closed").removeClass("gel-nav-opened gel-nav-closed");
        // Set aria roles to be in the closed/hidden state
        this.nav.find(".gel-nav-dropdown [aria-expanded]").attr("aria-expanded", "false");
        if (close) {
            // Closing
            this.nav.trigger("dropdownClosed");
        } else {
            // Opening
            // Set aria roles
            $(e.target).parent("li").find("[aria-expanded]").attr("aria-expanded", "true");
            this.nav.find(".gel-nav-dropdown [aria-expanded]").attr("aria-hidden", "false");
            $(e.target).parent("li").addClass("gel-nav-opened");
            $(e.target).parent("li").siblings("li").addClass("gel-nav-closed");
            this.nav.trigger("dropdownOpened");
        }
    };

    // Return a new instance of ToggleNav
    return new ToggleNav(selector, dropdowns);
};

// Function to initialise a search toggle based on a selector, returns a ToggleSearch class.
//
// ToggleSearch contains a .nav jquery item with the following listenable events:
//      searchToggled
//      searchOpened
//      searchClosed
gel.startSearch = function (panelSelector, wrapperSelector) {
    var index = 0;

    // Create a new search object
    var ToggleSearch = function (panelSelector, wrapperSelector, toggleSelector) {
        this.index = index++;
        this.panel = $(panelSelector); // Container div for the toggle button
        // Identify the toggle button
        this.button = this.panel.find(".gel-nav-toggle");
        this.wrapper = $(wrapperSelector);
        this.init();
    };

    // Called on creation
    ToggleSearch.prototype.init = function () {
        var self = this;

        // Generate the toggle button for this panel.
        self.button.appendTo(this.panel);
        self.button.click(function (e) {
            self.searchToggle(e);
        });

    };

    // Give all ToggleSearch instances a searchToggle function to use as an event callback.
    ToggleSearch.prototype.searchToggle = function (e, close) {
        // Are we closing?
        var close = close || this.panel.hasClass("opened")
        // Toggling
        this.panel.trigger("searchToggled");

        // set opened class based on close logic - false means add class.
        this.button.toggleClass("opened", !close)
        this.panel.toggleClass("opened", !close);
        this.wrapper.toggleClass("opened", !close);
        if (close) {
            // Closing
            this.panel.trigger("searchClosed");
        } else {
            // Opening
            this.panel.trigger("searchOpened");
            this.wrapper.find("input[type='search']").focus();
        }
    };

    // Return a new instance of ToggleSearch
    return new ToggleSearch(panelSelector, wrapperSelector);
};


// Hook up search on jQuery's document ready event
$(document).ready(function () {

    // just in case legacy still has the nojs class in the document, remove it
    $(".nojs").removeClass("nojs");
    // standardize presence of the gel-js class
    $("body").addClass("gel-js");
    // find the header or div that wraps the logo and top navs, remove nojs class, add js class
    $(".gel-nav-nojs").addClass("gel-nav-js").removeClass("gel-nav-nojs");

    // is there a main/primary navigation? Does it contain single/orphan item? 
    // Add a class so we can control the logo better
    if ($(".gel-nav-js .gel-logo").next(".gel-nav-panel:not(.gel-nav-task)").children("[data-navclass='nav-lonelyone']").length)  {
        $(".gel-logo").addClass("nav-nextislonely");
    }

    var newsearch;
    // Do we have a search panel?
    if ($("[data-searchtype]").length) {
        // Create our panel search
         newsearch = gel.startSearch("[data-searchtype]", ".gel-search-wrapper");
         $("header").addClass("gel-has-search");
        // CAN WE DO: ... multiple headers on an HTML page
        //$("[role='banner']").addClass("gel-has-search");
    }

    // Create our header nav
    $("[data-navtype='gel-nav-mobile']").each(function () {
        var newnav = gel.startToggleNav(this, $(".nav-li-1 > a:not(:only-child)"));

        var mq = $(this).data("navmobilemq");

        var resetNav = function (e) {
            newnav.hamburgerToggle(e, true);
            newnav.dropdownToggle(e, true);
        };
        

        if (mq) {
            enquire.register(mq, [{
                match: resetNav,
                unmatch: resetNav
            },
            {   // Add a class when we're in 'desktop' mode for more efficient css
                match: function () {
                    newnav.nav.addClass("gel-nav-dt");
                },
                unmatch: function () {
                    newnav.nav.removeClass("gel-nav-dt");
                }
            }]);
        }

        if (newsearch) {
            // When the dropdown is open or hamburger is opened, trigger search panel close event
            newnav.nav.on("dropdownOpened hamburgerOpened", function (e) {
                newsearch.searchToggle(e, true);
            });
            // When the search is opened, trigger the nav close events
            newsearch.panel.on("searchOpened", resetNav);
        }
    });

    

});;
"use strict";

var domReady = $;

var gel = gel || {};
var deluxe = deluxe || {};

// Create a LABjs instance for async script loading
gel.load = gel.load || $LAB.setOptions({ AllowDuplicates: false });

gel.utils = gel.utils || {};

gel.utils.toggleClass = gel.utils.toggleClass || function toggleClass(el, className) {
    if (el.classList) {
        el.classList.toggle(className);
    } else {
        var classes = el.className.split(' ');
        var existingIndex = classes.indexOf(className);

        if (existingIndex >= 0)
            classes.splice(existingIndex, 1);
        else
            classes.push(className);

        el.className = classes.join(' ');
    }
}

gel.utils.hasClass = gel.utils.hasClass || function hasClass(el, className) {
    if (el.classList)
        return el.classList.contains(className);
    else
        return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
}

gel.startBannerSearch = function startBannerSearch() {
    // If there is a search in the banner, hook up the events for it
    var bannerSearchClickTarget = document.querySelector("#bannerSearchParent label");
    var bannerSearchInput = document.querySelector("#bannerSearchParent input[type=search]");
    var bannerSearchReset = document.querySelector("#bannerSearchParent button[type=reset]");
    if (bannerSearchClickTarget) {
        bannerSearchClickTarget.addEventListener("click", function (e) {
            e.preventDefault();
            var labelParent = document.getElementById("bannerSearchParent");
            gel.utils.toggleClass(labelParent, "open");
            if (gel.utils.hasClass(labelParent, "open")) {
                bannerSearchInput.focus();
            } else {
                bannerSearchInput.blur();
            }
        });
        if (bannerSearchReset) {
            bannerSearchReset.addEventListener("click", function (e) {
                e.preventDefault();
                document.querySelector("#bannerSearchParent input[type=search]").value = "";
            });
        }
    };
}

/* Autocomplete */
deluxe.autoCompleteCache = {};

// Given a term typed in, check it against the cache
deluxe.autoCompleteTerm = function autoCompleteTerm(term, minlength, callback) {

}
// Set up our autocomplete handlers for each autocomplete input.
deluxe.initAutocomplete = function () {
    $('input[data-autocomplete-source]').each(function () {
        var self = this;
        var datasource = $(this).data("autocomplete-source");
        var simple = $(this).data("autocomplete-simple");
        var tag = $(this).data("autocomplete-tag");
        var acCache = {};
        
        // If we have done this query or one like it before, use the current results
        // but return only a subset of the cache that actually contains the term.
        var checkCache = function (term) {
            var minlength = Math.min(4, term.length) - 1;
            var cached = false;
            var subset = [];
            for (var i = minlength; i < term.length; i++) {
                var testcached = acCache[term.slice(0, i + 1)];
                if (testcached) {
                    cached = testcached;
                }
                // 15 is the max results returned by the server.
                if (cached.length < 15) {
                    break;
                }
            }
            if (cached.length >= 15) {
                return subset;
            }
            // While we might have the results for "Gall", the user may have typed
            // "Gallu" so only return results that contain their term just like
            /// the server would.
            for (var j = 0; j < cached.length; j++) {
                if (cached[j].toLowerCase().indexOf(term.toLowerCase()) != -1) {
                    subset.push(cached[j]);
                }
            }
            return subset;
        }

        // Do a post to the datasource asking for the results for that query
        var getAutocompleteData = function (request, response) {
            var cached = checkCache(request.term);
            if (cached.length) {
                response(cached);
                return
            }
            $.ajax({
                type: "POST",
                url: datasource,
                data: "{\"q\": \"" + request.term + "\"}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    acCache[request.term] = result.d;
                    response(result.d);
                }
            });
        }

        // Setup the default options for jQuery autocomplete
        var options = {
            "autoFocus ": true,
            "minLength": 4,
            "source": getAutocompleteData,
        }
        
        if (simple) {
            // Get all the results up front.
            options["delay"] = 0;
            $.ajax({
                type: "POST",
                url: datasource,
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    if (response.hasOwnProperty("d") && $.isArray(response.d)) {
                        var results = response.d;
                        if (results.length) {
                            // Base the minimum number of characters for autocomplete on the number of results
                            // Get the length of the string representation of the length of the number of results
                            // Subtract 1 and then force a minimum of 0. i.e. 4 topics = 0 character needed,
                            // 152 topics = 2 characters needed etc.
                            options["minLength"] = Math.max(0, results.length.toString().length - 1);
                            options["source"] = results;
                            if (tag) {
                                // On clicking a tag, redirect to the tag page instead of populating the input
                                options["select"] = function (e, ui) {
                                    e.preventDefault();
                                    if (ui.hasOwnProperty("item") && ui.item.hasOwnProperty("value")) {
                                        ga('send', 'event', { eventCategory: 'search_bar', eventAction: 'search_bar_click', eventLabel: '' + ui.item.label + '' });
                                        location.href = "/topic/" + ui.item.value + ".aspx";
                                    }
                                    $("#bannerSearchParent").find("input, button").prop("disabled", true);
                                };
                                // On focus, populate the search box with the label, not the value
                                options["focus"] = function (e, ui) {
                                    e.preventDefault();
                                    if (ui.hasOwnProperty("item") && ui.item.hasOwnProperty("value")) {
                                        $(self).val(ui.item.label);
                                    }
                                };
                            }
                            $(self).autocomplete(options);
                        }
                    }
                }
            });
        } else {
            $(self).autocomplete(options);
        }
    });
};

domReady(function () {
    try {
        gel.nav = gel.startNav("header .gel-nav-main");
        // Close the nav when we click outside it.
        document.addEventListener("click", function (e) {
            var openToggle = document.querySelector('.gel-nav-dropdown.opened > .gel-nav-dropdown-toggle');
            if (openToggle) {
                var parent = e.target.parentElement;
                while (parent) {
                    if (parent.className.indexOf('gel-nav-collapse') > -1) {
                        parent = false;
                        return;
                    } else {
                        parent = parent.parentElement;
                    }
                };
                // The nav is closed during a resize call. It saves us knowing whether to toggle or or off.
                gel.nav.resize();
            }
        });
    } catch (e) {
        // We don't have a nav!
        //console.log(e);
    }

    try {
        gel.startBannerSearch();
    } catch (e) {
        // We don't have a banner!
        console.log(e);
    }
    
    // If we have an autocomplete box, set up the required libraries
    if (document.querySelector('input[data-autocomplete-source]')) {
        var inputs = document.querySelectorAll('input[data-autocomplete-source]');
        Array.prototype.forEach.call(inputs, function (el, i) {
            var acScriptLoader = function (e) {
                gel.load.script('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js')
                .wait(function () {
                    deluxe.initAutocomplete();
                });
                el.removeEventListener("focus", acScriptLoader);
            }
            el.addEventListener("focus", acScriptLoader);
        });
        
    };
});

;
/*!
 * imagesLoaded PACKAGED v3.1.8
 * JavaScript is all like "You images are done yet or what?"
 * MIT License
 */

(function () { function e() { } function t(e, t) { for (var n = e.length; n--;) if (e[n].listener === t) return n; return -1 } function n(e) { return function () { return this[e].apply(this, arguments) } } var i = e.prototype, r = this, o = r.EventEmitter; i.getListeners = function (e) { var t, n, i = this._getEvents(); if ("object" == typeof e) { t = {}; for (n in i) i.hasOwnProperty(n) && e.test(n) && (t[n] = i[n]) } else t = i[e] || (i[e] = []); return t }, i.flattenListeners = function (e) { var t, n = []; for (t = 0; e.length > t; t += 1) n.push(e[t].listener); return n }, i.getListenersAsObject = function (e) { var t, n = this.getListeners(e); return n instanceof Array && (t = {}, t[e] = n), t || n }, i.addListener = function (e, n) { var i, r = this.getListenersAsObject(e), o = "object" == typeof n; for (i in r) r.hasOwnProperty(i) && -1 === t(r[i], n) && r[i].push(o ? n : { listener: n, once: !1 }); return this }, i.on = n("addListener"), i.addOnceListener = function (e, t) { return this.addListener(e, { listener: t, once: !0 }) }, i.once = n("addOnceListener"), i.defineEvent = function (e) { return this.getListeners(e), this }, i.defineEvents = function (e) { for (var t = 0; e.length > t; t += 1) this.defineEvent(e[t]); return this }, i.removeListener = function (e, n) { var i, r, o = this.getListenersAsObject(e); for (r in o) o.hasOwnProperty(r) && (i = t(o[r], n), -1 !== i && o[r].splice(i, 1)); return this }, i.off = n("removeListener"), i.addListeners = function (e, t) { return this.manipulateListeners(!1, e, t) }, i.removeListeners = function (e, t) { return this.manipulateListeners(!0, e, t) }, i.manipulateListeners = function (e, t, n) { var i, r, o = e ? this.removeListener : this.addListener, s = e ? this.removeListeners : this.addListeners; if ("object" != typeof t || t instanceof RegExp) for (i = n.length; i--;) o.call(this, t, n[i]); else for (i in t) t.hasOwnProperty(i) && (r = t[i]) && ("function" == typeof r ? o.call(this, i, r) : s.call(this, i, r)); return this }, i.removeEvent = function (e) { var t, n = typeof e, i = this._getEvents(); if ("string" === n) delete i[e]; else if ("object" === n) for (t in i) i.hasOwnProperty(t) && e.test(t) && delete i[t]; else delete this._events; return this }, i.removeAllListeners = n("removeEvent"), i.emitEvent = function (e, t) { var n, i, r, o, s = this.getListenersAsObject(e); for (r in s) if (s.hasOwnProperty(r)) for (i = s[r].length; i--;) n = s[r][i], n.once === !0 && this.removeListener(e, n.listener), o = n.listener.apply(this, t || []), o === this._getOnceReturnValue() && this.removeListener(e, n.listener); return this }, i.trigger = n("emitEvent"), i.emit = function (e) { var t = Array.prototype.slice.call(arguments, 1); return this.emitEvent(e, t) }, i.setOnceReturnValue = function (e) { return this._onceReturnValue = e, this }, i._getOnceReturnValue = function () { return this.hasOwnProperty("_onceReturnValue") ? this._onceReturnValue : !0 }, i._getEvents = function () { return this._events || (this._events = {}) }, e.noConflict = function () { return r.EventEmitter = o, e }, "function" == typeof define && define.amd ? define("eventEmitter/EventEmitter", [], function () { return e }) : "object" == typeof module && module.exports ? module.exports = e : this.EventEmitter = e }).call(this), function (e) { function t(t) { var n = e.event; return n.target = n.target || n.srcElement || t, n } var n = document.documentElement, i = function () { }; n.addEventListener ? i = function (e, t, n) { e.addEventListener(t, n, !1) } : n.attachEvent && (i = function (e, n, i) { e[n + i] = i.handleEvent ? function () { var n = t(e); i.handleEvent.call(i, n) } : function () { var n = t(e); i.call(e, n) }, e.attachEvent("on" + n, e[n + i]) }); var r = function () { }; n.removeEventListener ? r = function (e, t, n) { e.removeEventListener(t, n, !1) } : n.detachEvent && (r = function (e, t, n) { e.detachEvent("on" + t, e[t + n]); try { delete e[t + n] } catch (i) { e[t + n] = void 0 } }); var o = { bind: i, unbind: r }; "function" == typeof define && define.amd ? define("eventie/eventie", o) : e.eventie = o }(this), function (e, t) { "function" == typeof define && define.amd ? define(["eventEmitter/EventEmitter", "eventie/eventie"], function (n, i) { return t(e, n, i) }) : "object" == typeof exports ? module.exports = t(e, require("wolfy87-eventemitter"), require("eventie")) : e.imagesLoaded = t(e, e.EventEmitter, e.eventie) }(window, function (e, t, n) { function i(e, t) { for (var n in t) e[n] = t[n]; return e } function r(e) { return "[object Array]" === d.call(e) } function o(e) { var t = []; if (r(e)) t = e; else if ("number" == typeof e.length) for (var n = 0, i = e.length; i > n; n++) t.push(e[n]); else t.push(e); return t } function s(e, t, n) { if (!(this instanceof s)) return new s(e, t); "string" == typeof e && (e = document.querySelectorAll(e)), this.elements = o(e), this.options = i({}, this.options), "function" == typeof t ? n = t : i(this.options, t), n && this.on("always", n), this.getImages(), a && (this.jqDeferred = new a.Deferred); var r = this; setTimeout(function () { r.check() }) } function f(e) { this.img = e } function c(e) { this.src = e, v[e] = this } var a = e.jQuery, u = e.console, h = u !== void 0, d = Object.prototype.toString; s.prototype = new t, s.prototype.options = {}, s.prototype.getImages = function () { this.images = []; for (var e = 0, t = this.elements.length; t > e; e++) { var n = this.elements[e]; "IMG" === n.nodeName && this.addImage(n); var i = n.nodeType; if (i && (1 === i || 9 === i || 11 === i)) for (var r = n.querySelectorAll("img"), o = 0, s = r.length; s > o; o++) { var f = r[o]; this.addImage(f) } } }, s.prototype.addImage = function (e) { var t = new f(e); this.images.push(t) }, s.prototype.check = function () { function e(e, r) { return t.options.debug && h && u.log("confirm", e, r), t.progress(e), n++, n === i && t.complete(), !0 } var t = this, n = 0, i = this.images.length; if (this.hasAnyBroken = !1, !i) return this.complete(), void 0; for (var r = 0; i > r; r++) { var o = this.images[r]; o.on("confirm", e), o.check() } }, s.prototype.progress = function (e) { this.hasAnyBroken = this.hasAnyBroken || !e.isLoaded; var t = this; setTimeout(function () { t.emit("progress", t, e), t.jqDeferred && t.jqDeferred.notify && t.jqDeferred.notify(t, e) }) }, s.prototype.complete = function () { var e = this.hasAnyBroken ? "fail" : "done"; this.isComplete = !0; var t = this; setTimeout(function () { if (t.emit(e, t), t.emit("always", t), t.jqDeferred) { var n = t.hasAnyBroken ? "reject" : "resolve"; t.jqDeferred[n](t) } }) }, a && (a.fn.imagesLoaded = function (e, t) { var n = new s(this, e, t); return n.jqDeferred.promise(a(this)) }), f.prototype = new t, f.prototype.check = function () { var e = v[this.img.src] || new c(this.img.src); if (e.isConfirmed) return this.confirm(e.isLoaded, "cached was confirmed"), void 0; if (this.img.complete && void 0 !== this.img.naturalWidth) return this.confirm(0 !== this.img.naturalWidth, "naturalWidth"), void 0; var t = this; e.on("confirm", function (e, n) { return t.confirm(e.isLoaded, n), !0 }), e.check() }, f.prototype.confirm = function (e, t) { this.isLoaded = e, this.emit("confirm", this, t) }; var v = {}; return c.prototype = new t, c.prototype.check = function () { if (!this.isChecked) { var e = new Image; n.bind(e, "load", this), n.bind(e, "error", this), e.src = this.src, this.isChecked = !0 } }, c.prototype.handleEvent = function (e) { var t = "on" + e.type; this[t] && this[t](e) }, c.prototype.onload = function (e) { this.confirm(!0, "onload"), this.unbindProxyEvents(e) }, c.prototype.onerror = function (e) { this.confirm(!1, "onerror"), this.unbindProxyEvents(e) }, c.prototype.confirm = function (e, t) { this.isConfirmed = !0, this.isLoaded = e, this.emit("confirm", this, t) }, c.prototype.unbindProxyEvents = function (e) { n.unbind(e.target, "load", this), n.unbind(e.target, "error", this) }, s });

/* Masonry */
/*!
 * Isotope PACKAGED v2.0.0
 * Filter & sort magical layouts
 * http://isotope.metafizzy.co
 */

(function (t) { function e() { } function i(t) { function i(e) { e.prototype.option || (e.prototype.option = function (e) { t.isPlainObject(e) && (this.options = t.extend(!0, this.options, e)) }) } function n(e, i) { t.fn[e] = function (n) { if ("string" == typeof n) { for (var s = o.call(arguments, 1), a = 0, u = this.length; u > a; a++) { var p = this[a], h = t.data(p, e); if (h) if (t.isFunction(h[n]) && "_" !== n.charAt(0)) { var f = h[n].apply(h, s); if (void 0 !== f) return f } else r("no such method '" + n + "' for " + e + " instance"); else r("cannot call methods on " + e + " prior to initialization; " + "attempted to call '" + n + "'") } return this } return this.each(function () { var o = t.data(this, e); o ? (o.option(n), o._init()) : (o = new i(this, n), t.data(this, e, o)) }) } } if (t) { var r = "undefined" == typeof console ? e : function (t) { console.error(t) }; return t.bridget = function (t, e) { i(e), n(t, e) }, t.bridget } } var o = Array.prototype.slice; "function" == typeof define && define.amd ? define("jquery-bridget/jquery.bridget", ["jquery"], i) : i(t.jQuery) })(window), function (t) { function e(e) { var i = t.event; return i.target = i.target || i.srcElement || e, i } var i = document.documentElement, o = function () { }; i.addEventListener ? o = function (t, e, i) { t.addEventListener(e, i, !1) } : i.attachEvent && (o = function (t, i, o) { t[i + o] = o.handleEvent ? function () { var i = e(t); o.handleEvent.call(o, i) } : function () { var i = e(t); o.call(t, i) }, t.attachEvent("on" + i, t[i + o]) }); var n = function () { }; i.removeEventListener ? n = function (t, e, i) { t.removeEventListener(e, i, !1) } : i.detachEvent && (n = function (t, e, i) { t.detachEvent("on" + e, t[e + i]); try { delete t[e + i] } catch (o) { t[e + i] = void 0 } }); var r = { bind: o, unbind: n }; "function" == typeof define && define.amd ? define("eventie/eventie", r) : "object" == typeof exports ? module.exports = r : t.eventie = r }(this), function (t) { function e(t) { "function" == typeof t && (e.isReady ? t() : r.push(t)) } function i(t) { var i = "readystatechange" === t.type && "complete" !== n.readyState; if (!e.isReady && !i) { e.isReady = !0; for (var o = 0, s = r.length; s > o; o++) { var a = r[o]; a() } } } function o(o) { return o.bind(n, "DOMContentLoaded", i), o.bind(n, "readystatechange", i), o.bind(t, "load", i), e } var n = t.document, r = []; e.isReady = !1, "function" == typeof define && define.amd ? (e.isReady = "function" == typeof requirejs, define("doc-ready/doc-ready", ["eventie/eventie"], o)) : t.docReady = o(t.eventie) }(this), function () { function t() { } function e(t, e) { for (var i = t.length; i--;) if (t[i].listener === e) return i; return -1 } function i(t) { return function () { return this[t].apply(this, arguments) } } var o = t.prototype, n = this, r = n.EventEmitter; o.getListeners = function (t) { var e, i, o = this._getEvents(); if (t instanceof RegExp) { e = {}; for (i in o) o.hasOwnProperty(i) && t.test(i) && (e[i] = o[i]) } else e = o[t] || (o[t] = []); return e }, o.flattenListeners = function (t) { var e, i = []; for (e = 0; t.length > e; e += 1) i.push(t[e].listener); return i }, o.getListenersAsObject = function (t) { var e, i = this.getListeners(t); return i instanceof Array && (e = {}, e[t] = i), e || i }, o.addListener = function (t, i) { var o, n = this.getListenersAsObject(t), r = "object" == typeof i; for (o in n) n.hasOwnProperty(o) && -1 === e(n[o], i) && n[o].push(r ? i : { listener: i, once: !1 }); return this }, o.on = i("addListener"), o.addOnceListener = function (t, e) { return this.addListener(t, { listener: e, once: !0 }) }, o.once = i("addOnceListener"), o.defineEvent = function (t) { return this.getListeners(t), this }, o.defineEvents = function (t) { for (var e = 0; t.length > e; e += 1) this.defineEvent(t[e]); return this }, o.removeListener = function (t, i) { var o, n, r = this.getListenersAsObject(t); for (n in r) r.hasOwnProperty(n) && (o = e(r[n], i), -1 !== o && r[n].splice(o, 1)); return this }, o.off = i("removeListener"), o.addListeners = function (t, e) { return this.manipulateListeners(!1, t, e) }, o.removeListeners = function (t, e) { return this.manipulateListeners(!0, t, e) }, o.manipulateListeners = function (t, e, i) { var o, n, r = t ? this.removeListener : this.addListener, s = t ? this.removeListeners : this.addListeners; if ("object" != typeof e || e instanceof RegExp) for (o = i.length; o--;) r.call(this, e, i[o]); else for (o in e) e.hasOwnProperty(o) && (n = e[o]) && ("function" == typeof n ? r.call(this, o, n) : s.call(this, o, n)); return this }, o.removeEvent = function (t) { var e, i = typeof t, o = this._getEvents(); if ("string" === i) delete o[t]; else if (t instanceof RegExp) for (e in o) o.hasOwnProperty(e) && t.test(e) && delete o[e]; else delete this._events; return this }, o.removeAllListeners = i("removeEvent"), o.emitEvent = function (t, e) { var i, o, n, r, s = this.getListenersAsObject(t); for (n in s) if (s.hasOwnProperty(n)) for (o = s[n].length; o--;) i = s[n][o], i.once === !0 && this.removeListener(t, i.listener), r = i.listener.apply(this, e || []), r === this._getOnceReturnValue() && this.removeListener(t, i.listener); return this }, o.trigger = i("emitEvent"), o.emit = function (t) { var e = Array.prototype.slice.call(arguments, 1); return this.emitEvent(t, e) }, o.setOnceReturnValue = function (t) { return this._onceReturnValue = t, this }, o._getOnceReturnValue = function () { return this.hasOwnProperty("_onceReturnValue") ? this._onceReturnValue : !0 }, o._getEvents = function () { return this._events || (this._events = {}) }, t.noConflict = function () { return n.EventEmitter = r, t }, "function" == typeof define && define.amd ? define("eventEmitter/EventEmitter", [], function () { return t }) : "object" == typeof module && module.exports ? module.exports = t : this.EventEmitter = t }.call(this), function (t) { function e(t) { if (t) { if ("string" == typeof o[t]) return t; t = t.charAt(0).toUpperCase() + t.slice(1); for (var e, n = 0, r = i.length; r > n; n++) if (e = i[n] + t, "string" == typeof o[e]) return e } } var i = "Webkit Moz ms Ms O".split(" "), o = document.documentElement.style; "function" == typeof define && define.amd ? define("get-style-property/get-style-property", [], function () { return e }) : "object" == typeof exports ? module.exports = e : t.getStyleProperty = e }(window), function (t) { function e(t) { var e = parseFloat(t), i = -1 === t.indexOf("%") && !isNaN(e); return i && e } function i() { for (var t = { width: 0, height: 0, innerWidth: 0, innerHeight: 0, outerWidth: 0, outerHeight: 0 }, e = 0, i = s.length; i > e; e++) { var o = s[e]; t[o] = 0 } return t } function o(t) { function o(t) { if ("string" == typeof t && (t = document.querySelector(t)), t && "object" == typeof t && t.nodeType) { var o = r(t); if ("none" === o.display) return i(); var n = {}; n.width = t.offsetWidth, n.height = t.offsetHeight; for (var h = n.isBorderBox = !(!p || !o[p] || "border-box" !== o[p]), f = 0, c = s.length; c > f; f++) { var d = s[f], l = o[d]; l = a(t, l); var y = parseFloat(l); n[d] = isNaN(y) ? 0 : y } var m = n.paddingLeft + n.paddingRight, g = n.paddingTop + n.paddingBottom, v = n.marginLeft + n.marginRight, _ = n.marginTop + n.marginBottom, I = n.borderLeftWidth + n.borderRightWidth, L = n.borderTopWidth + n.borderBottomWidth, z = h && u, S = e(o.width); S !== !1 && (n.width = S + (z ? 0 : m + I)); var b = e(o.height); return b !== !1 && (n.height = b + (z ? 0 : g + L)), n.innerWidth = n.width - (m + I), n.innerHeight = n.height - (g + L), n.outerWidth = n.width + v, n.outerHeight = n.height + _, n } } function a(t, e) { if (n || -1 === e.indexOf("%")) return e; var i = t.style, o = i.left, r = t.runtimeStyle, s = r && r.left; return s && (r.left = t.currentStyle.left), i.left = e, e = i.pixelLeft, i.left = o, s && (r.left = s), e } var u, p = t("boxSizing"); return function () { if (p) { var t = document.createElement("div"); t.style.width = "200px", t.style.padding = "1px 2px 3px 4px", t.style.borderStyle = "solid", t.style.borderWidth = "1px 2px 3px 4px", t.style[p] = "border-box"; var i = document.body || document.documentElement; i.appendChild(t); var o = r(t); u = 200 === e(o.width), i.removeChild(t) } }(), o } var n = t.getComputedStyle, r = n ? function (t) { return n(t, null) } : function (t) { return t.currentStyle }, s = ["paddingLeft", "paddingRight", "paddingTop", "paddingBottom", "marginLeft", "marginRight", "marginTop", "marginBottom", "borderLeftWidth", "borderRightWidth", "borderTopWidth", "borderBottomWidth"]; "function" == typeof define && define.amd ? define("get-size/get-size", ["get-style-property/get-style-property"], o) : "object" == typeof exports ? module.exports = o(require("get-style-property")) : t.getSize = o(t.getStyleProperty) }(window), function (t, e) { function i(t, e) { return t[a](e) } function o(t) { if (!t.parentNode) { var e = document.createDocumentFragment(); e.appendChild(t) } } function n(t, e) { o(t); for (var i = t.parentNode.querySelectorAll(e), n = 0, r = i.length; r > n; n++) if (i[n] === t) return !0; return !1 } function r(t, e) { return o(t), i(t, e) } var s, a = function () { if (e.matchesSelector) return "matchesSelector"; for (var t = ["webkit", "moz", "ms", "o"], i = 0, o = t.length; o > i; i++) { var n = t[i], r = n + "MatchesSelector"; if (e[r]) return r } }(); if (a) { var u = document.createElement("div"), p = i(u, "div"); s = p ? i : r } else s = n; "function" == typeof define && define.amd ? define("matches-selector/matches-selector", [], function () { return s }) : window.matchesSelector = s }(this, Element.prototype), function (t) { function e(t, e) { for (var i in e) t[i] = e[i]; return t } function i(t) { for (var e in t) return !1; return e = null, !0 } function o(t) { return t.replace(/([A-Z])/g, function (t) { return "-" + t.toLowerCase() }) } function n(t, n, r) { function a(t, e) { t && (this.element = t, this.layout = e, this.position = { x: 0, y: 0 }, this._create()) } var u = r("transition"), p = r("transform"), h = u && p, f = !!r("perspective"), c = { WebkitTransition: "webkitTransitionEnd", MozTransition: "transitionend", OTransition: "otransitionend", transition: "transitionend" }[u], d = ["transform", "transition", "transitionDuration", "transitionProperty"], l = function () { for (var t = {}, e = 0, i = d.length; i > e; e++) { var o = d[e], n = r(o); n && n !== o && (t[o] = n) } return t }(); e(a.prototype, t.prototype), a.prototype._create = function () { this._transn = { ingProperties: {}, clean: {}, onEnd: {} }, this.css({ position: "absolute" }) }, a.prototype.handleEvent = function (t) { var e = "on" + t.type; this[e] && this[e](t) }, a.prototype.getSize = function () { this.size = n(this.element) }, a.prototype.css = function (t) { var e = this.element.style; for (var i in t) { var o = l[i] || i; e[o] = t[i] } }, a.prototype.getPosition = function () { var t = s(this.element), e = this.layout.options, i = e.isOriginLeft, o = e.isOriginTop, n = parseInt(t[i ? "left" : "right"], 10), r = parseInt(t[o ? "top" : "bottom"], 10); n = isNaN(n) ? 0 : n, r = isNaN(r) ? 0 : r; var a = this.layout.size; n -= i ? a.paddingLeft : a.paddingRight, r -= o ? a.paddingTop : a.paddingBottom, this.position.x = n, this.position.y = r }, a.prototype.layoutPosition = function () { var t = this.layout.size, e = this.layout.options, i = {}; e.isOriginLeft ? (i.left = this.position.x + t.paddingLeft + "px", i.right = "") : (i.right = this.position.x + t.paddingRight + "px", i.left = ""), e.isOriginTop ? (i.top = this.position.y + t.paddingTop + "px", i.bottom = "") : (i.bottom = this.position.y + t.paddingBottom + "px", i.top = ""), this.css(i), this.emitEvent("layout", [this]) }; var y = f ? function (t, e) { return "translate3d(" + t + "px, " + e + "px, 0)" } : function (t, e) { return "translate(" + t + "px, " + e + "px)" }; a.prototype._transitionTo = function (t, e) { this.getPosition(); var i = this.position.x, o = this.position.y, n = parseInt(t, 10), r = parseInt(e, 10), s = n === this.position.x && r === this.position.y; if (this.setPosition(t, e), s && !this.isTransitioning) return this.layoutPosition(), void 0; var a = t - i, u = e - o, p = {}, h = this.layout.options; a = h.isOriginLeft ? a : -a, u = h.isOriginTop ? u : -u, p.transform = y(a, u), this.transition({ to: p, onTransitionEnd: { transform: this.layoutPosition }, isCleaning: !0 }) }, a.prototype.goTo = function (t, e) { this.setPosition(t, e), this.layoutPosition() }, a.prototype.moveTo = h ? a.prototype._transitionTo : a.prototype.goTo, a.prototype.setPosition = function (t, e) { this.position.x = parseInt(t, 10), this.position.y = parseInt(e, 10) }, a.prototype._nonTransition = function (t) { this.css(t.to), t.isCleaning && this._removeStyles(t.to); for (var e in t.onTransitionEnd) t.onTransitionEnd[e].call(this) }, a.prototype._transition = function (t) { if (!parseFloat(this.layout.options.transitionDuration)) return this._nonTransition(t), void 0; var e = this._transn; for (var i in t.onTransitionEnd) e.onEnd[i] = t.onTransitionEnd[i]; for (i in t.to) e.ingProperties[i] = !0, t.isCleaning && (e.clean[i] = !0); if (t.from) { this.css(t.from); var o = this.element.offsetHeight; o = null } this.enableTransition(t.to), this.css(t.to), this.isTransitioning = !0 }; var m = p && o(p) + ",opacity"; a.prototype.enableTransition = function () { this.isTransitioning || (this.css({ transitionProperty: m, transitionDuration: this.layout.options.transitionDuration }), this.element.addEventListener(c, this, !1)) }, a.prototype.transition = a.prototype[u ? "_transition" : "_nonTransition"], a.prototype.onwebkitTransitionEnd = function (t) { this.ontransitionend(t) }, a.prototype.onotransitionend = function (t) { this.ontransitionend(t) }; var g = { "-webkit-transform": "transform", "-moz-transform": "transform", "-o-transform": "transform" }; a.prototype.ontransitionend = function (t) { if (t.target === this.element) { var e = this._transn, o = g[t.propertyName] || t.propertyName; if (delete e.ingProperties[o], i(e.ingProperties) && this.disableTransition(), o in e.clean && (this.element.style[t.propertyName] = "", delete e.clean[o]), o in e.onEnd) { var n = e.onEnd[o]; n.call(this), delete e.onEnd[o] } this.emitEvent("transitionEnd", [this]) } }, a.prototype.disableTransition = function () { this.removeTransitionStyles(), this.element.removeEventListener(c, this, !1), this.isTransitioning = !1 }, a.prototype._removeStyles = function (t) { var e = {}; for (var i in t) e[i] = ""; this.css(e) }; var v = { transitionProperty: "", transitionDuration: "" }; return a.prototype.removeTransitionStyles = function () { this.css(v) }, a.prototype.removeElem = function () { this.element.parentNode.removeChild(this.element), this.emitEvent("remove", [this]) }, a.prototype.remove = function () { if (!u || !parseFloat(this.layout.options.transitionDuration)) return this.removeElem(), void 0; var t = this; this.on("transitionEnd", function () { return t.removeElem(), !0 }), this.hide() }, a.prototype.reveal = function () { delete this.isHidden, this.css({ display: "" }); var t = this.layout.options; this.transition({ from: t.hiddenStyle, to: t.visibleStyle, isCleaning: !0 }) }, a.prototype.hide = function () { this.isHidden = !0, this.css({ display: "" }); var t = this.layout.options; this.transition({ from: t.visibleStyle, to: t.hiddenStyle, isCleaning: !0, onTransitionEnd: { opacity: function () { this.isHidden && this.css({ display: "none" }) } } }) }, a.prototype.destroy = function () { this.css({ position: "", left: "", right: "", top: "", bottom: "", transition: "", transform: "" }) }, a } var r = t.getComputedStyle, s = r ? function (t) { return r(t, null) } : function (t) { return t.currentStyle }; "function" == typeof define && define.amd ? define("outlayer/item", ["eventEmitter/EventEmitter", "get-size/get-size", "get-style-property/get-style-property"], n) : (t.Outlayer = {}, t.Outlayer.Item = n(t.EventEmitter, t.getSize, t.getStyleProperty)) }(window), function (t) { function e(t, e) { for (var i in e) t[i] = e[i]; return t } function i(t) { return "[object Array]" === f.call(t) } function o(t) { var e = []; if (i(t)) e = t; else if (t && "number" == typeof t.length) for (var o = 0, n = t.length; n > o; o++) e.push(t[o]); else e.push(t); return e } function n(t, e) { var i = d(e, t); -1 !== i && e.splice(i, 1) } function r(t) { return t.replace(/(.)([A-Z])/g, function (t, e, i) { return e + "-" + i }).toLowerCase() } function s(i, s, f, d, l, y) { function m(t, i) { if ("string" == typeof t && (t = a.querySelector(t)), !t || !c(t)) return u && u.error("Bad " + this.constructor.namespace + " element: " + t), void 0; this.element = t, this.options = e({}, this.constructor.defaults), this.option(i); var o = ++g; this.element.outlayerGUID = o, v[o] = this, this._create(), this.options.isInitLayout && this.layout() } var g = 0, v = {}; return m.namespace = "outlayer", m.Item = y, m.defaults = { containerStyle: { position: "relative" }, isInitLayout: !0, isOriginLeft: !0, isOriginTop: !0, isResizeBound: !0, isResizingContainer: !0, transitionDuration: "0.4s", hiddenStyle: { opacity: 0, transform: "scale(0.001)" }, visibleStyle: { opacity: 1, transform: "scale(1)" } }, e(m.prototype, f.prototype), m.prototype.option = function (t) { e(this.options, t) }, m.prototype._create = function () { this.reloadItems(), this.stamps = [], this.stamp(this.options.stamp), e(this.element.style, this.options.containerStyle), this.options.isResizeBound && this.bindResize() }, m.prototype.reloadItems = function () { this.items = this._itemize(this.element.children) }, m.prototype._itemize = function (t) { for (var e = this._filterFindItemElements(t), i = this.constructor.Item, o = [], n = 0, r = e.length; r > n; n++) { var s = e[n], a = new i(s, this); o.push(a) } return o }, m.prototype._filterFindItemElements = function (t) { t = o(t); for (var e = this.options.itemSelector, i = [], n = 0, r = t.length; r > n; n++) { var s = t[n]; if (c(s)) if (e) { l(s, e) && i.push(s); for (var a = s.querySelectorAll(e), u = 0, p = a.length; p > u; u++) i.push(a[u]) } else i.push(s) } return i }, m.prototype.getItemElements = function () { for (var t = [], e = 0, i = this.items.length; i > e; e++) t.push(this.items[e].element); return t }, m.prototype.layout = function () { this._resetLayout(), this._manageStamps(); var t = void 0 !== this.options.isLayoutInstant ? this.options.isLayoutInstant : !this._isLayoutInited; this.layoutItems(this.items, t), this._isLayoutInited = !0 }, m.prototype._init = m.prototype.layout, m.prototype._resetLayout = function () { this.getSize() }, m.prototype.getSize = function () { this.size = d(this.element) }, m.prototype._getMeasurement = function (t, e) { var i, o = this.options[t]; o ? ("string" == typeof o ? i = this.element.querySelector(o) : c(o) && (i = o), this[t] = i ? d(i)[e] : o) : this[t] = 0 }, m.prototype.layoutItems = function (t, e) { t = this._getItemsForLayout(t), this._layoutItems(t, e), this._postLayout() }, m.prototype._getItemsForLayout = function (t) { for (var e = [], i = 0, o = t.length; o > i; i++) { var n = t[i]; n.isIgnored || e.push(n) } return e }, m.prototype._layoutItems = function (t, e) { function i() { o.emitEvent("layoutComplete", [o, t]) } var o = this; if (!t || !t.length) return i(), void 0; this._itemsOn(t, "layout", i); for (var n = [], r = 0, s = t.length; s > r; r++) { var a = t[r], u = this._getItemLayoutPosition(a); u.item = a, u.isInstant = e || a.isLayoutInstant, n.push(u) } this._processLayoutQueue(n) }, m.prototype._getItemLayoutPosition = function () { return { x: 0, y: 0 } }, m.prototype._processLayoutQueue = function (t) { for (var e = 0, i = t.length; i > e; e++) { var o = t[e]; this._positionItem(o.item, o.x, o.y, o.isInstant) } }, m.prototype._positionItem = function (t, e, i, o) { o ? t.goTo(e, i) : t.moveTo(e, i) }, m.prototype._postLayout = function () { this.resizeContainer() }, m.prototype.resizeContainer = function () { if (this.options.isResizingContainer) { var t = this._getContainerSize(); t && (this._setContainerMeasure(t.width, !0), this._setContainerMeasure(t.height, !1)) } }, m.prototype._getContainerSize = h, m.prototype._setContainerMeasure = function (t, e) { if (void 0 !== t) { var i = this.size; i.isBorderBox && (t += e ? i.paddingLeft + i.paddingRight + i.borderLeftWidth + i.borderRightWidth : i.paddingBottom + i.paddingTop + i.borderTopWidth + i.borderBottomWidth), t = Math.max(t, 0), this.element.style[e ? "width" : "height"] = t + "px" } }, m.prototype._itemsOn = function (t, e, i) { function o() { return n++, n === r && i.call(s), !0 } for (var n = 0, r = t.length, s = this, a = 0, u = t.length; u > a; a++) { var p = t[a]; p.on(e, o) } }, m.prototype.ignore = function (t) { var e = this.getItem(t); e && (e.isIgnored = !0) }, m.prototype.unignore = function (t) { var e = this.getItem(t); e && delete e.isIgnored }, m.prototype.stamp = function (t) { if (t = this._find(t)) { this.stamps = this.stamps.concat(t); for (var e = 0, i = t.length; i > e; e++) { var o = t[e]; this.ignore(o) } } }, m.prototype.unstamp = function (t) { if (t = this._find(t)) for (var e = 0, i = t.length; i > e; e++) { var o = t[e]; n(o, this.stamps), this.unignore(o) } }, m.prototype._find = function (t) { return t ? ("string" == typeof t && (t = this.element.querySelectorAll(t)), t = o(t)) : void 0 }, m.prototype._manageStamps = function () { if (this.stamps && this.stamps.length) { this._getBoundingRect(); for (var t = 0, e = this.stamps.length; e > t; t++) { var i = this.stamps[t]; this._manageStamp(i) } } }, m.prototype._getBoundingRect = function () { var t = this.element.getBoundingClientRect(), e = this.size; this._boundingRect = { left: t.left + e.paddingLeft + e.borderLeftWidth, top: t.top + e.paddingTop + e.borderTopWidth, right: t.right - (e.paddingRight + e.borderRightWidth), bottom: t.bottom - (e.paddingBottom + e.borderBottomWidth) } }, m.prototype._manageStamp = h, m.prototype._getElementOffset = function (t) { var e = t.getBoundingClientRect(), i = this._boundingRect, o = d(t), n = { left: e.left - i.left - o.marginLeft, top: e.top - i.top - o.marginTop, right: i.right - e.right - o.marginRight, bottom: i.bottom - e.bottom - o.marginBottom }; return n }, m.prototype.handleEvent = function (t) { var e = "on" + t.type; this[e] && this[e](t) }, m.prototype.bindResize = function () { this.isResizeBound || (i.bind(t, "resize", this), this.isResizeBound = !0) }, m.prototype.unbindResize = function () { this.isResizeBound && i.unbind(t, "resize", this), this.isResizeBound = !1 }, m.prototype.onresize = function () { function t() { e.resize(), delete e.resizeTimeout } this.resizeTimeout && clearTimeout(this.resizeTimeout); var e = this; this.resizeTimeout = setTimeout(t, 100) }, m.prototype.resize = function () { this.isResizeBound && this.needsResizeLayout() && this.layout() }, m.prototype.needsResizeLayout = function () { var t = d(this.element), e = this.size && t; return e && t.innerWidth !== this.size.innerWidth }, m.prototype.addItems = function (t) { var e = this._itemize(t); return e.length && (this.items = this.items.concat(e)), e }, m.prototype.appended = function (t) { var e = this.addItems(t); e.length && (this.layoutItems(e, !0), this.reveal(e)) }, m.prototype.prepended = function (t) { var e = this._itemize(t); if (e.length) { var i = this.items.slice(0); this.items = e.concat(i), this._resetLayout(), this._manageStamps(), this.layoutItems(e, !0), this.reveal(e), this.layoutItems(i) } }, m.prototype.reveal = function (t) { var e = t && t.length; if (e) for (var i = 0; e > i; i++) { var o = t[i]; o.reveal() } }, m.prototype.hide = function (t) { var e = t && t.length; if (e) for (var i = 0; e > i; i++) { var o = t[i]; o.hide() } }, m.prototype.getItem = function (t) { for (var e = 0, i = this.items.length; i > e; e++) { var o = this.items[e]; if (o.element === t) return o } }, m.prototype.getItems = function (t) { if (t && t.length) { for (var e = [], i = 0, o = t.length; o > i; i++) { var n = t[i], r = this.getItem(n); r && e.push(r) } return e } }, m.prototype.remove = function (t) { t = o(t); var e = this.getItems(t); if (e && e.length) { this._itemsOn(e, "remove", function () { this.emitEvent("removeComplete", [this, e]) }); for (var i = 0, r = e.length; r > i; i++) { var s = e[i]; s.remove(), n(s, this.items) } } }, m.prototype.destroy = function () { var t = this.element.style; t.height = "", t.position = "", t.width = ""; for (var e = 0, i = this.items.length; i > e; e++) { var o = this.items[e]; o.destroy() } this.unbindResize(), delete this.element.outlayerGUID, p && p.removeData(this.element, this.constructor.namespace) }, m.data = function (t) { var e = t && t.outlayerGUID; return e && v[e] }, m.create = function (t, i) { function o() { m.apply(this, arguments) } return Object.create ? o.prototype = Object.create(m.prototype) : e(o.prototype, m.prototype), o.prototype.constructor = o, o.defaults = e({}, m.defaults), e(o.defaults, i), o.prototype.settings = {}, o.namespace = t, o.data = m.data, o.Item = function () { y.apply(this, arguments) }, o.Item.prototype = new y, s(function () { for (var e = r(t), i = a.querySelectorAll(".js-" + e), n = "data-" + e + "-options", s = 0, h = i.length; h > s; s++) { var f, c = i[s], d = c.getAttribute(n); try { f = d && JSON.parse(d) } catch (l) { u && u.error("Error parsing " + n + " on " + c.nodeName.toLowerCase() + (c.id ? "#" + c.id : "") + ": " + l); continue } var y = new o(c, f); p && p.data(c, t, y) } }), p && p.bridget && p.bridget(t, o), o }, m.Item = y, m } var a = t.document, u = t.console, p = t.jQuery, h = function () { }, f = Object.prototype.toString, c = "object" == typeof HTMLElement ? function (t) { return t instanceof HTMLElement } : function (t) { return t && "object" == typeof t && 1 === t.nodeType && "string" == typeof t.nodeName }, d = Array.prototype.indexOf ? function (t, e) { return t.indexOf(e) } : function (t, e) { for (var i = 0, o = t.length; o > i; i++) if (t[i] === e) return i; return -1 }; "function" == typeof define && define.amd ? define("outlayer/outlayer", ["eventie/eventie", "doc-ready/doc-ready", "eventEmitter/EventEmitter", "get-size/get-size", "matches-selector/matches-selector", "./item"], s) : t.Outlayer = s(t.eventie, t.docReady, t.EventEmitter, t.getSize, t.matchesSelector, t.Outlayer.Item) }(window), function (t) { function e(t) { function e() { t.Item.apply(this, arguments) } return e.prototype = new t.Item, e.prototype._create = function () { this.id = this.layout.itemGUID++, t.Item.prototype._create.call(this), this.sortData = {} }, e.prototype.updateSortData = function () { if (!this.isIgnored) { this.sortData.id = this.id, this.sortData["original-order"] = this.id, this.sortData.random = Math.random(); var t = this.layout.options.getSortData, e = this.layout._sorters; for (var i in t) { var o = e[i]; this.sortData[i] = o(this.element, this) } } }, e } "function" == typeof define && define.amd ? define("isotope/js/item", ["outlayer/outlayer"], e) : (t.Isotope = t.Isotope || {}, t.Isotope.Item = e(t.Outlayer)) }(window), function (t) { function e(t, e) { function i(t) { this.isotope = t, t && (this.options = t.options[this.namespace], this.element = t.element, this.items = t.filteredItems, this.size = t.size) } return function () { function t(t) { return function () { return e.prototype[t].apply(this.isotope, arguments) } } for (var o = ["_resetLayout", "_getItemLayoutPosition", "_manageStamp", "_getContainerSize", "_getElementOffset", "needsResizeLayout"], n = 0, r = o.length; r > n; n++) { var s = o[n]; i.prototype[s] = t(s) } }(), i.prototype.needsVerticalResizeLayout = function () { var e = t(this.isotope.element), i = this.isotope.size && e; return i && e.innerHeight !== this.isotope.size.innerHeight }, i.prototype._getMeasurement = function () { this.isotope._getMeasurement.apply(this, arguments) }, i.prototype.getColumnWidth = function () { this.getSegmentSize("column", "Width") }, i.prototype.getRowHeight = function () { this.getSegmentSize("row", "Height") }, i.prototype.getSegmentSize = function (t, e) { var i = t + e, o = "outer" + e; if (this._getMeasurement(i, o), !this[i]) { var n = this.getFirstItemSize(); this[i] = n && n[o] || this.isotope.size["inner" + e] } }, i.prototype.getFirstItemSize = function () { var e = this.isotope.filteredItems[0]; return e && e.element && t(e.element) }, i.prototype.layout = function () { this.isotope.layout.apply(this.isotope, arguments) }, i.prototype.getSize = function () { this.isotope.getSize(), this.size = this.isotope.size }, i.modes = {}, i.create = function (t, e) { function o() { i.apply(this, arguments) } return o.prototype = new i, e && (o.options = e), o.prototype.namespace = t, i.modes[t] = o, o }, i } "function" == typeof define && define.amd ? define("isotope/js/layout-mode", ["get-size/get-size", "outlayer/outlayer"], e) : (t.Isotope = t.Isotope || {}, t.Isotope.LayoutMode = e(t.getSize, t.Outlayer)) }(window), function (t) { function e(t, e) { var o = t.create("masonry"); return o.prototype._resetLayout = function () { this.getSize(), this._getMeasurement("columnWidth", "outerWidth"), this._getMeasurement("gutter", "outerWidth"), this.measureColumns(); var t = this.cols; for (this.colYs = []; t--;) this.colYs.push(0); this.maxY = 0 }, o.prototype.measureColumns = function () { if (this.getContainerWidth(), !this.columnWidth) { var t = this.items[0], i = t && t.element; this.columnWidth = i && e(i).outerWidth || this.containerWidth } this.columnWidth += this.gutter, this.cols = Math.floor((this.containerWidth + this.gutter) / this.columnWidth), this.cols = Math.max(this.cols, 1) }, o.prototype.getContainerWidth = function () { var t = this.options.isFitWidth ? this.element.parentNode : this.element, i = e(t); this.containerWidth = i && i.innerWidth }, o.prototype._getItemLayoutPosition = function (t) { t.getSize(); var e = t.size.outerWidth % this.columnWidth, o = e && 1 > e ? "round" : "ceil", n = Math[o](t.size.outerWidth / this.columnWidth); n = Math.min(n, this.cols); for (var r = this._getColGroup(n), s = Math.min.apply(Math, r), a = i(r, s), u = { x: this.columnWidth * a, y: s }, p = s + t.size.outerHeight, h = this.cols + 1 - r.length, f = 0; h > f; f++) this.colYs[a + f] = p; return u }, o.prototype._getColGroup = function (t) { if (2 > t) return this.colYs; for (var e = [], i = this.cols + 1 - t, o = 0; i > o; o++) { var n = this.colYs.slice(o, o + t); e[o] = Math.max.apply(Math, n) } return e }, o.prototype._manageStamp = function (t) { var i = e(t), o = this._getElementOffset(t), n = this.options.isOriginLeft ? o.left : o.right, r = n + i.outerWidth, s = Math.floor(n / this.columnWidth); s = Math.max(0, s); var a = Math.floor(r / this.columnWidth); a -= r % this.columnWidth ? 0 : 1, a = Math.min(this.cols - 1, a); for (var u = (this.options.isOriginTop ? o.top : o.bottom) + i.outerHeight, p = s; a >= p; p++) this.colYs[p] = Math.max(u, this.colYs[p]) }, o.prototype._getContainerSize = function () { this.maxY = Math.max.apply(Math, this.colYs); var t = { height: this.maxY }; return this.options.isFitWidth && (t.width = this._getContainerFitWidth()), t }, o.prototype._getContainerFitWidth = function () { for (var t = 0, e = this.cols; --e && 0 === this.colYs[e];) t++; return (this.cols - t) * this.columnWidth - this.gutter }, o.prototype.needsResizeLayout = function () { var t = this.containerWidth; return this.getContainerWidth(), t !== this.containerWidth }, o } var i = Array.prototype.indexOf ? function (t, e) { return t.indexOf(e) } : function (t, e) { for (var i = 0, o = t.length; o > i; i++) { var n = t[i]; if (n === e) return i } return -1 }; "function" == typeof define && define.amd ? define("masonry/masonry", ["outlayer/outlayer", "get-size/get-size"], e) : t.Masonry = e(t.Outlayer, t.getSize) }(window), function (t) { function e(t, e) { for (var i in e) t[i] = e[i]; return t } function i(t, i) { var o = t.create("masonry"), n = o.prototype._getElementOffset, r = o.prototype.layout, s = o.prototype._getMeasurement; e(o.prototype, i.prototype), o.prototype._getElementOffset = n, o.prototype.layout = r, o.prototype._getMeasurement = s; var a = o.prototype.measureColumns; o.prototype.measureColumns = function () { this.items = this.isotope.filteredItems, a.call(this) }; var u = o.prototype._manageStamp; return o.prototype._manageStamp = function () { this.options.isOriginLeft = this.isotope.options.isOriginLeft, this.options.isOriginTop = this.isotope.options.isOriginTop, u.apply(this, arguments) }, o } "function" == typeof define && define.amd ? define("isotope/js/layout-modes/masonry", ["../layout-mode", "masonry/masonry"], i) : i(t.Isotope.LayoutMode, t.Masonry) }(window), function (t) { function e(t) { var e = t.create("fitRows"); return e.prototype._resetLayout = function () { this.x = 0, this.y = 0, this.maxY = 0 }, e.prototype._getItemLayoutPosition = function (t) { t.getSize(), 0 !== this.x && t.size.outerWidth + this.x > this.isotope.size.innerWidth && (this.x = 0, this.y = this.maxY); var e = { x: this.x, y: this.y }; return this.maxY = Math.max(this.maxY, this.y + t.size.outerHeight), this.x += t.size.outerWidth, e }, e.prototype._getContainerSize = function () { return { height: this.maxY } }, e } "function" == typeof define && define.amd ? define("isotope/js/layout-modes/fit-rows", ["../layout-mode"], e) : e(t.Isotope.LayoutMode) }(window), function (t) { function e(t) { var e = t.create("vertical", { horizontalAlignment: 0 }); return e.prototype._resetLayout = function () { this.y = 0 }, e.prototype._getItemLayoutPosition = function (t) { t.getSize(); var e = (this.isotope.size.innerWidth - t.size.outerWidth) * this.options.horizontalAlignment, i = this.y; return this.y += t.size.outerHeight, { x: e, y: i } }, e.prototype._getContainerSize = function () { return { height: this.y } }, e } "function" == typeof define && define.amd ? define("isotope/js/layout-modes/vertical", ["../layout-mode"], e) : e(t.Isotope.LayoutMode) }(window), function (t) {
    function e(t, e) { for (var i in e) t[i] = e[i]; return t } function i(t) { return "[object Array]" === h.call(t) } function o(t) { var e = []; if (i(t)) e = t; else if (t && "number" == typeof t.length) for (var o = 0, n = t.length; n > o; o++) e.push(t[o]); else e.push(t); return e } function n(t, e) { var i = f(e, t); -1 !== i && e.splice(i, 1) } function r(t, i, r, u, h) {
        function f(t, e) { return function (i, o) { for (var n = 0, r = t.length; r > n; n++) { var s = t[n], a = i.sortData[s], u = o.sortData[s]; if (a > u || u > a) { var p = void 0 !== e[s] ? e[s] : e, h = p ? 1 : -1; return (a > u ? 1 : -1) * h } } return 0 } } var c = t.create("isotope", { layoutMode: "masonry", isJQueryFiltering: !0, sortAscending: !0 }); c.Item = u, c.LayoutMode = h, c.prototype._create = function () { this.itemGUID = 0, this._sorters = {}, this._getSorters(), t.prototype._create.call(this), this.modes = {}, this.filteredItems = this.items, this.sortHistory = ["original-order"]; for (var e in h.modes) this._initLayoutMode(e) }, c.prototype.reloadItems = function () { this.itemGUID = 0, t.prototype.reloadItems.call(this) }, c.prototype._itemize = function () { for (var e = t.prototype._itemize.apply(this, arguments), i = 0, o = e.length; o > i; i++) { var n = e[i]; n.id = this.itemGUID++ } return this._updateItemsSortData(e), e }, c.prototype._initLayoutMode = function (t) { var i = h.modes[t], o = this.options[t] || {}; this.options[t] = i.options ? e(i.options, o) : o, this.modes[t] = new i(this) }, c.prototype.layout = function () { return !this._isLayoutInited && this.options.isInitLayout ? (this.arrange(), void 0) : (this._layout(), void 0) }, c.prototype._layout = function () { var t = this._getIsInstant(); this._resetLayout(), this._manageStamps(), this.layoutItems(this.filteredItems, t), this._isLayoutInited = !0 }, c.prototype.arrange = function (t) { this.option(t), this._getIsInstant(), this.filteredItems = this._filter(this.items), this._sort(), this._layout() }, c.prototype._init = c.prototype.arrange, c.prototype._getIsInstant = function () { var t = void 0 !== this.options.isLayoutInstant ? this.options.isLayoutInstant : !this._isLayoutInited; return this._isInstant = t, t }, c.prototype._filter = function (t) { function e() { f.reveal(n), f.hide(r) } var i = this.options.filter; i = i || "*"; for (var o = [], n = [], r = [], s = this._getFilterTest(i), a = 0, u = t.length; u > a; a++) { var p = t[a]; if (!p.isIgnored) { var h = s(p); h && o.push(p), h && p.isHidden ? n.push(p) : h || p.isHidden || r.push(p) } } var f = this; return this._isInstant ? this._noTransition(e) : e(), o }, c.prototype._getFilterTest = function (t) { return s && this.options.isJQueryFiltering ? function (e) { return s(e.element).is(t) } : "function" == typeof t ? function (e) { return t(e.element) } : function (e) { return r(e.element, t) } }, c.prototype.updateSortData = function (t) {
            this._getSorters(), t = o(t); var e = this.getItems(t); e = e.length ? e : this.items, this._updateItemsSortData(e)
        }, c.prototype._getSorters = function () { var t = this.options.getSortData; for (var e in t) { var i = t[e]; this._sorters[e] = d(i) } }, c.prototype._updateItemsSortData = function (t) { for (var e = 0, i = t.length; i > e; e++) { var o = t[e]; o.updateSortData() } }; var d = function () { function t(t) { if ("string" != typeof t) return t; var i = a(t).split(" "), o = i[0], n = o.match(/^\[(.+)\]$/), r = n && n[1], s = e(r, o), u = c.sortDataParsers[i[1]]; return t = u ? function (t) { return t && u(s(t)) } : function (t) { return t && s(t) } } function e(t, e) { var i; return i = t ? function (e) { return e.getAttribute(t) } : function (t) { var i = t.querySelector(e); return i && p(i) } } return t }(); c.sortDataParsers = { parseInt: function (t) { return parseInt(t, 10) }, parseFloat: function (t) { return parseFloat(t) } }, c.prototype._sort = function () { var t = this.options.sortBy; if (t) { var e = [].concat.apply(t, this.sortHistory), i = f(e, this.options.sortAscending); this.filteredItems.sort(i), t !== this.sortHistory[0] && this.sortHistory.unshift(t) } }, c.prototype._mode = function () { var t = this.options.layoutMode, e = this.modes[t]; if (!e) throw Error("No layout mode: " + t); return e.options = this.options[t], e }, c.prototype._resetLayout = function () { t.prototype._resetLayout.call(this), this._mode()._resetLayout() }, c.prototype._getItemLayoutPosition = function (t) { return this._mode()._getItemLayoutPosition(t) }, c.prototype._manageStamp = function (t) { this._mode()._manageStamp(t) }, c.prototype._getContainerSize = function () { return this._mode()._getContainerSize() }, c.prototype.needsResizeLayout = function () { return this._mode().needsResizeLayout() }, c.prototype.appended = function (t) { var e = this.addItems(t); if (e.length) { var i = this._filterRevealAdded(e); this.filteredItems = this.filteredItems.concat(i) } }, c.prototype.prepended = function (t) { var e = this._itemize(t); if (e.length) { var i = this.items.slice(0); this.items = e.concat(i), this._resetLayout(), this._manageStamps(); var o = this._filterRevealAdded(e); this.layoutItems(i), this.filteredItems = o.concat(this.filteredItems) } }, c.prototype._filterRevealAdded = function (t) { var e = this._noTransition(function () { return this._filter(t) }); return this.layoutItems(e, !0), this.reveal(e), t }, c.prototype.insert = function (t) { var e = this.addItems(t); if (e.length) { var i, o, n = e.length; for (i = 0; n > i; i++) o = e[i], this.element.appendChild(o.element); var r = this._filter(e); for (this._noTransition(function () { this.hide(r) }), i = 0; n > i; i++) e[i].isLayoutInstant = !0; for (this.arrange(), i = 0; n > i; i++) delete e[i].isLayoutInstant; this.reveal(r) } }; var l = c.prototype.remove; return c.prototype.remove = function (t) { t = o(t); var e = this.getItems(t); if (l.call(this, t), e && e.length) for (var i = 0, r = e.length; r > i; i++) { var s = e[i]; n(s, this.filteredItems) } }, c.prototype._noTransition = function (t) { var e = this.options.transitionDuration; this.options.transitionDuration = 0; var i = t.call(this); return this.options.transitionDuration = e, i }, c
    } var s = t.jQuery, a = String.prototype.trim ? function (t) { return t.trim() } : function (t) { return t.replace(/^\s+|\s+$/g, "") }, u = document.documentElement, p = u.textContent ? function (t) { return t.textContent } : function (t) { return t.innerText }, h = Object.prototype.toString, f = Array.prototype.indexOf ? function (t, e) { return t.indexOf(e) } : function (t, e) { for (var i = 0, o = t.length; o > i; i++) if (t[i] === e) return i; return -1 }; "function" == typeof define && define.amd ? define(["outlayer/outlayer", "get-size/get-size", "matches-selector/matches-selector", "isotope/js/item", "isotope/js/layout-mode", "isotope/js/layout-modes/masonry", "isotope/js/layout-modes/fit-rows", "isotope/js/layout-modes/vertical"], r) : t.Isotope = r(t.Outlayer, t.getSize, t.matchesSelector, t.Isotope.Item, t.Isotope.LayoutMode)
}(window);;
/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/
; if ("document" in self && !("classList" in document.createElement("_"))) { (function (j) { "use strict"; if (!("Element" in j)) { return } var a = "classList", f = "prototype", m = j.Element[f], b = Object, k = String[f].trim || function () { return this.replace(/^\s+|\s+$/g, "") }, c = Array[f].indexOf || function (q) { var p = 0, o = this.length; for (; p < o; p++) { if (p in this && this[p] === q) { return p } } return -1 }, n = function (o, p) { this.name = o; this.code = DOMException[o]; this.message = p }, g = function (p, o) { if (o === "") { throw new n("SYNTAX_ERR", "An invalid or illegal string was specified") } if (/\s/.test(o)) { throw new n("INVALID_CHARACTER_ERR", "String contains an invalid character") } return c.call(p, o) }, d = function (s) { var r = k.call(s.getAttribute("class") || ""), q = r ? r.split(/\s+/) : [], p = 0, o = q.length; for (; p < o; p++) { this.push(q[p]) } this._updateClassName = function () { s.setAttribute("class", this.toString()) } }, e = d[f] = [], i = function () { return new d(this) }; n[f] = Error[f]; e.item = function (o) { return this[o] || null }; e.contains = function (o) { o += ""; return g(this, o) !== -1 }; e.add = function () { var s = arguments, r = 0, p = s.length, q, o = false; do { q = s[r] + ""; if (g(this, q) === -1) { this.push(q); o = true } } while (++r < p); if (o) { this._updateClassName() } }; e.remove = function () { var t = arguments, s = 0, p = t.length, r, o = false; do { r = t[s] + ""; var q = g(this, r); if (q !== -1) { this.splice(q, 1); o = true } } while (++s < p); if (o) { this._updateClassName() } }; e.toggle = function (p, q) { p += ""; var o = this.contains(p), r = o ? q !== true && "remove" : q !== false && "add"; if (r) { this[r](p) } return !o }; e.toString = function () { return this.join(" ") }; if (b.defineProperty) { var l = { get: i, enumerable: true, configurable: true }; try { b.defineProperty(m, a, l) } catch (h) { if (h.number === -2146823252) { l.enumerable = false; b.defineProperty(m, a, l) } } } else { if (b[f].__defineGetter__) { m.__defineGetter__(a, i) } } }(self)) };

/*!
     * enquire.js v2.1.1 - Awesome Media Queries in JavaScript
     * Copyright (c) 2014 Nick Williams - http://wicky.nillia.ms/enquire.js
     * License: MIT (http://www.opensource.org/licenses/mit-license.php)
     */

!function (a, b, c) { var d = window.matchMedia; "undefined" != typeof module && module.exports ? module.exports = c(d) : "function" == typeof define && define.amd ? define(function () { return b[a] = c(d) }) : b[a] = c(d) }("enquire", this, function (a) { "use strict"; function b(a, b) { var c, d = 0, e = a.length; for (d; e > d && (c = b(a[d], d), c !== !1) ; d++); } function c(a) { return "[object Array]" === Object.prototype.toString.apply(a) } function d(a) { return "function" == typeof a } function e(a) { this.options = a, !a.deferSetup && this.setup() } function f(b, c) { this.query = b, this.isUnconditional = c, this.handlers = [], this.mql = a(b); var d = this; this.listener = function (a) { d.mql = a, d.assess() }, this.mql.addListener(this.listener) } function g() { if (!a) throw new Error("matchMedia not present, legacy browsers require a polyfill"); this.queries = {}, this.browserIsIncapable = !a("only all").matches } return e.prototype = { setup: function () { this.options.setup && this.options.setup(), this.initialised = !0 }, on: function () { !this.initialised && this.setup(), this.options.match && this.options.match() }, off: function () { this.options.unmatch && this.options.unmatch() }, destroy: function () { this.options.destroy ? this.options.destroy() : this.off() }, equals: function (a) { return this.options === a || this.options.match === a } }, f.prototype = { addHandler: function (a) { var b = new e(a); this.handlers.push(b), this.matches() && b.on() }, removeHandler: function (a) { var c = this.handlers; b(c, function (b, d) { return b.equals(a) ? (b.destroy(), !c.splice(d, 1)) : void 0 }) }, matches: function () { return this.mql.matches || this.isUnconditional }, clear: function () { b(this.handlers, function (a) { a.destroy() }), this.mql.removeListener(this.listener), this.handlers.length = 0 }, assess: function () { var a = this.matches() ? "on" : "off"; b(this.handlers, function (b) { b[a]() }) } }, g.prototype = { register: function (a, e, g) { var h = this.queries, i = g && this.browserIsIncapable; return h[a] || (h[a] = new f(a, i)), d(e) && (e = { match: e }), c(e) || (e = [e]), b(e, function (b) { h[a].addHandler(b) }), this }, unregister: function (a, b) { var c = this.queries[a]; return c && (b ? c.removeHandler(b) : (c.clear(), delete this.queries[a])), this } }, new g });


function fixInteractives() {
    // This is somewhat nasty but right now, we're looking up interactives by their ID in spaces.
    var lookup = {
        "poll/125066": "stateofstates",
        "poll/142631": "usleadership",
        "poll/145913": "communitywellbeing",
        "poll/145487": "employment",
        "gallupcareers/178535": "selectionprocess"
    }
    var pathbits = document.location.pathname.split("/");
    if (pathbits.length > 2) {
        var interactive = lookup[pathbits[1] + "/" + pathbits[2]];
        // Do custom pre-load things for each interactive type:
        switch (interactive) {
            case "stateofstates":
                document.querySelector(".soslWrapper").style.display = "none";
                break;
            default:
                break;
        };
        if (interactive) {
            gel.load.script('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js')
            .wait()
            .script('/Assets/Themes/Wwwv7/Javascript/interactive-' + interactive + '.js');
            var css = document.createElement("link");
            css.rel = "stylesheet";
            css.href = '/Assets/Themes/WwwV7/CSS/interactive-' + interactive + '.css';
            document.head.appendChild(css);
        }
    }
};

domReady(function () {
    fixInteractives();
    picturefill({
        reevaluate: true
    });
});;
var masonryContainer = document.querySelector('.masonrycontainer');
var masonryInstance = null;
var masonryOptions = {
    transitionDuration: 0,
    stamp: '.tile-alert',
    hiddenStyle: {
        opacity: 0
    },
    masonry: {
        columnWidth: 'section',
        itemSelector: 'section'
    }
};

if (masonryContainer) {
    // Get all the elements from the aside, merge them into the main
    // with the logic 5 main, 5 aside, 5 main, 5 aside etc...
    (function mergeNews() {
        var mainParent = document.querySelector(".masonrycontainer");
        var asideItems = document.querySelectorAll("aside.newsfeed > section");
        var mainItems = mainParent.querySelectorAll(".masonrycontainer > section");
        var insertBeforeEls = [];

        for (var i = 0; i < mainItems.length; i += 5) {
            if (i > 0) {
                insertBeforeEls.push(mainItems[i]);
            }
        }

        for (var j = 0; j < insertBeforeEls.length; j++) {
            for (var k = j * 5; k < Math.min((j + 1) * 5, asideItems.length) ; k++) {
                var cloned = asideItems[k].cloneNode(true);
                cloned.className += ' fitem merged';
                mainParent.insertBefore(cloned, insertBeforeEls[j]);
            }
        }
    })();

    // Function to kill the current masonry instance, used when switching from desktop to mobile
    var killIsotope = function () {
        masonryContainer.classList.remove("masonry-active");
        if (masonryInstance) {
            masonryInstance.destroy();
        }
    };

    // Function to revive the current masonry instance, used when switching from mobile to desktop
    var resetIsotope = function () {
        killIsotope();
        loadIsotope();
    };

    var revealTiles = function () {
        // Animate in the tiles on page load.
        for (var i = 0; i < masonryContainer.children.length; i++) {
            if (masonryContainer.children[i].classList) {
                masonryContainer.children[i].classList.add("masonry-revealed");
            }
        };
    }

    // Single-run function for initializing the masonry layout
    var loadIsotope = function () {
        if (masonryInstance) {
            killIsotope();
        }
        if (masonryContainer.classList) {
            masonryContainer.classList.add("masonry-active");
        }
        else {
            masonryContainer.className += " masonry-active";
        }
        masonryInstance = new Isotope(masonryContainer, masonryOptions);
        masonryInstance.layout();
        revealTiles();
        if (document.readyState === "complete") {
            revealTiles();
        } else {
            window.addEventListener("load", function () {
                revealTiles();
            });
        }

        // layout Isotope again after all images have loaded
        if (imagesLoaded) {
            imagesLoaded(masonryContainer, function () {
                masonryInstance.layout();
                picturefill({
                    reevaluate: true
                });
            });
        };
    };

    // Register the masonry functions to trigger based on media queries
    enquire.register("screen and (min-width: 30.063em)", {
        match: resetIsotope,
        unmatch: killIsotope,
        destroy: killIsotope
    });
}

function addLoadMore() {
    // Search load more
    var contentMorePanel = document.querySelector(".content-more");
    var loadMoreButton = document.querySelector(".search-load-more");
    var loadMoreCount = -1;

    if (!loadMoreButton) {
        //
    } else if (!loadMoreButton.getAttribute("data-startpage")) {
        contentMorePanel.style.display = 'none';
    } else {
        loadMoreButton.addEventListener("click", function (event) {
            var startP = parseInt(loadMoreButton.getAttribute("data-startpage"), 10);
            var totalP = parseInt(loadMoreButton.getAttribute("data-totalpages"), 10);
            var currentP = parseInt(loadMoreButton.getAttribute("data-currentpage"), 10);
            var currentQ = loadMoreButton.getAttribute("data-qs") || window.location.href.slice(window.location.href.indexOf('?') + 1);
            //console.log(currentQ);
            var nextP = currentP + 1;
            if (startP && nextP <= totalP && nextP > loadMoreCount) {
                // Shy the load more
                loadMoreButton.style.opacity = 0.5;
                loadMoreCount = nextP;
                var request = new XMLHttpRequest();
                request.open('GET',
                            "/Search/raw.aspx?" + currentQ.replace("&p=" + startP, "&p=" + nextP),
                            true);

                request.onload = function () {
                    if (request.status >= 200 && request.status < 400) {
                        // Success!
                        loadMoreButton.setAttribute("data-currentpage", nextP);
                        var rt = request.responseText;
                        if (nextP + 1 > totalP) {
                            contentMorePanel.style.display = 'none';
                        }
                        // Do we have a masonry instance?
                        var resultsEl = document.querySelectorAll("div.masonrycontainer")[0];
                        if (masonryInstance) {
                            // Turn the response text into DOM nodes by making an element we dont need
                            var fragment = document.createElement("div");
                            fragment.innerHTML = request.responseText;
                            // Pop off all the created child elements
                            while (fragment.children.length > 0) {
                                var aChild = resultsEl.appendChild(fragment.children[0]);
                                masonryInstance.appended(aChild);
                            }
                            
                            for (var i = 0; i < masonryContainer.children.length; i++) {
                                if (masonryContainer.children[i].classList) {
                                    masonryContainer.children[i].classList.add("fitem");
                                    masonryContainer.children[i].classList.add("masonry-revealed");
                                }
                            };
                            masonryInstance.layout();
                            if (imagesLoaded) {
                                imagesLoaded(masonryContainer, function () {
                                    masonryInstance.layout();
                                    masonryInstance.options.transitionDuration = '0.4s';
                                });
                            }
                            loadMoreButton.style.opacity = 1;
                        } else {
                            resultsEl.insertAdjacentHTML('beforeend', request.responseText);
                        }

                    } else {
                        // We reached our target server, but it returned an error
                        contentMorePanel.style.display = 'none';

                    }
                };

                request.onerror = function () {
                    // There was a connection error of some sort
                    contentMorePanel.style.display = 'none';
                };

                request.send();
            } else {
                contentMorePanel.style.display = 'none';
            }
        });
    };
};

addLoadMore();;
