/* Minification failed. Returning unminified contents.
(5153,15-16): run-time error JS1010: Expected identifier: .
(5153,15-16): run-time error JS1195: Expected expression: .
 */
smithAndMorrisHtml = '\
<div id="boxes">\
    <div id="dialog" class="window">\
        <a href="#" class="close agree">\
            <img src="https://www.outdoorandcountry.co.uk/store/sm-april-oandc_merge_popup_2.jpg" /></a>\
    </div>\
    <div id="mask"></div>\
</div>';

ptarmiganHtml = '<div id="boxes-ptarmigan">\
    <div id="dialog-ptarmigan" class="window">\
        <a href="#" class="close agree">\
            <img src="https://www.outdoorandcountry.co.uk/store/ptarmigan-banner.jpg" /></a>\
    </div>\
    <div id="mask"></div>\
</div>';

clearanceHtml = '\
<div id="warehouse-clearance">\
    <div id="dialog-clearance" class="window">\
        <a href="#" class="close agree">\
            <img src="https://outdoorftp-325c.kxcdn.com/imgs/warehouse-clearance-banner.jpg" alt="Clearance banner" />\
            <img class="timer" src="http://s.mmgo.io/t/SMF" alt="Timer" />\
        </a>\
    </div>\
    <div id="mask"></div>\
</div>';

$(document).ready(function () {

    var domain = getQueryVariable("site");
    if (domain === null)
        return;

    if (domain == 'sm' && showPopupOnCookieMissing(smithAndMorrisHtml, 'visitedbysmithandmorris', '#dialog') === true)
        return;
    if (domain == 'ptarmigan' && showPopupOnCookieMissing(ptarmiganHtml, 'visitedbyptarmigan', '#dialog-ptarmigan') === true)
        return;

});

function showPopupOnCookieMissing(html, cookieName, elementSelector) {
    if ($.cookie(cookieName) !== null)
        return false; // Popup not shown, caller can check for more popups to show.

    var addedElements = addPopup(html);

    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    //Set heigth and width to mask to fill up the whole screen
    $('#mask').css({
        'width': maskWidth,
        'height': maskHeight
    });

    //transition effect
    $('#mask').fadeIn(500);
    $('#mask').fadeTo("slow", 0.9);

    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();

    // Set the popup window to center.
    var popupElement = $(elementSelector);
    popupElement.css('top', winH / 2 - popupElement.height() / 2);
    popupElement.css('left', winW / 2 - popupElement.width() / 2);

    //transition effect
    popupElement.fadeIn(2000);

    $('.window .close').click(function (e) { // If close button is clicked.
        e.preventDefault(); // Cancel the link behavior.
        $(elementSelector).parent().remove();
    });

    //if mask is clicked
    $('#mask').click(function (e) {
        e.preventDefault(); // Cancel the link behavior.
        $(elementSelector).parent().remove();
    });
    $.cookie(cookieName, "true", { expires: 7 });

    return true; // Popup shown, no need to check for more popups.
}

function addPopup(html) {
    return $("#navouter").prepend(html);
}

function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split('&');
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split('=');
        if (decodeURIComponent(pair[0]) == variable) {
            return decodeURIComponent(pair[1]);
        }
    }

};
function ShowExpressDeliveryTime(shipOption) {
    if (!shipOption.deliveryCutOff || !shipOption.nextDeliverySlot) {
        HideExpressDeliveryTime();
        return;
    }
    var container = findDeliveryContainer();
    var textOrderWithin = document.createTextNode('Order within ');
    var spanTimescale = document.createElement('span');
    spanTimescale.innerText = shipOption.deliveryCutOff;
    var initalTextForDelivery = document.createTextNode(' for delivery on ');
    var spanDate = document.createElement('span');
    spanDate.innerText = shipOption.nextDeliverySlot;
    var finalTextForDelivery = document.createTextNode(' by selecting Express delivery');
    clearElementChildren(container);
    container.appendChild(textOrderWithin);
    container.appendChild(spanTimescale);
    container.appendChild(initalTextForDelivery);
    container.appendChild(spanDate);
    container.appendChild(finalTextForDelivery);
}
function HideExpressDeliveryTime() {
    var anchor = document.createElement('a');
    anchor.href = "/returns-policy";
    anchor.innerText = "90 day satisfaction guarantee with free UK returns";
    var container = findDeliveryContainer();
    clearElementChildren(container);
    container.appendChild(anchor);
}
function clearElementChildren(node) {
    while (node.hasChildNodes()) {
        node.removeChild(node.lastChild);
    }
}
function findDeliveryContainer() {
    return (document.getElementsByClassName('express-delivery')[0]);
}
var deliveryTimerHander;
function SetDeliveryUpdateTimer(seconds, func) {
    StopDeliveryUpdateTimer();
    if (seconds > 0) {
        deliveryTimerHander = setTimeout(func, seconds * 1000);
    }
}
function StopDeliveryUpdateTimer() {
    if (deliveryTimerHander != 0) {
        clearTimeout(deliveryTimerHander);
    }
    deliveryTimerHander = 0;
}
//# sourceMappingURL=basketCommon.js.map;
var basketConfirmDialog;
$(document).ready(function () {
    basketConfirmDialog = createBasketConfirmPopup();
});
function setBasketConfirmPopupText(dlg, name, price) {
    dlg.removeClass('wishlist');
    dlg.removeClass('wishlist-login');
    dlg.find('.QuickAdd_Description').html('Added to Basket - ');
    dlg.find(".QuickAdd_Name").text(name);
    dlg.find(".item-price").text(price);
    dlg.find("#PopupLink").attr("href", '/your-basket');
    dlg.find("#PopupLink").text('Secure Checkout');
    dlg.find(".related").remove();
}
function basketSuccess(cartResult, addToBasketFunc, context) {
    var dlg = basketConfirmDialog;
    setBasketConfirmPopupText(dlg, '', '');
    $(".item-count").text(cartResult.itemCountText);
    $(".order-total").text(cartResult.orderTotalText);
    $('.minicart-box').show();
    $('.mobile-cart').addClass('cart-has-items');
    dlg.find('#PopupDialogHeader').text('Added to Basket');
    dlg.find(".QuickAdd_Name").text(cartResult.mostRecentProductName);
    if (cartResult.colour) {
        dlg.find(".QuickAdd_Colour").text('Colour: ' + cartResult.colour);
    }
    else {
        dlg.find(".QuickAdd_Colour").text('');
    }
    if (cartResult.size) {
        dlg.find(".QuickAdd_Size").text('Size: ' + cartResult.size);
    }
    else {
        dlg.find(".QuickAdd_Size").text('');
    }
    dlg.find(".QuickAdd_Image").attr('src', cartResult.imageUrl);
    dlg.find(".item-price").text(cartResult.mostRecentProductPrice);
    var quickAddInner = dlg.find(".linked-results");
    if (cartResult.linkedProducts.length === 0) {
        quickAddInner.hide();
    }
    else {
        quickAddInner.show();
    }
    quickAddInner.html('<h3>Would you also like to add these recommended accessories?</h3>');
    for (var i = 0; i < cartResult.linkedProducts.length; i++) {
        var html = CreateLinkedProductHtml(cartResult.linkedProducts[i], addToBasketFunc, context);
        quickAddInner.append(html);
    }
    dlg.dialog('open');
}
function CreateLinkedProductHtml(product, addToBasketFunc, context) {
    var para = $('<p></p>');
    para.addClass('QuickAdd_Info');
    para.append('<a href="' + product.styleUrl + '" class="QuickAdd_Name">' + product.name + '</a>');
    para.append('<span>' + product.description + '</span>');
    var spanPrice = $('<span></span>');
    spanPrice.addClass("QuickAdd_Price");
    spanPrice.append(product.formattedPrice);
    var control = $("<div class='control-box'></div>");
    var basketAddLink = $("<a class='btn'>Yes please</a>");
    basketAddLink.click(function (e) {
        if (context !== null)
            addToBasketFunc.call(context, product.productId, product.posCode);
        else
            addToBasketFunc(product.productId, product.posCode);
    });
    control.append(spanPrice);
    control.append(basketAddLink);
    var relatedImage = $("<img src='" + product.imageUrl + "' height='64' width='64' />");
    var linkBox = $("<div class='linked-result'></div>");
    linkBox.append(relatedImage);
    linkBox.append(para);
    linkBox.append(control);
    return linkBox;
}
function createBasketConfirmPopup() {
    var dialogOpts = {
        modal: false,
        width: 'auto',
        closeText: '',
        autoOpen: false,
        zIndex: 65001,
        draggable: false,
        resizable: false
    };
    var dlg = $("#PopupDialog");
    dlg.dialog(dialogOpts);
    $('.ui-dialog-titlebar').remove();
    if (dlg.find('.product-info').length > 0)
        dlg.find('.ui-dialog').addClass('product-checkout-dialog');
    dlg.find(".ClosePopupDialog").click(function () { dlg.dialog('close'); });
    return dlg;
}
function AddToWishListSuccess() {
    SetDialogToDefaultText();
    basketConfirmDialog.addClass('wishlist');
    basketConfirmDialog.find('.QuickAdd_Description').html('This item has now been added to your wish list.');
    basketConfirmDialog.find("#PopupLink").text('Go To Wish List');
    basketConfirmDialog.find("#PopupLink").attr("href", '/wishlist');
    basketConfirmDialog.find('#PopupDialogHeader').text('Added to Wish List');
    basketConfirmDialog.dialog('open');
}
function SetDialogToDefaultText() {
    setBasketConfirmPopupText(basketConfirmDialog, '', '');
}
function ShowWishlistLoginRequired() {
    basketConfirmDialog.addClass('wishlist-login');
    basketConfirmDialog.find("#PopupLink").attr("href", '/sign-in?ReturnUrl=%2fwishlist');
    basketConfirmDialog.find("#PopupLink").text('Please Sign In');
    basketConfirmDialog.find('#PopupDialogHeader').text('Please Sign In');
    basketConfirmDialog.find('.QuickAdd_Description').html('You need to sign in or register to add items to your wish list.');
    basketConfirmDialog.find(".item-price").text("");
    basketConfirmDialog.dialog('open');
}
function AddToWishListFailed(err) {
    SetDialogToDefaultText();
    if (err.status === 404 || err.status === 302) {
        ShowWishlistLoginRequired();
        return;
    }
    basketConfirmDialog.addClass('wishlist-error');
    basketConfirmDialog.find('.QuickAdd_Description').html('Sorry, we couldn\'t add this item.');
    basketConfirmDialog.find("#PopupLink").attr("href", '/wishlist');
    basketConfirmDialog.find("#PopupLink").text('Go To Wish List');
    basketConfirmDialog.find('#PopupDialogHeader').text('Unable to add to wish list');
    basketConfirmDialog.find('.QuickAdd_Name').text('This might be due to temporary network problem, please try again soon.');
    basketConfirmDialog.find(".item-price").text("");
    basketConfirmDialog.dialog('open');
}
//# sourceMappingURL=basketSuccess.js.map;
var PageScripts;
(function (PageScripts) {
    var Brands = (function () {
        function Brands() {
            this.wireUpEventHandlers();
        }
        Brands.prototype.wireUpEventHandlers = function () {
            var self = this;
            $('.alphabet-select ul li').click(function (e) { self.onAlphabetClicked(e, this); });
        };
        Brands.prototype.onAlphabetClicked = function (e, jQueryThis) {
            var linkClicked = $(jQueryThis);
            var currentLetter = linkClicked.text().charAt(0);
            var currentTitle = linkClicked.text();
            e.preventDefault();
            if (linkClicked.hasClass('select-all')) {
                $('.brands-list h2.c-selected-title').text(currentTitle);
                $('ul.c-brand-column li').show();
                $('.brands-list .brands-list-generated').remove();
            }
            else if (linkClicked.hasClass('empty')) {
            }
            else if (linkClicked.hasClass('select-number')) {
                var brandLinks = $('ul.c-brand-column li.item-number');
                this.buildListFromBrandClass(currentTitle, brandLinks);
            }
            else {
                var brandLinks = $('ul.c-brand-column li.item-' + currentLetter);
                this.buildListFromBrandClass(currentTitle, brandLinks);
            }
        };
        Brands.prototype.buildListFromBrandClass = function (currentTitle, brandLinks) {
            $('.brands-list h2.c-selected-title').text(currentTitle);
            $('ul.c-brand-column li').hide();
            $('.brands-list .brands-list-generated').remove();
            $('.brands-list').append("<div class='brands-list-generated'><ul></ul></div>");
            var $itemArray = new Array();
            brandLinks.each(function () {
                var brandLink = $(this);
                var $itemHtml = brandLink.html();
                $itemArray.push($itemHtml);
            });
            var i;
            for (i = 0; i < $itemArray.length; ++i) {
                $('.brands-list .brands-list-generated ul').append("<li class='item-" + i + "'>" + $itemArray[i] + "</li>");
            }
        };
        return Brands;
    }());
    PageScripts.Brands = Brands;
})(PageScripts || (PageScripts = {}));
$(document).ready(function () {
    new PageScripts.Brands();
});
//# sourceMappingURL=brands.js.map;
jQuery(document).ready(function () {
	$i = 0;
	jQuery('#menu-root li.spc1').each(function() {
		$i++;
		jQuery(this).addClass('item'+$i+'');
	});
});;
/* 
  ------------------------------------------------
  PVII Equal CSS Columns scripts -Version 2
  Copyright (c) 2005 Project Seven Development
  www.projectseven.com
  Version: 2.1.0
  ------------------------------------------------
*/
function P7_colH2(){ //v2.1.0 by PVII-www.projectseven.com
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ //v2.1.0 by PVII-www.projectseven.com
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ //v2.1.0 by PVII-www.projectseven.com
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];
 if(!el.id)
 {el.id="p7eq"+i;}}}
 if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}
}
function P7_eqA2(el,p,pt){ //v2.1.0 by PVII-www.projectseven.com
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
};
; (function ($) {

    var defaults = {

        // GENERAL
        mode: 'horizontal',
        slideSelector: '',
        infiniteLoop: true,
        hideControlOnEnd: false,
        speed: 500,
        easing: null,
        slideMargin: 0,
        startSlide: 0,
        randomStart: false,
        captions: false,
        ticker: false,
        tickerHover: false,
        adaptiveHeight: false,
        adaptiveHeightSpeed: 500,
        video: false,
        useCSS: true,
        preloadImages: 'visible',
        responsive: true,
        slideZIndex: 50,
        wrapperClass: 'bx-wrapper',

        // TOUCH
        touchEnabled: true,
        swipeThreshold: 50,
        oneToOneTouch: true,
        preventDefaultSwipeX: true,
        preventDefaultSwipeY: false,

        // ACCESSIBILITY
        ariaLive: true,
        ariaHidden: true,

        // KEYBOARD
        keyboardEnabled: false,

        // PAGER
        pager: true,
        pagerType: 'full',
        pagerShortSeparator: ' / ',
        pagerSelector: null,
        buildPager: null,
        pagerCustom: null,

        // CONTROLS
        controls: true,
        nextText: 'Next',
        prevText: 'Prev',
        nextSelector: null,
        prevSelector: null,
        autoControls: false,
        startText: 'Start',
        stopText: 'Stop',
        autoControlsCombine: false,
        autoControlsSelector: null,

        // AUTO
        auto: false,
        pause: 4000,
        autoStart: true,
        autoDirection: 'next',
        stopAutoOnClick: false,
        autoHover: false,
        autoDelay: 0,
        autoSlideForOnePage: false,

        // CAROUSEL
        minSlides: 1,
        maxSlides: 1,
        moveSlides: 0,
        slideWidth: 0,
        shrinkItems: false,

        // CALLBACKS
        onSliderLoad: function () { return true; },
        onSlideBefore: function () { return true; },
        onSlideAfter: function () { return true; },
        onSlideNext: function () { return true; },
        onSlidePrev: function () { return true; },
        onSliderResize: function () { return true; }
    };

    $.fn.bxSlider = function (options) {

        if (this.length === 0) {
            return this;
        }

        // support multiple elements
        if (this.length > 1) {
            this.each(function () {
                $(this).bxSlider(options);
            });
            return this;
        }

        // create a namespace to be used throughout the plugin
        var slider = {},
        // set a reference to our slider element
        el = this,
        // get the original window dimens (thanks a lot IE)
        windowWidth = $(window).width(),
        windowHeight = $(window).height();

        // Return if slider is already initialized
        if ($(el).data('bxSlider')) { return; }

        /**
         * ===================================================================================
         * = PRIVATE FUNCTIONS
         * ===================================================================================
         */

        /**
         * Initializes namespace settings to be used throughout plugin
         */
        var init = function () {
            // Return if slider is already initialized
            if ($(el).data('bxSlider')) { return; }
            // merge user-supplied options with the defaults
            slider.settings = $.extend({}, defaults, options);
            // parse slideWidth setting
            slider.settings.slideWidth = parseInt(slider.settings.slideWidth);
            // store the original children
            //slider.children = el.children(slider.settings.slideSelector);
            slider.children = el.find(slider.settings.slideSelector); // TODO: This is patched, the public version uses Children and breaks our slider. Wait for update before applying. https://github.com/stevenwanderski/bxslider-4/pull/653/files
            // check if actual number of slides is less than minSlides / maxSlides
            if (slider.children.length < slider.settings.minSlides) { slider.settings.minSlides = slider.children.length; }
            if (slider.children.length < slider.settings.maxSlides) { slider.settings.maxSlides = slider.children.length; }
            // if random start, set the startSlide setting to random number
            if (slider.settings.randomStart) { slider.settings.startSlide = Math.floor(Math.random() * slider.children.length); }
            // store active slide information
            slider.active = { index: slider.settings.startSlide };
            // store if the slider is in carousel mode (displaying / moving multiple slides)
            slider.carousel = slider.settings.minSlides > 1 || slider.settings.maxSlides > 1 ? true : false;
            // if carousel, force preloadImages = 'all'
            if (slider.carousel) { slider.settings.preloadImages = 'all'; }
            // calculate the min / max width thresholds based on min / max number of slides
            // used to setup and update carousel slides dimensions
            slider.minThreshold = (slider.settings.minSlides * slider.settings.slideWidth) + ((slider.settings.minSlides - 1) * slider.settings.slideMargin);
            slider.maxThreshold = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin);
            // store the current state of the slider (if currently animating, working is true)
            slider.working = false;
            // initialize the controls object
            slider.controls = {};
            // initialize an auto interval
            slider.interval = null;
            // determine which property to use for transitions
            slider.animProp = slider.settings.mode === 'vertical' ? 'top' : 'left';
            // determine if hardware acceleration can be used
            slider.usingCSS = slider.settings.useCSS && slider.settings.mode !== 'fade' && (function () {
                // create our test div element
                var div = document.createElement('div'),
                // css transition properties
                props = ['WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
                // test for each property
                for (var i = 0; i < props.length; i++) {
                    if (div.style[props[i]] !== undefined) {
                        slider.cssPrefix = props[i].replace('Perspective', '').toLowerCase();
                        slider.animProp = '-' + slider.cssPrefix + '-transform';
                        return true;
                    }
                }
                return false;
            }());
            // if vertical mode always make maxSlides and minSlides equal
            if (slider.settings.mode === 'vertical') { slider.settings.maxSlides = slider.settings.minSlides; }
            // save original style data
            el.data('origStyle', el.attr('style'));
            el.children(slider.settings.slideSelector).each(function () {
                $(this).data('origStyle', $(this).attr('style'));
            });

            // perform all DOM / CSS modifications
            setup();
        };

        /**
         * Performs all DOM and CSS modifications
         */
        var setup = function () {
            var preloadSelector = slider.children.eq(slider.settings.startSlide); // set the default preload selector (visible)

            // wrap el in a wrapper
            el.wrap('<div class="' + slider.settings.wrapperClass + '"><div class="bx-viewport"></div></div>');
            // store a namespace reference to .bx-viewport
            slider.viewport = el.parent();

            // add aria-live if the setting is enabled and ticker mode is disabled
            if (slider.settings.ariaLive && !slider.settings.ticker) {
                slider.viewport.attr('aria-live', 'polite');
            }
            // add a loading div to display while images are loading
            slider.loader = $('<div class="bx-loading" />');
            slider.viewport.prepend(slider.loader);
            // set el to a massive width, to hold any needed slides
            // also strip any margin and padding from el
            el.css({
                width: slider.settings.mode === 'horizontal' ? (slider.children.length * 1000 + 215) + '%' : 'auto',
                position: 'relative'
            });
            // if using CSS, add the easing property
            if (slider.usingCSS && slider.settings.easing) {
                el.css('-' + slider.cssPrefix + '-transition-timing-function', slider.settings.easing);
                // if not using CSS and no easing value was supplied, use the default JS animation easing (swing)
            } else if (!slider.settings.easing) {
                slider.settings.easing = 'swing';
            }
            // make modifications to the viewport (.bx-viewport)
            slider.viewport.css({
                width: '100%',
                overflow: 'hidden',
                position: 'relative'
            });
            slider.viewport.parent().css({
                maxWidth: getViewportMaxWidth()
            });
            // make modification to the wrapper (.bx-wrapper)
            if (!slider.settings.pager && !slider.settings.controls) {
                slider.viewport.parent().css({
                    margin: '0 auto 0px'
                });
            }
            // apply css to all slider children
            slider.children.css({
                float: slider.settings.mode === 'horizontal' ? 'left' : 'none',
                listStyle: 'none',
                position: 'relative'
            });
            // apply the calculated width after the float is applied to prevent scrollbar interference
            slider.children.css('width', getSlideWidth());
            // if slideMargin is supplied, add the css
            if (slider.settings.mode === 'horizontal' && slider.settings.slideMargin > 0) { slider.children.css('marginRight', slider.settings.slideMargin); }
            if (slider.settings.mode === 'vertical' && slider.settings.slideMargin > 0) { slider.children.css('marginBottom', slider.settings.slideMargin); }
            // if "fade" mode, add positioning and z-index CSS
            if (slider.settings.mode === 'fade') {
                slider.children.css({
                    position: 'absolute',
                    zIndex: 0,
                    display: 'none'
                });
                // prepare the z-index on the showing element
                slider.children.eq(slider.settings.startSlide).css({ zIndex: slider.settings.slideZIndex, display: 'block' });
            }
            // create an element to contain all slider controls (pager, start / stop, etc)
            slider.controls.el = $('<div class="bx-controls" />');
            // if captions are requested, add them
            if (slider.settings.captions) { appendCaptions(); }
            // check if startSlide is last slide
            slider.active.last = slider.settings.startSlide === getPagerQty() - 1;
            // if video is true, set up the fitVids plugin
            if (slider.settings.video) { el.fitVids(); }
            if (slider.settings.preloadImages === 'all' || slider.settings.ticker) { preloadSelector = slider.children; }
            // only check for control addition if not in "ticker" mode
            if (!slider.settings.ticker) {
                // if controls are requested, add them
                if (slider.settings.controls) { appendControls(); }
                // if auto is true, and auto controls are requested, add them
                if (slider.settings.auto && slider.settings.autoControls) { appendControlsAuto(); }
                // if pager is requested, add it
                if (slider.settings.pager) { appendPager(); }
                // if any control option is requested, add the controls wrapper
                if (slider.settings.controls || slider.settings.autoControls || slider.settings.pager) { slider.viewport.after(slider.controls.el); }
                // if ticker mode, do not allow a pager
            } else {
                slider.settings.pager = false;
            }
            loadElements(preloadSelector, start);
        };

        var loadElements = function (selector, callback) {
            var total = selector.find('img:not([src=""]), iframe').length,
            count = 0;
            if (total === 0) {
                callback();
                return;
            }
            selector.find('img:not([src=""]), iframe').each(function () {
                $(this).one('load error', function () {
                    if (++count === total) { callback(); }
                }).each(function () {
                    if (this.complete) { $(this).load(); }
                });
            });
        };

        /**
         * Start the slider
         */
        var start = function () {
            // if infinite loop, prepare additional slides
            if (slider.settings.infiniteLoop && slider.settings.mode !== 'fade' && !slider.settings.ticker) {
                var slice = slider.settings.mode === 'vertical' ? slider.settings.minSlides : slider.settings.maxSlides,
                sliceAppend = slider.children.slice(0, slice).clone(true).addClass('bx-clone'),
                slicePrepend = slider.children.slice(-slice).clone(true).addClass('bx-clone');
                if (slider.settings.ariaHidden) {
                    sliceAppend.attr('aria-hidden', true);
                    slicePrepend.attr('aria-hidden', true);
                }
                el.append(sliceAppend).prepend(slicePrepend);
            }
            // remove the loading DOM element
            slider.loader.remove();
            // set the left / top position of "el"
            setSlidePosition();
            // if "vertical" mode, always use adaptiveHeight to prevent odd behavior
            if (slider.settings.mode === 'vertical') { slider.settings.adaptiveHeight = true; }
            // set the viewport height
            slider.viewport.height(getViewportHeight());
            // make sure everything is positioned just right (same as a window resize)
            el.redrawSlider();
            // onSliderLoad callback
            slider.settings.onSliderLoad.call(el, slider.active.index);
            // slider has been fully initialized
            slider.initialized = true;
            // bind the resize call to the window
            if (slider.settings.responsive) { $(window).bind('resize', resizeWindow); }
            // if auto is true and has more than 1 page, start the show
            if (slider.settings.auto && slider.settings.autoStart && (getPagerQty() > 1 || slider.settings.autoSlideForOnePage)) { initAuto(); }
            // if ticker is true, start the ticker
            if (slider.settings.ticker) { initTicker(); }
            // if pager is requested, make the appropriate pager link active
            if (slider.settings.pager) { updatePagerActive(slider.settings.startSlide); }
            // check for any updates to the controls (like hideControlOnEnd updates)
            if (slider.settings.controls) { updateDirectionControls(); }
            // if touchEnabled is true, setup the touch events
            if (slider.settings.touchEnabled && !slider.settings.ticker) { initTouch(); }
            // if keyboardEnabled is true, setup the keyboard events
            if (slider.settings.keyboardEnabled && !slider.settings.ticker) {
                $(document).keydown(keyPress);
            }
        };

        /**
         * Returns the calculated height of the viewport, used to determine either adaptiveHeight or the maxHeight value
         */
        var getViewportHeight = function () {
            var height = 0;
            // first determine which children (slides) should be used in our height calculation
            var children = $();
            // if mode is not "vertical" and adaptiveHeight is false, include all children
            if (slider.settings.mode !== 'vertical' && !slider.settings.adaptiveHeight) {
                children = slider.children;
            } else {
                // if not carousel, return the single active child
                if (!slider.carousel) {
                    children = slider.children.eq(slider.active.index);
                    // if carousel, return a slice of children
                } else {
                    // get the individual slide index
                    var currentIndex = slider.settings.moveSlides === 1 ? slider.active.index : slider.active.index * getMoveBy();
                    // add the current slide to the children
                    children = slider.children.eq(currentIndex);
                    // cycle through the remaining "showing" slides
                    for (i = 1; i <= slider.settings.maxSlides - 1; i++) {
                        // if looped back to the start
                        if (currentIndex + i >= slider.children.length) {
                            children = children.add(slider.children.eq(i - 1));
                        } else {
                            children = children.add(slider.children.eq(currentIndex + i));
                        }
                    }
                }
            }
            // if "vertical" mode, calculate the sum of the heights of the children
            if (slider.settings.mode === 'vertical') {
                children.each(function (index) {
                    height += $(this).outerHeight();
                });
                // add user-supplied margins
                if (slider.settings.slideMargin > 0) {
                    height += slider.settings.slideMargin * (slider.settings.minSlides - 1);
                }
                // if not "vertical" mode, calculate the max height of the children
            } else {
                height = Math.max.apply(Math, children.map(function () {
                    return $(this).outerHeight(false);
                }).get());
            }

            if (slider.viewport.css('box-sizing') === 'border-box') {
                height += parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom')) +
                      parseFloat(slider.viewport.css('border-top-width')) + parseFloat(slider.viewport.css('border-bottom-width'));
            } else if (slider.viewport.css('box-sizing') === 'padding-box') {
                height += parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom'));
            }

            return height;
        };

        /**
         * Returns the calculated width to be used for the outer wrapper / viewport
         */
        var getViewportMaxWidth = function () {
            var width = '100%';
            if (slider.settings.slideWidth > 0) {
                if (slider.settings.mode === 'horizontal') {
                    width = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin);
                } else {
                    width = slider.settings.slideWidth;
                }
            }
            return width;
        };

        /**
         * Returns the calculated width to be applied to each slide
         */
        var getSlideWidth = function () {
            var newElWidth = slider.settings.slideWidth, // start with any user-supplied slide width
            wrapWidth = slider.viewport.width();    // get the current viewport width
            // if slide width was not supplied, or is larger than the viewport use the viewport width
            if (slider.settings.slideWidth === 0 ||
              (slider.settings.slideWidth > wrapWidth && !slider.carousel) ||
              slider.settings.mode === 'vertical') {
                newElWidth = wrapWidth;
                // if carousel, use the thresholds to determine the width
            } else if (slider.settings.maxSlides > 1 && slider.settings.mode === 'horizontal') {
                if (wrapWidth > slider.maxThreshold) {
                    return newElWidth;
                } else if (wrapWidth < slider.minThreshold) {
                    newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.minSlides - 1))) / slider.settings.minSlides;
                } else if (slider.settings.shrinkItems) {
                    newElWidth = Math.floor((wrapWidth + slider.settings.slideMargin) / (Math.ceil((wrapWidth + slider.settings.slideMargin) / (newElWidth + slider.settings.slideMargin))) - slider.settings.slideMargin);
                }
            }
            return newElWidth;
        };

        /**
         * Returns the number of slides currently visible in the viewport (includes partially visible slides)
         */
        var getNumberSlidesShowing = function () {
            var slidesShowing = 1,
            childWidth = null;
            if (slider.settings.mode === 'horizontal' && slider.settings.slideWidth > 0) {
                // if viewport is smaller than minThreshold, return minSlides
                if (slider.viewport.width() < slider.minThreshold) {
                    slidesShowing = slider.settings.minSlides;
                    // if viewport is larger than maxThreshold, return maxSlides
                } else if (slider.viewport.width() > slider.maxThreshold) {
                    slidesShowing = slider.settings.maxSlides;
                    // if viewport is between min / max thresholds, divide viewport width by first child width
                } else {
                    childWidth = slider.children.first().width() + slider.settings.slideMargin;
                    slidesShowing = Math.floor((slider.viewport.width() +
                      slider.settings.slideMargin) / childWidth);
                }
                // if "vertical" mode, slides showing will always be minSlides
            } else if (slider.settings.mode === 'vertical') {
                slidesShowing = slider.settings.minSlides;
            }
            return slidesShowing;
        };

        /**
         * Returns the number of pages (one full viewport of slides is one "page")
         */
        var getPagerQty = function () {
            var pagerQty = 0,
            breakPoint = 0,
            counter = 0;
            // if moveSlides is specified by the user
            if (slider.settings.moveSlides > 0) {
                if (slider.settings.infiniteLoop) {
                    pagerQty = Math.ceil(slider.children.length / getMoveBy());
                } else {
                    // when breakpoint goes above children length, counter is the number of pages
                    while (breakPoint < slider.children.length) {
                        ++pagerQty;
                        breakPoint = counter + getNumberSlidesShowing();
                        counter += slider.settings.moveSlides <= getNumberSlidesShowing() ? slider.settings.moveSlides : getNumberSlidesShowing();
                    }
                }
                // if moveSlides is 0 (auto) divide children length by sides showing, then round up
            } else {
                pagerQty = Math.ceil(slider.children.length / getNumberSlidesShowing());
            }
            return pagerQty;
        };

        /**
         * Returns the number of individual slides by which to shift the slider
         */
        var getMoveBy = function () {
            // if moveSlides was set by the user and moveSlides is less than number of slides showing
            if (slider.settings.moveSlides > 0 && slider.settings.moveSlides <= getNumberSlidesShowing()) {
                return slider.settings.moveSlides;
            }
            // if moveSlides is 0 (auto)
            return getNumberSlidesShowing();
        };

        /**
         * Sets the slider's (el) left or top position
         */
        var setSlidePosition = function () {
            var position, lastChild, lastShowingIndex;
            // if last slide, not infinite loop, and number of children is larger than specified maxSlides
            if (slider.children.length > slider.settings.maxSlides && slider.active.last && !slider.settings.infiniteLoop) {
                if (slider.settings.mode === 'horizontal') {
                    // get the last child's position
                    lastChild = slider.children.last();
                    position = lastChild.position();
                    // set the left position
                    setPositionProperty(-(position.left - (slider.viewport.width() - lastChild.outerWidth())), 'reset', 0);
                } else if (slider.settings.mode === 'vertical') {
                    // get the last showing index's position
                    lastShowingIndex = slider.children.length - slider.settings.minSlides;
                    position = slider.children.eq(lastShowingIndex).position();
                    // set the top position
                    setPositionProperty(-position.top, 'reset', 0);
                }
                // if not last slide
            } else {
                // get the position of the first showing slide
                position = slider.children.eq(slider.active.index * getMoveBy()).position();
                // check for last slide
                if (slider.active.index === getPagerQty() - 1) { slider.active.last = true; }
                // set the respective position
                if (position !== undefined) {
                    if (slider.settings.mode === 'horizontal') { setPositionProperty(-position.left, 'reset', 0); }
                    else if (slider.settings.mode === 'vertical') { setPositionProperty(-position.top, 'reset', 0); }
                }
            }
        };

        /**
         * Sets the el's animating property position (which in turn will sometimes animate el).
         * If using CSS, sets the transform property. If not using CSS, sets the top / left property.
         *
         * @param value (int)
         *  - the animating property's value
         *
         * @param type (string) 'slide', 'reset', 'ticker'
         *  - the type of instance for which the function is being
         *
         * @param duration (int)
         *  - the amount of time (in ms) the transition should occupy
         *
         * @param params (array) optional
         *  - an optional parameter containing any variables that need to be passed in
         */
        var setPositionProperty = function (value, type, duration, params) {
            var animateObj, propValue;
            // use CSS transform
            if (slider.usingCSS) {
                // determine the translate3d value
                propValue = slider.settings.mode === 'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value + 'px, 0, 0)';
                // add the CSS transition-duration
                el.css('-' + slider.cssPrefix + '-transition-duration', duration / 1000 + 's');
                if (type === 'slide') {
                    // set the property value
                    el.css(slider.animProp, propValue);
                    if (duration !== 0) {
                        // bind a callback method - executes when CSS transition completes
                        el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function (e) {
                            //make sure it's the correct one
                            if (!$(e.target).is(el)) { return; }
                            // unbind the callback
                            el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
                            updateAfterSlideTransition();
                        });
                    } else { //duration = 0
                        updateAfterSlideTransition();
                    }
                } else if (type === 'reset') {
                    el.css(slider.animProp, propValue);
                } else if (type === 'ticker') {
                    // make the transition use 'linear'
                    el.css('-' + slider.cssPrefix + '-transition-timing-function', 'linear');
                    el.css(slider.animProp, propValue);
                    if (duration !== 0) {
                        el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function (e) {
                            //make sure it's the correct one
                            if (!$(e.target).is(el)) { return; }
                            // unbind the callback
                            el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
                            // reset the position
                            setPositionProperty(params.resetValue, 'reset', 0);
                            // start the loop again
                            tickerLoop();
                        });
                    } else { //duration = 0
                        setPositionProperty(params.resetValue, 'reset', 0);
                        tickerLoop();
                    }
                }
                // use JS animate
            } else {
                animateObj = {};
                animateObj[slider.animProp] = value;
                if (type === 'slide') {
                    el.animate(animateObj, duration, slider.settings.easing, function () {
                        updateAfterSlideTransition();
                    });
                } else if (type === 'reset') {
                    el.css(slider.animProp, value);
                } else if (type === 'ticker') {
                    el.animate(animateObj, duration, 'linear', function () {
                        setPositionProperty(params.resetValue, 'reset', 0);
                        // run the recursive loop after animation
                        tickerLoop();
                    });
                }
            }
        };

        /**
         * Populates the pager with proper amount of pages
         */
        var populatePager = function () {
            var pagerHtml = '',
            linkContent = '',
            pagerQty = getPagerQty();
            // loop through each pager item
            for (var i = 0; i < pagerQty; i++) {
                linkContent = '';
                // if a buildPager function is supplied, use it to get pager link value, else use index + 1
                if (slider.settings.buildPager && $.isFunction(slider.settings.buildPager) || slider.settings.pagerCustom) {
                    linkContent = slider.settings.buildPager(i);
                    slider.pagerEl.addClass('bx-custom-pager');
                } else {
                    linkContent = i + 1;
                    slider.pagerEl.addClass('bx-default-pager');
                }
                // var linkContent = slider.settings.buildPager && $.isFunction(slider.settings.buildPager) ? slider.settings.buildPager(i) : i + 1;
                // add the markup to the string
                pagerHtml += '<div class="bx-pager-item"><a href="" data-slide-index="' + i + '" class="bx-pager-link">' + linkContent + '</a></div>';
            }
            // populate the pager element with pager links
            slider.pagerEl.html(pagerHtml);
        };

        /**
         * Appends the pager to the controls element
         */
        var appendPager = function () {
            if (!slider.settings.pagerCustom) {
                // create the pager DOM element
                slider.pagerEl = $('<div class="bx-pager" />');
                // if a pager selector was supplied, populate it with the pager
                if (slider.settings.pagerSelector) {
                    $(slider.settings.pagerSelector).html(slider.pagerEl);
                    // if no pager selector was supplied, add it after the wrapper
                } else {
                    slider.controls.el.addClass('bx-has-pager').append(slider.pagerEl);
                }
                // populate the pager
                populatePager();
            } else {
                slider.pagerEl = $(slider.settings.pagerCustom);
            }
            // assign the pager click binding
            slider.pagerEl.on('click touchend', 'a', clickPagerBind);
        };

        /**
         * Appends prev / next controls to the controls element
         */
        var appendControls = function () {
            slider.controls.next = $('<a class="bx-next" href="">' + slider.settings.nextText + '</a>');
            slider.controls.prev = $('<a class="bx-prev" href="">' + slider.settings.prevText + '</a>');
            // bind click actions to the controls
            slider.controls.next.bind('click touchend', clickNextBind);
            slider.controls.prev.bind('click touchend', clickPrevBind);
            // if nextSelector was supplied, populate it
            if (slider.settings.nextSelector) {
                $(slider.settings.nextSelector).append(slider.controls.next);
            }
            // if prevSelector was supplied, populate it
            if (slider.settings.prevSelector) {
                $(slider.settings.prevSelector).append(slider.controls.prev);
            }
            // if no custom selectors were supplied
            if (!slider.settings.nextSelector && !slider.settings.prevSelector) {
                // add the controls to the DOM
                slider.controls.directionEl = $('<div class="bx-controls-direction" />');
                // add the control elements to the directionEl
                slider.controls.directionEl.append(slider.controls.prev).append(slider.controls.next);
                // slider.viewport.append(slider.controls.directionEl);
                slider.controls.el.addClass('bx-has-controls-direction').append(slider.controls.directionEl);
            }
        };

        /**
         * Appends start / stop auto controls to the controls element
         */
        var appendControlsAuto = function () {
            slider.controls.start = $('<div class="bx-controls-auto-item"><a class="bx-start" href="">' + slider.settings.startText + '</a></div>');
            slider.controls.stop = $('<div class="bx-controls-auto-item"><a class="bx-stop" href="">' + slider.settings.stopText + '</a></div>');
            // add the controls to the DOM
            slider.controls.autoEl = $('<div class="bx-controls-auto" />');
            // bind click actions to the controls
            slider.controls.autoEl.on('click', '.bx-start', clickStartBind);
            slider.controls.autoEl.on('click', '.bx-stop', clickStopBind);
            // if autoControlsCombine, insert only the "start" control
            if (slider.settings.autoControlsCombine) {
                slider.controls.autoEl.append(slider.controls.start);
                // if autoControlsCombine is false, insert both controls
            } else {
                slider.controls.autoEl.append(slider.controls.start).append(slider.controls.stop);
            }
            // if auto controls selector was supplied, populate it with the controls
            if (slider.settings.autoControlsSelector) {
                $(slider.settings.autoControlsSelector).html(slider.controls.autoEl);
                // if auto controls selector was not supplied, add it after the wrapper
            } else {
                slider.controls.el.addClass('bx-has-controls-auto').append(slider.controls.autoEl);
            }
            // update the auto controls
            updateAutoControls(slider.settings.autoStart ? 'stop' : 'start');
        };

        /**
         * Appends image captions to the DOM
         */
        var appendCaptions = function () {
            // cycle through each child
            slider.children.each(function (index) {
                // get the image title attribute
                var title = $(this).find('img:first').attr('title');
                // append the caption
                if (title !== undefined && ('' + title).length) {
                    $(this).append('<div class="bx-caption"><span>' + title + '</span></div>');
                }
            });
        };

        /**
         * Click next binding
         *
         * @param e (event)
         *  - DOM event object
         */
        var clickNextBind = function (e) {
            e.preventDefault();
            if (slider.controls.el.hasClass('disabled')) { return; }
            // if auto show is running, stop it
            if (slider.settings.auto && slider.settings.stopAutoOnClick) { el.stopAuto(); }
            el.goToNextSlide();
        };

        /**
         * Click prev binding
         *
         * @param e (event)
         *  - DOM event object
         */
        var clickPrevBind = function (e) {
            e.preventDefault();
            if (slider.controls.el.hasClass('disabled')) { return; }
            // if auto show is running, stop it
            if (slider.settings.auto && slider.settings.stopAutoOnClick) { el.stopAuto(); }
            el.goToPrevSlide();
        };

        /**
         * Click start binding
         *
         * @param e (event)
         *  - DOM event object
         */
        var clickStartBind = function (e) {
            el.startAuto();
            e.preventDefault();
        };

        /**
         * Click stop binding
         *
         * @param e (event)
         *  - DOM event object
         */
        var clickStopBind = function (e) {
            el.stopAuto();
            e.preventDefault();
        };

        /**
         * Click pager binding
         *
         * @param e (event)
         *  - DOM event object
         */
        var clickPagerBind = function (e) {
            var pagerLink, pagerIndex;
            e.preventDefault();
            if (slider.controls.el.hasClass('disabled')) {
                return;
            }
            // if auto show is running, stop it
            if (slider.settings.auto && slider.settings.stopAutoOnClick) { el.stopAuto(); }
            pagerLink = $(e.currentTarget);
            if (pagerLink.attr('data-slide-index') !== undefined) {
                pagerIndex = parseInt(pagerLink.attr('data-slide-index'));
                // if clicked pager link is not active, continue with the goToSlide call
                if (pagerIndex !== slider.active.index) { el.goToSlide(pagerIndex); }
            }
        };

        /**
         * Updates the pager links with an active class
         *
         * @param slideIndex (int)
         *  - index of slide to make active
         */
        var updatePagerActive = function (slideIndex) {
            // if "short" pager type
            var len = slider.children.length; // nb of children
            if (slider.settings.pagerType === 'short') {
                if (slider.settings.maxSlides > 1) {
                    len = Math.ceil(slider.children.length / slider.settings.maxSlides);
                }
                slider.pagerEl.html((slideIndex + 1) + slider.settings.pagerShortSeparator + len);
                return;
            }
            // remove all pager active classes
            slider.pagerEl.find('a').removeClass('active');
            // apply the active class for all pagers
            slider.pagerEl.each(function (i, el) { $(el).find('a').eq(slideIndex).addClass('active'); });
        };

        /**
         * Performs needed actions after a slide transition
         */
        var updateAfterSlideTransition = function () {
            // if infinite loop is true
            if (slider.settings.infiniteLoop) {
                var position = '';
                // first slide
                if (slider.active.index === 0) {
                    // set the new position
                    position = slider.children.eq(0).position();
                    // carousel, last slide
                } else if (slider.active.index === getPagerQty() - 1 && slider.carousel) {
                    position = slider.children.eq((getPagerQty() - 1) * getMoveBy()).position();
                    // last slide
                } else if (slider.active.index === slider.children.length - 1) {
                    position = slider.children.eq(slider.children.length - 1).position();
                }
                if (position) {
                    if (slider.settings.mode === 'horizontal') { setPositionProperty(-position.left, 'reset', 0); }
                    else if (slider.settings.mode === 'vertical') { setPositionProperty(-position.top, 'reset', 0); }
                }
            }
            // declare that the transition is complete
            slider.working = false;
            // onSlideAfter callback
            slider.settings.onSlideAfter.call(el, slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
        };

        /**
         * Updates the auto controls state (either active, or combined switch)
         *
         * @param state (string) "start", "stop"
         *  - the new state of the auto show
         */
        var updateAutoControls = function (state) {
            // if autoControlsCombine is true, replace the current control with the new state
            if (slider.settings.autoControlsCombine) {
                slider.controls.autoEl.html(slider.controls[state]);
                // if autoControlsCombine is false, apply the "active" class to the appropriate control
            } else {
                slider.controls.autoEl.find('a').removeClass('active');
                slider.controls.autoEl.find('a:not(.bx-' + state + ')').addClass('active');
            }
        };

        /**
         * Updates the direction controls (checks if either should be hidden)
         */
        var updateDirectionControls = function () {
            if (getPagerQty() === 1) {
                slider.controls.prev.addClass('disabled');
                slider.controls.next.addClass('disabled');
            } else if (!slider.settings.infiniteLoop && slider.settings.hideControlOnEnd) {
                // if first slide
                if (slider.active.index === 0) {
                    slider.controls.prev.addClass('disabled');
                    slider.controls.next.removeClass('disabled');
                    // if last slide
                } else if (slider.active.index === getPagerQty() - 1) {
                    slider.controls.next.addClass('disabled');
                    slider.controls.prev.removeClass('disabled');
                    // if any slide in the middle
                } else {
                    slider.controls.prev.removeClass('disabled');
                    slider.controls.next.removeClass('disabled');
                }
            }
        };

        /**
         * Initializes the auto process
         */
        var initAuto = function () {
            // if autoDelay was supplied, launch the auto show using a setTimeout() call
            if (slider.settings.autoDelay > 0) {
                var timeout = setTimeout(el.startAuto, slider.settings.autoDelay);
                // if autoDelay was not supplied, start the auto show normally
            } else {
                el.startAuto();

                //add focus and blur events to ensure its running if timeout gets paused
                $(window).focus(function () {
                    el.startAuto();
                }).blur(function () {
                    el.stopAuto();
                });
            }
            // if autoHover is requested
            if (slider.settings.autoHover) {
                // on el hover
                el.hover(function () {
                    // if the auto show is currently playing (has an active interval)
                    if (slider.interval) {
                        // stop the auto show and pass true argument which will prevent control update
                        el.stopAuto(true);
                        // create a new autoPaused value which will be used by the relative "mouseout" event
                        slider.autoPaused = true;
                    }
                }, function () {
                    // if the autoPaused value was created be the prior "mouseover" event
                    if (slider.autoPaused) {
                        // start the auto show and pass true argument which will prevent control update
                        el.startAuto(true);
                        // reset the autoPaused value
                        slider.autoPaused = null;
                    }
                });
            }
        };

        /**
         * Initializes the ticker process
         */
        var initTicker = function () {
            var startPosition = 0,
            position, transform, value, idx, ratio, property, newSpeed, totalDimens;
            // if autoDirection is "next", append a clone of the entire slider
            if (slider.settings.autoDirection === 'next') {
                el.append(slider.children.clone().addClass('bx-clone'));
                // if autoDirection is "prev", prepend a clone of the entire slider, and set the left position
            } else {
                el.prepend(slider.children.clone().addClass('bx-clone'));
                position = slider.children.first().position();
                startPosition = slider.settings.mode === 'horizontal' ? -position.left : -position.top;
            }
            setPositionProperty(startPosition, 'reset', 0);
            // do not allow controls in ticker mode
            slider.settings.pager = false;
            slider.settings.controls = false;
            slider.settings.autoControls = false;
            // if autoHover is requested
            if (slider.settings.tickerHover) {
                if (slider.usingCSS) {
                    idx = slider.settings.mode === 'horizontal' ? 4 : 5;
                    slider.viewport.hover(function () {
                        transform = el.css('-' + slider.cssPrefix + '-transform');
                        value = parseFloat(transform.split(',')[idx]);
                        setPositionProperty(value, 'reset', 0);
                    }, function () {
                        totalDimens = 0;
                        slider.children.each(function (index) {
                            totalDimens += slider.settings.mode === 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true);
                        });
                        // calculate the speed ratio (used to determine the new speed to finish the paused animation)
                        ratio = slider.settings.speed / totalDimens;
                        // determine which property to use
                        property = slider.settings.mode === 'horizontal' ? 'left' : 'top';
                        // calculate the new speed
                        newSpeed = ratio * (totalDimens - (Math.abs(parseInt(value))));
                        tickerLoop(newSpeed);
                    });
                } else {
                    // on el hover
                    slider.viewport.hover(function () {
                        el.stop();
                    }, function () {
                        // calculate the total width of children (used to calculate the speed ratio)
                        totalDimens = 0;
                        slider.children.each(function (index) {
                            totalDimens += slider.settings.mode === 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true);
                        });
                        // calculate the speed ratio (used to determine the new speed to finish the paused animation)
                        ratio = slider.settings.speed / totalDimens;
                        // determine which property to use
                        property = slider.settings.mode === 'horizontal' ? 'left' : 'top';
                        // calculate the new speed
                        newSpeed = ratio * (totalDimens - (Math.abs(parseInt(el.css(property)))));
                        tickerLoop(newSpeed);
                    });
                }
            }
            // start the ticker loop
            tickerLoop();
        };

        /**
         * Runs a continuous loop, news ticker-style
         */
        var tickerLoop = function (resumeSpeed) {
            var speed = resumeSpeed ? resumeSpeed : slider.settings.speed,
            position = { left: 0, top: 0 },
            reset = { left: 0, top: 0 },
            animateProperty, resetValue, params;

            // if "next" animate left position to last child, then reset left to 0
            if (slider.settings.autoDirection === 'next') {
                position = el.find('.bx-clone').first().position();
                // if "prev" animate left position to 0, then reset left to first non-clone child
            } else {
                reset = slider.children.first().position();
            }
            animateProperty = slider.settings.mode === 'horizontal' ? -position.left : -position.top;
            resetValue = slider.settings.mode === 'horizontal' ? -reset.left : -reset.top;
            params = { resetValue: resetValue };
            setPositionProperty(animateProperty, 'ticker', speed, params);
        };

        /**
         * Check if el is on screen
         */
        var isOnScreen = function (el) {
            var win = $(window),
            viewport = {
                top: win.scrollTop(),
                left: win.scrollLeft()
            },
            bounds = el.offset();

            viewport.right = viewport.left + win.width();
            viewport.bottom = viewport.top + win.height();
            bounds.right = bounds.left + el.outerWidth();
            bounds.bottom = bounds.top + el.outerHeight();

            return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
        };

        /**
         * Initializes keyboard events
         */
        var keyPress = function (e) {
            var activeElementTag = document.activeElement.tagName.toLowerCase(),
            tagFilters = 'input|textarea',
            p = new RegExp(activeElementTag, ['i']),
            result = p.exec(tagFilters);

            if (result == null && isOnScreen(el)) {
                if (e.keyCode === 39) {
                    clickNextBind(e);
                    return false;
                } else if (e.keyCode === 37) {
                    clickPrevBind(e);
                    return false;
                }
            }
        };

        /**
         * Initializes touch events
         */
        var initTouch = function () {
            // initialize object to contain all touch values
            slider.touch = {
                start: { x: 0, y: 0 },
                end: { x: 0, y: 0 }
            };
            slider.viewport.bind('touchstart MSPointerDown pointerdown', onTouchStart);

            //for browsers that have implemented pointer events and fire a click after
            //every pointerup regardless of whether pointerup is on same screen location as pointerdown or not
            slider.viewport.on('click', '.bxslider a', function (e) {
                if (slider.viewport.hasClass('click-disabled')) {
                    e.preventDefault();
                    slider.viewport.removeClass('click-disabled');
                }
            });
        };

        /**
         * Event handler for "touchstart"
         *
         * @param e (event)
         *  - DOM event object
         */
        var onTouchStart = function (e) {
            //disable slider controls while user is interacting with slides to avoid slider freeze that happens on touch devices when a slide swipe happens immediately after interacting with slider controls
            slider.controls.el.addClass('disabled');

            if (slider.working) {
                e.preventDefault();
                slider.controls.el.removeClass('disabled');
            } else {
                // record the original position when touch starts
                slider.touch.originalPos = el.position();
                var orig = e.originalEvent,
                touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig];
                // record the starting touch x, y coordinates
                slider.touch.start.x = touchPoints[0].pageX;
                slider.touch.start.y = touchPoints[0].pageY;

                if (slider.viewport.get(0).setPointerCapture) {
                    slider.pointerId = orig.pointerId;
                    slider.viewport.get(0).setPointerCapture(slider.pointerId);
                }
                // bind a "touchmove" event to the viewport
                slider.viewport.bind('touchmove MSPointerMove pointermove', onTouchMove);
                // bind a "touchend" event to the viewport
                slider.viewport.bind('touchend MSPointerUp pointerup', onTouchEnd);
                slider.viewport.bind('MSPointerCancel pointercancel', onPointerCancel);
            }
        };

        /**
         * Cancel Pointer for Windows Phone
         *
         * @param e (event)
         *  - DOM event object
         */
        var onPointerCancel = function (e) {
            /* onPointerCancel handler is needed to deal with situations when a touchend
            doesn't fire after a touchstart (this happens on windows phones only) */
            setPositionProperty(slider.touch.originalPos.left, 'reset', 0);

            //remove handlers
            slider.controls.el.removeClass('disabled');
            slider.viewport.unbind('MSPointerCancel pointercancel', onPointerCancel);
            slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove);
            slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd);
            if (slider.viewport.get(0).releasePointerCapture) {
                slider.viewport.get(0).releasePointerCapture(slider.pointerId);
            }
        };

        /**
         * Event handler for "touchmove"
         *
         * @param e (event)
         *  - DOM event object
         */
        var onTouchMove = function (e) {
            var orig = e.originalEvent,
            touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig],
            // if scrolling on y axis, do not prevent default
            xMovement = Math.abs(touchPoints[0].pageX - slider.touch.start.x),
            yMovement = Math.abs(touchPoints[0].pageY - slider.touch.start.y),
            value = 0,
            change = 0;

            // x axis swipe
            if ((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX) {
                e.preventDefault();
                // y axis swipe
            } else if ((yMovement * 3) > xMovement && slider.settings.preventDefaultSwipeY) {
                e.preventDefault();
            }
            if (slider.settings.mode !== 'fade' && slider.settings.oneToOneTouch) {
                // if horizontal, drag along x axis
                if (slider.settings.mode === 'horizontal') {
                    change = touchPoints[0].pageX - slider.touch.start.x;
                    value = slider.touch.originalPos.left + change;
                    // if vertical, drag along y axis
                } else {
                    change = touchPoints[0].pageY - slider.touch.start.y;
                    value = slider.touch.originalPos.top + change;
                }
                setPositionProperty(value, 'reset', 0);
            }
        };

        /**
         * Event handler for "touchend"
         *
         * @param e (event)
         *  - DOM event object
         */
        var onTouchEnd = function (e) {
            slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove);
            //enable slider controls as soon as user stops interacing with slides
            slider.controls.el.removeClass('disabled');
            var orig = e.originalEvent,
            touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig],
            value = 0,
            distance = 0;
            // record end x, y positions
            slider.touch.end.x = touchPoints[0].pageX;
            slider.touch.end.y = touchPoints[0].pageY;
            // if fade mode, check if absolute x distance clears the threshold
            if (slider.settings.mode === 'fade') {
                distance = Math.abs(slider.touch.start.x - slider.touch.end.x);
                if (distance >= slider.settings.swipeThreshold) {
                    if (slider.touch.start.x > slider.touch.end.x) {
                        el.goToNextSlide();
                    } else {
                        el.goToPrevSlide();
                    }
                    el.stopAuto();
                }
                // not fade mode
            } else {
                // calculate distance and el's animate property
                if (slider.settings.mode === 'horizontal') {
                    distance = slider.touch.end.x - slider.touch.start.x;
                    value = slider.touch.originalPos.left;
                } else {
                    distance = slider.touch.end.y - slider.touch.start.y;
                    value = slider.touch.originalPos.top;
                }
                // if not infinite loop and first / last slide, do not attempt a slide transition
                if (!slider.settings.infiniteLoop && ((slider.active.index === 0 && distance > 0) || (slider.active.last && distance < 0))) {
                    setPositionProperty(value, 'reset', 200);
                } else {
                    // check if distance clears threshold
                    if (Math.abs(distance) >= slider.settings.swipeThreshold) {
                        if (distance < 0) {
                            el.goToNextSlide();
                        } else {
                            el.goToPrevSlide();
                        }
                        el.stopAuto();
                    } else {
                        // el.animate(property, 200);
                        setPositionProperty(value, 'reset', 200);
                    }
                }
            }
            slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd);
            if (slider.viewport.get(0).releasePointerCapture) {
                slider.viewport.get(0).releasePointerCapture(slider.pointerId);
            }
        };

        /**
         * Window resize event callback
         */
        var resizeWindow = function (e) {
            // don't do anything if slider isn't initialized.
            if (!slider.initialized) { return; }
            // Delay if slider working.
            if (slider.working) {
                window.setTimeout(resizeWindow, 10);
            } else {
                // get the new window dimens (again, thank you IE)
                var windowWidthNew = $(window).width(),
                windowHeightNew = $(window).height();
                // make sure that it is a true window resize
                // *we must check this because our dinosaur friend IE fires a window resize event when certain DOM elements
                // are resized. Can you just die already?*
                if (windowWidth !== windowWidthNew || windowHeight !== windowHeightNew) {
                    // set the new window dimens
                    windowWidth = windowWidthNew;
                    windowHeight = windowHeightNew;
                    // update all dynamic elements
                    el.redrawSlider();
                    // Call user resize handler
                    slider.settings.onSliderResize.call(el, slider.active.index);
                }
            }
        };

        /**
         * Adds an aria-hidden=true attribute to each element
         *
         * @param startVisibleIndex (int)
         *  - the first visible element's index
         */
        var applyAriaHiddenAttributes = function (startVisibleIndex) {
            var numberOfSlidesShowing = getNumberSlidesShowing();
            // only apply attributes if the setting is enabled and not in ticker mode
            if (slider.settings.ariaHidden && !slider.settings.ticker) {
                // add aria-hidden=true to all elements
                slider.children.attr('aria-hidden', 'true');
                // get the visible elements and change to aria-hidden=false
                slider.children.slice(startVisibleIndex, startVisibleIndex + numberOfSlidesShowing).attr('aria-hidden', 'false');
            }
        };

        /**
         * Returns index according to present page range
         *
         * @param slideOndex (int)
         *  - the desired slide index
         */
        var setSlideIndex = function (slideIndex) {
            if (slideIndex < 0) {
                if (slider.settings.infiniteLoop) {
                    return getPagerQty() - 1;
                } else {
                    //we don't go to undefined slides
                    return slider.active.index;
                }
                // if slideIndex is greater than children length, set active index to 0 (this happens during infinite loop)
            } else if (slideIndex >= getPagerQty()) {
                if (slider.settings.infiniteLoop) {
                    return 0;
                } else {
                    //we don't move to undefined pages
                    return slider.active.index;
                }
                // set active index to requested slide
            } else {
                return slideIndex;
            }
        };

        /**
         * ===================================================================================
         * = PUBLIC FUNCTIONS
         * ===================================================================================
         */

        /**
         * Performs slide transition to the specified slide
         *
         * @param slideIndex (int)
         *  - the destination slide's index (zero-based)
         *
         * @param direction (string)
         *  - INTERNAL USE ONLY - the direction of travel ("prev" / "next")
         */
        el.goToSlide = function (slideIndex, direction) {
            // onSlideBefore, onSlideNext, onSlidePrev callbacks
            // Allow transition canceling based on returned value
            var performTransition = true,
            moveBy = 0,
            position = { left: 0, top: 0 },
            lastChild = null,
            lastShowingIndex, eq, value, requestEl;
            // store the old index
            slider.oldIndex = slider.active.index;
            //set new index
            slider.active.index = setSlideIndex(slideIndex);

            // if plugin is currently in motion, ignore request
            //if (slider.working || slider.active.index === slider.oldIndex) { return; }
            // declare that plugin is in motion
            slider.working = true;

            performTransition = slider.settings.onSlideBefore.call(el, slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);

            // If transitions canceled, reset and return
            if (typeof (performTransition) !== 'undefined' && !performTransition) {
                slider.active.index = slider.oldIndex; // restore old index
                slider.working = false; // is not in motion
                return;
            }

            if (direction === 'next') {
                // Prevent canceling in future functions or lack there-of from negating previous commands to cancel
                if (!slider.settings.onSlideNext.call(el, slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index)) {
                    performTransition = false;
                }
            } else if (direction === 'prev') {
                // Prevent canceling in future functions or lack there-of from negating previous commands to cancel
                if (!slider.settings.onSlidePrev.call(el, slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index)) {
                    performTransition = false;
                }
            }

            // check if last slide
            slider.active.last = slider.active.index >= getPagerQty() - 1;
            // update the pager with active class
            if (slider.settings.pager || slider.settings.pagerCustom) { updatePagerActive(slider.active.index); }
            // // check for direction control update
            if (slider.settings.controls) { updateDirectionControls(); }
            // if slider is set to mode: "fade"
            if (slider.settings.mode === 'fade') {
                // if adaptiveHeight is true and next height is different from current height, animate to the new height
                if (slider.settings.adaptiveHeight && slider.viewport.height() !== getViewportHeight()) {
                    slider.viewport.animate({ height: getViewportHeight() }, slider.settings.adaptiveHeightSpeed);
                }
                // fade out the visible child and reset its z-index value
                slider.children.filter(':visible').fadeOut(slider.settings.speed).css({ zIndex: 0 });
                // fade in the newly requested slide
                slider.children.eq(slider.active.index).css('zIndex', slider.settings.slideZIndex + 1).fadeIn(slider.settings.speed, function () {
                    $(this).css('zIndex', slider.settings.slideZIndex);
                    updateAfterSlideTransition();
                });
                // slider mode is not "fade"
            } else {
                // if adaptiveHeight is true and next height is different from current height, animate to the new height
                if (slider.settings.adaptiveHeight && slider.viewport.height() !== getViewportHeight()) {
                    slider.viewport.animate({ height: getViewportHeight() }, slider.settings.adaptiveHeightSpeed);
                }
                // if carousel and not infinite loop
                if (!slider.settings.infiniteLoop && slider.carousel && slider.active.last) {
                    if (slider.settings.mode === 'horizontal') {
                        // get the last child position
                        lastChild = slider.children.eq(slider.children.length - 1);
                        position = lastChild.position();
                        // calculate the position of the last slide
                        moveBy = slider.viewport.width() - lastChild.outerWidth();
                    } else {
                        // get last showing index position
                        lastShowingIndex = slider.children.length - slider.settings.minSlides;
                        position = slider.children.eq(lastShowingIndex).position();
                    }
                    // horizontal carousel, going previous while on first slide (infiniteLoop mode)
                } else if (slider.carousel && slider.active.last && direction === 'prev') {
                    // get the last child position
                    eq = slider.settings.moveSlides === 1 ? slider.settings.maxSlides - getMoveBy() : ((getPagerQty() - 1) * getMoveBy()) - (slider.children.length - slider.settings.maxSlides);
                    lastChild = el.children('.bx-clone').eq(eq);
                    position = lastChild.position();
                    // if infinite loop and "Next" is clicked on the last slide
                } else if (direction === 'next' && slider.active.index === 0) {
                    // get the last clone position
                    position = el.find('> .bx-clone').eq(slider.settings.maxSlides).position();
                    slider.active.last = false;
                    // normal non-zero requests
                } else if (slideIndex >= 0) {
                    //parseInt is applied to allow floats for slides/page
                    requestEl = slideIndex * parseInt(getMoveBy());
                    position = slider.children.eq(requestEl).position();
                }

                /* If the position doesn't exist
                 * (e.g. if you destroy the slider on a next click),
                 * it doesn't throw an error.
                 */
                if (typeof (position) !== 'undefined') {
                    value = slider.settings.mode === 'horizontal' ? -(position.left - moveBy) : -position.top;
                    // plugin values to be animated
                    setPositionProperty(value, 'slide', slider.settings.speed);
                } else {
                    slider.working = false;
                }
            }
            if (slider.settings.ariaHidden) { applyAriaHiddenAttributes(slider.active.index * getMoveBy()); }
        };

        /**
         * Transitions to the next slide in the show
         */
        el.goToNextSlide = function () {
            // if infiniteLoop is false and last page is showing, disregard call
            if (!slider.settings.infiniteLoop && slider.active.last) { return; }
            var pagerIndex = parseInt(slider.active.index) + 1;
            el.goToSlide(pagerIndex, 'next');
        };

        /**
         * Transitions to the prev slide in the show
         */
        el.goToPrevSlide = function () {
            // if infiniteLoop is false and last page is showing, disregard call
            if (!slider.settings.infiniteLoop && slider.active.index === 0) { return; }
            var pagerIndex = parseInt(slider.active.index) - 1;
            el.goToSlide(pagerIndex, 'prev');
        };

        /**
         * Starts the auto show
         *
         * @param preventControlUpdate (boolean)
         *  - if true, auto controls state will not be updated
         */
        el.startAuto = function (preventControlUpdate) {
            // if an interval already exists, disregard call
            if (slider.interval) { return; }
            // create an interval
            slider.interval = setInterval(function () {
                if (slider.settings.autoDirection === 'next') {
                    el.goToNextSlide();
                } else {
                    el.goToPrevSlide();
                }
            }, slider.settings.pause);
            // if auto controls are displayed and preventControlUpdate is not true
            if (slider.settings.autoControls && preventControlUpdate !== true) { updateAutoControls('stop'); }
        };

        /**
         * Stops the auto show
         *
         * @param preventControlUpdate (boolean)
         *  - if true, auto controls state will not be updated
         */
        el.stopAuto = function (preventControlUpdate) {
            // if no interval exists, disregard call
            if (!slider.interval) { return; }
            // clear the interval
            clearInterval(slider.interval);
            slider.interval = null;
            // if auto controls are displayed and preventControlUpdate is not true
            if (slider.settings.autoControls && preventControlUpdate !== true) { updateAutoControls('start'); }
        };

        /**
         * Returns current slide index (zero-based)
         */
        el.getCurrentSlide = function () {
            return slider.active.index;
        };

        /**
         * Returns current slide element
         */
        el.getCurrentSlideElement = function () {
            return slider.children.eq(slider.active.index);
        };

        /**
         * Returns a slide element
         * @param index (int)
         *  - The index (zero-based) of the element you want returned.
         */
        el.getSlideElement = function (index) {
            return slider.children.eq(index);
        };

        /**
         * Returns number of slides in show
         */
        el.getSlideCount = function () {
            return slider.children.length;
        };

        /**
         * Return slider.working variable
         */
        el.isWorking = function () {
            return slider.working;
        };

        /**
         * Update all dynamic slider elements
         */
        el.redrawSlider = function () {
            // resize all children in ratio to new screen size
            slider.children.add(el.find('.bx-clone')).outerWidth(getSlideWidth());
            // adjust the height
            slider.viewport.css('height', getViewportHeight());
            // update the slide position
            if (!slider.settings.ticker) { setSlidePosition(); }
            // if active.last was true before the screen resize, we want
            // to keep it last no matter what screen size we end on
            if (slider.active.last) { slider.active.index = getPagerQty() - 1; }
            // if the active index (page) no longer exists due to the resize, simply set the index as last
            if (slider.active.index >= getPagerQty()) { slider.active.last = true; }
            // if a pager is being displayed and a custom pager is not being used, update it
            if (slider.settings.pager && !slider.settings.pagerCustom) {
                populatePager();
                updatePagerActive(slider.active.index);
            }
            if (slider.settings.ariaHidden) { applyAriaHiddenAttributes(slider.active.index * getMoveBy()); }
        };

        /**
         * Destroy the current instance of the slider (revert everything back to original state)
         */
        el.destroySlider = function () {
            // don't do anything if slider has already been destroyed
            if (!slider.initialized) { return; }
            slider.initialized = false;
            $('.bx-clone', this).remove();
            slider.children.each(function () {
                if ($(this).data('origStyle') !== undefined) {
                    $(this).attr('style', $(this).data('origStyle'));
                } else {
                    $(this).removeAttr('style');
                }
            });
            if ($(this).data('origStyle') !== undefined) {
                this.attr('style', $(this).data('origStyle'));
            } else {
                $(this).removeAttr('style');
            }
            $(this).unwrap().unwrap();
            if (slider.controls.el) { slider.controls.el.remove(); }
            if (slider.controls.next) { slider.controls.next.remove(); }
            if (slider.controls.prev) { slider.controls.prev.remove(); }
            if (slider.pagerEl && slider.settings.controls && !slider.settings.pagerCustom) { slider.pagerEl.remove(); }
            $('.bx-caption', this).remove();
            if (slider.controls.autoEl) { slider.controls.autoEl.remove(); }
            clearInterval(slider.interval);
            if (slider.settings.responsive) { $(window).unbind('resize', resizeWindow); }
            if (slider.settings.keyboardEnabled) { $(document).unbind('keydown', keyPress); }
            //remove self reference in data
            $(this).removeData('bxSlider');
        };

        /**
         * Reload the slider (revert all DOM changes, and re-initialize)
         */
        el.reloadSlider = function (settings) {
            if (settings !== undefined) { options = settings; }
            el.destroySlider();
            init();
            //store reference to self in order to access public functions later
            $(el).data('bxSlider', this);
        };

        init();

        $(el).data('bxSlider', this);

        // returns the current jQuery object
        return this;
    };

})(jQuery);;
/*!
 * hoverIntent r7 // 2013.03.11 // jQuery 1.9.1+
 * http://cherne.net/brian/resources/jquery.hoverIntent.html
 *
 * You may use hoverIntent under the terms of the MIT license. Basically that
 * means you are free to use hoverIntent as long as this header is left intact.
 * Copyright 2007, 2013 Brian Cherne
 */
 
/* hoverIntent is similar to jQuery's built-in "hover" method except that
 * instead of firing the handlerIn function immediately, hoverIntent checks
 * to see if the user's mouse has slowed down (beneath the sensitivity
 * threshold) before firing the event. The handlerOut function is only
 * called after a matching handlerIn.
 *
 * // basic usage ... just like .hover()
 * .hoverIntent( handlerIn, handlerOut )
 * .hoverIntent( handlerInOut )
 *
 * // basic usage ... with event delegation!
 * .hoverIntent( handlerIn, handlerOut, selector )
 * .hoverIntent( handlerInOut, selector )
 *
 * // using a basic configuration object
 * .hoverIntent( config )
 *
 * @param  handlerIn   function OR configuration object
 * @param  handlerOut  function OR selector for delegation OR undefined
 * @param  selector    selector OR undefined
 * @author Brian Cherne <brian(at)cherne(dot)net>
 */
(function($) {
    $.fn.hoverIntent = function(handlerIn,handlerOut,selector) {

        // default configuration values
        var cfg = {
            interval: 100,
            sensitivity: 7,
            timeout: 0
        };

        if ( typeof handlerIn === "object" ) {
            cfg = $.extend(cfg, handlerIn );
        } else if ($.isFunction(handlerOut)) {
            cfg = $.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector } );
        } else {
            cfg = $.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut } );
        }

        // instantiate variables
        // cX, cY = current X and Y position of mouse, updated by mousemove event
        // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
        var cX, cY, pX, pY;

        // A private function for getting mouse position
        var track = function(ev) {
            cX = ev.pageX;
            cY = ev.pageY;
        };

        // A private function for comparing current and previous mouse position
        var compare = function(ev,ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            // compare mouse positions to see if they've crossed the threshold
            if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
                $(ob).off("mousemove.hoverIntent",track);
                // set hoverIntent state to true (so mouseOut can be called)
                ob.hoverIntent_s = 1;
                return cfg.over.apply(ob,[ev]);
            } else {
                // set previous coordinates for next time
                pX = cX; pY = cY;
                // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
                ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
            }
        };

        // A private function for delaying the mouseOut function
        var delay = function(ev,ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            ob.hoverIntent_s = 0;
            return cfg.out.apply(ob,[ev]);
        };

        // A private function for handling mouse 'hovering'
        var handleHover = function(e) {
            // copy objects to be passed into t (required for event object to be passed in IE)
            var ev = jQuery.extend({},e);
            var ob = this;

            // cancel hoverIntent timer if it exists
            if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

            // if e.type == "mouseenter"
            if (e.type == "mouseenter") {
                // set "previous" X and Y position based on initial entry point
                pX = ev.pageX; pY = ev.pageY;
                // update "current" X and Y position based on mousemove
                $(ob).on("mousemove.hoverIntent",track);
                // start polling interval (self-calling timeout) to compare mouse coordinates over time
                if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

                // else e.type == "mouseleave"
            } else {
                // unbind expensive mousemove event
                $(ob).off("mousemove.hoverIntent",track);
                // if hoverIntent state is true, then call the mouseOut function after the specified delay
                if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
            }
        };

        // listen for mouseenter and mouseleave
        return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector);
    };
})(jQuery);
;
var Outdoor;
(function (Outdoor) {
    var Pages;
    (function (Pages) {
        var QuickAdd = (function () {
            function QuickAdd() {
                this.cachedQuickAddId = 'QuickAdd_Dialog';
                if ($('#QuickAdd_Dialog').length === 0) {
                    return;
                }
                this.associateQuickAddLinks();
            }
            QuickAdd.prototype.onQuickAddClicked = function (e) {
                e.preventDefault();
                var styleId = $(e.target).data('id');
                this.showQuickAdd(styleId);
                return false;
            };
            QuickAdd.prototype.showQuickAdd = function (styleId) {
                this.cachedDialog = this.createQuickAdd(styleId);
                this.requestQuickAddData(this.cachedDialog, styleId);
            };
            QuickAdd.prototype.showTheLook = function (childStyleId) {
                this.cachedDialog = this.createQuickAdd(childStyleId);
                this.requestQuickAddData(this.cachedDialog, childStyleId);
            };
            QuickAdd.prototype.createQuickAdd = function (styleId) {
                var _this = this;
                this.LoadSwipePlugIn();
                if (this.cachedDialog == null) {
                    this.cachedDialog = $('#QuickAdd_Dialog');
                }
                this.cachedDialog.data('id', styleId);
                this.cachedDialog.find('.QuickAdd_Sizes').change(function (ev) { _this.quickAddSizeChanged(ev, _this.cachedQuickAddId); });
                this.cachedDialog.find('.QuickAdd_Colours').change(function (ev) { _this.quickAddColourChanged(ev, _this.cachedQuickAddId); });
                this.cachedDialog.find('#QuickAddToBasket').click(function (ev) { _this.onQuickAddToBasketClicked(ev, _this.cachedQuickAddId); });
                this.cachedDialog.find('.QuickAdd_AddToWishlist').click(function (ev) { _this.quickAddToWishlist(ev, _this.cachedQuickAddId); });
                this.cachedDialog.find('.close').click(function () { _this.cachedDialog.fadeOut('fast'); });
                this.cachedDialog.find('.overlay').click(function () { _this.cachedDialog.fadeOut('fast'); });
                this.logQuickViewOperation('click');
                this.cachedDialog.css({
                    'top': 0, 'left': 0, 'position': 'fixed', 'width': '100%', 'height': '100%;'
                })
                    .fadeIn('slow');
                this.WireUpPriceEditMonitoring();
                return this.cachedDialog;
            };
            QuickAdd.prototype.is_touch_device = function () {
                return !!('ontouchstart' in window)
                    || !!('onmsgesturechange' in window);
            };
            QuickAdd.prototype.LoadSwipePlugIn = function () {
                if (this.is_touch_device()) {
                    this.WireUpSwipeHandler();
                }
            };
            QuickAdd.prototype.WireUpSwipeHandler = function () {
                var _this = this;
                $(".quickadd-inner").swipe({
                    swipe: function (event, direction, distance, duration, fingerCount) { _this.OnSwipe(direction); }
                });
            };
            QuickAdd.prototype.OnSwipe = function (direction) {
                if (direction === 'right') {
                    var previousStyleId = this.PreviousStyleId(this.CurrentStyleId());
                    this.requestQuickAddData(this.cachedDialog, previousStyleId);
                }
                else if (direction === 'left') {
                    var nextStyleId = this.NextStyleId(this.CurrentStyleId());
                    this.requestQuickAddData(this.cachedDialog, nextStyleId);
                }
            };
            QuickAdd.prototype.CurrentStyleId = function () {
                return this.cachedDialog.data('id');
            };
            QuickAdd.prototype.PreviousStyleId = function (styleId) {
                var thumb = this.CurrentStyleThumb(styleId);
                var previous = thumb.parent().prev();
                if (previous.length === 0) {
                    previous = this.LastStyleThumb();
                }
                return previous.find('img').data('id');
            };
            QuickAdd.prototype.NextStyleId = function (styleId) {
                var thumb = this.CurrentStyleThumb(styleId);
                var next = thumb.parent().next();
                if (next.length === 0) {
                    next = this.FirstStyleThumb();
                }
                return next.find('img').data('id');
            };
            QuickAdd.prototype.FirstStyleThumb = function () {
                return this.cachedDialog.find("ul.category-products li").first();
            };
            QuickAdd.prototype.LastStyleThumb = function () {
                return this.cachedDialog.find("ul.category-products li").last();
            };
            QuickAdd.prototype.CurrentStyleThumb = function (styleId) {
                var container = this.cachedDialog.find("ul.category-products li img");
                for (var i = 0; i < container.length; i++) {
                    var thumb = $(container[i]);
                    if (thumb.data('id') == styleId) {
                        return thumb;
                    }
                }
                return null;
            };
            QuickAdd.prototype.associateQuickAddLinks = function () {
                var _this = this;
                $('body').on('click', '.QuickAdd_Show', function (e) { _this.onQuickAddClicked(e); });
            };
            QuickAdd.prototype.requestQuickAddData = function (qaDialog, productStyleId) {
                var _this = this;
                $.ajax({
                    type: "POST",
                    url: "/ws/style-info/" + productStyleId,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data, textStatus) {
                        _this.requestQuickAddDataComplete(qaDialog, data, textStatus);
                    },
                    error: function (data) {
                    }
                });
            };
            QuickAdd.prototype.requestQuickAddDataComplete = function (parentDialog, data, textStatus) {
                if (textStatus !== 'success') {
                    alert(textStatus);
                    return;
                }
                parentDialog.data('Stock', data);
                parentDialog.data('id', data.productStyleId);
                parentDialog.find('.product-name').text(data.name);
                parentDialog.find('.QuickAdd_Description').html(data.description);
                parentDialog.find('.QuickAdd_ProductLink').attr('href', data.productLink);
                var lifestyle = parentDialog.find('.sub-name');
                if (data.lifestyleShortDescription !== '' || data.lifestyleLongDescription !== '') {
                    lifestyle.text(data.lifestyleShortDescription);
                    lifestyle.attr('data-balloon', data.lifestyleLongDescription);
                    if (data.lifestyleLongDescription !== '') {
                        Outdoor.Utilities.CssManipulator.addClass(lifestyle[0], 'data-balloon');
                    }
                    else {
                        Outdoor.Utilities.CssManipulator.removeClass(lifestyle[0], 'data-balloon');
                    }
                    Outdoor.Utilities.CssManipulator.removeClass(lifestyle[0], 'hidden');
                }
                else {
                    Outdoor.Utilities.CssManipulator.addClass(lifestyle[0], 'hidden');
                }
                parentDialog.find('#SupplierImage').attr('src', data.brandNameImageUrl);
                parentDialog.find('#SupplierImage').attr('alt', data.brandName);
                parentDialog.find('#product-code').text('Product Code: ' + data.code);
                var element = parentDialog.find('.item-price');
                var sizeAndColourContainer = parentDialog.find('#size-and-colour-container');
                var giftcardContainer = parentDialog.find('#giftcard-amount-container');
                if (data.productClass === ProductClass.GiftCard) {
                    giftcardContainer.removeClass('hidden');
                    sizeAndColourContainer.addClass('hidden');
                    element.addClass('hidden');
                }
                else {
                    giftcardContainer.addClass('hidden');
                    sizeAndColourContainer.removeClass('hidden');
                    element.removeClass('hidden');
                }
                var freeDelivery = parentDialog.find('.delivery-text');
                freeDelivery.removeClass('hidden');
                freeDelivery.addClass('hidden');
                this.setQuickAddImage(parentDialog);
                this.PopulateThumbnails(data.images, parentDialog);
                this.populateQuickAddSizes(data, parentDialog);
                this.setQuickAddButtonState(parentDialog);
                this.updateSelectedColourDependencies(parentDialog);
            };
            QuickAdd.prototype.updatePriceWithoutVat = function (parentDialog, text) {
                var element = parentDialog.find('.exvatmessage');
                if (text) {
                    var innerPriceElement = parentDialog.find("#PriceWithoutVAT");
                    innerPriceElement.html(text);
                    element.removeClass('hidden');
                }
                else {
                    element.addClass('hidden');
                }
            };
            QuickAdd.prototype.setElementTextOrHide = function (element, text) {
                element.html(text);
                if (text === '') {
                    element.addClass('hidden');
                }
                else {
                    element.removeClass('hidden');
                }
            };
            QuickAdd.prototype.PopulateThumbnails = function (images, parentDialog) {
                if (MagicScroll.running('quick-view-images') === true) {
                    MagicScroll.stop('quick-view-images');
                }
                var container = parentDialog.find(".product-list-new");
                container.empty();
                for (var image in images) {
                    var imageElement = this.CreateScrollImageElement(images[image]);
                    container.append(imageElement);
                }
                container.addClass('MagicScroll');
                MagicScroll.refresh('quick-view-images');
                MagicScroll.start('quick-view-images');
            };
            QuickAdd.prototype.CreateScrollImageElement = function (image) {
                var productImg = document.createElement("img");
                productImg.src = image.imageUrl;
                productImg.alt = image.colour;
                return productImg;
            };
            QuickAdd.prototype.populateQuickAddSizes = function (stock, parentDialog) {
                var selectListElem = (parentDialog.find(".QuickAdd_Sizes")[0]);
                selectListElem.options.length = 0;
                var selectList = $(selectListElem);
                selectList.append($('<option></option>').val("").html("Select Size"));
                var sizes = stock.sizes;
                for (var sizePosCode in sizes) {
                    selectList.append($('<option></option>').val(sizePosCode).html(sizes[sizePosCode]));
                }
                this.resetQuickAddColours(parentDialog, '(Colour) Select Size First');
                this.setQuickAddButtonState(parentDialog);
            };
            QuickAdd.prototype.resetQuickAddColours = function (parentDialog, notSelectedText) {
                var selectListElem = parentDialog.find(".QuickAdd_Colours")[0];
                selectListElem.options.length = 0;
                var option = document.createElement('option');
                option.innerHTML = notSelectedText;
                selectListElem.options.add(option);
                return selectListElem;
            };
            QuickAdd.prototype.loadStyleInfoFromDataAttribute = function (parentDialog) {
                return parentDialog.data('Stock');
            };
            QuickAdd.prototype.populateQuickAddColours = function (parentDialog) {
                var selectList = this.resetQuickAddColours(parentDialog, 'Select Colour');
                var stock = this.loadStyleInfoFromDataAttribute(parentDialog);
                var selectedSizePosCode = parentDialog.find('.QuickAdd_Sizes').val();
                if (selectedSizePosCode === '') {
                    this.updateSelectedColourDependencies(parentDialog);
                    return;
                }
                for (var i = 0; i < stock.colours.length; i++) {
                    var colour = stock.colours[i];
                    var posCode = stock.productStylePosCode + colour.colourPosCode + selectedSizePosCode;
                    var stockText;
                    var cssClass = '';
                    switch (stock.availability[posCode]) {
                        case 1:
                            stockText = 'Order Now';
                            cssClass = 'instock';
                            break;
                        case 2:
                            stockText = 'Order Now';
                            cssClass = 'instock';
                            break;
                        case 3:
                            stockText = 'Out of Stock (Request Email Alert)';
                            cssClass = 'requestemail';
                            break;
                        default:
                            stockText = 'Discontinued and Sold Out';
                            cssClass = 'discontinued';
                    }
                    var colourOptionText = colour.description + " - " + stockText;
                    if (stock.splitColourPricing) {
                        if (colour.formattedPrice !== null && colour.formattedPrice !== '') {
                            colourOptionText += " (" + colour.formattedPrice + ")";
                        }
                        else {
                            colourOptionText += " (" + stock.price + ")";
                        }
                    }
                    var option = document.createElement('option');
                    option.className = cssClass;
                    option.value = colour.colourPosCode;
                    option.innerHTML = colourOptionText;
                    selectList.options.add(option);
                }
                var colourCount = selectList.options.length;
                if (colourCount == 2) {
                    selectList.selectedIndex = 1;
                    $(selectList).trigger('change');
                }
                this.setQuickAddButtonState(parentDialog);
            };
            QuickAdd.prototype.quickAddSizeChanged = function (e, dialogId) {
                var quickAddDialog = $('#' + dialogId);
                this.populateQuickAddColours(quickAddDialog);
            };
            QuickAdd.prototype.WireUpPriceEditMonitoring = function () {
                var _this = this;
                $('#gift-voucher-price')
                    .keydown(function (e) { return _this.filterGiftCardInput(e); })
                    .keyup(function (e) { return _this.onGiftCardPriceChanged(e); });
            };
            QuickAdd.prototype.filterGiftCardInput = function (e) {
                if (e.keyCode === 13 || e.keyCode === 46 || e.keyCode === 190) {
                    e.preventDefault();
                }
            };
            QuickAdd.prototype.onGiftCardPriceChanged = function (e) {
                this.setQuickAddButtonState(this.cachedDialog);
            };
            QuickAdd.prototype.giftCardValue = function () {
                var priceAsText = $('#gift-voucher-price').val();
                if (!$.isNumeric(priceAsText)) {
                    return null;
                }
                return parseInt(priceAsText);
            };
            QuickAdd.prototype.onQuickAddToBasketClicked = function (e, dialogId) {
                var qaDialog = $('#' + dialogId);
                var stockInfo = this.getQuickAddSelectedStockInfo(qaDialog);
                this.logQuickViewOperation('Add To Basket');
                switch (stockInfo.availability) {
                    case StockLevel.Stock_InStock:
                    case StockLevel.Stock_LowStock:
                        {
                            var price = null;
                            if (stockInfo.productClass === ProductClass.GiftCard) {
                                price = this.giftCardValue();
                                if (price === null) {
                                    alert('Please enter a gift card value of at least £5.');
                                    return;
                                }
                            }
                            else {
                                price = stockInfo.priceGbp;
                            }
                            this.quickAddToBasket(stockInfo.productId, stockInfo.posCode, price);
                        }
                        break;
                    case StockLevel.Stock_Enquiries:
                    case StockLevel.Stock_Unavailable:
                        window.location.href = "/out-of-stock?ProductId=" + stockInfo.productId;
                        break;
                    default:
                        alert('You need to select a size and colour combination first.');
                }
            };
            QuickAdd.prototype.logQuickViewOperation = function (eventAction) {
                if (ga) {
                    ga('send', 'event', 'QuickView', eventAction);
                }
            };
            QuickAdd.prototype.quickAddToWishlist = function (e, dialogId) {
                var qaDialog = $('#' + dialogId);
                var stockInfo = this.getQuickAddSelectedStockInfo(qaDialog);
                this.addToWishList(stockInfo.productId);
            };
            QuickAdd.prototype.quickAddToBasketComplete = function (result, textStatus) {
                if (textStatus !== 'success') {
                    alert(textStatus);
                    return;
                }
                if (result.errors && result.errors.length > 0) {
                    alert("The product was not added;\n" + result.errors.join("\n"));
                    return;
                }
                basketSuccess(result, this.quickAddToBasket, null);
            };
            QuickAdd.prototype.addToWishList = function (productId) {
                $.ajax({
                    type: "POST",
                    url: "/wishlist/add",
                    data: "{productId:'" + productId + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function () { AddToWishListSuccess(); },
                    error: function (err) { AddToWishListFailed(err); }
                });
            };
            QuickAdd.prototype.quickAddToBasket = function (productId, posCode, price) {
                var _this = this;
                var postData = { productId: productId.toString(), price: null };
                if (price) {
                    postData.price = price;
                }
                $.ajax({
                    type: "POST",
                    url: "/ws/add-item",
                    data: JSON.stringify(postData),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data, textStatus) { return _this.quickAddToBasketComplete(data, textStatus); },
                    error: function (data) {
                    }
                });
            };
            QuickAdd.prototype.quickAddColourChanged = function (e, dialogId) {
                var quickAddDialog = $('#' + dialogId);
                this.updateSelectedColourDependencies(quickAddDialog);
            };
            QuickAdd.prototype.updateSelectedColourDependencies = function (quickAddDialog) {
                var data = this.loadStyleInfoFromDataAttribute(quickAddDialog);
                this.setQuickAddButtonState(quickAddDialog);
                this.setQuickAddImage(quickAddDialog);
                var stockInfo = this.getQuickAddSelectedStockInfo(quickAddDialog);
                var selectedColour = this.getQuickAddSelectedColour(quickAddDialog);
                var exVatPrice = data.priceWithoutVat;
                var price = data.price;
                if (selectedColour && stockInfo.price) {
                    exVatPrice = stockInfo.priceExVat;
                    price = stockInfo.price;
                }
                this.updatePriceWithoutVat(quickAddDialog, exVatPrice);
                quickAddDialog.find('.item-price').html(price);
                if (selectedColour === null) {
                    quickAddDialog.find(".stock-message").text("Select size and colour above to view stock availability");
                    $('#quickViewZoomCaption').hide();
                }
                else if (stockInfo.stockLevelMessage) {
                    quickAddDialog.find(".stock-message").text(stockInfo.stockLevelMessage);
                    $('#quickViewZoomCaption').text(selectedColour.description).show();
                }
                else {
                    quickAddDialog.find(".stock-message").text('Discontinued and Sold Out');
                    $('#quickViewZoomCaption').text(selectedColour.description).show();
                }
                var element = quickAddDialog.find('.percentage-off');
                this.setElementTextOrHide(element, stockInfo.percentageSaving);
            };
            QuickAdd.prototype.getQuickAddSelectedStockInfo = function (parentDialog) {
                var stock = this.loadStyleInfoFromDataAttribute(parentDialog);
                if (stock.productClass === ProductClass.GiftCard) {
                    if (this.giftCardValue() === null) {
                        return this.NotAvailable(ProductClass.GiftCard);
                    }
                    var firstProductPosCode = Object.keys(stock.posCodeToIdLookup)[0];
                    return this.CreateStockInfo(ProductClass.GiftCard, stock.posCodeToIdLookup[firstProductPosCode]);
                }
                var selectedSizePosCode = parentDialog.find('.QuickAdd_Sizes').val();
                var selectedColourPosCode = parentDialog.find('.QuickAdd_Colours').val();
                var posCode = stock.productStylePosCode + selectedColourPosCode + selectedSizePosCode;
                var stockInfo = stock.posCodeToIdLookup[posCode];
                if (stockInfo) {
                    return this.CreateStockInfo(ProductClass.PhysicalProduct, stockInfo);
                }
                return this.NotAvailable(ProductClass.PhysicalProduct);
            };
            QuickAdd.prototype.CreateStockInfo = function (productClass, stockData) {
                stockData["ProductClass"] = productClass;
                return stockData;
            };
            QuickAdd.prototype.NotAvailable = function (productClass) {
                return {
                    availability: StockLevel.Stock_NotSelected,
                    percentageSaving: '',
                    posCode: '',
                    priceHeading: '',
                    price: "",
                    priceExVat: "",
                    priceGbp: 0,
                    productClass: productClass,
                    productId: 0,
                    stockLevelMessage: '',
                };
            };
            QuickAdd.prototype.getQuickAddSelectedColour = function (parentDialog) {
                var stock = this.loadStyleInfoFromDataAttribute(parentDialog);
                var selectedColourPos = parentDialog.find('.QuickAdd_Colours').val();
                for (var i in stock.colours) {
                    var col = stock.colours[i];
                    if (col.colourPosCode == selectedColourPos) {
                        return col;
                    }
                }
                return null;
            };
            QuickAdd.prototype.getLargeImageForColourId = function (parentDialog, colourId) {
                var stock = this.loadStyleInfoFromDataAttribute(parentDialog);
                var imageUrl = stock.images.length > 0 ? stock.images[0].imageUrl : '';
                $.each(stock.images, function (index, value) {
                    if (value.colourId === colourId) {
                        imageUrl = value.imageUrl;
                        return false;
                    }
                });
                return imageUrl;
            };
            QuickAdd.prototype.setQuickAddButtonState = function (parentDialog) {
                var buttonClass;
                var buttonText;
                var buttonDisabled = false;
                var buttonRef = parentDialog.find("#QuickAddToBasket");
                var wishlistButton = $(parentDialog.find(".QuickAdd_AddToWishlist")[0]);
                var stockInfo = this.getQuickAddSelectedStockInfo(parentDialog);
                switch (stockInfo.availability) {
                    case StockLevel.Stock_InStock:
                    case StockLevel.Stock_LowStock:
                        buttonClass = "btn btn-primary on";
                        buttonText = "Add to Basket";
                        break;
                    case StockLevel.Stock_Enquiries:
                    case StockLevel.Stock_Unavailable:
                        buttonClass = "btn btn-primary outofstock notice";
                        buttonText = "Email me when in stock";
                        break;
                    default:
                        buttonClass = "btn btn-primary off";
                        buttonText = 'Add to Basket';
                        buttonDisabled = true;
                }
                var internalSpan = buttonRef.contents().last()[0];
                internalSpan.nodeValue = buttonText;
                buttonRef.attr('class', buttonClass);
                buttonRef.prop("disabled", buttonDisabled);
                wishlistButton.prop("disabled", buttonDisabled);
            };
            QuickAdd.prototype.setQuickAddImage = function (parentDialog) {
                var colour = this.getQuickAddSelectedColour(parentDialog);
                if (colour === null) {
                    return;
                }
                var img = parentDialog.find('img.fullsize');
                img.attr('src', this.getLargeImageForColourId(parentDialog, colour.colourId));
            };
            return QuickAdd;
        }());
        Pages.QuickAdd = QuickAdd;
    })(Pages = Outdoor.Pages || (Outdoor.Pages = {}));
})(Outdoor || (Outdoor = {}));
$(document).ready(function () {
    quickAdd = new Outdoor.Pages.QuickAdd();
});
//# sourceMappingURL=QuickAdd.js.map;
//function ajaxsearchsubmit(form) {
//    var search = encodeURIComponent(form.w.value);
//    window.location = "/search/go#w=" + search;
//    return false;
//}
;
var Outdoor;
(function (Outdoor) {
    var Pages;
    (function (Pages) {
        var Account;
        (function (Account) {
            var SignIn = (function () {
                function SignIn() {
                    var _this = this;
                    this.continueElement = document.getElementById("continue");
                    this.emailElement = $("#Email");
                    this.backToEmailPanelElement = document.getElementById("back-to-email-panel-link");
                    this.passwordElement = $("#Password");
                    this.setPasswordElement = $("#SetPassword");
                    this.validationCodeElement = $("#ValidationCode");
                    this.backToEmailPanelElement.onclick = function (ev) { return _this.onBackToEmailPanelClicked(ev); };
                    this.continueElement.onclick = function (ev) { return _this.onContinueClicked(ev); };
                    Outdoor.Utilities.EnterCallback.register(this.emailElement[0], function () { _this.verifyEmail(); });
                    Outdoor.Utilities.EnterCallback.register(this.passwordElement[0], function () { _this.verifyLogin(); });
                    Outdoor.Utilities.EnterCallback.register(this.setPasswordElement[0], function () { _this.setPassword(); });
                    Outdoor.Utilities.EnterCallback.register(this.validationCodeElement[0], function () { _this.validateAccount(); });
                }
                SignIn.Init = function () {
                    new SignIn();
                };
                SignIn.prototype.verifyEmail = function () {
                    var _this = this;
                    if (!this.emailElement.valid()) {
                        return;
                    }
                    fetch("/ws/verify-email", {
                        body: JSON.stringify({ email: this.emailElement.val() }),
                        headers: { 'Content-Type': 'application/json' },
                        method: "post",
                    }).then(function (response) {
                        if (response.ok) {
                            return response.json();
                        }
                        Outdoor.Pages.IssueLogger.log("Unable to validate email address.", "sign-in");
                        _this.showValidationError("Unable to verify your email address.", SignInPanels.Email);
                    }).then(function (data) {
                        if (!data) {
                            Outdoor.Pages.IssueLogger.log("Server error validating email address.", "sign-in");
                            _this.showValidationError("Unable to check your email address.", SignInPanels.Email);
                            return;
                        }
                        if (data.customerAccountState === CustomerAccountState.Interactive) {
                            _this.setPanelVisibility(SignInPanels.Password);
                        }
                        else if (data.customerAccountState === CustomerAccountState.DoesNotExist) {
                            window.location.href = "/register-customer";
                        }
                        else if (data.customerAccountState === CustomerAccountState.NotInteractive) {
                            _this.setPanelVisibility(SignInPanels.Validation);
                        }
                        else if (data.customerAccountState === CustomerAccountState.AccountDisabled) {
                            _this.setPanelVisibility(SignInPanels.Email);
                            _this.showValidationError("This account has been locked, please contact customer services for more information.", SignInPanels.Email);
                        }
                        else {
                            _this.setPanelVisibility(SignInPanels.Email);
                            _this.showValidationError("We could not log you in, if this problem persists please contact customer services.", SignInPanels.Email);
                        }
                    });
                };
                SignIn.prototype.showValidationError = function (errorText, panel) {
                    this.setPanelError(errorText, SignInPanels.Email, panel === SignInPanels.Email);
                    this.setPanelError(errorText, SignInPanels.Password, panel === SignInPanels.Password);
                    this.setPanelError(errorText, SignInPanels.SetPassword, panel === SignInPanels.SetPassword);
                    this.setPanelError(errorText, SignInPanels.Validation, panel === SignInPanels.Validation);
                };
                SignIn.prototype.setPanelError = function (text, panel, isPanelActive) {
                    var elementId = "email-error-message";
                    if (panel === SignInPanels.Password) {
                        elementId = "password-error-message";
                    }
                    else if (panel === SignInPanels.SetPassword) {
                        elementId = "set-password-error-message";
                    }
                    else if (panel === SignInPanels.Validation) {
                        elementId = "validation-error-message";
                    }
                    var errorSpan = document.getElementById(elementId);
                    errorSpan.innerText = text;
                    if (isPanelActive) {
                        Outdoor.Utilities.CssManipulator.removeClass(errorSpan, "field-validation-valid");
                        Outdoor.Utilities.CssManipulator.addClass(errorSpan, "field-validation-error");
                    }
                    else {
                        Outdoor.Utilities.CssManipulator.removeClass(errorSpan, "field-validation-error");
                        Outdoor.Utilities.CssManipulator.addClass(errorSpan, "field-validation-valid");
                    }
                };
                SignIn.prototype.onBackToEmailPanelClicked = function (ev) {
                    ev.preventDefault();
                    this.setPanelVisibility(SignInPanels.Email);
                };
                SignIn.prototype.onContinueClicked = function (ev) {
                    ev.preventDefault();
                    if (this.emailElement.is(":visible")) {
                        if (this.emailElement.valid()) {
                            this.verifyEmail();
                        }
                    }
                    else if (this.validationCodeElement.is(":visible")) {
                        if (this.validationCodeElement.valid()) {
                            this.validateAccount();
                        }
                    }
                    else if (this.setPasswordElement.is(":visible")) {
                        if (this.setPasswordElement.valid()) {
                            this.setPassword();
                        }
                    }
                    else if (this.passwordElement.valid()) {
                        this.verifyLogin();
                    }
                };
                SignIn.prototype.verifyLogin = function () {
                    var _this = this;
                    if (this.passwordElement.is(":visible") && this.passwordElement.valid()) {
                        var postData = {
                            email: this.emailElement.val(),
                            password: this.passwordElement.val(),
                        };
                        fetch("/ws/verify-login", {
                            body: JSON.stringify(postData),
                            headers: { 'Content-Type': 'application/json' },
                            method: "post",
                        }).then(function (response) {
                            if (response.ok) {
                                return response.json();
                            }
                            Outdoor.Pages.IssueLogger.log("Unable to log in.", "sign-in");
                            _this.showValidationError("Unable to log you in due to an error.", SignInPanels.Password);
                        }).then(function (data) {
                            if (!data) {
                                Outdoor.Pages.IssueLogger.log("Unable to log in due to server error.", "sign-in");
                                _this.showValidationError("Unable to check your login due to an error.", SignInPanels.Password);
                                return;
                            }
                            if (data.redirectUrl) {
                                window.location.href = data.redirectUrl;
                            }
                            else {
                                _this.showValidationError(data.errorText, SignInPanels.Password);
                            }
                        });
                    }
                    else {
                        this.setPanelVisibility(SignInPanels.Password);
                    }
                };
                SignIn.prototype.setPassword = function () {
                    var _this = this;
                    if (this.setPasswordElement.is(":visible") && this.setPasswordElement.valid()) {
                        var postData = {
                            email: this.emailElement.val(),
                            newPassword: this.setPasswordElement.val(),
                            validationCode: this.validationCodeElement.val(),
                        };
                        fetch("/ws/set-password", {
                            body: JSON.stringify(postData),
                            headers: { 'Content-Type': 'application/json' },
                            method: "post",
                        }).then(function (response) {
                            if (response.ok) {
                                return response.json();
                            }
                            Outdoor.Pages.IssueLogger.log("Unable to set account active.", "sign-in");
                            _this.showValidationError("Unable to set your password due to an error.", SignInPanels.SetPassword);
                        }).then(function (data) {
                            if (!data) {
                                Outdoor.Pages.IssueLogger.log("Unable to set account active due to server error.", "sign-in");
                                _this.showValidationError("Unable to set your account up due to an error.", SignInPanels.SetPassword);
                                return;
                            }
                            if (data.success) {
                                window.location.href = "/account/home";
                            }
                            else {
                                _this.showValidationError("Unable to set your password, please ensure it is more than 6 characters.", SignInPanels.SetPassword);
                            }
                        });
                    }
                    else {
                        this.setPanelVisibility(SignInPanels.SetPassword);
                    }
                };
                SignIn.prototype.validateAccount = function () {
                    var _this = this;
                    if (this.validationCodeElement.is(":visible") && this.validationCodeElement.valid()) {
                        var postData = {
                            email: this.emailElement.val(),
                            validationCode: this.validationCodeElement.val(),
                        };
                        fetch("/ws/validate-account", {
                            body: JSON.stringify(postData),
                            headers: { 'Content-Type': 'application/json' },
                            method: "post",
                        }).then(function (response) {
                            if (response.ok) {
                                return response.json();
                            }
                            Outdoor.Pages.IssueLogger.log("Unable to validate account.", "sign-in");
                            _this.showValidationError("Unable to validate your account due to an error.", SignInPanels.Validation);
                        }).then(function (data) {
                            if (!data) {
                                Outdoor.Pages.IssueLogger.log("Unable to validate account due to server error.", "sign-in");
                                _this.showValidationError("Unable to check your log in due to an error.", SignInPanels.Validation);
                                return;
                            }
                            if (data.accountValidated) {
                                _this.setPanelVisibility(SignInPanels.SetPassword);
                            }
                            else {
                                _this.showValidationError("The validation code did not match, please check and try again.", SignInPanels.Validation);
                            }
                        });
                    }
                    else {
                        this.setPanelVisibility(SignInPanels.Validation);
                    }
                };
                SignIn.prototype.setPanelVisibility = function (panelToMakeVisible) {
                    var panelEmail = document.getElementById("sign-in-email");
                    var panelPassword = document.getElementById("sign-in-password");
                    var panelSetPassword = document.getElementById("sign-in-set-password");
                    var panelValidation = document.getElementById("sign-in-validation");
                    Outdoor.Utilities.CssManipulator.addClass(panelEmail, "hidden");
                    Outdoor.Utilities.CssManipulator.addClass(panelPassword, "hidden");
                    Outdoor.Utilities.CssManipulator.addClass(panelSetPassword, "hidden");
                    Outdoor.Utilities.CssManipulator.addClass(panelValidation, "hidden");
                    Outdoor.Utilities.CssManipulator.addClass(this.backToEmailPanelElement, "hidden");
                    if (panelToMakeVisible == SignInPanels.Email) {
                        Outdoor.Utilities.CssManipulator.removeClass(panelEmail, "hidden");
                        this.emailElement.focus();
                    }
                    else if (panelToMakeVisible == SignInPanels.Password) {
                        Outdoor.Utilities.CssManipulator.removeClass(panelPassword, "hidden");
                        Outdoor.Utilities.CssManipulator.removeClass(this.backToEmailPanelElement, "hidden");
                        this.passwordElement.focus();
                    }
                    else if (panelToMakeVisible == SignInPanels.SetPassword) {
                        Outdoor.Utilities.CssManipulator.removeClass(panelSetPassword, "hidden");
                        Outdoor.Utilities.CssManipulator.removeClass(this.backToEmailPanelElement, "hidden");
                        this.setPasswordElement.focus();
                    }
                    else {
                        Outdoor.Utilities.CssManipulator.removeClass(panelValidation, "hidden");
                        Outdoor.Utilities.CssManipulator.removeClass(this.backToEmailPanelElement, "hidden");
                        this.validationCodeElement.focus();
                    }
                };
                return SignIn;
            }());
            Account.SignIn = SignIn;
        })(Account = Pages.Account || (Pages.Account = {}));
    })(Pages = Outdoor.Pages || (Outdoor.Pages = {}));
})(Outdoor || (Outdoor = {}));
//# sourceMappingURL=sign-in.js.map;
jQuery(window).load(function () {
    var isMobile = jQuery(window).width() <= 1024;
    var stickyNavHeight = 0;
    var target = "";
    let rootElementSelector = null;

    if (isMobile) {
        rootElementSelector = "#navsearch";
        target = '#navsearch';
    }
    else {
        rootElementSelector = ".nav-container";
        target = '.topmenu';
    }
    let rootElement = jQuery(rootElementSelector);

    if (rootElement.length === 0) {
        // On checkout these elements do not exist.
        return;
    }

    stickyNavHeight = rootElement.offset().top;

    var stickyNavigation = function () {
        var scrollTop = jQuery(window).scrollTop();

        if (scrollTop > stickyNavHeight) {
            jQuery(target).addClass('sticky');
        } else {
            jQuery(target).removeClass('sticky');
        }
    };
    stickyNavigation();

    jQuery(window).scroll(function () {
        stickyNavigation();
    });
    jQuery(window).resize(function () {
        stickyNavigation();
    });
});
;
jQuery(window).load(function () {
    jQuery("#navmain .sub-nav .drop-level2,.sub-nav .drop-level3").prev('a').addClass('parent-link');

    jQuery("#navmain .sub-nav").each(function () {
        var menuDropHeight = jQuery(this).height();
        jQuery(this).find('.drop-level2').each(function () {
            jQuery(this).css('height', menuDropHeight);
            jQuery(this).find('.drop-level3').css('height', menuDropHeight);
            jQuery(this).parent().parent().css('height', menuDropHeight);
        });
    });

    var config = {
        sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
        interval: 100,  // number = milliseconds for onMouseOver polling interval    
        over: doOpen,   // function = onMouseOver callback (REQUIRED)    
        timeout: 200,   // number = milliseconds delay before onMouseOut    
        out: doClose    // function = onMouseOut callback (REQUIRED)    
    };
    function doOpen() {
        if (jQuery(window).width() > 1004) {
            jQuery(this).addClass('active').find('div.sub-nav').slideDown();
        }
    }
    function doClose() {
        if (jQuery(window).width() > 1004) {
            jQuery(this).removeClass('active').find('div.sub-nav').slideUp();
        }
    }
    jQuery("#navmain #DesktopMenuRoot li.spc1").hoverIntent(config);

    var config_sub = {
        sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
        interval: 100,  // number = milliseconds for onMouseOver polling interval    
        over: doOpenSub,   // function = onMouseOver callback (REQUIRED)    
        timeout: 500,   // number = milliseconds delay before onMouseOut    
        out: doCloseSub    // function = onMouseOut callback (REQUIRED)    
    };
    function doOpenSub() {
        jQuery(this).addClass('active').find('ul:first').show();
    }
    function doCloseSub() {
        jQuery(this).removeClass('active').find('ul:first').hide();
    }
    jQuery("#navmain .sub-nav li").each(function () {
        if (jQuery(window).width() > 1004) {
            jQuery(this).hoverIntent(config_sub);
        }
    });
});

jQuery(document).ready(function () {
    jQuery('.mobnav-expander').click(function () {
        jQuery('.header-bottom').find('.mobile-menu,#DesktopMenuRoot').slideToggle();
    });

    if (jQuery('html').hasClass('no-canvas')) {

    } else {
        //mobnavInit();
        jQuery(window).resize(function () {
            //mobnavInit();
        });
    }

});


function mobnavInit() {
    if ((jQuery(window).width() <= 768)) {
        jQuery('#DesktopMenuRoot').hide();
        jQuery('#navmain').addClass('mobnav');
        jQuery('#navsearch').addClass('mobnav-icon');
        jQuery('#navinner').addClass('mobnav-contain');
    } else {
        jQuery('#DesktopMenuRoot').show();
        jQuery('#navmain').removeClass('mobnav');
        jQuery('#navsearch').removeClass('mobnav-icon');
        jQuery('#navinner').removeClass('mobnav-contain');
    }
}
;
// Start of Clerk.io E-commerce Personalisation tool - www.clerk.io

$('body').click(function () {
    $('.clerk-design-component-tSKL0ay9').remove();
});


(function (w, d) {
    var e = d.createElement('script'); e.type = 'text/javascript'; e.async = true;
    e.src = (d.location.protocol == 'https:' ? 'https' : 'http') + '://cdn.clerk.io/clerk.js';
    var s = d.getElementsByTagName('script')[0]; s.parentNode.insertBefore(e, s);
    w.__clerk_q = w.__clerk_q || []; w.Clerk = w.Clerk || function () { w.__clerk_q.push(arguments) };
})(window, document);

Clerk('config', {
    key: 'o8YE50IvJKrpIcEOx5mf61VefAoAEAQS'
});

// End of Clerk.io E-commerce Personalisation tool - www.clerk.io
;
/*


   Magic Scroll v2.0.38 
   Copyright 2018 Magic Toolbox
   Buy a license: https://www.magictoolbox.com/magicscroll/
   License agreement: https://www.magictoolbox.com/license/


*/
eval(function(m,a,g,i,c,k){c=function(e){return(e<a?'':c(parseInt(e/a)))+((e=e%a)>35?String.fromCharCode(e+29):e.toString(36))};if(!''.replace(/^/,String)){while(g--){k[c(g)]=i[g]||c(g)}i=[function(e){return k[e]}];c=function(){return'\\w+'};g=1};while(g--){if(i[g]){m=m.replace(new RegExp('\\b'+c(g)+'\\b','g'),i[g])}}return m}('1l.5f=(17(){1a u,v;u=v=(17(){1a R={5g:"jC.3-b5-1-gE",fq:0,9q:{},$6O:17(V){18(V.$7a||(V.$7a=++L.fq))},a5:17(V){18(L.9q[V]||(L.9q[V]={}))},$F:17(){},$1c:17(){18 1c},$1d:17(){18 1d},fJ:"eJ-"+1g.64(1g.7I()*1v de().fD()),3e:17(V){18(2U!=V)},bu:17(W,V){18(2U!=W)?W:V},aL:17(V){18!!(V)},1P:17(V){if(!L.3e(V)){18 1c}if(V.$4Z){18 V.$4Z}if(!!V.5a){if(1==V.5a){18"7q"}if(3==V.5a){18"fF"}}if(V.1r&&V.34){18"gB"}if(V.1r&&V.aJ){18"3h"}if((V 4x 1l.fo||V 4x 1l.cH)&&V.4P===L.4p){18"2C"}if(V 4x 1l.6h){18"4c"}if(V 4x 1l.cH){18"17"}if(V 4x 1l.eM){18"2e"}if(L.1f.5W){if(L.3e(V.dP)){18"1E"}}1b{if(V===1l.1E||V.4P==1l.1u||V.4P==1l.gG||V.4P==1l.gC||V.4P==1l.gt||V.4P==1l.gs){18"1E"}}if(V 4x 1l.de){18"fG"}if(V 4x 1l.gu){18"gL"}if(V===1l){18"1l"}if(V===1k){18"1k"}18 bR(V)},1U:17(aa,Z){if(!(aa 4x 1l.6h)){aa=[aa]}if(!Z){18 aa[0]}1s(1a Y=0,W=aa.1r;Y<W;Y++){if(!L.3e(aa)){4V}1s(1a X in Z){if(!fo.27.4v.2m(Z,X)){4V}3f{aa[Y][X]=Z[X]}3v(V){}}}18 aa[0]},a4:17(Z,Y){if(!(Z 4x 1l.6h)){Z=[Z]}1s(1a X=0,V=Z.1r;X<V;X++){if(!L.3e(Z[X])){4V}if(!Z[X].27){4V}1s(1a W in(Y||{})){if(!Z[X].27[W]){Z[X].27[W]=Y[W]}}}18 Z[0]},fE:17(X,W){if(!L.3e(X)){18 X}1s(1a V in(W||{})){if(!X[V]){X[V]=W[V]}}18 X},$3f:17(){1s(1a W=0,V=3h.1r;W<V;W++){3f{18 3h[W]()}3v(X){}}18 1i},$A:17(X){if(!L.3e(X)){18 L.$([])}if(X.fB){18 L.$(X.fB())}if(X.34){1a W=X.1r||0,V=1v 6h(W);4U(W--){V[W]=X[W]}18 L.$(V)}18 L.$(6h.27.c2.2m(X))},66:17(){18 1v de().fD()},6F:17(Z){1a X;7B(L.1P(Z)){1S"7S":X={};1s(1a Y in Z){X[Y]=L.6F(Z[Y])}1N;1S"4c":X=[];1s(1a W=0,V=Z.1r;W<V;W++){X[W]=L.6F(Z[W])}1N;2E:18 Z}18 L.$(X)},$:17(X){1a V=1d;if(!L.3e(X)){18 1i}if(X.$di){18 X}7B(L.1P(X)){1S"4c":X=L.fE(X,L.1U(L.6h,{$di:L.$F}));X.1A=X.eL;18 X;1N;1S"2e":1a W=1k.ez(X);if(L.3e(W)){18 L.$(W)}18 1i;1N;1S"1l":1S"1k":L.$6O(X);X=L.1U(X,L.4b);1N;1S"7q":L.$6O(X);X=L.1U(X,L.3K);1N;1S"1E":X=L.1U(X,L.1u);1N;1S"fF":1S"17":1S"4c":1S"fG":2E:V=1c;1N}if(V){18 L.1U(X,{$di:L.$F})}1b{18 X}},$1v:17(V,X,W){18 L.$(L.c3.6u(V)).dO(X||{}).2Y(W||{})},da:17(Y,Z,W){1a V,ab,X,ad=[],ac=-1;W||(W=L.fJ);V=L.$(W)||L.$1v("3g",{id:W,1I:"bo/b7"}).43((1k.h6||1k.4d),"1L");ab=V.eY||V.f9;if("2e"!=L.1P(Z)){1s(1a X in Z){ad.2a(X+":"+Z[X])}Z=ad.9p(";")}if(ab.fC){ac=ab.fC(Y+" {"+Z+"}",ab.h1.1r)}1b{3f{ac=ab.gZ(Y,Z,ab.gY.1r)}3v(aa){}}18 ac},cy:17(Y,V){1a X,W;X=L.$(Y);if("7q"!==L.1P(X)){18}W=X.eY||X.f9;if(W.fa){W.fa(V)}1b{if(W.fg){W.fg(V)}}},gQ:17(){18"gF-gw-gN-hc-hb".5n(/[gM]/g,17(X){1a W=1g.7I()*16|0,V=X=="x"?W:(W&3|8);18 V.9j(16)}).8e()},gO:(17(){1a V;18 17(W){if(!V){V=1k.6u("a")}V.3i("bl",W);18("!!"+V.bl).5n("!!","")}})(),gU:17(X){1a Y=0,V=X.1r;1s(1a W=0;W<V;++W){Y=31*Y+X.gR(W);Y%=gP}18 Y}};1a L=R;1a M=R.$;if(!1l.bY){1l.bY=R;1l.$eJ=R.$}L.6h={$4Z:"4c",5I:17(Y,Z){1a V=14.1r;1s(1a W=14.1r,X=(Z<0)?1g.6e(0,W+Z):Z||0;X<W;X++){if(14[X]===Y){18 X}}18-1},3l:17(V,W){18 14.5I(V,W)!=-1},eL:17(V,Y){1s(1a X=0,W=14.1r;X<W;X++){if(X in 14){V.2m(Y,14[X],X,14)}}},52:17(V,aa){1a Z=[];1s(1a Y=0,W=14.1r;Y<W;Y++){if(Y in 14){1a X=14[Y];if(V.2m(aa,14[Y],Y,14)){Z.2a(X)}}}18 Z},f4:17(V,Z){1a Y=[];1s(1a X=0,W=14.1r;X<W;X++){if(X in 14){Y[X]=V.2m(Z,14[X],X,14)}}18 Y}};L.a4(eM,{$4Z:"2e",4i:17(){18 14.5n(/^\\s+|\\s+$/g,"")},eq:17(V,W){18(W||1c)?(14.9j()===V.9j()):(14.36().9j()===V.36().9j())},6a:17(){18 14.5n(/-\\D/g,17(V){18 V.aw(1).8e()})},aq:17(){18 14.5n(/[A-Z]/g,17(V){18("-"+V.aw(0).36())})},gS:17(V){18 1V(14,V||10)},gV:17(){18 3p(14)},ds:17(){18!14.5n(/1d/i,"").4i()},9J:17(W,V){V=V||"";18(V+14+V).5I(V+W+V)>-1}});R.a4(cH,{$4Z:"17",1e:17(){1a W=L.$A(3h),V=14,X=W.6Y();18 17(){18 V.5x(X||1i,W.bP(L.$A(3h)))}},6p:17(){1a W=L.$A(3h),V=14,X=W.6Y();18 17(Y){18 V.5x(X||1i,L.$([Y||(L.1f.1C?1l.1E:1i)]).bP(W))}},3y:17(){1a W=L.$A(3h),V=14,X=W.6Y();18 1l.5h(17(){18 V.5x(V,W)},X||0)},dW:17(){1a W=L.$A(3h),V=14;18 17(){18 V.3y.5x(V,W)}},ei:17(){1a W=L.$A(3h),V=14,X=W.6Y();18 1l.h3(17(){18 V.5x(V,W)},X||0)}});1a S={},K=3N.h5.36(),J=K.4B(/(4W|8B|5W|bJ)\\/(\\d+\\.?\\d*)/i),O=K.4B(/(h9|cf)\\/(\\d+\\.?\\d*)/i)||K.4B(/(fb|9M|fP|gm|8J|cf)\\/(\\d+\\.?\\d*)/i),Q=K.4B(/5g\\/(\\d+\\.?\\d*)/i),F=1k.6G.3g;17 G(W){1a V=W.aw(0).8e()+W.c2(1);18 W in F||("gq"+V)in F||("fm"+V)in F||("ms"+V)in F||("O"+V)in F}L.1f={4R:{he:!!(1k.h2),gv:!!(1l.gz),iP:!!(1k.iQ),7M:!!(1k.iR||1k.iS||1k.aG||1k.dT||1k.j2||1k.jr||1k.js||1k.jm||1k.jt),eE:!!(1l.jv)&&!!(1l.jw)&&(1l.aH&&"jx"in 1v aH),2L:G("2L"),8g:G("8g"),ex:G("ex"),2r:G("2r"),5H:1c,fl:1c,c7:1c,4h:1c,bd:(17(){18 1k.jy.ju("jk://j5.jj.ji/jf/je/jc#j9","1.1")})()},dn:17(){18"j6"in 1l||(1l.dU&&1k 4x dU)||(3N.j4>0)||(3N.iu>0)}(),7l:K.4B(/(9W|bb\\d+|it).+|hB|hH\\/|hK|hL|hM|hN|hI|hy|hi|ip(fy|fz|ad)|hx|hw|hv |hu|ht|jB|7l.+gm|hq|8J m(hp|in)i|ho( hn)?|fI|p(hm|hQ)\\/|i8|ia|ib|ic(4|6)0|ig|ih|ii\\.(1f|i9)|ij|im|io (ce|fI)|ir|is/)?1d:1c,7G:(J&&J[1])?J[1].36():(1l.8J)?"bJ":!!(1l.ik)?"5W":(2U!==1k.i7||1i!=1l.hS)?"8B":(1i!==1l.i6||!3N.i3)?"4W":"i2",5g:(J&&J[2])?3p(J[2]):0,8c:(O&&O[1])?O[1].36():"",b2:(O&&O[2])?3p(O[2]):0,gl:"",c1:"",5p:"",1C:0,8j:K.4B(/ip(?:ad|fz|fy)/)?"dL":(K.4B(/(?:i1|9W)/)||3N.8j.4B(/i0|aK|hU/i)||["hT"])[0].36(),gg:1k.ba&&"ef"==1k.ba.36(),fM:0,5U:17(){18(1k.ba&&"ef"==1k.ba.36())?1k.4d:1k.6G},5H:1l.5H||1l.hV||1l.hW||1l.hX||1l.hY||2U,9Y:1l.9Y||1l.fu||1l.fu||1l.hZ||1l.i4||1l.i5||2U,5M:1c,7Q:17(){if(L.1f.5M){18}1a Y,X;L.1f.5M=1d;L.4d=L.$(1k.4d);L.aK=L.$(1l);3f{1a W=L.$1v("2Z").2Y({1x:2F,1B:2F,6I:"2q",2H:"6J",1L:-iq}).43(1k.4d);L.1f.fM=W.e9-W.dy;W.2o()}3v(V){}3f{Y=L.$1v("2Z");X=Y.3g;X.f5="f8:ao(cc://),ao(cc://),il ao(cc://)";L.1f.4R.fl=(/(ao\\s*\\(.*?){3}/).3C(X.f8);X=1i;Y=1i}3v(V){}if(!L.1f.eZ){L.1f.eZ=L.av("8g").aq()}3f{Y=L.$1v("2Z");Y.3g.f5=L.av("52").aq()+":gc(hz);";L.1f.4R.c7=!!Y.3g.1r&&(!L.1f.1C||L.1f.1C>9);Y=1i}3v(V){}if(!L.1f.4R.c7){L.$(1k.6G).2V("gp-hP-4t")}3f{L.1f.4R.4h=(17(){1a Z=L.$1v("4h");18!!(Z.8M&&Z.8M("2d"))})()}3v(V){}if(2U===1l.hj&&2U!==1l.hk){S.6N="hl"}L.4b.1o.2m(L.$(1k),"8W")}};(17(){1a aa=[],Z,Y,W;17 V(){18!!(3h.aJ.bs)}7B(L.1f.7G){1S"5W":if(!L.1f.5g){L.1f.5g=!!(1l.aH)?3:2}1N;1S"8B":L.1f.5g=(O&&O[2])?3p(O[2]):0;1N}L.1f[L.1f.7G]=1d;if(O&&"fb"===O[1]){L.1f.8c="9M"}if(!!1l.9M){L.1f.9M=1d}if(O&&"cf"===O[1]){L.1f.8c="8J";L.1f.8J=1d}if("fP"===L.1f.8c&&(Q&&Q[1])){L.1f.b2=3p(Q[1])}if("9W"==L.1f.8j&&L.1f.4W&&(Q&&Q[1])){L.1f.gf=1d}Z=({8B:["-g2-","fm","g2"],4W:["-4W-","gq","4W"],5W:["-ms-","ms","ms"],bJ:["-o-","O","o"]})[L.1f.7G]||["","",""];L.1f.gl=Z[0];L.1f.c1=Z[1];L.1f.5p=Z[2];L.1f.1C=(!L.1f.5W)?2U:(1k.gj)?1k.gj:17(){1a ab=0;if(L.1f.gg){18 5}7B(L.1f.5g){1S 2:ab=6;1N;1S 3:ab=7;1N}18 ab}();aa.2a(L.1f.8j+"-4t");if(L.1f.7l){aa.2a("7l-4t")}if(L.1f.gf){aa.2a("9W-1f-4t")}if(L.1f.1C){L.1f.8c="ie";L.1f.b2=L.1f.1C;aa.2a("ie"+L.1f.1C+"-4t");1s(Y=11;Y>L.1f.1C;Y--){aa.2a("lt-ie"+Y+"-4t")}}if(L.1f.4W&&L.1f.5g<hs){L.1f.4R.7M=1c}if(L.1f.5H){L.1f.5H.2m(1l,17(){L.1f.4R.5H=1d})}if(L.1f.4R.bd){aa.2a("bd-4t")}1b{aa.2a("gp-bd-4t")}W=(1k.6G.6s||"").4B(/\\S+/g)||[];1k.6G.6s=L.$(W).bP(aa).9p(" ");3f{1k.6G.3i("2c-4t-fY",L.1f.8c);1k.6G.3i("2c-4t-fY-hO",L.1f.b2)}3v(X){}if(L.1f.1C&&L.1f.1C<9){1k.6u("4w");1k.6u("33")}})();(17(){L.1f.7M={bI:L.1f.4R.7M,fT:17(){18!!(1k.hJ||1k[L.1f.5p+"hA"]||1k.7M||1k.hG||1k[L.1f.5p+"hF"])},dY:17(V,W){W||(W={});if(14.bI){L.$(1k).1H(14.cl,14.gh=17(X){if(14.fT()){W.eT&&W.eT()}1b{L.$(1k).1W(14.cl,14.gh);W.eV&&W.eV()}}.6p(14));L.$(1k).1H(14.bV,14.5u=17(X){W.aY&&W.aY();L.$(1k).1W(14.bV,14.5u)}.6p(14));(V[L.1f.5p+"hE"]||V[L.1f.5p+"hD"]||V.hC||17(){}).2m(V)}1b{if(W.aY){W.aY()}}},hR:(1k.aG||1k.dT||1k[L.1f.5p+"j7"]||1k[L.1f.5p+"j8"]||17(){}).1e(1k),cl:1k.e1?"ja":(1k.aG?"":L.1f.5p)+"jb",bV:1k.e1?"jd":(1k.aG?"":L.1f.5p)+"jg",jh:L.1f.5p,jA:1i}})();1a U=/\\S+/g,I=/^(5Y(eB|eC|eK|eI)jz)|((5B|6j)(eB|eC|eK|eI))$/,N={"jq":("2U"===bR(F.ed))?"jp":"ed"},P={hg:1d,jo:1d,3w:1d,cT:1d,cY:1d},H=(1l.eo)?17(X,V){1a W=1l.eo(X,1i);18 W?W.jn(V)||W[V]:1i}:17(Y,W){1a X=Y.jl,V=1i;V=X?X[W]:1i;if(1i==V&&Y.3g&&Y.3g[W]){V=Y.3g[W]}18 V};17 T(X){1a V,W;W=(L.1f.4W&&"52"==X)?1c:(X in F);if(!W){V=L.1f.c1+X.aw(0).8e()+X.c2(1);if(V in F){18 V}}18 X}L.av=T;L.3K={8Y:17(V){18!(V||"").9J(" ")&&(14.6s||"").9J(V," ")},2V:17(Z){1a W=(14.6s||"").4B(U)||[],Y=(Z||"").4B(U)||[],V=Y.1r,X=0;1s(;X<V;X++){if(!L.$(W).3l(Y[X])){W.2a(Y[X])}}14.6s=W.9p(" ");18 14},4L:17(aa){1a W=(14.6s||"").4B(U)||[],Z=(aa||"").4B(U)||[],V=Z.1r,Y=0,X;1s(;Y<V;Y++){if((X=L.$(W).5I(Z[Y]))>-1){W.d6(X,1)}}14.6s=aa?W.9p(" "):"";18 14},j3:17(V){18 14.8Y(V)?14.4L(V):14.2V(V)},2j:17(W){1a X=W.6a(),V=1i;W=N[X]||(N[X]=T(X));V=H(14,W);if("21"===V){V=1i}if(1i!==V){if("3w"==W){18 L.3e(V)?3p(V):1}if(I.3C(W)){V=1V(V,10)?V:"cK"}}18 V},1M:17(W,V){1a Y=W.6a();3f{if("3w"==W){14.3Z(V);18 14}W=N[Y]||(N[Y]=T(Y));14.3g[W]=V+(("5y"==L.1P(V)&&!P[Y])?"2K":"")}3v(X){}18 14},2Y:17(W){1s(1a V in W){14.1M(V,W[V])}18 14},iM:17(){1a V={};L.$A(3h).1A(17(W){V[W]=14.2j(W)},14);18 V},3Z:17(X,V){1a W;V=V||1c;14.3g.3w=X;X=1V(3p(X)*2F);if(V){if(0===X){if("6l"!=14.3g.6m){14.3g.6m="6l"}}1b{if("6X"!=14.3g.6m){14.3g.6m="6X"}}}if(L.1f.1C&&L.1f.1C<9){if(!6C(X)){if(!~14.3g.52.5I("ca")){14.3g.52+=" eA:dI.dH.ca(am="+X+")"}1b{14.3g.52=14.3g.52.5n(/am=\\d*/i,"am="+X)}}1b{14.3g.52=14.3g.52.5n(/eA:dI.dH.ca\\(am=\\d*\\)/i,"").4i();if(""===14.3g.52){14.3g.3P("52")}}}18 14},dO:17(V){1s(1a W in V){if("2C"===W){14.2V(""+V[W])}1b{14.3i(W,""+V[W])}}18 14},ix:17(){1a W=0,V=0;W=14.2j("2L-3T");V=14.2j("2L-c8");W=W.5I("ms")>-1?3p(W):W.5I("s")>-1?3p(W)*9t:0;V=V.5I("ms")>-1?3p(V):V.5I("s")>-1?3p(V)*9t:0;18 W+V},5b:17(){18 14.2Y({4S:"40",6m:"6l"})},2M:17(){18 14.2Y({4S:"",6m:"6X"})},2p:17(){18{1x:14.e9,1B:14.67}},iy:17(W){1a V=14.2p();V.1x-=(3p(14.2j("5Y-1O-1x")||0)+3p(14.2j("5Y-6w-1x")||0));V.1B-=(3p(14.2j("5Y-1L-1x")||0)+3p(14.2j("5Y-5s-1x")||0));if(!W){V.1x-=(3p(14.2j("5B-1O")||0)+3p(14.2j("5B-6w")||0));V.1B-=(3p(14.2j("5B-1L")||0)+3p(14.2j("5B-5s")||0))}18 V},bm:17(){18{1L:14.9R,1O:14.9Q}},iz:17(){1a V=14,W={1L:0,1O:0};do{W.1O+=V.9Q||0;W.1L+=V.9R||0;V=V.3j}4U(V);18 W},5t:17(){1a Z=14,W=0,Y=0;if(L.3e(1k.6G.bX)){1a V=14.bX(),X=L.$(1k).bm(),aa=L.1f.5U();18{1L:V.1L+X.y-aa.iA,1O:V.1O+X.x-aa.iB}}do{W+=Z.ff||0;Y+=Z.cs||0;Z=Z.iC}4U(Z&&!(/^(?:4d|iD)$/i).3C(Z.2x));18{1L:Y,1O:W}},iE:17(){1a W=14.5t();1a V=14.2p();18{1L:W.1L,5s:W.1L+V.1B,1O:W.1O,6w:W.1O+V.1x}},iF:17(W){3f{14.dB=W}3v(V){14.iG=W}18 14},2o:17(){18(14.3j)?14.3j.9z(14):14},5c:17(){L.$A(14.2h).1A(17(V){if(3==V.5a||8==V.5a){18}L.$(V).5c()});14.2o();14.cQ();if(14.$7a){L.9q[14.$7a]=1i;5v L.9q[14.$7a]}18 1i},2k:17(X,W){W=W||"5s";1a V=14.3r;("1L"==W&&V)?14.7C(X,V):14.8S(X);18 14},43:17(X,W){1a V=L.$(X).2k(14,W);18 14},iH:17(V){14.2k(V.3j.iI(14,V));18 14},iJ:17(V){if("7q"!==L.1P("2e"==L.1P(V)?V=1k.ez(V):V)){18 1c}18(14==V)?1c:(14.3l&&!(L.1f.dA))?(14.3l(V)):(14.dM)?!!(14.dM(V)&16):L.$A(14.7N(V.2x)).3l(V)}};L.3K.iK=L.3K.2j;L.3K.iw=L.3K.2Y;if(!1l.3K){1l.3K=L.$F;if(L.1f.7G.4W){1l.1k.6u("iL")}1l.3K.27=(L.1f.7G.4W)?1l["[[iV.27]]"]:{}}L.a4(1l.3K,{$4Z:"7q"});L.4b={2p:17(){if(L.1f.dn||L.1f.j1||L.1f.dA){18{1x:1l.j0,1B:1l.iZ}}18{1x:L.1f.5U().dy,1B:L.1f.5U().iY}},bm:17(){18{x:1l.iX||L.1f.5U().9Q,y:1l.iW||L.1f.5U().9R}},iU:17(){1a V=14.2p();18{1x:1g.6e(L.1f.5U().iN,V.1x),1B:1g.6e(L.1f.5U().iT,V.1B)}}};L.1U(1k,{$4Z:"1k"});L.1U(1l,{$4Z:"1l"});L.1U([L.3K,L.4b],{2s:17(Y,W){1a V=L.a5(14.$7a),X=V[Y];if(2U!==W&&2U===X){X=V[Y]=W}18(L.3e(X)?X:1i)},3u:17(X,W){1a V=L.a5(14.$7a);V[X]=W;18 14},3L:17(W){1a V=L.a5(14.$7a);5v V[W];18 14}});if(!(1l.bA&&1l.bA.27&&1l.bA.27.bN)){L.1U([L.3K,L.4b],{bN:17(V){18 L.$A(14.bj("*")).52(17(X){3f{18(1==X.5a&&X.6s.9J(V," "))}3v(W){}})}})}L.1U([L.3K,L.4b],{f7:17(){18 14.bN(3h[0])},7N:17(){18 14.bj(3h[0])}});if(L.1f.7M.bI&&!1k.e2){L.3K.e2=17(){L.1f.7M.dY(14)}}L.1u={$4Z:"1E",78:L.$1c,29:17(){18 14.81().4u()},81:17(){if(14.dN){14.dN()}1b{14.dP=1d}18 14},4u:17(){if(14.bE){14.bE()}1b{14.fp=1c}18 14},8i:17(){14.78=L.$1d;18 14},ej:17(){1a W,V;W=((/5F/i).3C(14.1I))?14.3n[0]:14;18(!L.3e(W))?{x:0,y:0}:{x:W.3c,y:W.3a}},6R:17(){1a W,V;W=((/5F/i).3C(14.1I))?14.3n[0]:14;18(!L.3e(W))?{x:0,y:0}:{x:W.6A||W.3c+L.1f.5U().9Q,y:W.6D||W.3a+L.1f.5U().9R}},bz:17(){1a V=14.1Z||14.iO;4U(V&&3==V.5a){V=V.3j}18 V},a0:17(){1a W=1i;7B(14.1I){1S"5l":1S"iv":1S"hh":W=14.9C||14.gK;1N;1S"7c":1S"hf":1S"gy":W=14.9C||14.gx;1N;2E:18 W}3f{4U(W&&3==W.5a){W=W.3j}}3v(V){W=1i}18 W},7p:17(){if(!14.dZ&&14.3R!==2U){18(14.3R&1?1:(14.3R&2?3:(14.3R&4?2:0)))}18 14.dZ},gI:17(){18(14.3o&&("5F"===14.3o||14.3o===14.6P))||(/5F/i).3C(14.1I)},gH:17(){18 14.3o?(("5F"===14.3o||14.6P===14.3o)&&14.c0):1===14.3n.1r&&(14.8y.1r?14.8y[0].4I==14.3n[0].4I:1d)}};L.b4="dw";L.8F="gD";L.7o="";if(!1k.dw){L.b4="gA";L.8F="ha";L.7o="3s"}L.1u.1w={1I:"",x:1i,y:1i,3b:1i,3R:1i,1Z:1i,9C:1i,$4Z:"1E.h7",78:L.$1c,6t:L.$([]),4K:17(V){1a W=V;14.6t.2a(W)},29:17(){18 14.81().4u()},81:17(){14.6t.1A(17(W){3f{W.81()}3v(V){}});18 14},4u:17(){14.6t.1A(17(W){3f{W.4u()}3v(V){}});18 14},8i:17(){14.78=L.$1d;18 14},ej:17(){18{x:14.3c,y:14.3a}},6R:17(){18{x:14.x,y:14.y}},bz:17(){18 14.1Z},a0:17(){18 14.9C},7p:17(){18 14.3R},h4:17(){18 14.6t.1r>0?14.6t[0].bz():2U}};L.1U([L.3K,L.4b],{1H:17(X,Z,aa,ad){1a ac,V,Y,ab,W;if("2e"==L.1P(X)){W=X.7R(" ");if(W.1r>1){X=W}}if(L.1P(X)=="4c"){L.$(X).1A(14.1H.6p(14,Z,aa,ad));18 14}if(!X||!Z||L.1P(X)!="2e"||L.1P(Z)!="17"){18 14}if(X=="8W"&&L.1f.5M){Z.2m(14);18 14}X=S[X]||X;aa=1V(aa||50);if(!Z.$4n){Z.$4n=1g.64(1g.7I()*L.66())}ac=L.4b.2s.2m(14,"9h",{});V=ac[X];if(!V){ac[X]=V=L.$([]);Y=14;if(L.1u.1w[X]){L.1u.1w[X].1Q.6B.2m(14,ad)}1b{V.3O=17(ae){ae=L.1U(ae||1l.e,{$4Z:"1E"});L.4b.1o.2m(Y,X,L.$(ae))};14[L.b4](L.7o+X,V.3O,1c)}}ab={1I:X,fn:Z,bK:aa,e8:Z.$4n};V.2a(ab);V.h0(17(af,ae){18 af.bK-ae.bK});18 14},1W:17(ab){1a Z=L.4b.2s.2m(14,"9h",{}),X,V,W,ac,aa,Y;aa=3h.1r>1?3h[1]:-2F;if("2e"==L.1P(ab)){Y=ab.7R(" ");if(Y.1r>1){ab=Y}}if(L.1P(ab)=="4c"){L.$(ab).1A(14.1W.6p(14,aa));18 14}ab=S[ab]||ab;if(!ab||L.1P(ab)!="2e"||!Z||!Z[ab]){18 14}X=Z[ab]||[];1s(W=0;W<X.1r;W++){V=X[W];if(-2F==aa||!!aa&&aa.$4n===V.e8){ac=X.d6(W--,1)}}if(0===X.1r){if(L.1u.1w[ab]){L.1u.1w[ab].1Q.2o.2m(14)}1b{14[L.8F](L.7o+ab,X.3O,1c)}5v Z[ab]}18 14},1o:17(Z,ab){1a Y=L.4b.2s.2m(14,"9h",{}),X,V,W;Z=S[Z]||Z;if(!Z||L.1P(Z)!="2e"||!Y||!Y[Z]){18 14}3f{ab=L.1U(ab||{},{1I:Z})}3v(aa){}if(2U===ab.3b){ab.3b=L.66()}X=Y[Z]||[];1s(W=0;W<X.1r&&!(ab.78&&ab.78());W++){X[W].fn.2m(14,ab)}},gT:17(W,V){1a Z=("8W"==W)?1c:1d,Y=14,X;W=S[W]||W;if(!Z){L.4b.1o.2m(14,W);18 14}if(Y===1k&&1k.au&&!Y.dC){Y=1k.6G}if(1k.au){X=1k.au(W);X.gW(V,1d,1d)}1b{X=1k.gX();X.aS=W}if(1k.au){Y.dC(X)}1b{Y.h8("3s"+V,X)}18 X},cQ:17(){1a W=L.4b.2s.2m(14,"9h");if(!W){18 14}1s(1a V in W){L.4b.1W.2m(14,V)}L.4b.3L.2m(14,"9h");18 14}});(17(V){if("5o"===1k.9n){18 V.1f.7Q.3y(1)}if(V.1f.4W&&V.1f.5g<hd){(17(){(V.$(["4O","5o"]).3l(1k.9n))?V.1f.7Q():3h.aJ.3y(50)})()}1b{if(V.1f.5W&&V.1f.1C<9&&1l==1L){(17(){(V.$3f(17(){V.1f.5U().gJ("1O");18 1d}))?V.1f.7Q():3h.aJ.3y(50)})()}1b{V.4b.1H.2m(V.$(1k),"fU",V.1f.7Q);V.4b.1H.2m(V.$(1l),"2G",V.1f.7Q)}}})(R);L.4p=17(){1a Z=1i,W=L.$A(3h);if("2C"==L.1P(W[0])){Z=W.6Y()}1a V=17(){1s(1a ac in 14){14[ac]=L.6F(14[ac])}if(14.4P.$4e){14.$4e={};1a ae=14.4P.$4e;1s(1a ad in ae){1a ab=ae[ad];7B(L.1P(ab)){1S"17":14.$4e[ad]=L.4p.fZ(14,ab);1N;1S"7S":14.$4e[ad]=L.6F(ab);1N;1S"4c":14.$4e[ad]=L.6F(ab);1N}}}1a aa=(14.4k)?14.4k.5x(14,3h):14;5v 14.bs;18 aa};if(!V.27.4k){V.27.4k=L.$F}if(Z){1a Y=17(){};Y.27=Z.27;V.27=1v Y;V.$4e={};1s(1a X in Z.27){V.$4e[X]=Z.27[X]}}1b{V.$4e=1i}V.4P=L.4p;V.27.4P=V;L.1U(V.27,W[0]);L.1U(V,{$4Z:"2C"});18 V};R.4p.fZ=17(V,W){18 17(){1a Y=14.bs;1a X=W.5x(V,3h);18 X}};(17(Y){1a X=Y.$;1a V=5,W=8A;Y.1u.1w.2N=1v Y.4p(Y.1U(Y.1u.1w,{1I:"2N",4k:17(ab,aa){1a Z=aa.6R();14.x=Z.x;14.y=Z.y;14.3c=aa.3c;14.3a=aa.3a;14.3b=aa.3b;14.3R=aa.7p();14.1Z=ab;14.4K(aa)}}));Y.1u.1w.2N.1Q={1t:{87:W,3R:1},6B:17(Z){14.3u("1E:2N:1t",Y.1U(Y.6F(Y.1u.1w.2N.1Q.1t),Z||{}));14.1H("8f",Y.1u.1w.2N.1Q.3O,1);14.1H("6x",Y.1u.1w.2N.1Q.3O,1);14.1H("4m",Y.1u.1w.2N.1Q.bv,1);if(Y.1f.5W&&Y.1f.1C<9){14.1H("9r",Y.1u.1w.2N.1Q.3O,1)}},2o:17(){14.1W("8f",Y.1u.1w.2N.1Q.3O);14.1W("6x",Y.1u.1w.2N.1Q.3O);14.1W("4m",Y.1u.1w.2N.1Q.bv);if(Y.1f.5W&&Y.1f.1C<9){14.1W("9r",Y.1u.1w.2N.1Q.3O)}},bv:17(Z){Z.4u()},3O:17(ac){1a ab,Z,aa;Z=14.2s("1E:2N:1t");if(ac.1I!="9r"&&ac.7p()!=Z.3R){18}if(14.2s("1E:2N:bW")){14.3L("1E:2N:bW");18}if("8f"==ac.1I){ab=1v Y.1u.1w.2N(14,ac);14.3u("1E:2N:9S",ab)}1b{if("6x"==ac.1I){ab=14.2s("1E:2N:9S");if(!ab){18}aa=ac.6R();14.3L("1E:2N:9S");ab.4K(ac);if(ac.3b-ab.3b<=Z.87&&1g.8n(1g.4N(aa.x-ab.x,2)+1g.4N(aa.y-ab.y,2))<=V){14.1o("2N",ab)}1k.1o("6x",ac)}1b{if(ac.1I=="9r"){ab=1v Y.1u.1w.2N(14,ac);14.1o("2N",ab)}}}}}})(R);(17(W){1a V=W.$;W.1u.1w.2D=1v W.4p(W.1U(W.1u.1w,{1I:"2D",56:"4a",6Q:1c,4k:17(aa,Z,Y){1a X=Z.6R();14.x=X.x;14.y=X.y;14.3c=Z.3c;14.3a=Z.3a;14.3b=Z.3b;14.3R=Z.7p();14.1Z=aa;14.4K(Z);14.56=Y}}));W.1u.1w.2D.1Q={6B:17(){1a Y=W.1u.1w.2D.1Q.f3.6p(14),X=W.1u.1w.2D.1Q.b6.6p(14);14.1H("8f",W.1u.1w.2D.1Q.bF,1);14.1H("6x",W.1u.1w.2D.1Q.b6,1);1k.1H("aZ",Y,1);1k.1H("6x",X,1);14.3u("1E:2D:5q:1k:7h",Y);14.3u("1E:2D:5q:1k:5C",X)},2o:17(){14.1W("8f",W.1u.1w.2D.1Q.bF);14.1W("6x",W.1u.1w.2D.1Q.b6);V(1k).1W("aZ",14.2s("1E:2D:5q:1k:7h")||W.$F);V(1k).1W("6x",14.2s("1E:2D:5q:1k:5C")||W.$F);14.3L("1E:2D:5q:1k:7h");14.3L("1E:2D:5q:1k:5C")},bF:17(Y){1a X;if(1!=Y.7p()){18}X=1v W.1u.1w.2D(14,Y,"4a");14.3u("1E:2D:4a",X)},b6:17(Y){1a X;X=14.2s("1E:2D:4a");if(!X){18}Y.4u();X=1v W.1u.1w.2D(14,Y,"9v");14.3L("1E:2D:4a");14.1o("2D",X)},f3:17(Y){1a X;X=14.2s("1E:2D:4a");if(!X){18}Y.4u();if(!X.6Q){X.6Q=1d;14.1o("2D",X)}X=1v W.1u.1w.2D(14,Y,"f0");14.1o("2D",X)}}})(R);(17(W){1a V=W.$;W.1u.1w.4D=1v W.4p(W.1U(W.1u.1w,{1I:"4D",8v:1c,7Y:1i,4k:17(Z,Y){1a X=Y.6R();14.x=X.x;14.y=X.y;14.3c=Y.3c;14.3a=Y.3a;14.3b=Y.3b;14.3R=Y.7p();14.1Z=Z;14.4K(Y)}}));W.1u.1w.4D.1Q={1t:{87:5N},6B:17(X){14.3u("1E:4D:1t",W.1U(W.6F(W.1u.1w.4D.1Q.1t),X||{}));14.1H("2N",W.1u.1w.4D.1Q.3O,1)},2o:17(){14.1W("2N",W.1u.1w.4D.1Q.3O)},3O:17(Z){1a Y,X;Y=14.2s("1E:4D:1E");X=14.2s("1E:4D:1t");if(!Y){Y=1v W.1u.1w.4D(14,Z);Y.7Y=5h(17(){Y.8v=1d;Z.78=W.$1c;14.1o("2N",Z);14.3L("1E:4D:1E")}.1e(14),X.87+10);14.3u("1E:4D:1E",Y);Z.8i()}1b{3x(Y.7Y);14.3L("1E:4D:1E");if(!Y.8v){Y.4K(Z);Z.8i().29();14.1o("4D",Y)}1b{}}}}})(R);(17(ab){1a aa=ab.$;17 V(ac){18 ac.3o?(("5F"===ac.3o||ac.6P===ac.3o)&&ac.c0):1===ac.3n.1r&&(ac.8y.1r?ac.8y[0].4I==ac.3n[0].4I:1d)}17 X(ac){if(ac.3o){18("5F"===ac.3o||ac.6P===ac.3o)?ac.9D:1i}1b{18 ac.3n[0].4I}}17 Y(ac){if(ac.3o){18("5F"===ac.3o||ac.6P===ac.3o)?ac:1i}1b{18 ac.3n[0]}}ab.1u.1w.3F=1v ab.4p(ab.1U(ab.1u.1w,{1I:"3F",id:1i,4k:17(ad,ac){1a ae=Y(ac);14.id=ae.9D||ae.4I;14.x=ae.6A;14.y=ae.6D;14.6A=ae.6A;14.6D=ae.6D;14.3c=ae.3c;14.3a=ae.3a;14.3b=ac.3b;14.3R=0;14.1Z=ad;14.4K(ac)}}));1a W=10,Z=5N;ab.1u.1w.3F.1Q={6B:17(ac){14.1H(["7T",1l.3N.4Q?"9F":"9G"],ab.1u.1w.3F.1Q.8l,1);14.1H(["7U",1l.3N.4Q?"8o":"8k"],ab.1u.1w.3F.1Q.7J,1);14.1H("4m",ab.1u.1w.3F.1Q.cu,1)},2o:17(){14.1W(["7T",1l.3N.4Q?"9F":"9G"],ab.1u.1w.3F.1Q.8l);14.1W(["7U",1l.3N.4Q?"8o":"8k"],ab.1u.1w.3F.1Q.7J);14.1W("4m",ab.1u.1w.3F.1Q.cu)},cu:17(ac){ac.4u()},8l:17(ac){if(!V(ac)){14.3L("1E:3F:1E");18}14.3u("1E:3F:1E",1v ab.1u.1w.3F(14,ac));14.3u("1E:2N:bW",1d)},7J:17(af){1a ad=ab.66(),ae=14.2s("1E:3F:1E"),ac=14.2s("1E:3F:1t");if(!ae||!V(af)){18}14.3L("1E:3F:1E");if(ae.id==X(af)&&af.3b-ae.3b<=Z&&1g.8n(1g.4N(Y(af).6A-ae.x,2)+1g.4N(Y(af).6D-ae.y,2))<=W){14.3L("1E:2N:9S");af.29();ae.4K(af);14.1o("3F",ae)}}}})(R);L.1u.1w.4T=1v L.4p(L.1U(L.1u.1w,{1I:"4T",8v:1c,7Y:1i,4k:17(W,V){14.x=V.x;14.y=V.y;14.3c=V.3c;14.3a=V.3a;14.3b=V.3b;14.3R=0;14.1Z=W;14.4K(V)}}));L.1u.1w.4T.1Q={1t:{87:8A},6B:17(V){14.3u("1E:4T:1t",L.1U(L.6F(L.1u.1w.4T.1Q.1t),V||{}));14.1H("3F",L.1u.1w.4T.1Q.3O,1)},2o:17(){14.1W("3F",L.1u.1w.4T.1Q.3O)},3O:17(X){1a W,V;W=14.2s("1E:4T:1E");V=14.2s("1E:4T:1t");if(!W){W=1v L.1u.1w.4T(14,X);W.7Y=5h(17(){W.8v=1d;X.78=L.$1c;14.1o("3F",X)}.1e(14),V.87+10);14.3u("1E:4T:1E",W);X.8i()}1b{3x(W.7Y);14.3L("1E:4T:1E");if(!W.8v){W.4K(X);X.8i().29();14.1o("4T",W)}1b{}}}};(17(aa){1a Z=aa.$;17 V(ab){18 ab.3o?(("5F"===ab.3o||ab.6P===ab.3o)&&ab.c0):1===ab.3n.1r&&(ab.8y.1r?ab.8y[0].4I==ab.3n[0].4I:1d)}17 X(ab){if(ab.3o){18("5F"===ab.3o||ab.6P===ab.3o)?ab.9D:1i}1b{18 ab.3n[0].4I}}17 Y(ab){if(ab.3o){18("5F"===ab.3o||ab.6P===ab.3o)?ab:1i}1b{18 ab.3n[0]}}1a W=10;aa.1u.1w.2t=1v aa.4p(aa.1U(aa.1u.1w,{1I:"2t",56:"4a",id:1i,6Q:1c,4k:17(ad,ac,ab){1a ae=Y(ac);14.id=ae.9D||ae.4I;14.3c=ae.3c;14.3a=ae.3a;14.6A=ae.6A;14.6D=ae.6D;14.x=ae.6A;14.y=ae.6D;14.3b=ac.3b;14.3R=0;14.1Z=ad;14.4K(ac);14.56=ab}}));aa.1u.1w.2t.1Q={6B:17(){1a ac=aa.1u.1w.2t.1Q.bc.1e(14),ab=aa.1u.1w.2t.1Q.7J.1e(14);14.1H(["7T",1l.3N.4Q?"9F":"9G"],aa.1u.1w.2t.1Q.8l,1);14.1H(["7U",1l.3N.4Q?"8o":"8k"],aa.1u.1w.2t.1Q.7J,1);14.1H(["aN",1l.3N.4Q?"9I":"9L"],aa.1u.1w.2t.1Q.bc,1);14.3u("1E:2t:5q:1k:7h",ac);14.3u("1E:2t:5q:1k:5C",ab);Z(1k).1H(1l.3N.4Q?"9I":"9L",ac,1);Z(1k).1H(1l.3N.4Q?"8o":"8k",ab,1)},2o:17(){14.1W(["7T",1l.3N.4Q?"9F":"9G"],aa.1u.1w.2t.1Q.8l);14.1W(["7U",1l.3N.4Q?"8o":"8k"],aa.1u.1w.2t.1Q.7J);14.1W(["aN",1l.3N.4Q?"9I":"9L"],aa.1u.1w.2t.1Q.bc);Z(1k).1W(1l.3N.4Q?"9I":"9L",14.2s("1E:2t:5q:1k:7h")||aa.$F,1);Z(1k).1W(1l.3N.4Q?"8o":"8k",14.2s("1E:2t:5q:1k:5C")||aa.$F,1);14.3L("1E:2t:5q:1k:7h");14.3L("1E:2t:5q:1k:5C")},8l:17(ac){1a ab;if(!V(ac)){18}ab=1v aa.1u.1w.2t(14,ac,"4a");14.3u("1E:2t:4a",ab)},7J:17(ac){1a ab;ab=14.2s("1E:2t:4a");if(!ab||!ab.6Q||ab.id!=X(ac)){18}ab=1v aa.1u.1w.2t(14,ac,"9v");14.3L("1E:2t:4a");14.1o("2t",ab)},bc:17(ac){1a ab;ab=14.2s("1E:2t:4a");if(!ab||!V(ac)){18}if(ab.id!=X(ac)){14.3L("1E:2t:4a");18}if(!ab.6Q&&1g.8n(1g.4N(Y(ac).6A-ab.x,2)+1g.4N(Y(ac).6D-ab.y,2))>W){ab.6Q=1d;14.1o("2t",ab)}if(!ab.6Q){18}ab=1v aa.1u.1w.2t(14,ac,"f0");14.1o("2t",ab)}}})(R);L.1u.1w.4y=1v L.4p(L.1U(L.1u.1w,{1I:"4y",7w:1,bT:1,fQ:1,56:"k3",4k:17(W,V){14.3b=V.3b;14.3R=0;14.1Z=W;14.x=V.57[0].3c+(V.57[1].3c-V.57[0].3c)/2;14.y=V.57[0].3a+(V.57[1].3a-V.57[0].3a)/2;14.f6=1g.8n(1g.4N(V.57[0].3c-V.57[1].3c,2)+1g.4N(V.57[0].3a-V.57[1].3a,2));14.4K(V)},7z:17(V){1a W;14.56="lL";if(V.3n[0].4I!=14.6t[0].57[0].4I||V.3n[1].4I!=14.6t[0].57[1].4I){18}W=1g.8n(1g.4N(V.3n[0].3c-V.3n[1].3c,2)+1g.4N(V.3n[0].3a-V.3n[1].3a,2));14.bT=14.7w;14.7w=W/14.f6;14.fQ=14.7w/14.bT;14.x=V.3n[0].3c+(V.3n[1].3c-V.3n[0].3c)/2;14.y=V.3n[0].3a+(V.3n[1].3a-V.3n[0].3a)/2;14.4K(V)}}));L.1u.1w.4y.1Q={6B:17(){14.1H("7T",L.1u.1w.4y.1Q.cg,1);14.1H("7U",L.1u.1w.4y.1Q.c5,1);14.1H("aN",L.1u.1w.4y.1Q.bD,1)},2o:17(){14.1W("7T",L.1u.1w.4y.1Q.cg);14.1W("7U",L.1u.1w.4y.1Q.c5);14.1W("aN",L.1u.1w.4y.1Q.bD)},cg:17(W){1a V;if(W.57.1r!=2){18}W.4u();V=1v L.1u.1w.4y(14,W);14.3u("1E:4y:1E",V)},c5:17(W){1a V;V=14.2s("1E:4y:1E");if(!V){18}W.4u();14.3L("1E:4y:1E")},bD:17(W){1a V;V=14.2s("1E:4y:1E");if(!V){18}W.4u();V.7z(W);14.1o("4y",V)}};(17(aa){1a Y=aa.$;aa.1u.1w.4r=1v aa.4p(aa.1U(aa.1u.1w,{1I:"4r",4k:17(ag,af,ai,ac,ab,ah,ad){1a ae=af.6R();14.x=ae.x;14.y=ae.y;14.3b=af.3b;14.1Z=ag;14.lM=ai||0;14.3W=ac||0;14.3V=ab||0;14.lN=ah||0;14.lO=ad||0;14.c9=af.c9||0;14.51=1c;14.4K(af)}}));1a Z,W;17 V(){Z=1i}17 X(ab,ac){18(ab>50)||(1===ac&&!("aK"==aa.1f.8j&&ab<1))||(0===ab%12)||(0==ab%4.lP)}aa.1u.1w.4r.1Q={aS:"lQ"in 1k||aa.1f.1C>8?"lR":"aW",6B:17(){14.1H(aa.1u.1w.4r.1Q.aS,aa.1u.1w.4r.1Q.3O,1)},2o:17(){14.1W(aa.1u.1w.4r.1Q.aS,aa.1u.1w.4r.1Q.3O,1)},3O:17(ag){1a ah=0,ae=0,ac=0,ab=0,af,ad;if(ag.g9){ac=ag.g9*-1}if(ag.fS!==2U){ac=ag.fS}if(ag.fV!==2U){ac=ag.fV}if(ag.gb!==2U){ae=ag.gb*-1}if(ag.3V){ac=-1*ag.3V}if(ag.3W){ae=ag.3W}if(0===ac&&0===ae){18}ah=0===ac?ae:ac;ab=1g.6e(1g.1F(ac),1g.1F(ae));if(!Z||ab<Z){Z=ab}af=ah>0?"64":"8U";ah=1g[af](ah/Z);ae=1g[af](ae/Z);ac=1g[af](ac/Z);if(W){3x(W)}W=5h(V,5N);ad=1v aa.1u.1w.4r(14,ag,ah,ae,ac,0,Z);ad.51=X(Z,ag.c9||0);14.1o("4r",ad)}}})(R);L.aK=L.$(1l);L.c3=L.$(1k);18 R})();(17(H){if(!H){6r"7x 7t 7s"}1a G=H.$;1a F=1l.lS||1l.lT||1i;u.fh=1v H.4p({2g:1i,5M:1c,1t:{aI:H.$F,6c:H.$F,8N:H.$F,5u:H.$F,7V:H.$F,e0:H.$F,9X:1c,dS:1d},1z:1i,9k:1i,bZ:0,8p:{aI:17(I){if(I.1Z&&(5N===I.1Z.bn||e6===I.1Z.bn)&&I.lK){14.1t.aI.1e(1i,(I.4O-(14.1t.dS?14.bZ:0))/I.lU).3y(1);14.bZ=I.4O}},6c:17(I){if(I){G(I).29()}14.9l();if(14.5M){18}14.5M=1d;14.9m();!14.1t.9X&&14.1t.aI.1e(1i,1).3y(1);14.1t.6c.1e(1i,14).3y(1);14.1t.7V.1e(1i,14).3y(1)},8N:17(I){if(I){G(I).29()}14.9l();14.5M=1c;14.9m();14.1t.8N.1e(1i,14).3y(1);14.1t.7V.1e(1i,14).3y(1)},5u:17(I){if(I){G(I).29()}14.9l();14.5M=1c;14.9m();14.1t.5u.1e(1i,14).3y(1);14.1t.7V.1e(1i,14).3y(1)}},aD:17(){G(["2G","8O","7F"]).1A(17(I){14.2g.1H(I,14.8p["3s"+I].6p(14).dW(1))},14)},9l:17(){if(14.9k){3f{3x(14.9k)}3v(I){}14.9k=1i}G(["2G","8O","7F"]).1A(17(J){14.2g.1W(J)},14)},9m:17(){14.2p();if(14.2g.2s("1v")){1a I=14.2g.3j;14.2g.2o().3L("1v").2Y({2H:"lW",1L:"21"});I.5c()}},eH:17(J){1a K=1v aH(),I;G(["8O","1K"]).1A(17(L){K["3s"+L]=G(17(M){14.8p["3s"+L].2m(14,M)}).1e(14)},14);K.5u=G(17(){14.1t.e0.1e(1i,14).3y(1);14.1t.9X=1c;14.aD();14.2g.4j=J}).1e(14);K.6c=G(17(){if(5N!==K.bn&&e6!==K.bn){14.8p.5u.2m(14);18}I=K.lX;14.aD();if(F&&!H.1f.5W&&!("dL"===H.1f.8j&&H.1f.5g<lY)){14.2g.3i("4j",F.lZ(I))}1b{14.2g.4j=J}}).1e(14);K.m0("m1",J);K.m2="m3";K.m4()},4k:17(J,I){14.1t=H.1U(14.1t,I);14.2g=G(J)||H.$1v("2g",{},{"6e-1x":"40","6e-1B":"40"}).43(H.$1v("2Z").2V("4t-m5-2g").2Y({2H:"6J",1L:-lV,1x:10,1B:10,6I:"6l"}).43(1k.4d)).3u("1v",1d);if(H.1f.4R.eE&&14.1t.9X&&"2e"==H.1P(J)){14.eH(J);18}1a K=17(){if(14.es()){14.8p.6c.2m(14)}1b{14.8p.5u.2m(14)}K=1i}.1e(14);14.aD();if("2e"==H.1P(J)){14.2g.4j=J}1b{if(H.1f.5W&&5==H.1f.5g&&H.1f.1C<9){14.2g.ek=17(){if(/4O|5o/.3C(14.2g.9n)){14.2g.ek=1i;K&&K()}}.1e(14)}14.2g.4j=J.3Q("4j")}14.2g&&14.2g.5o&&K&&(14.9k=K.3y(2F))},fd:17(){14.9l();14.9m();14.5M=1c;18 14},es:17(){1a I=14.2g;18(I.ch)?(I.ch>0):(I.9n)?("5o"==I.9n):I.1x>0},2p:17(){18 14.1z||(14.1z={1x:14.2g.ch||14.2g.1x,1B:14.2g.lI||14.2g.1B})}})})(u);(17(G){if(!G){6r"7x 7t 7s"}if(G.4z){18}1a F=G.$;G.4z=1v G.4p({4k:17(I,H){1a J;14.el=G.$(I);14.1t=G.1U(14.1t,H);14.6o=1c;14.8b=14.9N;J=G.4z.9o[14.1t.2L]||14.1t.2L;if("17"===G.1P(J)){14.8b=J}1b{14.5Q=14.8D(J)||14.8D("7O")}if("2e"==G.1P(14.1t.8s)){14.1t.8s="3B"===14.1t.8s?lw:1V(14.1t.8s)||1}},1t:{eb:60,3T:db,2L:"7O",8s:1,1J:"lH",8C:G.$F,5L:G.$F,b8:G.$F,dz:G.$F,al:1c,ll:1c},4Y:1i,5Q:1i,8b:1i,lm:17(H){14.1t.2L=H;H=G.4z.9o[14.1t.2L]||14.1t.2L;if("17"===G.1P(H)){14.8b=H}1b{14.8b=14.9N;14.5Q=14.8D(H)||14.8D("7O")}},2y:17(J){1a H=/\\%$/,I;14.4Y=J||{};14.cd=0;14.56=0;14.ln=0;14.9T={};14.8u="8u"===14.1t.1J||"8u-4C"===14.1t.1J;14.2v="2v"===14.1t.1J||"2v-4C"===14.1t.1J;1s(I in 14.4Y){H.3C(14.4Y[I][0])&&(14.9T[I]=1d);if("4C"===14.1t.1J||"8u-4C"===14.1t.1J||"2v-4C"===14.1t.1J){14.4Y[I].4C()}}14.bU=G.66();14.eG=14.bU+14.1t.3T;14.1t.8C.2m();if(0===14.1t.3T){14.7j(1);14.1t.5L.2m()}1b{14.a9=14.1n.1e(14);if(!14.1t.al&&G.1f.4R.5H){14.6o=G.1f.5H.2m(1l,14.a9)}1b{14.6o=14.a9.ei(1g.5R(9t/14.1t.eb))}}18 14},ck:17(){if(14.6o){if(!14.1t.al&&G.1f.4R.5H&&G.1f.9Y){G.1f.9Y.2m(1l,14.6o)}1b{lo(14.6o)}14.6o=1c}},29:17(H){H=G.3e(H)?H:1c;14.ck();if(H){14.7j(1);14.1t.5L.3y(10)}18 14},bL:17(J,I,H){J=3p(J);I=3p(I);18(I-J)*H+J},1n:17(){1a I=G.66(),H=(I-14.bU)/14.1t.3T,J=1g.64(H);if(I>=14.eG&&J>=14.1t.8s){14.ck();14.7j(1);14.1t.5L.3y(10);18 14}if(14.8u&&14.cd<J){1s(1a K in 14.4Y){14.4Y[K].4C()}}14.cd=J;if(!14.1t.al&&G.1f.4R.5H){14.6o=G.1f.5H.2m(1l,14.a9)}14.7j((14.2v?J:0)+14.8b(H%1))},7j:17(H){1a I={},K=H;1s(1a J in 14.4Y){if("3w"===J){I[J]=1g.5R(14.bL(14.4Y[J][0],14.4Y[J][1],H)*2F)/2F}1b{I[J]=14.bL(14.4Y[J][0],14.4Y[J][1],H);14.9T[J]&&(I[J]+="%")}}14.1t.b8(I,14.el);14.2n(I);14.1t.dz(I,14.el)},2n:17(H){18 14.el.2Y(H)},8D:17(H){1a I,J=1i;if("2e"!==G.1P(H)){18 1i}7B(H){1S"9a":J=F([0,0,1,1]);1N;1S"7O":J=F([0.25,0.1,0.25,1]);1N;1S"7O-in":J=F([0.42,0,1,1]);1N;1S"7O-an":J=F([0,0,0.58,1]);1N;1S"7O-in-an":J=F([0.42,0,0.58,1]);1N;1S"eO":J=F([0.47,0,0.lp,0.lq]);1N;1S"ew":J=F([0.39,0.lr,0.ls,1]);1N;1S"lu":J=F([0.lk,0.cj,0.55,0.95]);1N;1S"er":J=F([0.55,0.m7,0.68,0.53]);1N;1S"ep":J=F([0.25,0.46,0.45,0.94]);1N;1S"lx":J=F([0.ly,0.du,0.lz,0.lA]);1N;1S"en":J=F([0.55,0.lB,0.lC,0.19]);1N;1S"ea":J=F([0.lD,0.61,0.dK,1]);1N;1S"lE":J=F([0.lF,0.dq,0.dK,1]);1N;1S"lG":J=F([0.m6,0.du,0.lJ,0.22]);1N;1S"m8":J=F([0.eg,0.84,0.44,1]);1N;1S"mw":J=F([0.77,0,0.dF,1]);1N;1S"mA":J=F([0.mB,0.cj,0.mv,0.mC]);1N;1S"mF":J=F([0.23,1,0.32,1]);1N;1S"mi":J=F([0.86,0,0.mt,1]);1N;1S"et":J=F([0.95,0.cj,0.md,0.me]);1N;1S"eu":J=F([0.19,1,0.22,1]);1N;1S"ml":J=F([1,0,0,1]);1N;1S"mq":J=F([0.6,0.ma,0.98,0.mp]);1N;1S"mo":J=F([0.mn,0.82,0.eg,1]);1N;1S"mk":J=F([0.mj,0.mh,0.15,0.86]);1N;1S"ee":J=F([0.6,-0.28,0.m9,0.dq]);1N;1S"ec":J=F([0.dF,0.mg,0.32,1.mf]);1N;1S"mc":J=F([0.68,-0.55,0.mr,1.55]);1N;2E:H=H.5n(/\\s/g,"");if(H.4B(/^5S-5J\\((?:-?[0-9\\.]{0,}[0-9]{1,},){3}(?:-?[0-9\\.]{0,}[0-9]{1,})\\)$/)){J=H.5n(/^5S-5J\\s*\\(|\\)$/g,"").7R(",");1s(I=J.1r-1;I>=0;I--){J[I]=3p(J[I])}}}18 F(J)},9N:17(T){1a H=0,S=0,P=0,U=0,R=0,N=0,O=14.1t.3T;17 M(V){18((H*V+S)*V+P)*V}17 L(V){18((U*V+R)*V+N)*V}17 J(V){18(3*H*V+2*S)*V+P}17 Q(V){18 1/(5N*V)}17 I(V,W){18 L(K(V,W))}17 K(ac,ad){1a ab,aa,Z,W,V,Y;17 X(ae){if(ae>=0){18 ae}1b{18 0-ae}}1s(Z=ac,Y=0;Y<8;Y++){W=M(Z)-ac;if(X(W)<ad){18 Z}V=J(Z);if(X(V)<0.mu){1N}Z=Z-W/V}ab=0;aa=1;Z=ac;if(Z<ab){18 ab}if(Z>aa){18 aa}4U(ab<aa){W=M(Z);if(X(W-ac)<ad){18 Z}if(ac>W){ab=Z}1b{aa=Z}Z=(aa-ab)*0.5+ab}18 Z}P=3*14.5Q[0];S=3*(14.5Q[2]-14.5Q[0])-P;H=1-P-S;N=3*14.5Q[1];R=3*(14.5Q[3]-14.5Q[1])-N;U=1-N-R;18 I(T,Q(O))}});G.4z.9o={9a:"9a",mE:"eO",mz:"ew",my:"et",mx:"eu",lv:"er",lj:"ep",kt:"en",lh:"ea",k5:"ee",k6:"ec",ev:17(I,H){H=H||[];18 1g.4N(2,10*--I)*1g.eS(20*I*1g.3J*(H[0]||1)/3)},k7:17(I,H){18 1-G.4z.9o.ev(1-I,H)},eQ:17(J){1s(1a I=0,H=1;1;I+=H,H/=2){if(J>=(7-4*I)/11){18 H*H-1g.4N((11-6*I-11*J)/4,2)}}},k8:17(H){18 1-G.4z.9o.eQ(1-H)},40:17(H){18 0}}})(u);(17(G){if(!G){6r"7x 7t 7s"}if(G.eP){18}1a F=G.$;G.eP=1v G.4p(G.4z,{4k:17(H,I){14.cb=H;14.1t=G.1U(14.1t,I);14.6o=1c;14.$4e.4k()},2y:17(L){1a H=/\\%$/,K,J,I=L.1r;14.bx=L;14.9U=1v 6h(I);1s(J=0;J<I;J++){14.9U[J]={};1s(K in L[J]){H.3C(L[J][K][0])&&(14.9U[J][K]=1d);if("4C"===14.1t.1J||"8u-4C"===14.1t.1J||"2v-4C"===14.1t.1J){14.bx[J][K].4C()}}}14.$4e.2y({});18 14},7j:17(H){1s(1a I=0;I<14.cb.1r;I++){14.el=G.$(14.cb[I]);14.4Y=14.bx[I];14.9T=14.9U[I];14.$4e.7j(H)}}})})(u);(17(G){if(!G){6r"7x 7t 7s";18}if(G.bH){18}1a F=G.$;G.bH=17(I,J){1a H=14.7P=G.$1v("2Z",1i,{2H:"6J","z-1T":e7}).2V("k9");G.$(I).1H("5l",17(){H.43(1k.4d)});G.$(I).1H("7c",17(){H.2o()});G.$(I).1H("aZ",17(O){1a Q=20,N=G.$(O).6R(),M=H.2p(),L=G.$(1l).2p(),P=G.$(1l).bm();17 K(T,R,S){18(S<(T-R)/2)?S:((S>(T+R)/2)?(S-R):(T-R)/2)}H.2Y({1O:P.x+K(L.1x,M.1x+2*Q,N.x-P.x)+Q,1L:P.y+K(L.1B,M.1B+2*Q,N.y-P.y)+Q})});14.bo(J)};G.bH.27.bo=17(H){14.7P.3r&&14.7P.9z(14.7P.3r);14.7P.2k(1k.aC(H))}})(u);(17(G){if(!G){6r"7x 7t 7s";18}if(G.ka){18}1a F=G.$;G.bh=17(K,J,I,H){14.bf=1i;14.6d=G.$1v("aR",1i,{2H:"6J","z-1T":e7,6m:"6l",3w:0.8}).2V(H||"").43(I||1k.4d);14.dG(K);14.2M(J)};G.bh.27.2M=17(H){14.6d.2M();14.bf=14.5b.1e(14).3y(G.bu(H,kb))};G.bh.27.5b=17(H){3x(14.bf);14.bf=1i;if(14.6d&&!14.bQ){14.bQ=1v u.4z(14.6d,{3T:G.bu(H,9i),5L:17(){14.6d.5c();5v 14.6d;14.bQ=1i}.1e(14)}).2y({3w:[14.6d.2j("3w"),0]})}};G.bh.27.dG=17(H){14.6d.3r&&14.7P.9z(14.6d.3r);14.6d.2k(1k.aC(H))}})(u);(17(G){if(!G){6r"7x 7t 7s"}if(G.cL){18}1a J=G.$,F=1i,N={"5D":1,4c:2,5y:3,"17":4,2e:2F},H={"5D":17(Q,P,O){if("5D"!=G.1P(P)){if(O||"2e"!=G.1P(P)){18 1c}1b{if(!/^(1d|1c)$/.3C(P)){18 1c}1b{P=P.ds()}}}if(Q.4v("3I")&&!J(Q["3I"]).3l(P)){18 1c}F=P;18 1d},2e:17(Q,P,O){if("2e"!==G.1P(P)){18 1c}1b{if(Q.4v("3I")&&!J(Q["3I"]).3l(P)){18 1c}1b{F=""+P;18 1d}}},5y:17(R,Q,P){1a O=1c,T=/%$/,S=(G.1P(Q)=="2e"&&T.3C(Q));if(P&&!"5y"==bR Q){18 1c}Q=3p(Q);if(6C(Q)){18 1c}if(6C(R.7D)){R.7D=bM.kc}if(6C(R.bS)){R.bS=bM.kd}if(R.4v("3I")&&!J(R["3I"]).3l(Q)){18 1c}if(R.7D>Q||Q>R.bS){18 1c}F=S?(Q+"%"):Q;18 1d},4c:17(R,P,O){if("2e"===G.1P(P)){3f{P=1l.ke.k4(P)}3v(Q){18 1c}}if(G.1P(P)==="4c"){F=P;18 1d}1b{18 1c}},"17":17(Q,P,O){if(G.1P(P)==="17"){F=P;18 1d}1b{18 1c}}},I=17(T,S,P){1a R;R=T.4v("3S")?T.3S:[T];if("4c"!=G.1P(R)){18 1c}1s(1a Q=0,O=R.1r-1;Q<=O;Q++){if(H[R[Q].1I](R[Q],S,P)){18 1d}}18 1c},L=17(T){1a R,Q,S,O,P;if(T.4v("3S")){O=T.3S.1r;1s(R=0;R<O;R++){1s(Q=R+1;Q<O;Q++){if(N[T.3S[R]["1I"]]>N[T.3S[Q].1I]){P=T.3S[R];T.3S[R]=T.3S[Q];T.3S[Q]=P}}}}18 T},M=17(R){1a Q;Q=R.4v("3S")?R.3S:[R];if("4c"!=G.1P(Q)){18 1c}1s(1a P=Q.1r-1;P>=0;P--){if(!Q[P].1I||!N.4v(Q[P].1I)){18 1c}if(G.3e(Q[P]["3I"])){if("4c"!==G.1P(Q[P]["3I"])){18 1c}1s(1a O=Q[P]["3I"].1r-1;O>=0;O--){if(!H[Q[P].1I]({1I:Q[P].1I},Q[P]["3I"][O],1d)){18 1c}}}}if(R.4v("2E")&&!I(R,R["2E"],1d)){18 1c}18 1d},K=17(O){14.5z={};14.1t={};14.e5(O)};G.1U(K.27,{e5:17(Q){1a P,O,R;1s(P in Q){if(!Q.4v(P)){4V}O=(P+"").4i().6a();if(!14.5z.4v(O)){14.5z[O]=L(Q[P]);if(!M(14.5z[O])){6r"kf kh li kj \'"+P+"\' kk in "+Q}14.1t[O]=2U}}},2n:17(P,O){P=(P+"").4i().6a();if(G.1P(O)=="2e"){O=O.4i()}if(14.5z.4v(P)){F=O;if(I(14.5z[P],O)){14.1t[P]=F}F=1i}},dv:17(O){O=(O+"").4i().6a();if(14.5z.4v(O)){18 G.3e(14.1t[O])?14.1t[O]:14.5z[O]["2E"]}},7n:17(P){1s(1a O in P){14.2n(O,P[O])}},kl:17(){1a P=G.1U({},14.1t);1s(1a O in P){if(2U===P[O]&&2U!==14.5z[O]["2E"]){P[O]=14.5z[O]["2E"]}}18 P},9y:17(O){J(O.7R(";")).1A(J(17(P){P=P.7R(":");14.2n(P.6Y().4i(),P.9p(":"))}).1e(14))},aL:17(O){O=(O+"").4i().6a();18 14.5z.4v(O)},km:17(O){O=(O+"").4i().6a();18 14.aL(O)&&G.3e(14.1t[O])},2o:17(O){O=(O+"").4i().6a();if(14.aL(O)){5v 14.1t[O];5v 14.5z[O]}}});G.cL=K}(u));v.$8z=17(F){1a H=[],G;1s(G in F){if(!F.4v(G)||(G+"").kn(0,2)=="$J"){4V}H.2a(F[G])}18 v.$A(H)};v.8E={4m:2,9r:2,6x:2,8f:2,ko:2,aW:2,kp:2,5l:2,7c:2,aZ:2,kq:2,kg:2,8X:2,k2:2,jQ:2,k1:2,gc:2,jF:2,9H:2,jG:2,jH:2,2G:1,jI:1,jJ:2,5X:1,7h:1,fU:1,jK:1,7F:1,8O:1};v.jL={1k:1d,7q:1d,"2C":1d,7S:1d};v.6S={2O:17(J,I,G){if(v.1P(J)=="4c"){k(J).1A(14.2O.6p(14,I,G));18 14}if(!J||!I||v.1P(J)!="2e"||v.1P(I)!="17"){18 14}if(J=="8W"&&v.1f.5M){I.2m(14);18 14}G=1V(G||10);if(!I.$4n){I.$4n=1g.64(1g.7I()*v.66())}1a H=14.2s("8H",{});H[J]||(H[J]={});H[J][G]||(H[J][G]={});H[J]["5j"]||(H[J]["5j"]={});if(H[J][G][I.$4n]){18 14}if(H[J]["5j"][I.$4n]){14.g6(J,I)}1a F=14,K=17(L){18 I.2m(F,k(L))};if(v.8E[J]&&!H[J]["17"]){if(v.8E[J]==2){K=17(L){L=v.1U(L||1l.e,{$4Z:"1E"});18 I.2m(F,k(L))}}H[J]["17"]=17(L){F.1o(J,L)};14[v.b4](v.7o+J,H[J]["17"],1c)}H[J][G][I.$4n]=K;H[J]["5j"][I.$4n]=G;18 14},1o:17(G,I){3f{I=v.1U(I||{},{1I:G})}3v(H){}if(!G||v.1P(G)!="2e"){18 14}1a F=14.2s("8H",{});F[G]||(F[G]={});F[G]["5j"]||(F[G]["5j"]={});v.$8z(F[G]).1A(17(J){if(J!=F[G]["5j"]&&J!=F[G]["17"]){v.$8z(J).1A(17(K){K(14)},14)}},I);18 14},g6:17(I,H){if(!I||!H||v.1P(I)!="2e"||v.1P(H)!="17"){18 14}if(!H.$4n){H.$4n=1g.64(1g.7I()*v.66())}1a G=14.2s("8H",{});G[I]||(G[I]={});G[I]["5j"]||(G[I]["5j"]={});4M=G[I]["5j"][H.$4n];G[I][4M]||(G[I][4M]={});if(4M>=0&&G[I][4M][H.$4n]){5v G[I][4M][H.$4n];5v G[I]["5j"][H.$4n];if(v.$8z(G[I][4M]).1r==0){5v G[I][4M];if(v.8E[I]&&v.$8z(G[I]).1r==0){1a F=14;14[v.8F](v.7o+I,G[I]["17"],1c)}}}18 14},g3:17(H){if(!H||v.1P(H)!="2e"){18 14}1a G=14.2s("8H",{});if(v.8E[H]){1a F=14;14[v.8F](v.7o+H,G[H]["17"],1c)}G[H]={};18 14},jM:17(H,G){1a F=14.2s("8H",{});1s(t in F){if(G&&t!=G){4V}1s(4M in F[t]){if(4M=="5j"||4M=="17"){4V}1s(f in F[t][4M]){k(H).2O(t,F[t][4M][f],4M)}}}18 14},jN:17(I,H){if(1!==I.5a){18 14}1a G=14.2s("6t");if(!G){18 14}1s(1a F in G){if(H&&F!=H){4V}1s(1a J in G[F]){k(I).2O(F,G[F][J])}}18 14},2s:v.3K.2s,3u:v.3K.3u};(17(F){if(!F){6r"7x 7t 7s";18}F.1U=17(N,M){if(!(N 4x 1l.6h)){N=[N]}if(!(M 4x 1l.6h)){M=[M]}1s(1a K=0,H=N.1r;K<H;K++){if(!F.3e(N[K])){4V}1s(1a J=0,L=M.1r;J<L;J++){if(!F.3e(M[J])){4V}1s(1a I in(M[J]||{})){3f{N[K][I]=M[J][I]}3v(G){}}}}18 N[0]};F.cW=17(I,H){17 G(){}G.27=H.27;I.$4e=H.27;I.27=1v G();I.27.4P=I};F.1U([F.3K,1l.bY.3K],{fW:F.3K.2p,2p:17(G,I){1a H,J={1x:0,1B:0};if(I){J=14.fW()}1b{H=14.bX();J.1x=H.1x;J.1B=H.1B}if(G){J.1x+=(1V(14.2j("6j-1O")||0)+1V(14.2j("6j-6w")||0));J.1B+=(1V(14.2j("6j-1L")||0)+((14.2j("4S")!="73")?1V(14.2j("6j-5s")||0):0))}18 J}})})(u);v.3X||(v.3X={});v.3X.eF=(17(){1a F=["85","7X"],I;17 J(L,K){18 v.$1v("3R",{1I:"3R"},{4S:"8r-73"}).2V(I["2C"]).2V(I.1R).2V(I["2C"]+"-ga").2V(I["2C"]+"-ga-"+L).43(K)}17 G(K,L){L.81();14.1o(K)}1a H=17(L,K){v.$6O(14);14.1t={"2C":"",as:"",a1:"",2H:"eX",1R:"ms-3k",jO:"3R"};I=14.o=14.1t;v.1U(14.o,L);14.7X=J("7X",K);14.85=J("85",K);14.85.1H("4m",17(M){M.29()}).1H("2N 3F",G.1e(14,"1G"));14.7X.1H("4m",17(M){M.29()}).1H("2N 3F",G.1e(14,"2B"))};H.27={7H:17(K){j(K&&[K]||F).1A(17(L){14[L].2V(I.a1)},14)},4f:17(K){j(K&&[K]||F).1A(17(L){14[L].4L(I.a1)},14)},5b:17(K){j(K&&[K]||F).1A(17(L){14[L].2V(I.as)},14)},2M:17(K){j(K&&[K]||F).1A(17(L){14[L].4L(I.as)},14)},2o:17(K){j(K&&[K]||F).1A(17(L){14[L].5c()},14)},ey:17(K){j(F).1A(17(L){14[L].4L("1Y-"+I.1R);14[L].2V("1Y-"+K)},14);14.o.1R="1Y-"+K}};v.1U(H.27,v.6S);18 H})();v.3X||(v.3X={});v.3X.eh=(17(){1a G="jE",F=17(J,I,H){v.$6O(14);14.8q={};14.o=14.8q;v.1U(14.o,J);14.2b=v.$([]);14.4G=H;14.5Z={};14.bg=1c;14.1j=v.$1v("2Z",{"2C":"1Y-2b"});14.1j.43(I)};F.27={2a:17(H){1a I=j(17(K){1a J=14.2b.1r;14.2b.2a({1T:J,4f:1c,2S:K,1q:v.$1v("2Z",{"2C":"1Y-go 1Y-go-"+J})});if(!J){14.5Z=14.2b[J];14.8V(14.2b[J]);14.2b[J].4f=1d}14.2b[J].1q.1H("4m",j(17(L){L.29();if(14.2b[J].1T==14.5Z.1T){18}14.bg=14.4G();!14.bg&&14.1o("2b-4m",{1J:14.gn(14.2b[J]),eR:14.2b[J].2S})}).1e(14));14.2b[J].1q.43(14.1j)}).1e(14);14.9H();H.1A(j(17(J){I(J)}).1e(14))},dg:17(H,I){if(14.5Z.1T==H[0]){18}14.8V(14.gi(H,I))},2M:17(){14.1j.2V("2M")},7z:17(){if(14.5Z.1q){14.bC();14.8V(14.2b[0])}},2o:17(){14.2b.1A(17(H){H.1q.5c()});14.1j.5c()},bC:17(){14.5Z.4f=1c;14.5Z.1q.4L(G)},8V:17(H){14.bC();14.5Z=H;H.4f=1d;H.1q.2V(G)},gn:17(H){1a I=14.5Z.1T>H.1T?"2B":"1G";14.8V(H);18 I},gi:17(H,K){1a L,J=14.2b.1r-1,I=14.5Z;1s(1a L=J;L>=0;L--){if(14.2b[L].2S<=H[0]){I=14.2b[L];1N}}if(K){if(14.o.1h-1==H[H.1r-1]){I=14.2b[J]}}18 I},9H:17(){14.bg=1c;14.5Z={};14.2b.1A(17(H){H.1q.5c()});14.2b.1r=0}};v.1U(F.27,v.6S);18 F})();v.3X||(v.3X={});v.3X.9g=(17(){1a G=8A,F=17(H,I){14.8P="40";14.1q=v.$1v("2Z",{"2C":"1Y-3E"});if(v.1f.1C&&v.1f.1C<10){14.1q.2k(v.$1v("2Z",{"2C":"1Y-3E-bo"}).2k(v.c3.aC("jP...")))}1b{if(I){14.1q.2k(v.$1v("2Z",{"2C":"1Y-3E-ge"}).2k(v.$1v("2Z",{"2C":"1Y-34-3E"},{"z-1T":jR})))}1b{14.1q.2k(v.$1v("2Z",{"2C":"1Y-3E-ge"}).2k(v.$1v("2Z",{"2C":"1Y-3E-2R 1Y-3E-jS"})).2k(v.$1v("2Z",{"2C":"1Y-3E-2R 1Y-3E-jT"})).2k(v.$1v("2Z",{"2C":"1Y-3E-2R 1Y-3E-jU"})).2k(v.$1v("2Z",{"2C":"1Y-3E-2R 1Y-3E-jV"})).2k(v.$1v("2Z",{"2C":"1Y-3E-2R 1Y-3E-jW"})).2k(v.$1v("2Z",{"2C":"1Y-3E-2R 1Y-3E-jX"})).2k(v.$1v("2Z",{"2C":"1Y-3E-2R 1Y-3E-jY"})).2k(v.$1v("2Z",{"2C":"1Y-3E-2R 1Y-3E-jZ"})))}}14.1q.43(H);14.1q.5b()};F.27={2M:17(){if(14.8P==="2M"){18}if(14.1q){14.8P="2M";14.1q.3Z(1);14.1q.2M()}},5b:17(H){if(14.8P==="5b"){18}if(14.1q){14.8P="5b";14.1q.3Z(0);14.1q.5b()}},2o:17(){14.1q&&14.1q.5c()}};18 F})();v.3X||(v.3X={});v.3X.k0=(17(){1a F=17(){1a M=[],H=8A,J=0,K=0,N=1c,L=14;v.$6O(14);17 I(){1a Q;if(M.1r==0){L.1o("5o");18}if(!N&&M.1r>0){N=1d;Q=M.6Y();1a P=j([]);P.2a(Q.34);if(Q.34.5k&&Q.34.5k.1r>0){j(Q.34.5k).1A(j(17(R){P.2a(R)}).1e(14))}P.1A(17(S,R){K+=1;if(Q.6X){if(R){Q.6X=1c}}O(S,!!R,Q.6X,Q.4G,17(){N=1c;I()},Q.8w)})}}17 G(Q,S,P,R){if(Q.1K){Q.1K.5b(1d)}J++;if(J==K){K=J=0;P();R()}}17 O(V,U,R,S,Q,P){1a W,X,T=j(V.2l);if(V.2G=="4O"){G(V,U,S,Q);18}if(R){if(v.1f.1C&&v.1f.1C<10){X=j(T).2p();W={3w:[0,1],1L:[X.1B/2,0],1O:[X.1x/2,0],1x:[0,X.1x],1B:[0,X.1B]};14.fj=1v v.4z(T,{3T:H,5L:j(17(Z,Y){T.2Y({6I:"",2H:"",1L:"",1O:"",1x:"",1B:""});U&&(V.2G="4O");G(V,U,Z,Y)}).1e(14,S,Q),8C:j(17(){T.2Y({2H:"fN",6I:"6l"})}).1e(14)});14.fj.2y(W)}1b{T.1M(g,"7w(0.2, 0.2)");T.1M("2L","40");T.3Z(0);T.67;T.3j.67;T.1H("6N",j(17(Y){if(Y.1Z==T){14.1W(Y.1I);14.1M(g,"");14.1M("2L","")}}).1e(T));if(!U&&P){P(V)}T.1M("2L",g+" "+H+"ms 5S-5J(.5,.5,.69,1.9), 3w "+H+"ms 9a");T.67;T.3j.67;T.1M(g,"7w(1.0, 1.0)");T.3Z(1);U&&(V.2G="4O");G(V,U,S,Q)}}1b{T.3Z(1);if(U){V.2G="4O"}1b{P(V)}G(V,U,S,Q)}}14.2a=17(R,Q,P,S){M.2a({34:R,6X:Q,4G:P,8w:S});I()}};v.1U(F.27,v.6S);18 F})();(17(F){F.cq=17(M,H){1a G=0,L=14,K,I;17 P(Q){18 17(R){(H[Q]||F.$F).2m(L,R,R.fe);G--;O()}}17 O(){1a Q;if(!M.1r){}1b{if(G<(H.6T||3)){K=M.6Y();Q=J(K.1q);if(Q){I=1v F.fh(Q,{6c:P("6c"),5u:P("5u"),8N:P("8N"),7V:P("7V")});I.fe=K}1b{(H.6c||F.$F).2m(L,{1z:j(K.1q).2p(),2g:Q},K);G--;O()}G++}}}17 N(Q){1a R,S;R=(Q&&Q 4x kr);if(R){S=Q.3Q("2c-4j")||1i;if(S){Q.3i("4j",S)}}18(R&&Q.3Q("4j"))?Q:1i}17 J(Q){18 F.1P(K)=="2e"?Q:(F.1P(Q)=="7S"?N(Q.2g):((Q.2x=="A"||Q.2x.36()=="4w")?N(j(Q).7N("6i")[0]||Q.3r):(Q.2x=="6i"?N(Q):1i)))}14.2a=17(Q,R){M[R?"jD":"2a"](Q);H.c8||O();18 14};14.8O=17(){I.fd();ks--};14.2G=O;H.c8||M.1r&&O()}})(u);1a m,j=v.$,D=j,k=j;1a o;1a p=17(){18"kW$kX kY$"+"f1.0.38".5n("v","")+" kZ$"+"c".8e()+((1l.c6$c4&&"2e"==v.1P(1l.c6$c4))?" l0$"+1l.c6$c4.36():"")};17 c(){v.da(".fv-ft-fs-fr",{4S:"73 !4s","7W-1B":"0 !4s","7W-1x":"0 !4s","6e-1B":"40 !4s","6e-1x":"40 !4s",1x:"f2 !4s",1B:"f2 !4s",2H:"6J !4s",1L:"-cI !4s",1O:"0 !4s",6I:"6l !4s","-4W-8g":"40 !4s",8g:"40 !4s","-4W-2L":"40 !4s",2L:"40 !4s"},"l1-9H-b7")}v.5e={};m={1x:{3S:[{1I:"5y",7D:1},{1I:"2e","3I":["21"]}],"2E":"21"},1B:{3S:[{1I:"5y",7D:1},{1I:"2e","3I":["21"]}],"2E":"21"},1h:{3S:[{1I:"5y",7D:1},{1I:"4c"},{1I:"2e","3I":["21","8x"]}],"2E":"21"},4E:{3S:[{1I:"5D"},{1I:"2e","3I":["21"]}],"2E":"21"},2f:{3S:[{1I:"5D"},{1I:"2e","3I":["eX","df","az"]}],"2E":"df"},4q:{1I:"5y","2E":0},9e:{1I:"5y","2E":db},1n:{3S:[{1I:"2e","3I":["3B","6n","az"]},{1I:"5D","3I":[1c]}],"2E":"3B"},3U:{1I:"5D","2E":1c},1R:{1I:"2e","3I":["3k","3A"],"2E":"3k"},3H:{3S:[{1I:"5y",7D:0},{1I:"2e","3I":["21"]}],"2E":"21"},76:{1I:"5D","2E":1d},2u:{1I:"2e","3I":["2q","2r","5K","6b-6k"],"2E":"2q"},cF:{1I:"5D","2E":1c},8d:{1I:"2e","2E":"5S-5J(.8, 0, .5, 1)"},6H:{1I:"5D","2E":1c},bq:{1I:"5D","2E":1d},cO:{1I:"17","2E":v.$F},cN:{1I:"17","2E":v.$F},cM:{1I:"17","2E":v.$F},g7:{1I:"17","2E":v.$F},aM:{1I:"17","2E":v.$F},aO:{1I:"17","2E":v.$F}};1k.6u("4w");1k.6u("33");1a n=17(F){18{1x:((1V(F.2j("6j-1O"))||0)+(1V(F.2j("6j-6w"))||0)),1B:((1V(F.2j("6j-1L"))||0)+(1V(F.2j("6j-5s"))||0))}},i=17(F){18{1x:((1V(F.2j("5B-1O"))||0)+(1V(F.2j("5B-6w"))||0)),1B:((1V(F.2j("5B-1L"))||0)+(1V(F.2j("5B-5s"))||0))}},r=17(F){18{1x:((1V(F.2j("5Y-1O-1x"))||0)+(1V(F.2j("5Y-6w-1x"))||0)),1B:((1V(F.2j("5Y-1L-1x"))||0)+(1V(F.2j("5Y-5s-1x"))||0))}},E=17(F){18{1x:j(F).2j("1x"),1B:j(F).2j("1B")}},w=v.1f.5p,g=v.av("8g").aq(),b=17(G,H){1a F=1c,I=0;v.$6O(14);14.8q={4o:1d,6z:"5S-5J(.8, 0, .5, 1)",1p:"2q",2v:1c,1K:1c,74:1c,1R:"3k",3T:9i,1n:1d,3U:1d,3H:"21",76:1d,6H:1c};14.o=14.8q;v.1U(14.o,H);14.1j=j(G).1M("l2-l3","l4");14.1n={2X:1c,2W:1c};14.b9();14.aF=j(17(L){1a K={},J=1d;if(37===L.bO||39===L.bO){K.1J=L.bO==39?"1G":"2B";if(!14.o.1n){if("1G"===K.1J){if(14.1n.2W){J=1c}}1b{if(14.1n.2X){J=1c}}}J&&14.1o("dD",K)}}).1e(14);14.7r="2q";14.1h=j([]);14.4l=j([]);14.7b=j([]);14.5G=j([]);14.6V=j([]);14.1m=0;14.3q=0;14.2A=14.o.3H;14.1D=0;14.l=1i;14.5w=1i;14.2i=1i;14.2I=0;14.7L=0;14.24=0;14.1J="1G";14.4G=v.$F;14.3D=0;14.72=1c;14.2T=1i;14.9b=0;14.80=1i;14.dj=14.1m;14.62=1c;14.by=1c;14.ci=1c;14.5E=1c;14.ay=1i;14.41={};14.at=0;14.8K={1J:"1G",79:1c};14.8T=1i;14.6T=1v v.cq([],{6T:1,5u:j(17(K,L){1a J=14.1h[L.1T];J.2G="7F";if(J.1K){J.1K.2o();J.1K=1i}J.1q.2V("1Y-fO");14.9B(j(17(N,M){if(N.1T==J.1T){N.2k=1d;if(N.1K){N.1K.2o();N.1K=1i}N.1q.2G="7F";N.1q.2V("1Y-fO")}}).1e(14));I++;if(14.o.3U){if(14.9O()){if(14.o.4o||!14.41.5d){14.1o("9s");14.1o("bG")}if(!14.2J){14.7E()}!14.41.5d&&14.1o("5o")}}1b{if(I==14.l&&!14.o.3U){14.5E=1d;!14.41.5d&&14.1o("5o")}}14.bw()}).1e(14),6c:(17(M,N){1a L=[],K=14.1h[N.1T],J;if(!K){18}K.1q.2k(K.2l);3f{14.aU(K)}3v(M){}if(!14.ci){3f{14.9u(K)}3v(M){14.ci=1d}}14.bt(K,j(17(){1a O=1d;if(j(["2q","2r"]).3l(14.7r)){if(!14.41.5d&&!14.o.3U){O=N.1T<14.3D}}14.bB(K,O,14.8w);K.2G="4O";I++;if(14.o.3U){14.cX(I)}1b{if(I==14.l){14.5E=1d;!14.41.5d&&14.1o("5o")}}14.bw()}).1e(14))}).1e(14)})};b.27={4P:b,8w:v.$F,9u:v.$F,aU:v.$F,cX:17(F){if(14.9O()){if(14.o.4o||!14.41.5d){14.1o("9s");14.1o("bG")}if(!14.41.5d){14.1o("5o")}}},bB:17(J,M,L){1a F,I,H,K=9i,G=J.2l;if(M){if(v.1f.1C&&v.1f.1C<10){F=j(G).2p();I={3w:[0,1],1L:[F.1B/2,0],1O:[F.1x/2,0],1x:[0,F.1x],1B:[0,F.1B]};H=1v v.4z(G,{3T:K,5L:j(17(O,N){G.2Y({6I:"",2H:"",1L:"",1O:"",1x:"",1B:""});if(J.1K){J.1K.2o();J.1K=1i}}).1e(14),8C:j(17(){G.2Y({2H:"fN",6I:"6l"})}).1e(14)});H.2y(I)}1b{G.1M("2L","40");G.3Z(0);G.67;G.3j.67;G.1H("6N",j(17(N){if(N.1Z==G){14.1W(N.1I);14.1M(g,"");14.1M("2L","");if(J.1K){J.1K.2o();J.1K=1i}}}).1e(G));G.1M("2L",g+" "+K+"ms 5S-5J(.5,.5,.69,1.9), 3w "+K+"ms 9a");G.67;G.3j.67;G.3Z(1);L&&L(J)}}1b{G.3Z(1);if(J.1K){J.1K.2o();J.1K=1i}}J.5k.1r>0&&j(J.5k).1A(j(17(N){if(N){j(N.2l).3Z(1);N.2G="4O";if(N.1K){N.1K.2o();N.1K=1i}}}).1e(14))},bw:17(){1a F=0;14.1h.1A(j(17(G){if(G.2G=="4O"||G.2G=="7F"){F++}if(14.l==F){14.5E=1d;14.1o("9s")}}).1e(14))},9O:17(){1a F=0,G=0;if(14.5E){18 1d}1s(;F<14.3D;F++){if(14.1h[14.3G(14.1m+F)].2G=="4O"||14.1h[14.3G(14.1m+F)].2G=="7F"){G+=1}}18 G==14.3D},7d:17(){18 14.1j.3j.2p()[14.1y.1z]},b9:17(){1a F={3k:{1z:"1x",1X:"1O",fK:"1B"},3A:{1z:"1B",1X:"1L",fK:"1x"}};14.1y=F[14.o.1R];if(14.o.3H==0){14.o.3H="21"}if(!14.o.1n||"6n"===14.o.1n){14.1n.2X=1d}if(v.1f.1C&&v.1f.1C<10){14.1j.1M(14.1y.1X,0)}1b{14.1j.1M(g,"4J(0, 0, 0)")}},8Z:17(){14.1j.67},aQ:17(){if(14.5E||14.by){18}14.by=1d;14.1o("9w");14.1h.1A(j(17(F){if(F.2G=="7u"){if(F.1K){F.1K.2o();F.1K=1i}F.5k.1r>0&&j(F.5k).1A(17(G){if(G.1K){G.1K.2o();G.1K=1i}});14.6T.2a({1q:F.2l,1T:F.1T})}}).1e(14));14.5E=1d},8h:17(G){1a H,J=14.1m,F=j([]),I,K;if(14.5E){18}if(14.o.3U){G&&(J=(G=="1G")?14.3G(J+14.3D):14.3G(J-14.3D));K=j(17(L){if(L.2G=="7u"){if(14.o.4o){!G&&14.1o("9w")}1b{L.1K&&L.1K.2M()}L.2G="2G";14.6T.2a({1q:L.2l,1T:L.1T})}}).1e(14);1s(H=0;H<14.3D;H++){I=14.1h[14.3G(J+H)];K(I);if(!G){K(14.1h[14.3G(I.1T+14.3D)]);K(14.1h[14.3G(I.1T-14.3D)])}}}},dk:17(K){1a L,G,I,H,F=0,J=14.ay.1r;if(K=="2B"){F=J-1;J=-1}if(!14.5E){4U(F!=J){H=14.ay[F];L=H.5t();G=H.3Q("2c-34");if(L[14.1y.1X]+14.1h[0].1z[14.1y.1z]>14.at[14.1y.1X]&&L[14.1y.1X]<14.at[14.1y.1X]+14.24){I=14.1h[G];if(I.2G=="7u"){I.2G="2G";I.1K&&I.1K.2M();j(I.5k).1A(j(17(M){M.1K&&M.1K.2M()}).1e(14));14.6T.2a({1q:I.2l,1T:I.1T})}}K=="1G"?F++:F--}}},8t:17(J){1a G,F,I,H;if(14.41.7Z){18}14.41.7Z=1d;F=14.l=14.1h.1r;14.24=14.7d();I=j(14.1j.3j).5t();1s(G=0;G<14.l;G++){H=14.1h[G];H.1z=H.1q.2p(1d);14.2I+=H.1z[14.1y.1z]}14.3Y()},a7:17(G){14.41.5d=1d;14.ax();if(!v.1f.1C||v.1f.1C&&v.1f.1C>9){if(14.o.76){14.7m()}}14.83();if((!v.1f.1C||v.1f.1C&&v.1f.1C>9)&&"2q"===14.o.1p&&14.o.4E){14.7f()}if(j(["2q","2r"]).3l(14.7r)){1s(1a F=0;F<14.1h.1r;F++){if(F>=14.3D){14.1h[F].1K&&14.1h[F].1K.2M()}}}14.1m=0;14.3q=14.4l.1r;j(1l).1H("5X",14.3Y.1e(14));if(14.o.6H){j(1k).1H("8X",14.aF)}14.3Y();G&&G()},83:17(){14.1h.1A(j(17(F){F.2l.eW=j(17(){14.1o("2M-14",{1T:F.1T})}).1e(14);F.2l.1H("4m",j(17(G){if(14.2J){G.29()}}).1e(14))}).1e(14))},ax:17(H){1a F,G=0;if(14.72){18}if(14.o.2v){14.2A=14.3D;18}1s(F=0;F<14.l;F++){G+=14.1h[F].1z[14.1y.1z];if(G>=14.24){if(14.2A=="21"||14.2A>=F){if(14.o.1p=="2r"&&G-14.1h[F].1z[14.1y.1z]+5<14.24||G==14.24){F+=1}14.2A=F;if(14.o.3H!="21"&&14.o.3H<14.2A){14.2A=14.o.3H}}1N}}!14.2A&&(14.2A=1)},cD:17(G){1a F=G.6y();4w=1k.6u("4w"),33=1k.6u("33");v.$A(G.3r.2h).1A(j(17(H){if(H.2x.36()=="33"){v.$A(H.2h).1A(j(17(I){j(33).2k(I.6y(1d))}).1e(14));v.$A(H.fH).1A(j(17(I){4w.3i(I,I.9K)}).1e(14));4w.2k(33)}1b{j(4w).2k(H.6y(1d))}}).1e(14));v.$A(G.3r.fH).1A(j(17(H){4w.3i(H,H.9K)}).1e(14));F.2k(4w);18 F},9B:17(F){if(14.4l.1r>0){j([14.4l,14.7b]).1A(j(17(G){G.1A(j(17(I,H){F(I,H)}).1e(14))}).1e(14))}},bt:17(G,H){if(14.4l.1r>0){1a F=j(17(){1a I;if(v.1f.1C&&v.1f.1C<9&&G.1q.3r.2x.36()=="4w"){I=14.cD(G.2l.6y(1d))}1b{I=G.2l.6y(1d)}I.2h&&v.$A(I.2h).1A(j(17(J){if(j(J).8Y&&j(J).8Y("5f-1K-kU")){J.5c()}}).1e(14));18 I}).1e(14);14.9B(j(17(J,I){if(J.1T==G.1T&&!J.2k){J.2l=F();14.1h[G.1T].5k.2a(J);J.2k=1d;J.1q.2k(J.2l)}}).1e(14))}H&&H()},cE:17(){1a F,G=0,J=0,L=0,I={1O:0,1L:0},K,H;if(14.72){18}1s(F=0;F<14.l;F++){G+=14.1h[F].1z[14.1y.1z];L++;if(14.24<=G){1N}}if(14.l>1&&(L>14.3D||14.4l.1r==0)){J=14.4l.1r;1s(F=J;F<L;F++){K={1q:14.1h[14.l-1-F].1q.6y(),2G:"7u",2k:1c};j(K.1q).3i("2c-34",14.l-1-F);K.1T=14.1h[14.l-1-F].1T;if(14.o.3U&&14.o.1K){K.1K=1v v.3X.9g(K.1q);K.1K.2M()}14.4l.2a(K);H={1q:14.1h[F].1q.6y(),2G:"7u",2k:1c};j(H.1q).3i("2c-34",F);H.1T=14.1h[F].1T;if(14.o.3U&&14.o.1K){H.1K=1v v.3X.9g(H.1q);H.1K.2M()}14.7b.2a(H);j([H.1q,K.1q]).1A(j(17(M){M.1H("4m",j(17(N){if(14.2J){N.29()}}).1e(14))}).1e(14));14.1j.2k(H.1q);14.1j.2k(K.1q,"1L");j([14.1h[14.l-1-F],14.1h[F]]).1A(j(17(M){if(M.2G=="4O"){14.bt(M,j(17(){1a N=1d;if(j(["2q","2r"]).3l(14.7r)){if(!14.41.5d&&!14.o.3U){N=M.1T<14.3D}}14.bB(M,N);M.5k.1r>0&&j(M.5k).1A(17(O){if(O.1K){O.1K.2o();O.1K=1i}})}).1e(14))}}).1e(14))}if(J){14.3D+=L-J}1b{14.3D=L}}1b{14.3D=L}14.7L=14.1D=0;G=0;1s(F=0;F<14.4l.1r;F++){G+=14.1h[14.l-1-F].1z[14.1y.1z]}14.7L+=G;14.1D-=G;I[14.1y.1X]=14.1D;if(v.1f.1C&&v.1f.1C<10){14.1j.1M(14.1y.1X,I[14.1y.1X])}1b{14.9P()}},2a:17(F){14.l=14.1h.1r;F.1T=14.l;F.2G="7u";F.5k=[];if("8B"===v.1f.7G){F.2l.1H("4a",17(G){G.bE()})}if(14.o.1K&&14.o.3U){F.1K=1v v.3X.9g(F.1q,1d);if(!14.o.4o){F.1K.2M()}}F.1q.3i("2c-34",F.1T);F.1q.1H("5l 7c",j(17(H){1a G=H.a0();4U(G&&G!==F.1q){G=G.3j}if(G==F.1q){18}if("5l"===H.1I){14.1o("3s-34-dJ",{ar:F.1T})}1b{14.1o("3s-34-an",{ar:F.1T})}}).1e(14));14.1h.2a(F)},3G:17(F){F%=14.l;F<0&&(F=F+14.l);18 F},2S:17(G,H){1a F;if(G=="1G"||G=="2B"){14.1J=G}if(14.2J||14.62){18}14.2J=1d;if(v.1P(G)=="7S"){14.1J=G.1J;G.79=1c;G.8m=1c}1b{if(/1G|2B|^\\+|^\\-/.3C(G)){if(/^\\+|^\\-/.3C(G)){F=/^\\+/.3C(G)?"1G":"2B";G={6q:1g.1F(1V(G)),1J:F};G.6q>14.l&&(G.6q=14.l);G.1Z=14.3G(G.1J=="1G"?(14.1m+G.6q):(14.1m-G.6q))}1b{G={1J:G};G.1Z=14.3G(G.1J=="1G"?(14.1m+14.2A):(14.1m-14.2A))}G.79=1c;G.8m=1d}1b{if(v.1P(1V(G))=="5y"){G={1Z:14.3G(G),79:1d,8m:1c}}}}G.4G=H;if(!14.o.1n){if(14.1n.2X||14.1n.2W){if(14.1n.2X){if("2B"===G.1J){14.2J=1c;H(1i,1d);18}}1b{if("1G"===G.1J){14.2J=1c;H(1i,1d);18}}}}14["l5"+14.7r](G)},5V:17(I,G){1a H={1O:0,1L:0},J=1c,F=G||14.1D;if(I=="1G"){if(F+14.7L-14.2i+14.2I<0){14.1D=F+14.2I;H[14.1y.1X]=14.1D;J=1d}}1b{if(F+14.2i>0){14.1D=F-14.2I;H[14.1y.1X]=14.1D;J=1d}}if(J){if(v.1f.1C&&v.1f.1C<10){14.1j.1M(14.1y.1X,H[14.1y.1X]+"2K")}1b{14.1j.1M(g,"4J("+H.1O+"2K, "+H.1L+"2K, 0)");14.1j.1M("2L",g+" a2 "+14.o.6z);14.8Z();if(14.o.1p=="2r"){14.8I=14.3q=14.6K();if(I=="1G"){14.3q+=14.2A}1b{14.3q-=14.2A}}}}18 J},6U:17(I,H){1a G,F=1d;if(!H){if(14.o.3H=="21"){14.2A="21";14.ax(I=="2B")}F=1c;H=14.2A}1b{14.o.4o=1c}1s(G=H;G>0;G--){14.1m=14.3G((I=="1G")?(14.1m+1):(14.1m-1));14.3q=(I=="1G")?(14.3q+1):(14.3q-1);14.2i+=14.1h[(I=="1G")?14.3G(14.1m-1):14.1m].1z[14.1y.1z]}if("3B"===14.o.1n){if(!14.o.2v){14.1o("3s-2y-1p",{3z:14.4A()})}}1b{if("2q"===14.o.1p&&14.1n.2W&&I=="2B"){if(F){14.1m-=(14.7K-1)}1b{14.1m-=(H-1)}if(14.1m<0){14.1m=0}}14.1o("4f");if(14.1n.2W&&I=="1G"){14.1n.2W=1c;14.1n.2X=1d;14.1D=0;14.2i=0;14.1m=0;14.3q=0;14.1o("5A-3m");14.1o("3s-2y-1p",{3z:14.4A()})}1b{if(14.1n.2X&&I=="2B"){14.1n.2X=1c;14.1n.2W=1d;14.2i=0;14.1m=14.l-1;if(14.o.1p=="2q"){14.3q=14.l-14.7K;14.1D=(14.2I-14.24)*(-1)}1b{14.3q=14.l-14.l%14.7K;14.1D=(1g.8U(14.l/14.2A)-1)*14.24*(-1)}14.1o("1m-3m");14.1o("3s-2y-1p",{3z:14.4A(1d)})}1b{14.1n.2W=1c;14.1n.2X=1c;if(I=="1G"){if(14.1D-14.2i<=14.24-14.2I||14.1D-14.2i+1<=14.24-14.2I){14.1o("1m-3m");if(14.o.1p=="2q"||14.o.1p=="2r"&&"3B"===14.o.1n){14.2i=14.1D-(14.24-14.2I)}1b{14.2i=14.24}14.1n.2W=1d;14.1m=14.l-1;14.1o("3s-2y-1p",{3z:14.4A(1d)})}1b{14.1o("3s-2y-1p",{3z:14.4A()})}}1b{if(14.1D+14.2i>=0||14.1D+14.2i===-1){14.1o("5A-3m");14.2i=1g.1F(14.1D);14.1n.2X=1d;14.3q=0;14.1m=0;14.1o("3s-2y-1p",{3z:14.4A()})}1b{14.1o("3s-2y-1p",{3z:14.4A()})}}}}}},fA:17(J){1a F,H,G=0,I;if(!J.1J){G=1g.64(14.3D/2);if(14.3D%2==0){G-=1}G<0&&(G=0)}if("3B"===14.o.1n){J.1Z=14.3G(J.1Z-G)}if(14.1m!=J.1Z){14.o.4o=1c;I=j(17(N){1a L=14.1m,M=0,K;do{M++;!N?L++:L--;K=14.3G(L)}4U(K!=J.1Z);18 M}).1e(14);if(!J.1J){if("3B"===14.o.1n){J.1J=I()<=I(1d)?"1G":"2B"}1b{J.1J=J.1Z>14.1m?"1G":"2B"}}14.1o("4f");if("3B"===14.o.1n){4U(14.1m!=J.1Z){14.1m=14.3G(J.1J=="1G"?++14.1m:--14.1m);14.3q=J.1J=="1G"?++14.3q:--14.3q;14.2i+=14.1h[14.1m].1z[14.1y.1z]}14.1o("3s-2y-1p",{3z:14.4A()})}1b{14.1n.2W=1c;14.1n.2X=1c;14.1m=J.1Z;H=0;1s(F=0;F<J.1Z-G;F++){H+=14.1h[F].1z[14.1y.1z]}14.3q=J.1Z;14.1D=0-14.7L-H;if(14.o.1p=="2q"&&14.1D<=0-(14.2I-14.24)||14.1D<=0-((14.2I+(14.l%14.2A)*14.1h[0].1z[14.1y.1z])-14.24)){if(14.o.1p=="2q"){14.1D=0-(14.2I-14.24)}14.1n.2W=1d;14.1o("1m-3m");14.1m=14.l-1;14.1o("3s-2y-1p",{3z:14.4A(1d)})}1b{14.1o("3s-2y-1p",{3z:14.4A()})}if(14.1D>=0){14.1D=0;14.1o("5A-3m");14.1n.2X=1d;14.1m=0;14.1o("3s-2y-1p",{3z:14.4A()})}}}1b{14.2J=1c;14.62=1c;14.1o("dd")}},fc:17(I){1a F=14.1D,G=1c,H;14.8I=14.3q;14.2i=0;if((!14.o.1n||"6n"===14.o.1n)&&14.o.1p=="2r"){if(14.1n.2W&&I.1J=="1G"||14.1n.2X&&I.1J=="2B"){G=1d}}if(I.8m){14.6U(I.1J,I.6q)}1b{14.fA(I);if(!14.o.1n){if(F===14.1D){14.2J=1c;14.62=1c;14.1o("dd")}}}if(G){I.1J=I.1J=="1G"?"2B":"1G"}if(0!==14.9b){H=14.1h[14.dj].1z[14.1y.1z]-14.9b;if(I.1J=="1G"){14.2i-=H}1b{14.2i+=H}14.9b=0}"3B"===14.o.1n&&14.5V(I.1J);if(I.1J=="1G"){14.1D-=14.2i}1b{14.1D+=14.2i}14.8K.1J=I.1J;14.8K.79=I.79;if(F!=14.1D){14.4G=I.4G;if(14.o.4o&&!14.5E&&!14.9O()){14.1o("9w");14.8h();14.2O("bG",j(17(J){14.2J&&14.6L(1i,J.1J,J.79)}).1e(14,14.8K))}1b{if(!14.5E){14.8h()}14.6L(1i,I.1J,I.79)}}1b{14.2J=1c;14.62=1c;14.1o("dt")}},6L:17(G,F,I){1a H={1O:0,1L:0};14.2J=1d;if(v.1f.1C&&v.1f.1C<10){H={};H[14.1y.1X]=[1V(14.1j.2j(14.1y.1X)),14.1D];14.fx=1v v.4z(14.1j,{2L:14.o.6z,3T:G||14.o.3T,5L:14.75.1e(14),8C:j(17(){14.fL=1c}).1e(14)}).2y(H)}1b{H[14.1y.1X]=14.1D;if(14.o.1p=="2r"&&!I){14.fw(F,H)}1b{14.1j.1W("6N");14.1j.1H("6N",j(17(J){if(J.1Z==14.1j){14.1j.1W(J.1I);if(I){14.3q=14.6K();14.dm()}14.75()}}).1e(14));14.1j.1M(g,"4J("+H.1O+"2K, "+H.1L+"2K, 0)");14.1j.1M("2L",g+" "+(G||14.o.3T)+"ms "+14.o.6z)}}},fw:17(L,K){1a J,G,I,H=14.1j.2h,F=H.1r,M=j(17(N){N%=14.5w;N<0&&(N=N+14.5w);18 N}).1e(14);14.5G.1r=0;14.6V.1r=0;1s(J=0;J<14.2A;J++){if("3B"===14.o.1n){G=M(14.8I+J)}1b{G=14.8I+J<F?14.8I+J:1i}G!=1i&&14.5G.2a(H[G]);if("3B"===14.o.1n){I=M(14.3q+J)}1b{I=14.3q+J<F?14.3q+J:1i}I!=1i&&14.6V.2a(H[I])}if(L=="2B"){14.5G.4C();14.6V.4C()}14.1j.3i("2c-"+L,"");14.5G.1A(j(17(O,N){O.1H(w+"93 9c",j(17(P,Q,R){if(P==14.5G[Q]){P.1W(w+"93 9c").3i("2c-dh","");if(Q==14.5G.1r-1){14.5G.1A(j(17(T,S){T.3P("2c-2r-92");T.3P("2c-91")}).1e(14));14.6V.1A(j(17(T,S){if(S==14.6V.1r-1){T.1H(w+"93 9c",j(17(U){if(U.1Z==T){T.1W(w+"93 9c");14.6V.1A(j(17(V,W){V.3P("2c-2r-92");V.3P("2c-91")}).1e(14));14.5G.1A(j(17(V,W){V.3P("2c-dh")}).1e(14));14.1j.3P("2c-"+L);14.8Z();14.75()}}).1e(14))}T.3i("2c-d8","");T.1H(w+"97 96",j(17(U){if(U.1Z==14){14.1W(w+"97 96");T.3P("2c-d8")}}).1e(T));T.3i("2c-91","l7");T.3i("2c-2r-92",(S+1))}).1e(14));14.1j.1M(g,"4J("+K.1O+"2K, "+K.1L+"2K, 0)")}}}).1e(14,O,N))}).1e(14));14.5G.1A(j(17(O,N){O.3i("2c-dp","");O.1H(w+"97 96",j(17(P){if(P.1Z==14){O.1W(w+"97 96");14.3P("2c-dp")}}).1e(O));O.3i("2c-91","l8");O.3i("2c-2r-92",(N+1))}).1e(14))},4A:17(I){1a J=0,H=14.2A,F=[],G;if(I){if(14.o.1p=="2q"){J=14.l-14.2A}1b{J=14.l%14.2A?14.l-14.l%14.2A:14.l-14.2A}H=14.l}1s(;J<H;J++){if(!I){G=14.1m+J}1b{G=J}F.2a(14.3G(G))}18 F},75:17(){14.2J=1c;14.9f=1c;14.4G&&14.4G(14.4A(14.1n.2W))},dm:17(){14.1j.1M("2L",g+" a2")},9Z:17(K){1a J={x:0,y:0},H=K.2j(g)||"",I=/3d/.3C(H)?(/l9\\(([^\\)]+)\\)/):(/la\\(([^\\)]+)\\)/),G=/3d/.3C(H)?12:4,F=/3d/.3C(H)?13:5;(K.2j(g)||"").5n(I,17(N,M){1a L=M.7R(",");J.x+=1V(L[G],10);J.y+=1V(L[F])});18 J},6K:17(){1a I;1a H;1a F;1a G=bM.lb;1a J=14.1j.3j.5t()[14.1y.1X];1s(I=0;I<14.5w;I++){H=14.1j.2h[I].5t()[14.1y.1X];if(G>1g.1F(J-H)){G=1g.1F(J-H);F=I}1b{1N}}18 F},7E:17(){if(14.4l.1r==0){18}1a G,F,H=j(17(J,K){1a L,I;if(14.1h[K].1q!=J&&14.1h[K].2G=="4O"){1s(I=0;I<14.5w;I++){if(14.1h[K].1q==14.1j.2h[I]){L=I;1N}}if(L<F){14.1j.7C(J,14.1j.2h[L]);if(F+1<=14.5w-1){14.1j.7C(14.1h[K].1q,14.1j.2h[F+1])}1b{14.1j.8S(14.1h[K].1q)}}1b{14.1j.7C(14.1h[K].1q,J);if(L+1<=14.5w-1){14.1j.7C(J,14.1j.2h[L+1])}1b{14.1j.8S(J)}}}}).1e(14);F=14.6K();1s(G=0;G<14.3D;G++){H(14.1j.2h[F],14.3G(14.1m+G));F++}},a6:17(N){1a L,J,K,Q=0,G=0,P,M=14.1j.3j.5t()[14.1y.1X]+1,I=14.1j.5t()[14.1y.1X]-M,O=1g.1F(1g.1F(I)-1g.1F(14.1D)),H,F=j(17(R){18 1V(14.1j.2h[R].3Q("2c-34"))}).1e(14);(O>0&&O<1)&&(O=0);if(N=="1G"){M+=O}1b{M-=O}1s(L=0;L<14.5w;L++){K=14.1j.2h[L].5t()[14.1y.1X];if(K==M){14.1m=F(L);18 0}P=1V(14.1j.2h[L].2p()[14.1y.1z]);if(K<M&&K+P>M){H=L;if(N=="1G"){H=L+1>14.5w-1?14.5w-1:L+1;L++}1s(J=0;J<L;J++){G+=14.1h[F(J)].1z[14.1y.1z]}Q=1g.1F(1g.1F(14.1D)-G);14.1m=F(H);1N}}18 Q},7m:17(){1a af,L,ad,V,ae,K,G=(14.1y.1X=="1O")?"x":"y",M={x:0,y:0},T=14.o.1p=="2q",W,Y=1d,P={x:0,y:0},I=1c,X=1c,N=1i,R=0,Z=1i,S=1c,H=j(17(ai){1a ah,ag=0;if(ai>14.24){ai=14.24}1s(ah=1.5;ah<=90;ah+=1.5){ag+=(ai*1g.eS(ah/1g.3J/2))}18 14.24>ag?ag:14.24}).1e(14),J=j(17(ai){1a aj,ag=0,ah,ak;4U(ag>14.1D){ag-=14.24}if(1g.1F(ag-14.1D)>14.24/2){ag+=14.24}ak=ag;1s(aj=0;aj<14.5w;aj++){ah=1V(14.1j.2h[aj].3Q("2c-34"));if(ak==0){14.1m=ah;1N}ak+=14.1h[ah].1z[14.1y.1z]}18 ag}).1e(14),ab=j(17(ag){X=1d;j(1k.4d).2V("1Y-88");14.o.4o=1c;Y=1d;3x(14.2T);if(14.o.1p=="2r"){14.d9()}14.99&&14.99();M={x:0,y:0};G=(14.1y.1X=="1O")?"x":"y";14.1o("5r-2y");14.1j.1W("6N");14.1D=14.9Z(14.1j)[G];M[G]=14.1D;14.1j.1M(g,"4J("+M.x+"2K, "+M.y+"2K, 0)");14.1j.1M("2L","40");14.8Z();14.o.1p=="2q"&&(T=1d);14.2J=1d}).1e(14),F=j(17(){if(14.o.1p=="2r"){14.1j.1M("2L","40");14.3q=14.6K()}if(14.o.1p=="2r"){14.1m=1V(14.1j.2h[14.6K()].3Q("2c-34"))}if("3B"===14.o.1n){14.7E()}14.2J=1c;14.62=1c;T=1c;Y=1d;14.8h();14.1o("5r-5C",{3z:14.4A(14.1n.2W)})}).1e(14),U=j(17(ah){j(1k.4d).4L("1Y-88");if(X){X=1c;1a ag=14.1D;if(!Y){ah.fp=1c;Q();L=ah.3b-af;if(14.o.1p=="2q"){if(L>5N){K=ae;T=1c}1b{K=H(1g.1F(P[G]-ah[G]))}ae=K;if("3B"===14.o.1n){14.2i=1g.1F(ae);14.5V(ad)}if("3B"===14.o.1n||14.1D<=0){if(1g.1F(14.1D)<ae){ae=1g.1F(14.1D)}14.1D-=ae}ad=="1G"?14.1D-=14.a6(ad):14.1D+=14.a6(ad);if(!14.o.1n||"6n"===14.o.1n){14.1o("4f");14.1n.2X=1c;14.1n.2W=1c;if(14.1D>0){14.1D=0;14.1m=0;T=1d;14.1o("5A-3m");14.1n.2X=1d}if(14.1D<14.24-14.2I){14.1D=14.24-14.2I;14.1m=14.l-1;T=1d;14.1o("1m-3m");14.1n.2W=1d}}W=T?db:8A}1b{T=1d;14.2i=0;14.1D=J();"3B"===14.o.1n&&14.5V(ad);if(L<5N){14.2i=14.24;"3B"===14.o.1n&&14.5V(ad);if(ad=="1G"){14.1D-=14.24}1b{14.1D+=14.24}}if(!14.o.1n||"6n"===14.o.1n){14.1o("4f");14.1n.2X=1c;14.1n.2W=1c;if(14.1D>=0){14.1D=0;14.1m=0;14.1n.2X=1d;14.1o("5A-3m")}if(14.1D<=(1g.8U(14.l/14.2A)-1)*14.24*(-1)){14.1D=(1g.8U(14.l/14.2A)-1)*14.24*(-1);14.1m=14.l-1;14.1n.2W=1d;14.1o("1m-3m")}}W=9i}M[G]=14.1D;14.1j.1H("6N",j(17(ai){if(ai.1Z==14.1j){F()}}).1e(14));if(ag==14.1D){14.2J=1c;T=1c;Y=1d}14.1j.1M("2L",g+" "+W+"ms 5S-5J(.22,.63,.49,.8)");14.1j.1M(g,"4J("+M.x+"2K, "+M.y+"2K, 0)")}1b{if(!v.1f.7l){F()}1b{14.2J=1c}}}}).1e(14),O=0,Q=j(17(){3x(Z);Z=1i;S=1c;O=0}).1e(14),ac=j(17(){1a ag=O*0.2;if(1g.1F(ag)<0.lc){Q();18}O-=ag;14.1D-=ag;M[G]=14.1D;14.1j.1M(g,"4J("+M.x+"2K, "+M.y+"2K, 0)");Z=5h(ac,16)}).1e(14),aa=j(17(ah){if(X){1a ag=ah[G]-R>0?"2B":"1G";Y=1c;if("3B"===14.o.1n){14.2i=1g.1F(ae);14.5V(ag)}if(v.1f.1C){O+=ae;if(!S){S=1d;ac()}}1b{14.1j.1M("2L",g+" a2");if(14.o.1p=="2r"){}14.1D-=ae;M[G]=14.1D;14.1j.1M(g,"4J("+M.x+"2K, "+M.y+"2K, 0)")}14.dk(ag)}}).1e(14);14.8T=j(17(ag){if(14.72||14.o.1p=="2r"&&T){18}if("4a"==ag.56){af=ag.3b;P.x=ag.x;P.y=ag.y;R=ag[G]}1b{ad=(ae>0)?"1G":"2B";ae=R-ag[G];14.8K.1J=ad;if("9v"==ag.56){if(I){I=1c;U(ag)}}1b{if(14.o.1R=="3A"||1g.1F(ag.x-P.x)>1g.1F(ag.y-P.y)){ag.4u();if(!I){if(14.o.1p=="2r"&&14.2J){18}I=1d;ab(ag)}1b{aa(ag)}}}}R=ag[G]}).1e(14);if(!v.1f.1C||v.1f.1C&&v.1f.1C>9){14.1j.3j.1H("2D 2t",14.8T)}},7f:17(){1a J,K,G=0,I={x:0,y:0},H=(14.1y.1X=="1O")?"x":"y",F=j(17(M){1a L=G*(M||0.2);J=L>0?"1G":"2B";G-=L;if(1g.1F(L)<0.bp){3x(14.2T);14.1m=1V(14.1j.2h[14.6K()].3Q("2c-34"));14.7E();14.9b=14.cC();14.dj=14.1m;G=0;14.2i=0;14.2T=1i;14.62=1c;14.2J=1c;14.1o("5r-5C",{3z:14.4A(14.1n.2W)});18}14.2i=1g.1F(L);"3B"===14.o.1n&&14.5V(J);14.1D-=L;14.2i=0;14.dk(J);if(!14.o.1n||"6n"===14.o.1n){if(14.1D>0){14.1D=0;G=0.bp;14.1o("5A-3m")}1b{if(14.1D<14.24-14.2I){14.1D=14.24-14.2I;G=0.bp;14.1o("1m-3m")}1b{14.1o("4f")}}}I[H]=14.1D;14.1j.1M(g,"4J("+I.x+"2K, "+I.y+"2K, 0)");14.2T=5h(F.1e(14,M),30)}).1e(14);if(v.1f.1C&&v.1f.1C<10||14.72){18}14.99=j(17(){if(14.62){3x(14.2T);G=0;14.2i=0;14.2T=1i;14.62=1c;14.2J=1c}}).1e(14);14.1j.1H("4r",j(17(L){1a M=(1g.1F(L.3V)<1g.1F(L.3W)?L.3W:L.3V*(!L.51?-1:-30));if(14.2J){18}if((1d===14.o.4E&&L.51)||"3A"===14.o.1R&&1g.1F(L.3V)>1g.1F(L.3W)||"3k"===14.o.1R&&1g.1F(L.3V)<1g.1F(L.3W)){L.29();14.62=1d;if(0===G){14.1j.1M("2L",g+" a2");I={x:0,y:0};H=(14.1y.1X=="1O")?"x":"y"}14.1o("5r-2y");G+=M;if(!14.2T){F(0.4)}}}).1e(14))},cC:17(){1a G,F,H=14.1D,I=j(["80","1h","7b"]);14.80=[];14.4l.1A(j(17(J){14.80.2a(J)}).1e(14));14.80.4C();1s(G=0;G<I.1r;G++){1s(F=0;F<14[I[G]].1r;F++){H+=14.1h[14[I[G]][F].1T].1z[14.1y.1z];if(H>0){14.1m=14[I[G]][F].1T;14.80=1i;18 H}}}},5i:17(){1a F,G;if(!14.o.2v||14.9f||!14.2J||14.o.1p=="2r"){18}14.9f=1d;if(v.1f.1C&&v.1f.1C<10){14.fx&&(14.fx.1t.5L=v.$F);14.fx&&14.fx.29();14.fx=1i;14.1D=1g.5R(1V(14.1j.2j(14.1y.1X)))}1b{14.1D=14.9Z(14.1j)[(14.1y.1X=="1O")?"x":"y"]}F=14.a6(14.1J);G=14.o.3T/14.2i*F;if(14.1J=="1G"){14.1D-=F}1b{14.1D+=F}14.6L(G)},29:17(){14.fL=1d;14.2J=1c;14.99&&14.99();if(14.o.1p=="2r"){14.d9()}if(v.1f.1C&&v.1f.1C<10){14.fx&&14.fx.29(1d);14.fx=1i}1b{14.dm()}},d9:17(){1a F={x:0,y:0};if(!v.1f.1C||v.1f.1C&&v.1f.1C>10){F[14.1y.1X]=14.1D;14.1j.3P("2c-1G");14.1j.3P("2c-2B");j([14.5G,14.6V]).1A(j(17(G,H){if(G.1r>0){G.1A(j(17(J,I){J.1W(w+"97 96 "+w+"93 9c");J.3P("2c-2r-92");J.3P("2c-91");if(!H){J.3P("2c-dp");J.3P("2c-dh")}1b{J.3P("2c-d8")}}).1e(14))}}).1e(14));14.1j.1M(g,"4J("+F.1O+"2K, "+F.1L+"2K, 0)");14.2J=1c;14.8Z()}},3Y:17(){1a G,H,F,I;14.29();14.9f=1c;14.at=j(14.1j.3j).5t();14.24=14.7d();14.7K=0;14.2I=0;1s(G=0;G<14.l;G++){14.1h[G].1z=14.1h[G].1q.2p(1d);14.2I+=14.1h[G].1z[14.1y.1z];if(14.2I<=14.24){14.7K+=1}}if(v.1f.1C&&v.1f.1C<10){14.1m=0}1b{14.9P()}14.2i=0;14.2A=14.o.3H;if(14.2I<=14.24){14.72=1d;14.1o("e3");14.1o("7H");14.7L=0;14.1D=0;if(v.1f.1C&&v.1f.1C<10){14.1j.1M(14.1y.1X,0)}1b{14.1j.1M(g,"4J(cK, cK, 0)")}14.9E()}1b{14.72=1c;14.1o("dQ");14.1o("4f");if(!14.o.1n||"6n"===14.o.1n){if(14.1n.2X){14.1o("5A-3m")}if(14.1n.2W){14.1o("1m-3m")}}}if((14.2I>14.24)&&("3B"===14.o.1n||14.o.2v)){14.cE()}1b{14.3D=H=0;1s(G=0;G<14.l;G++){H+=14.1h[G].1z[14.1y.1z];14.3D++;if(14.24<=H){1N}}}14.5V("1G");14.1j.1W("6N");14.3q=14.6K();14.5w=14.1j.2h.1r;14.ax();14.7E();14.ay=v.$A(14.1j.2h);14.o.3U?14.8h():14.aQ()},9P:17(){1a H,J,I={1O:0,1L:0},G=14.1h[14.1m].1q.5t()[14.1y.1X],F=14.1j.3j.5t()[14.1y.1X];if(v.1f.1C&&v.1f.1C<10){}1b{if(!14.o.1n&&14.1n.2W){if("2q"===14.o.1p){I[14.1y.1X]=14.24-14.2I}1b{J=14.7K-14.l%14.7K;I[14.1y.1X]=14.24-(14.2I+14.1h[0].1z[14.1y.1z]*J)}}1b{H=14.9Z(14.1j)["1O"===14.1y.1X?"x":"y"];I[14.1y.1X]=H-(G-F)}14.1D=I[14.1y.1X];14.1j.1M(g,"4J("+I.1O+"2K, "+I.1L+"2K, 0)")}},fk:17(G){1a M=0,L=1d,H=14.l-1,I=j(["7b","1h","4l"]),K=j(17(Q,O){1a N,P=1i;1s(N=0;N<Q.1r;N++){if(Q[N].1T==O){P=Q[N].1q;1N}}18 P}).1e(14),J=j(17(N){18(M==0)?N-1:(M-1)}).1e(14),F=j(17(Q,O){1a P,N=Q.1r;if(N>0){1s(P=0;P<N;P++){if(L){L=1c;M=N-1;14.1j.8S(Q[M].1q)}1b{14.1j.7C(K(Q,!M?H:J(N)),K(!M?14[I[O-1]]:Q,M));M=!M?H:M-1}}}}).1e(14);I.1A(j(17(N,O){F(14[N],O);M=0}).1e(14));if(!G){14.1m=0}},9E:17(){14.4l.1A(17(F){F.1q.5c()});14.4l=j([]);14.7b.1A(17(F){F.1q.5c()});14.7b=j([])},7z:17(G){1a F={1O:0,1L:0};14.29();if(G){14.1D=14.1m=0}if(v.1f.1C&&v.1f.1C<10){14.1j.2Y(F)}1b{if(G){14.1j.1M(g,"4J("+F.1O+"2K, "+F.1L+"2K, 0)")}1b{14.9P()}}14.2A=14.o.3H;if((!14.o.2v&&(!14.o.1n||"6n"===14.o.1n))&&14.4l.1r>0){14.7L=0;14.9E()}14.3Y();14.fk(!G);if(G){14.1j.3j.1W("2D 2t",14.8T);if(14.o.76){14.1j.3j.1H("2D 2t",14.8T)}}14.2J=1c},gk:17(F){1s(1a G in F){14.o[G]=F[G]}14.b9()},7e:17(){14.29();14.9E();j(1l).1W("5X");j(1k).1W("8X");14.1j.1W("2t 2D");14.1h.1A(j(17(F){F.1q.1W("5l 7c");5v F.2l.eW}).1e(14))}};v.1U(b.27,v.6S);v.5e.cG=b;1a y=17(F,G){v.5e.cG.5x(14,3h);14.8q={5T:"21",7A:j([0.44,0.59,0.35,0.89]),9A:kw,6z:"5S-5J(.8, 0, .5, 1)"};14.7r="5K";14.o=14.8q;v.1U(14.o,G);14.2i=70;14.6v=0;14.2w=0;14.2T=1i;14.bk=1g.4N(10,8);14.2R=2*1g.3J;14.1m=0;14.kx=j([]);14.be=1i;14.4H=1i;14.6f=1i;14.5T=0;14.l=0;14.cp=1i};v.cW(y,v.5e.cG);v.1U(y.27,{4P:y,cE:v.$F,7E:v.$F,fc:v.$F,5i:v.$F,cP:v.$F,9B:v.$F,cD:v.$F,8h:v.$F,cC:v.$F,7A:v.1U({},v.4z.27),5V:17(){14.6v%=14.2R;14.2w=14.6v},8t:17(H){1a G,F;if(14.41.7Z){18}14.41.7Z=1d;F=14.l=14.1h.1r;14.24=14.7d();if(v.1f.1C&&v.1f.1C<10&&14.1h[0].2l.1r&&14.1h[0].2l.aE.2x.36()=="33"){14.cp=1V(14.1h[0].2l.aE.2j("ky-1z"))}14.7A.5Q=14.o.7A;1s(G=0;G<14.l;G++){14.1h[G].1z=14.1h[G].1q.2p(1d,1d);14.2I+=14.1h[G].1z[14.1y.1z];14.1h[G].1q.1M("2H","6J");14.1h[G].2g=14.d3(14.1h[G])}if("3B"===14.o.1n){14.1o("4f")}14.1h.1A(j(17(I){if(I.33&&!I.7y){if(I.2l.2x.36()!="4w"){I.7y=1d}}}).1e(14));14.3Y();14.aQ()},a7:17(F){14.41.5d=1d;14.83();14.4H=14.2R/14.l;14.6f=(14.2R-14.4H)*(-1);14.2A=1;14.7m();14.o.4E&&14.7f();j(1l).1H("5X",14.3Y.1e(14));if(14.o.6H){j(1k).1H("8X",14.aF)}F&&F();14.3Y()},83:17(){y.$4e.83.5x(14);14.1h.1A(j(17(F){F.1q.1H("4m",j(17(G){14.1o("34-4m",{1T:F.1T})}).1e(14))}).1e(14))},8w:17(G){1a F=9t;if(v.1f.1C&&v.1f.1C<10||!G.4h){18}G.4h.3Z(1);G.4h.1M("2L","3w "+F+"ms")},9u:17(H){1a F,G,I=j(17(J){if(J.4h||J.7y){F=J.2g.2p(1c,1d);G=J.2g.cs+F.1B;if(J.4h){J.4h.2Y({1L:G,1O:J.2g.ff,1x:F.1x})}if(J.7y&&J.33){J.33.2Y({1L:G})}}}).1e(14);H?I(H):14.1h.1A(j(17(J){I(J)}).1e(14))},d3:17(H){1a F,G=H.2l;if(G.2x=="6i"){F=G}1b{if(G.3r.2x=="6i"){F=G.3r}1b{if(G.3r.2x=="cB"&&G.3r.3r.2x=="6i"){F=G.3r.3r}1b{F=1i}}}if(F){j(F).1M("z-1T",2F)}18 F},aU:17(S){if(14.o.1R=="3A"){18}1a H=v.$1v("4h",{},{3w:0}),T=v.$1v("4h"),G,F,K,Q,P,R,U=1,N,O,L,I,M,J;if(v.1f.1C&&v.1f.1C<10){18}if(H.8M){G=H.8M("2d");F=T.8M("2d");if(!S.2g){18}P=j(S.2g).2p(1c,1d);R=P.1B/2F*30;T.1x=P.1x;T.1B=P.1B;F.fR();F.7w(1,-1);F.kB(S.2g,0,P.1B*(-1),P.1x,P.1B);K=F.kC(0,0,P.1x,R);F.gd();H.1x=P.1x;H.1B=R;G.fR();O=K.2c;J=O.1r;I=J/4/P.1x;L=14.o.9A;N=J/I;1s(M=3;M<J;M+=4){if(M>N){N+=(J/I);U++;L=1g.5R(14.o.9A-14.o.9A*14.7A.9N(1/(I/U)))}O[M]=L}G.kD(K,0,0);G.gd();S.4h=H;if((!S.2l.2h||S.2l.2h.1r<2)&&S.2l.2x.36()!=="a"){S.1q.8S(H)}1b{S.2l.7C(H,S.2l.2h[1])}H.2V("1Y-kE")}},d4:17(G){1a H=0,F=14.2i/(14.l/2),I=2F-F;if(G>I){H=(G-I)/F}18 H},5m:17(M){1a J={1O:0,1L:0},H={1O:0,1L:0},T={1O:0,1L:0},N,S,R=14.l,O=14.2i,F=14.2R/R,Q,I,G,L,K,P;J[14.1y.1X]=14.5T;v.3e(M)||(M=0);14.6v=M;1s(K=0;K<R;K++){I=G=K*F+M;G%=14.2R;I%=14.2R;if(G!=0&&G!=1g.3J){if(1g.8U(1g.1F(G)/1g.3J)%2==0){if(1g.1F(G)%1g.3J!=0){I=1g.3J-(1g.1F(G)%1g.3J)}}1b{I=1g.1F(G)}}I=1g.1F(I*2F/1g.3J);if(14.1h[K].33){14.1h[K].33.3Z(14.d4(2F-(I*O/2F)))}I=2F-1g.5R(I*O/2F);!14.be&&(14.be=14.1h[K].1z);N=1g.1F(G);if(N>1g.3J/2&&N<1g.3J+1g.3J/2){if(N>1g.3J){N=1g.3J/2-1g.1F(N-1g.3J)}1b{N=N-1g.3J/2}N=(1-1g.65(N))*0.7}1b{N=1}if(v.1f.1C&&v.1f.1C<10){L={1x:14.cr("1x",I),1B:14.cr("1B",I)};14.1h[K].1q.2Y(L);14.1h[K].1q.2Y({1L:1g.65(G)*J.1L+1V(14.8L.1B)/2-1V(L.1B)/2,1O:1g.65(G)*J.1O+1V(14.8L.1x)/2-1V(L.1x)/2});if(14.1h[K].2l.1r&&14.1h[K].2l.aE.2x.36()=="33"){14.1h[K].2l.aE.3g.ku=14.gr(I/2F*I)}if(14.1h[K].7y){Q=14.1h[K].2g.2p(1c,1d);14.1h[K].33.2Y({1L:14.1h[K].2g.cs+Q.1B})}}1b{T[14.1y.1X]=6g/14.2R*G;14.o.1R=="3A"&&(T[14.1y.1X]*=(-1));P=1g.1F(G);S=1g.8n(1-1g.65(P)*1g.65(P));if(P>1g.3J/2&&P<1g.3J+1g.3J/2){P=14.5T*(S)+14.5T}1b{P=14.5T*(1-S)}P>0&&(P*=(-1));H[14.1y.1X]=(1g.65(G)*J[14.1y.1X]+1V(14.8L[14.1y.1z])/2-14.1h[K].1z[14.1y.1z]/2);14.1h[K].1q.1M(g,"kF("+H.1O+"2K)kH("+H.1L+"2K)b0("+P+"2K)g4("+T.1L+"b3)g5("+T.1O+"b3)")}14.1h[K].1q.1M("z-1T",0+I);14.1h[K].1q.3Z(N)}},5R:17(F,G){1a H=1g.4N(10,G||15);18 1g.5R(F*H)/H},6U:17(I){1a G,H,F=6g/14.l;if(I.8m){if(I.6q){if(I.1J=="1G"&&14.1m>I.1Z){G=14.l-14.1m;G+=I.1Z}1b{if(I.1J=="2B"&&14.1m<I.1Z){G=14.l-I.1Z;G+=14.1m}}!G&&(G=1g.1F(14.1m-I.1Z));14.1m=I.1Z}1b{G=14.2A;14.1m=14.3G(I.1J=="1G"?14.1m+G:14.1m-G)}}1b{H=(6g-14.1m*F+I.1Z*F)%6g;if(H>=0&&H<=d2){!I.1J&&(I.1J="1G")}1b{if(H>=d2&&H<=6g){!I.1J&&(I.1J="2B")}}if(I.1J=="1G"){G=1g.5R(H/F)}1b{G=1g.5R((6g-H)/F)}14.1m=I.1Z}18 v.1U(I,{4H:G*14.4H})},fX:17(G){1a F;G=14.6U(G);F=G.4H;if(!14.o.1n){14.1o("4f")}if(G.1J=="1G"){14.2w-=F;if(!14.o.1n){if(14.2w==14.6f){14.1o("1m-3m")}1b{if(14.2w<14.6f){14.1m=0;14.2w=0;14.1o("5A-3m")}}}}1b{14.2w+=F;if(!14.o.1n){if(14.2w==0){14.1o("5A-3m")}1b{if(14.2w>0){14.1m=14.l-1;14.2w=14.6f;14.1o("1m-3m")}}}}14.1o("3s-2y-1p",{3z:[14.1m]});14.4G=G.4G;14.6L(14.2w)},cr:17(F,G){18 14.be[F]/2F*G},gr:17(F){18 1g.5R(14.cp/2F*F)+"2K"},6L:17(F){14.fx=1v v.4z(14.1j,{3T:14.o.3T,2L:14.o.6z,b8:(17(G){14.5m(G.4H/14.bk)}).1e(14),5L:j(17(){14.75()}).1e(14)}).2y({4H:[14.bk*14.6v,14.bk*F]})},75:17(){14.5V();y.$4e.75.5x(14)},71:17(G){1a F=1g.1F(14.2w-14.6v)*(G||0.2);if(1g.1F(F)<0.bp){3x(14.2T);14.2T=1i;14.2J=1c;14.1o("5r-5C",{3z:[14.1m]});18}if(14.2w<14.6v){F*=(-1)}14.5m(14.6v+F);14.2T=5h(14.71.1e(14,G),30)},8a:17(){1a H,I=14.2w%14.2R,G=1V(1g.1F(14.2w/14.2R)),K,J,F=j(17(L){4U(G!=0){G--;if(I<=0){L-=14.2R}1b{L+=14.2R}}18 L}).1e(14);1s(H=0;H<14.l;H++){K=(H*14.2R)/14.l;J=((H+1)*14.2R)/14.l;if(I<=0){K*=(-1);J*=(-1)}1b{K=14.2R-K;J=14.2R-J}if(K!=I){if(K>I&&I>J){if(1g.1F(I-K)<=1g.1F(J-I)){14.2w=F(K);14.1m=H}1b{14.2w=F(J);14.1m=14.3G(H+1)}}}1b{14.1m=H}}},7f:17(){1a H,G,F=14.2R/6g*15;14.1j.1H("4r",j(17(I){if(1d===14.o.4E||I.51||"3A"===14.o.1R&&1g.1F(I.3V)>1g.1F(I.3W)||"3k"===14.o.1R&&1g.1F(I.3V)<1g.1F(I.3W)){14.1o("5r-2y");14.fx&&14.fx.29(1d);14.fx=1i;I.29();if(v.1f.1C&&v.1f.1C<10){I.51=1d}G=1g.1F(I.3V)<1g.1F(I.3W)?I.3W:-1*I.3V;G=I.51?(G*F):(G*(8/kI));!I.51&&(G=G>0?1g.7W(14.4H/4,G):1g.6e(14.4H/4*(-1),G));14.2w-=G;3x(H);H=5h(j(17(){14.8a()}).1e(14),2F);if(!14.o.1n){if(14.2w>=0){14.1o("5A-3m");14.2w=0;14.1m=0}1b{if(14.2w<=14.6f){14.1o("1m-3m");14.2w=14.6f;14.1m=14.l-1}}}if(!14.2T){14.71(0.dR)}}}).1e(14))},7m:17(){1a K=(14.1y.1X=="1O")?"x":"y",M={x:0,y:0},L={x:0,y:0},J,G=1c,I="1G",F=1c,H=j(17(N){if("4a"==N.56){j(1k.4d).2V("1Y-88");F=1d;M.x=L.x=N.x;M.y=L.y=N.y}1b{if(F){M.x=N.x;M.y=N.y;if("9v"==N.56){j(1k.4d).4L("1Y-88");F=1c;if(G){G=1c;14.8a()}}1b{if(14.o.1R=="3A"||1g.1F(N.x-L.x)>1g.1F(N.y-L.y)){N.4u();if(!G){G=1d;14.2J=1d;14.fx&&14.fx.29();14.1o("5r-2y");3x(14.2T);14.2T=1i}I=L[K]<M[K]?"2B":"1G";J=1g.1F(L[K]-M[K])/14.5T;if(I=="1G"){14.2w-=J;if(!14.o.1n){if(14.2w<=14.6f){14.1o("1m-3m");14.2w=14.6f;14.1m=14.l-1}}}1b{14.2w+=J;if(!14.o.1n){if(14.2w>=0){14.1o("5A-3m");14.2w=0;14.1m=0}}}!14.2T&&14.71()}L.x=M.x;L.y=M.y}}}}).1e(14);14.1j.1H("2t 2D",H)},29:17(){14.fx&&14.fx.29(1d);14.fx=1i;3x(14.2T);14.2T=1i;14.2w&&14.5m(14.2w)},3Y:17(){1a G,H,F,I;14.29();14.24=14.7d();14.8L=14.1j.3j.2p(1c,1d);14.2I=0;1s(G=0;G<14.l;G++){14.1h[G].1z=14.1h[G].1q.2p(1d,1d);14.2I+=14.1h[G].1z[14.1y.1z]}14.4H=1*14.2R/14.l;14.6f=(14.2R-14.4H)*(-1);H=14.2I/14.2R;14.5T=14.8L[14.1y.1z]/2;(14.5T<H)&&(14.5T=H);(v.1f.1C&&v.1f.1C<10)&&(14.5T-=(14.1h[0].1z[14.1y.1z]/2));14.6v=14.2w=0;14.5m();14.9u();F=14.1m;14.1m=0;I=14.6U({1Z:F});if("1G"===I.1J){14.2w-=I.4H}1b{14.2w+=I.4H}14.5m(14.2w)},7z:17(F){14.29();14.1m=0;if(14.o.1R=="3A"){14.co()}1b{14.1h.1A(j(17(G){if(!G.4h){14.aU(G)}}).1e(14))}14.1j.1W("2t 2D 4r");14.7m();14.o.4E&&14.7f();14.cP();14.b9();14.3Y();if(14.o.1R=="3k"){14.1h.1A(j(17(G){14.8w(G)}).1e(14))}14.2J=1c},co:17(){14.1h.1A(j(17(F){if(F.4h){F.4h.2o();5v F.4h}}).1e(14))},7e:17(){y.$4e.7e.5x(14);14.1j.1W("4r");14.co();14.1h.1A(j(17(F){F.1q.1W("4m")}).1e(14))}});v.1U(y.27,v.6S);v.5e.d5=y;1a d=17(F,G){v.5e.d5.5x(14,3h);14.7r="kJ";14.2z=1i;14.2i=1i;14.2Q=1i;14.4F=1i;14.4g=1i;14.d0=kK;14.2A=1;14.2T=1i;14.3M=1i;14.2P=1i;14.3t=1i;14.cV=0};v.cW(d,v.5e.d5);v.1U(d.27,{4P:d,5V:v.$F,fX:v.$F,d4:v.$F,dV:17(){1a F,H,G;14.3t=14.2Q;if(14.o.1R=="3A"){G=14.2Q+14.2Q*0.8;14.3t/=2}1b{G=14.2Q*2}1s(F=0;F<14.l;F++){H=(F==1)?G:14.3t;14.1h[F].2H=!F?(14.2z-14.2Q):(14.1h[F-1].2H+H)}},cT:17(F){if(14.o.1R=="3k"){18 1g.5R(14.2I-1g.1F(14.2z-(F.2H+14.2Q)))}},8t:17(H){1a G,F;if(14.7Z){18}14.7Z=1d;F=14.l=14.1h.1r;14.24=14.7d();14.7A.5Q=14.o.7A;1s(G=0;G<14.l;G++){14.1h[G].1z=14.1h[G].1q.2p(1d,1d);14.2I+=14.1h[G].1z[14.1y.1z];14.1h[G].1q.1M("2H","6J");14.1h[G].2g=14.d3(14.1h[G]);14.1h[G].33&&j(14.1h[G].33).3Z(0)}14.o.1n=1c;14.1h.1A(j(17(I){if(I.33&&!I.7y){if(I.2l.2x.36()!="4w"){I.7y=1d}}}).1e(14));14.3Y();!14.o.3U&&14.aQ()},a7:17(F){14.41.5d=1d;14.83();14.2A=1;14.7m();14.o.4E&&14.7f();j(1l).1H("5X",14.3Y.1e(14));if(14.o.6H){j(1k).1H("8X",14.aF)}F&&F();14.3Y()},cY:17(N){1a L,G,M,K,H=1,F,I=N.2H+14.2Q,J=N.2H+14.2Q<=14.2z;K=J?(14.2z-I):(I-14.2z);K/=((J?(14.2z-14.3M):(14.2P-14.2z))/2F);G=(90/2F*K)*(1g.3J/d2);L=60*1g.65(G);F=1-1*1g.65(G);if(14.o.1R=="3k"){!J&&(L*=(-1))}1b{L*=(-1);J&&(H=1-0.7*1g.65(G))}M=14.d0*1g.65(G)*(-1);18{8G:L,b0:M,3w:H,cU:F}},g0:17(J,L){1a H,G=1c,K=1c,F=J.2H+14.2Q,M,I={8G:60,b0:14.d0*(-1),3w:1};M=F-L;if(F>=14.2P){if(F-L<14.2P){H=F-14.2P;K=1d;L-=H;if(L<=14.2Q){L=(14.2P-14.2z)/14.3t*L}1b{if(L<=14.2Q*2){L=(14.2P-14.3M)/(14.3t*2)*L}1b{L+=(14.2Q*2);K=1c}}J.2H-=H}G=1d;J.2H-=L}1b{if(F<=14.3M){if(14.o.1R=="3A"){L=(14.2P-14.2z)/14.3t*L}1b{if(F-L>14.3M){K=1d;H=14.3M-F;L+=H;if(L>=14.2Q*(-1)){L=(14.2P-14.2z)/14.3t*L}1b{if(L>=14.2Q*2*(-1)){L=(14.2P-14.3M)/(14.3t*2)*L}1b{L-=(14.2Q*2)}}J.2H+=H}}G=1d;J.2H-=L}1b{if(F>14.3M&&F<14.2P){L=(14.2P-14.2z)/14.3t*L;if(F-L>=14.2P){H=14.2P-F;L+=H;L=14.3t/((14.2P-14.2z)/L);J.2H+=H}1b{if(F-L<=14.3M){if(14.o.1R=="3k"){H=F-14.3M;L-=H;L=14.3t/((14.2P-14.2z)/L);J.2H-=H}}1b{K=1d}}J.2H-=L}}}if(14.o.1R=="3k"){J.2H>14.2z&&(I.8G*=(-1))}1b{I.8G=60*(-1);J.2H<14.2z&&(I.3w=0.3)}K&&(I=14.cY(J));G&&(I.cU=0);if(14.o.3U){if(14.24>M-14.2Q&&"7u"===J.2G){14.cV=J.1T;J.2G="2G";if(14.o.4o){14.1o("9w")}1b{J.1K&&J.1K.2M()}14.6T.2a({1q:J.2l,1T:J.1T})}}18 I},cX:17(F){if(14.cV===F-1){if(14.o.4o||!14.41.5d){14.1o("9s")}if(!14.41.5d){14.1o("5o")}}},5m:17(I){1a G,H,K,F,J=14.4F-I;I||(I=0);14.4F=I;1s(G=0;G<14.l;G++){K={1O:0,1L:0};F={1O:0,1L:0};H=14.g0(14.1h[G],J);K[14.1y.1X]=14.1h[G].2H;F[14.1y.1X]=H.8G;14.1h[G].1q.1M(g,"4J("+K.1O+"2K, "+K.1L+"2K, "+H.b0+"2K)g4("+F.1L+"b3)g5("+F.1O+"b3)");14.1h[G].33&&14.1h[G].33.3Z(H.cU);if(14.o.1R=="3k"){14.1h[G].1q.1M("z-1T",14.cT(14.1h[G]))}1b{14.1h[G].1q.3Z(H.3w)}}},6U:17(G){1a F=14.2A;if(G.8m){G.6q&&(F=G.6q);if(G.1J=="1G"){14.1n.2X=1c;if(14.1m+F>14.l-1){if(14.1m!=14.l-1){F=14.l-1-14.1m;14.1m+=F;14.1n.2W=1d}1b{14.1m=0;F=14.l-1;14.1n.2X=1d;14.1n.2W=1c;G.1J="2B"}}1b{14.1m+=F;if(14.1m===14.l-1){14.1n.2W=1d}}}1b{14.1n.2W=1c;if(14.1m-F<0){if(14.1m!=0){F=14.1m;14.1m-=F;14.1n.2X=1d}1b{14.1m=14.l-1;F=14.l-1;14.1n.2X=1c;14.1n.2W=1d;G.1J="1G"}}1b{14.1m-=F;if(14.1m===0){14.1n.2X=1d}}}}1b{!G.1J&&(G.1J=G.1Z>=14.1m?"1G":"2B");F=1g.1F(14.1m-G.1Z);14.1m=G.1Z}14.2i=14.3t*F;18 G.1J},kL:17(F){F.1J=14.6U(F);14.4G=F.4G;14.1o("3s-2y-1p",{3z:[14.1m]});14.6L(F.1J=="1G"?14.4F-14.2i:14.4F+14.2i)},6L:17(F){14.4g=F;14.fx=1v v.4z(14.1j,{3T:9i,2L:14.o.6z,b8:(17(G){14.5m(G.1X)}).1e(14),5L:j(17(){14.75()}).1e(14)}).2y({1X:[14.4F,F]})},71:17(G){1a F=1g.1F(14.4g-14.4F)*(G||0.2);if(1g.1F(F)<0.kM){3x(14.2T);14.2T=1i;14.2J=1c;14.1o("5r-5C",{3z:[14.1m]});18}if(14.4g<14.4F){F*=(-1)}14.5m(14.4F+F);14.2T=5h(14.71.1e(14,G),30)},cR:17(J,K){1a H,G=J.2H+14.2Q,F=J.2H,I=j(17(L){if(G>14.3M&&G<14.2P||L){K=(14.2P-14.2z)/14.3t*K;if(G-K>=14.2P){H=14.2P-G;K+=H;K=14.3t/((14.2P-14.2z)/K);F+=H}1b{if(G-K<=14.3M){if(14.o.1R=="3k"){H=G-14.3M;K-=H;K=14.3t/((14.2P-14.2z)/K);F-=H}}}F-=K}}).1e(14);if(G>=14.2P){if(G-K<14.2P){H=G-14.2P;K-=H;F-=H;I(1d)}1b{F-=K}}1b{if(G<=14.3M){if(14.o.1R=="3A"){K=(14.2P-14.2z)/14.3t*K}if(G-K>14.3M){H=14.3M-G;K+=H;F+=H;I(1d)}1b{F-=K}}1b{I()}}18 F},8a:17(){1a H,G,F,I=14.4F-14.4g;if(14.o.1R=="3A"){I*=2}1s(H=0;H<14.l;H++){G=!G?14.cR(14.1h[H],I):F;F=(H+1<14.l)?14.cR(14.1h[H+1],I):1i;if(G+14.2Q>14.3M||H==14.l-1){if(F&&F+14.2Q>=14.2P||!F){F=kN}if(14.2z-(G+14.2Q)<(F+14.2Q)-14.2z){14.1m=H}1b{14.1m=H+1}if(14.1m===0){14.1n.2X=1d}1b{if(14.1m===14.l-1){14.1n.2W=1d}}14.4g=14.2z-14.1m*14.3t;1N}}},7f:17(){1a G,F;14.1j.1H("4r",j(17(H){if(1d===14.o.4E||H.51||"3A"===14.o.1R&&1g.1F(H.3V)>1g.1F(H.3W)||"3k"===14.o.1R&&1g.1F(H.3V)<1g.1F(H.3W)){14.1o("5r-2y");14.fx&&14.fx.29();14.fx=1i;H.29();F=1g.1F(H.3V)<1g.1F(H.3W)?H.3W:-1*H.3V;F=H.51?(F*14.3t):(F*(8/13));!H.51&&(F=F>0?1g.7W(14.3t/4,F):1g.6e(14.3t/4*(-1),F));14.4g-=F;3x(G);G=5h(j(17(){14.8a()}).1e(14),2F);if(14.4g>=14.2z){14.4g=14.2z;14.1m=0}1b{if(14.4g<=14.2z-((14.l-1)*14.3t)){14.4g=14.2z-((14.l-1)*14.3t);14.1m=14.l-1}}if(!14.2T){14.71(0.dR)}}}).1e(14))},7m:17(){1a I=(14.1y.1X=="1O")?"x":"y",K={x:0,y:0},J={x:0,y:0},G=1c,F=1c,H=j(17(L){if("4a"==L.56){j(1k.4d).2V("1Y-88");F=1d;K.x=J.x=L.x;K.y=J.y=L.y;14.1n.2X=1c;14.1n.2W=1c}1b{if(F){K.x=L.x;K.y=L.y;if("9v"==L.56){j(1k.4d).4L("1Y-88");F=1c;if(G){14.8a();G=1c}}1b{if(14.o.1R=="3A"||1g.1F(L.x-J.x)>1g.1F(L.y-J.y)){L.4u();if(!G){14.fx&&14.fx.29();14.1o("5r-2y");3x(14.2T);14.2J=1d;14.2T=1i;G=1d}14.4g-=(J[I]-K[I]);!14.2T&&14.71()}1b{14.2J=1c}J.x=K.x;J.y=K.y}}}}).1e(14);14.1j.1H("2t 2D",H)},29:17(){14.fx&&14.fx.29(1d);14.fx=1i;3x(14.2T);14.2T=1i;14.4g&&14.5m(14.4g)},3Y:17(){1a G,F,I,H;14.29();14.2i=0;14.24=14.7d();14.2I=0;1s(G=0;G<14.l;G++){14.1h[G].1z=14.1h[G].1q.2p(1d,1d);14.2I+=14.1h[G].1z[14.1y.1z]}14.2Q=14.1h[0].1z[14.1y.1z]/2;if(14.o.1R=="3k"){14.2z=14.24/2}1b{14.2z=14.2Q+(14.2Q/50*15)}14.4F=14.4g=14.2z;if(14.o.1R=="3k"){14.3M=14.2z-(14.2Q*2);14.2P=14.2z+(14.2Q*2)}1b{14.3M=0;14.2P=14.2z+14.2Q+14.2Q*0.8}14.dV();14.5m(14.4F);14.9u();F=14.1m;14.1m=0;I=14.6U({1Z:F});H=I=="1G"?14.4F-14.2i:14.4F+14.2i;14.4g=H;14.5m(H)},cP:17(){14.1h.1A(j(17(F){if(14.o.1R=="3k"){F.1q.3g.3w=""}1b{F.1q.1M("z-1T","")}}).1e(14))}});v.1U(d.27,v.6S);v.5e.ki=d;17 s(H,K,J,I){1a G={1x:J.1x,1B:J.1B},F=17(L){18 L!=="21"&&!(/%$/.3C(L))};if(I==="3k"){if(F(K)){K=1V(K,10);if(K<G.1B){G.1B=K;G.1x=J.1x/J.1B*G.1B}}}1b{if(F(H)){H=1V(H,10);if(H<G.1x){G.1x=1V(H,10);G.1B=J.1B/J.1x*G.1x}}}18 G}1a B=17(I,S){1a M,K,G,O,R,J,N,P,L=0,F,H,Q="kQ kP 2q 1z.";14.1t=1v v.cL(m);14.o=14.1t.dv.1e(14.1t);14.2n=14.1t.2n.1e(14.1t);14.1t.7n(1l.aA||{});14.1t.7n((1l.a3||{})[I.3Q("id")||""]||{});14.1t.9y(I.3Q("2c-1t")||"");if(v.1f.7l){14.1t.7n(1l.a8||{});14.1t.7n((1l.ap||{})[I.3Q("id")||""]||{});14.1t.9y(I.3Q("2c-7l-1t")||"")}if("2e"==v.1P(S)){14.1t.9y(S||"")}1b{14.1t.7n(S||{})}if(!14.o("bq")){18 1c}14.kO=j(I).3u("2q",14);v.$6O(14);14.6M=1c;if(v.1f.1C){v.$A(I.bj("a")).1A(17(T){T.bl=T.bl});v.$A(I.bj("2g")).1A(17(T){T.4j=T.4j})}14.g8=j(I).3Q("2C")||j(I).3Q("6s");14.6E=[];14.26={4q:14.o("4q"),5i:1d,74:1c,1K:1d,2v:1c,dX:"2q",4o:1d,eN:"5S-5J(.8, 0, .5, 1)",7g:"21"};14.id=I.3Q("id")||"5f-"+1g.64(1g.7I()*v.66());14.1j=I.3u("2q",14);14.48=v.$1v("2Z",{"2C":"1Y-48"},{4S:"8r-73"});14.6Z=v.$1v("2Z",{"2C":"1Y-1h-1j"});14.6M=1c;1s(M=14.1j.2h.1r-1;M>=0;M--){G=14.1j.2h[M];if(G.5a===3||G.5a===8){14.1j.9z(G)}1b{14.6E.2a(G)}}if(14.6E.1r===0){18}J=17(U){1a T=17(X){1a W=U.2h[X],V=W.2x.36();if("br"===V||"hr"===V){18 T(++X)}1b{18 W}};18 T(0)};P=J(14.1j);if(P.2x=="cB"){P=j(P).7N("6i")[0]||P.3r}if(P.2x=="A"){P=j(P).7N("6i")[0]||P.3r}14.9V=1c;if(P.2x=="6i"){14.9V=P;N=P.3Q("2c-4j");if(N){N=(N+"").4i();if(""!=N){P.3i("4j",N)}}}14.aP=1i;F=j(17(T){14.aP=5h(j(17(){14.7k=j(J(14.1j)).2p();if(14.7k.1B==0){if(L<2F){L++;F(T)}}1b{3x(14.aP);T()}}).1e(14),2F)}).1e(14);F(j(17(){14.7i=j([]);O=v.$A(14.1j.2h);14.2X=O[0];j(O[0]).1M("4S","40");14.dx={1z:E(O[0]),5Y:r(O[0]),5B:i(O[0]),6j:n(O[0])};O[0].1M("4S","8r-73");14.1j.1M("4S","40");14.cz=E(14.1j);14.1j.1M("4S","8r-73");14.4X=1i;14.d1();14.7k=s(14.cw,14.cn,14.7k,14.o("1R"));if(14.26.1K){14.1K=1v v.3X.9g(14.1j)}14.ct();14.dE();H=j(17(){1a U,W=1d,T={};14.6W=v.$1v("2Z",1i,{2H:"6J",1O:"-cI",1L:"-cI"}).43(1k.4d);14.2M();1s(M=0,K=O.1r;M<K;M++){U=O[M].2x.36();if(W){if("br"===U||"hr"===U){4V}}1b{if("br"===U||"hr"===U){4V}}3f{if(p){o.2k(v.$1v("2Z",{},{4S:"40",6m:"6l"}).2k(1k.aC(p)));p=2U}}3v(V){}W=1c;j(O[M]).3Z(0).1M("4S","8r-73");14.2a(O[M],T);T={};if(M==K-1){14.8t()}}}).1e(14);1v v.cq([{1q:O[0]}],{6T:1,5u:17(T){6r"eD: 5f: eD kA kz - "+T.2g.4j+". "+Q},6c:(17(T,U){14.4X=(T.2g)?T.2g.2p():T.1z;14.4X=s(14.cw,14.cn,14.4X,14.o("1R"));if(U.1q.2x.36()=="4w"){v.$A(U.1q.2h).1A(j(17(W){if(W.2x&&W.2x.36()=="33"){1a V=n(j(W));14.9x=W.2p();14.9x.1x+=V.1x;14.9x.1B+=V.1B;14.4X.1B+=14.9x.1B}}).1e(14))}H()}).1e(14)})}).1e(14))};v.1U(B.27,{dl:1c,d1:17(){if("2r"==14.o("2u")&&(v.1f.1C||!v.1f.4R.2r)){14.2n("2u","2q")}if(v.1f.1C&&v.1f.1C<=9&&14.o("2u")=="6b-6k"){14.2n("2u","2q")}14.26.74=1k.kv.kR.5I("#4t-74-2u")!=-1;if(v.1P(14.o("1h"))==="4c"){14.26.7g=14.o("1h");j(17(){1a H,J,G,I=14.26.7g,F=I.1r;1s(H=0;H<F;H++){1s(J=H+1;J<F;J++){if(I[H][0]<I[J][0]){G=I[H];I[H]=I[J];I[J]=G}}}14.26.7g=I}).1e(14)();14.2n("1h","21")}if(14.o("9e")===0){14.2n("9e",10)}if(14.o("4q")<0||14.o("3H")==0){14.26.2v=1d}if(j(["6b-6k","2r"]).3l(14.o("2u"))){14.26.2v=1c}if("az"===14.o("1n")||"1c"===14.o("1n")){14.2n("1n",1c)}if(14.o("2u")=="5K"||14.26.2v){14.2n("1n","3B")}if(14.o("2u")=="6b-6k"){14.2n("1n",1c)}if("6n"===14.o("1n")&&"2r"===14.o("2u")){14.2n("1n",1c)}if(j(["6b-6k","5K"]).3l(14.o("2u"))||14.26.2v){14.2n("cF",1c)}if(j(["6b-6k","5K"]).3l(14.o("2u"))&&!14.26.2v){14.2n("3H",1)}if(j(["6b-6k","5K"]).3l(14.o("2u"))&&!j(["21","8x"]).3l(14.o("1h"))){14.2n("1h","21")}if(14.o("2u")=="2r"&&14.o("1h")=="21"){14.2n("1h","8x")}if(14.o("2u")=="2r"){14.2n("3H","21")}if(14.26.2v){14.2n("8d","5S-5J(0, 0, 1, 1)")}1b{if(14.o("8d")=="5S-5J(0, 0, 1, 1)"){14.2n("8d",14.26.eN)}}if("5K"===14.o("2u")){14.2n("3U",1c)}if(j(["6b-6k","5K"]).3l(14.o("2u"))){14.26.7g="21"}14.cw=14.o("1x");14.cn=14.o("1B");if(14.26.2v){14.2n("4q",0)}if(j(["6b-6k","5K"]).3l(14.o("2u"))||14.26.2v){14.2n("2f",1c)}if("1c"===14.o("2f")||"az"===14.o("2f")){14.2n("2f",1c)}if(14.o("2f")){14.1j.2V("5f-2f-"+14.o("2f"))}14.1j.2V("5f-"+14.o("1R"));14.1j.3i("2c-2u",14.o("2u"))},ct:17(){if(!14.o("cF")){if(14.2b){14.2b.2o();14.2b=1i}18}if(!14.2b){14.2b=1v v.3X.eh({},14.1j,j(17(){18 14.5O}).1e(14));14.1j.2V("5f-2b");14.2b.2O("2b-4m",j(17(F){14.2S({1J:F.1J,1Z:F.eR})}).1e(14))}},cv:17(){1a G,F=j([]);if(!14.1p){18}1s(G=0;G<14.1p.l;G++){if(j(["2q","2r"]).3l(14.o("2u"))){if(G%14.1p.2A==0){F.2a(14.1p.1h[G].1T)}}1b{F.2a(14.1p.1h[G].1T)}}14.2b.2a(F)},cJ:17(){1a F=i(14.1j);if(14.2f){14.2f.2o();14.2f=1i}14.48.2Y({1L:"",1O:"",6w:"",5s:""});if(14.o("2f")){if(!14.2f){14.2f=1v v.3X.eF({1R:"1Y-"+14.o("1R"),"2C":"1Y-3R",as:"1Y-6l",a1:"1Y-kG"},14.1j);14.1p.2O("7H",14.2f.7H.1e(14.2f,2U));14.1p.2O("4f",14.2f.4f.1e(14.2f,2U));14.1p.2O("e3",14.2f.5b.1e(14.2f,2U));14.1p.2O("dQ",14.2f.2M.1e(14.2f,2U));if(!14.o("1n")){14.1p.2O("2q",14.2f.4f.1e(14.2f,2U));14.1p.2O("1m-3m",14.2f.7H.1e(14.2f,"85"));14.1p.2O("5A-3m",14.2f.7H.1e(14.2f,"7X"))}14.2f.2O("1G",(17(J){14.2S("1G")}).1e(14));14.2f.2O("2B",(17(J){14.2S("2B")}).1e(14))}1b{14.2f.ey(14.o("1R"))}if(14.o("2f")=="df"){1a I=14.o("1R")=="3k"?j(["1O","6w"]):j(["1L","5s"]),G=14.o("1R")=="3k"?"1x":"1B",H=1V(14.2f.85.2p()[G]);I.1A(j(17(J){14.48.1M(J,H+(F[G]/2))}).1e(14))}}},9d:17(){if(14.o("1x")!="21"){14.1j.1M("1x",14.o("1x"))}if(14.o("1B")!="21"){14.1j.1M("1B",14.o("1B"))}18},dE:17(){1a F=j(["2q","2r"]).3l(14.o("2u"))?"1p":14.o("2u");14.1p=1v v.5e[("-"+F).6a()](14.6Z,{1R:14.o("1R"),3T:14.o("9e"),2v:14.26.2v,6z:14.o("8d"),1n:14.o("1n"),3H:14.o("3H"),1p:14.o("2u"),3U:14.o("3U"),1K:14.26.1K,4o:14.26.4o,74:14.26.74,4E:14.o("4E"),76:14.o("76"),6H:14.o("6H")});if(14.o("1h")!="21"&&14.o("3H")=="21"){14.2n("3H",14.o("1h"))}14.1p.2O("dt",j(17(){14.5O=1c;14.21()}).1e(14))},2S:17(F,G){if(14.o("2u")=="2r"&&/^\\+|^\\-/.3C(F)){F=/^\\+/.3C(F)?"1G":"2B"}if(!14.5O&&!14.1p.72){14.5O=1d;3x(14.7v);14.1p.2S(F,j(17(H,I){14.5O=1c;if(I){18}14.1o("cZ-2q");if(!14.26.2v||14.dl||14.5P){if(14.6W.2h.1r==0){14.6W.2o()}if(14.o("1n")){14.1p.7E()}14.o("aO")({id:14.id,1h:H});14.1p.kS=1c;G&&G()}1b{14.2S("1G",G)}}).1e(14))}},dr:17(K){1a G,J,H,F,I;if(K.2x.8e()=="A"){if((F=j(K).7N("6i")[0])){if((I=j(K).7N("aR")[0])&&""!==I.dB.4i()){J=j(I.6y(1d)).2V("1Y-dc");J.3i("4t-cm","eU")}1b{if(((G=F.e4)&&3==G.5a&&""!==G.9K.4i())||(I&&(G=I.e4)&&3==G.5a&&""!==G.9K.4i())){J=v.$1v("aR",{"2C":"1Y-dc"}).2k(G.6y(1d))}}1s(H=K.2h.1r-1;H>=0;H--){if(F!==K.2h[H]){K.9z(K.2h[H])}}if(J){K.2k(J)}}}1b{if(K.2x.36()=="4w"){v.$A(K.2h).1A(j(17(L){if(L.2x&&L.2x.36()=="33"){G=L.3Q("id")||"33-"+1g.64(1g.7I()*v.66());L.3i("id",G);j(L).2V("1Y-dc");J=L;14.l6=v.da("#"+G+":lg",{"5B-1L":(14.9x.1B+r(j(L))/2)/1V(14.7k.1x)*2F+"%"})}}).1e(14))}}18{1q:K,33:J}},aT:17(F){if(14.o("1h")!="21"){F.1q.1M(14.o("1R")=="3k"?"1x":"1B",2F/14.o("1h")+"%")}},aV:17(G){1a H,F;if(14.o("1h")=="8x"){14.2n("1h",1g.64(14.48.2p()[14.1p.1y.1z]/14.4X[14.1p.1y.1z]))}1b{if(14.o("1h")=="21"){if(!14.dx.1z[14.1p.1y.1z]){H=14.4X[14.1p.1y.1z]||14.7k[14.1p.1y.1z];F=14.6Z.2p();if("3A"===14.o("1R")){H=1g.7W(H,F[14.1p.1y.1z])}F=(H+n(G.2l)[14.1p.1y.1z]+r(G.2l)[14.1p.1y.1z]+i(G.2l)[14.1p.1y.1z]+i(G.1q)[14.1p.1y.1z])/14.6Z.2p()[14.1p.1y.1z]*2F;if(F>2F){F=2F}G.1q.1M(14.1p.1y.1z,F+"%")}}}},2a:17(G,F){G.2M();G={2l:G};if(F.1L){F.1L.1A(17(I){I.2o()})}if(F.5s){F.5s.1A(17(I){I.2o()})}G.lf=F;1a H=14.dr(G.2l);G.2l=H.1q;G.33=H.33;G.1q=v.$1v("2Z",{"2C":"1Y-34"});G.1q.43(14.6Z);14.aV(G);14.aT(G);G.2l.43(14.6W);14.1p.2a(G)},2M:17(){if(14.d7){18}14.d7=1d;14.1j.2k(14.48.2k(14.6Z)).2M().3i("id",14.id);14.1j.1M("4S","8r-73");if(14.o("2f")){14.cJ();14.o("1n")&&14.2f.7H("7X");14.2f.5b()}14.b1();14.9d();if(14.9V){if("3k"===14.o("1R")&&14.1j.2p().1x<14.4X.1x){14.b1(1d);14.9d()}}14.aX();j(1l).1H("5X",14.3Y.1e(14))},8t:17(F){14.1p.2O("dD",j(17(G){14.2S(G.1J)}).1e(14));14.1p.2O("2M-14",j(17(G){14.2S(G.1T)}).1e(14));14.1p.2O("9w",j(17(){14.1K&&14.1K.2M()}).1e(14));14.1p.2O("9s",j(17(){14.1K&&14.1K.5b()}).1e(14));14.1p.2O("5o",j(17(){14.1p.a7(j(17(){14.1p.2O("dd",j(17(){14.5O=1c}).1e(14));14.1p.2O("34-4m",j(17(I){1a H=1d,G,J;if(14.o("2u")=="5K"){G=6g/14.1p.l;J=(6g-14.1p.1m*G+I.1T*G)%6g;if(J>90&&J<le){H=1c}}H&&14.2S(I.1T)}).1e(14));if(14.2b){14.2b.o.1h=14.1p.1h.1r;14.cv();14.2b.2M()}14.1p.2O("3s-34-dJ",j(17(G){14.o("cO")({id:14.id,34:G.ar})}).1e(14));14.1p.2O("3s-34-an",j(17(G){14.o("cN")({id:14.id,34:G.ar})}).1e(14));14.1p.2O("3s-2y-1p",j(17(G){14.2b&&14.2b.dg(G.3z,!14.o("1n"));14.o("aM")({id:14.id,1h:G.3z})}).1e(14));14.1p.2O("5r-2y",j(17(){14.5O=1d;14.o("aM")({id:14.id,1h:[]});14.21()}).1e(14));14.1p.2O("5r-5C",j(17(G){14.2b&&14.2b.dg(G.3z,!14.o("1n"));14.5O=1c;14.o("aO")({id:14.id,1h:G.3z});if(14.6W.2h.1r==0){14.6W.2o()}14.21()}).1e(14));14.1j.1M("6I","6X");14.6M=1d;14.o("cM").2m(14,14.id);j(1l).1H("5X",j(17(){14.5O=1c;if(14.26.2v){14.2S.1e(14,"1G").3y(5N)}1b{14.21()}}).1e(14));14.cx();if("3A"===14.o("1R")&&/%$/.3C(14.o("1B"))){14.2n("1B",14.1j.2p().1B);14.9d()}if(14.o("4q")!=0){14.21()}1b{14.5P=1d}if(14.26.2v){14.5P=1c;14.2S.1e(14,"1G").3y(5N)}14.6M=1d}).1e(14))}).1e(14));14.1p.8t()},cx:17(){14.2O("cZ-2q",j(17(){if(14.26.4q!=0){!14.26.2v&&14.21()}}).1e(14));if(!v.1f.dn&&(14.26.5i||14.26.2v)){14.48.1H("5l 7c",j(17(G){G.29();1a F=G.a0();4U(F&&F!==14.48){F=F.3j}if(F==14.48){18}if(14.26.5i&&!14.5P){14.fi="5l"==G.1I;14.dl="5l"==G.1I;if(14.26.2v){if(G.1I=="5l"){14.cS()}1b{14.2S("1G")}}1b{14.21()}}}).1e(14))}if(!14.26.2v&&"2r"===14.o("2u")&&14.o("4E")){14.48.1H("4r",j(17(F){1a G=-1*(1g.1F(F.3V)<1g.1F(F.3W)?F.3W:-1*F.3V);G=F.51?(G):(G*(8/54));if((1d===14.o("4E")&&F.51)||"3A"===14.o("1R")&&1g.1F(F.3V)>1g.1F(F.3W)||"3k"===14.o("1R")&&1g.1F(F.3V)<1g.1F(F.3W)){F.29();if(1g.1F(G)<0.6){18}14.2S(G>0?"2B":"1G")}}).1e(14))}},b1:17(N){1a M="1x",O="1B",J=14.o("1R")=="3A",F=14.1j.2p(),I={1x:0,1B:0},K=i(14.1j),R=r(14.48),V=n(14.48),P=i(14.48),Q=n(14.2X),L=v.$1v("2Z",{"2C":"1Y-34"}).43(14.48.3r),S,T,H,U,G=i(L);L.2o();if(14.1j.2j("em-ld")=="5Y-em"){I=r(14.1j)}if(J){M=O;O="1x"}if(14.o(M)=="21"&&!1V(14.cz[M])){if(J){if(!6C(14.o("1h"))){14.2n(M,F[M]*14.o("1h"))}1b{14.2n(M,F[M])}}1b{14.2n(M,"2F%")}}if(14.o(O)=="21"&&!1V(14.cz[O])||N){H=I[O]+K[O]+R[O]+Q[O]+G[O];if(J){S=1g.7W(14.4X[O],F[O])}1b{if(14.9V){S=14.4X[O];T=14.4X[O]/14.4X[M];if(14.4X[M]>F[M]){S=F[M]*T}}}U=(S+n(j(14.6E[0]))[O]+i(14.6E[0])[O]+r(14.6E[0])[O])||14.7k[O]||F[O];U+=H;U+="";14.2n(O,U)}},aX:17(){1a I,H,G,K,J=1d,F=14.o("1h");if(14.26.7g!="21"&&j(["2q","2r"]).3l(14.o("2u"))){K=14.26.7g;G=K.1r;H=14.26.dX=="2q"?14.1j.2p()[14.o("1R")=="3A"?"1B":"1x"]:j(1l).2p()[14.o("1R")=="3A"?"1B":"1x"];1s(I=G-1;I>=0;I--){if(H<=K[I][0]&&!6C(K[I][1])){14.2n("1h",K[I][1]);J=1c;1N}1b{if(0===I){if(j(["5K","6b-6k"]).3l(14.o("2u"))){14.2n("1h",1)}1b{if("2r"===14.o("2u")){14.2n("1h","8x")}1b{14.2n("1h","8x")}}}}}if(F===14.o("1h")){18}v.$A(14.6Z.2h).1A(j(17(M,L){14.aV({1q:M,2l:M.3r});14.aT({1q:M})}).1e(14));if(14.1p.1h.1r>0){14.1p.7z()}}},3Y:17(){14.aX()},5X:17(){if(14.6M){14.3Y();14.1p.3Y()}},cS:17(){14.1p.5i()},29:17(){14.1j.3u("kV-1h-3w",1c);14.1p&&14.1p.29();14.5O=1c;3x(14.7v);14.7v=1c},kT:17(F){18 F==14.o("2u")},cA:17(G,F){if(!j(["cO","cN","cM","aM","aO"]).3l(G)){18}14.2n(G,F)},7e:17(){1a F,G,H;14.29();3x(14.aP);14.48.1W("5l 7c");14.48.1W("aW");14.1p&&14.1p.7e();if(14.7i){1s(F=0;F<14.7i.1r;F++){v.cy("g1-b7",14.7i[F])}}14.1j.4L("5f-2b");j(14.6E).1A(j(17(I){if(I.3j){j(I).2o()}H=I;if(H.2x=="cB"){H=H.3r}if(H.2x=="A"){H=H.3r}if(H&&H.2x=="6i"){G=H.3Q("2c-4j");if(G){G=(G+"").4i();if(""!=G){H.3P("4j")}}}if(I.2h.1r>0&&I.2x.36()=="a"){v.$A(I.2h).1A(j(17(J){if(J.2x&&J.2x.36()=="aR"){J=j(J);if("eU"===J.3Q("4t-cm")){J.3P("4t-cm");I.2k(J)}1b{I.2k(J.2h[0]);J.2o()}}}).1e(14))}I.2Y({6m:"",3w:"1"})}).1e(14));14.6W&&14.6W.2o();v.$A(14.1j.2h).1A(17(I){j(I).5c()});j(14.1j).3P("2c-2u");j(14.1j).cQ().4L().2V(14.g8);14.1j.2Y({1x:"",1B:"",6m:"",4S:"",6I:""});14.1j.3L("2q");1s(F=14.6E.1r-1;F>=0;F--){j(14.6E[F]).2Y({3w:""}).43(14.1j)}14.o("g7").2m(14,14.id);18 1i},8R:17(F){if(1i===F||2U===F){F=14.o("4q")}1b{F||(F=9t);F=1V(F);if(6C(F)){F=14.o("4q")}}if(!14.5P){18}if(!14.7v){14.5P=1c;14.1p.9f=1c;14.26.4q=F;14.2S("1G")}},5i:17(){if(14.5P){18}14.5P=1d;if(14.26.2v){14.cS()}1b{14.29()}14.21()},8Q:17(F){1a I,H={1B:"",1x:""},G=14.o("2u");14.29();14.1j.4L("5f-2f-"+14.o("2f"));14.1j.4L("5f-"+14.o("1R"));14.48.1W("5l 7c aW");14.g3("cZ-2q");14.1K=1i;14.1j.4L("5f-2b");if("2e"==v.1P(F)){14.1t.9y(F||"")}1b{14.1t.7n(F||{})}if(G!=14.o("2u")){18 1c}14.26.4q=14.o("4q");14.d1();14.1p.1h.1A(j(17(J){J.1q.2Y(H)}).1e(14));14.1p.4l.1A(j(17(J){j(J).1q.2Y(H)}).1e(14));14.1p.7b.1A(j(17(J){j(J).1q.2Y(H)}).1e(14));14.cJ();1s(I=0;I<14.7i.1r;I++){14.7i[I]&&v.cy("g1-b7",14.7i[I])}14.1p.gk({1R:14.o("1R"),3T:14.o("9e"),2v:14.26.2v,6z:14.o("8d"),1n:14.o("1n"),3H:14.o("3H"),1p:14.o("2u"),3U:14.o("3U"),1K:14.26.1K,4o:14.26.4o,74:14.26.74,4E:14.o("4E"),76:14.o("76"),6H:14.o("6H")});14.b1();14.9d();14.aX();v.$A(14.6Z.2h).1A(j(17(K,J){14.aV({1q:K,2l:K.3r});14.aT({1q:K})}).1e(14));14.1p.7z(1d);14.ct();if(14.2b){14.cv();14.2b.2M()}if(14.o("4q")==0){14.5i()}1b{14.5P=1c}14.o("2f")&&14.2f.2M();14.cx();if(14.26.2v){14.2S.1e(14,"1G").3y(5N);14.5P=1c}1b{14.21()}18 1d},21:17(){1a F="1G";3x(14.7v);14.7v=1c;if(14.5O||14.5P||14.fi){18}if(14.26.4q!=0){14.7v=5h(j(17(){14.2S(F)}).1e(14),1g.1F(14.26.4q))}}});v.1U(B.27,v.6S);v.5e.bi=B;1a C=17(G){1a F=h(G);if(!F){18}18{cA:F.cA.1e(F),5i:F.5i.1e(F),8R:j(17(H){14.8R(H)}).1e(F),1G:j(17(H){H=!H?"1G":a(H,"+");14.2S(H)}).1e(F),2B:j(17(H){H=!H?"2B":a(H,"-");14.2S(H)}).1e(F),2S:j(17(H){if(!H||6C(1g.1F(1V(H)))){H="1G"}14.2S(H)}).1e(F),8Q:j(17(H){if(!H||v.1P(H)!="7S"){H={}}14.8Q(H)}).1e(F)}},h=17(G){1a F=1i;if(v.1P(G)=="2e"&&j(G)||v.1P(G)=="7q"){F=j(G).2s("2q")}1b{if(v.1P(G)=="17"&&(G 4x v.5e.bi)||G&&G.d7){F=G}}18 F},e=17(H,I,G){1a F=h(H);if(F){if(F.6M){18 F[G](I)}1b{18 1c}}1b{I=H;H=z}j(H).1A(17(J){if(J.6M){J[G](I)}})},a=17(G,F){if(v.1P(G)==="2e"){G=1V(G);if(6C(G)){G=G}}if(v.1P(G)==="5y"){G=F+G}18 G},x=17(G){1a F=v.$A((G||1k).f7("5f")).f4(17(H){18 q.2y(H)});l=1d;18 F},l=1c,A=17(F){18 z=j(z).52(17(G){18 G.7e()})},z=[],q={5g:"f1.0.38",2y:17(G){1a F=1i;if(3h.1r){G=j(G);if(G&&j(G).8Y("5f")){if(F=j(G).2s("2q")){18 F}1b{F=1v v.5e.bi(G,l?{bq:1d}:{});if(!F.o("bq")){F=1i;18 1c}1b{z.2a(F);18 F}}}1b{18 1c}}1b{18 x()}},29:17(F){if(3h.1r){F=(F 4x v.5e.bi)?F:(j(F)&&j(F).2s("2q")||1i);if(!F){18}z.d6(j(z).5I(F),1);F.7e()}1b{A();18}},mb:17(F){if(F){q.29(F);18 q.2y(F.id||F)}1b{A();18 x()}},mm:17(H){1a G,F=1c;if(H){G=h(H);if(G){F=G.6M}}18 F},mD:17(F){18 C(F)},8Q:17(F,G){18 e(F,G,"8Q")},5X:17(F){if(F){e(F,1i,"5X")}1b{j(z).1A(17(G){q.5X(G)})}},2S:17(F,G){if(2U!=F&&1i!=F){e(F,G,"2S")}},5i:17(F){e(F,1i,"5i")},8R:17(F,G){e(F,G,"8R")},1G:17(F,G){1a H;G=!G?"1G":a(G,"+");if(!F){F=G}1b{if(!h(F)){F=a(F,"+")}}e(F,G,"2S")},2B:17(F,G){1a H;G=!G?"2B":a(G,"-");if(!F){F=G}1b{if(!h(F)){F=a(F,"-")}}e(F,G,"2S")}};j(1k).1H("8W",17(){p=p();o=v.$1v("2Z",{"2C":"fv-ft-fs-fr"}).43(1k.4d);v.3e(1l.aA)||(1l.aA={});v.3e(1l.a8)||(1l.a8={});v.3e(1l.a3)||(1l.a3={});v.3e(1l.ap)||(1l.ap={});1a F=1l.ap.aB||1l.a3.aB||1l.a8.aB||1l.aA.aB||v.$F;F();q.2y.3y(10)});18 q})();',62,1406,'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||this|||function|return||var|else|false|true|jBind|browser|Math|items|null|container|document|window|last|loop|jCallEvent|effect|node|length|for|options|Event|new|Custom|width|p_|size|jEach|height|ieMode|containerPosition|event|abs|forward|jAddEvent|type|direction|progress|top|jSetCssProp|break|left|jTypeOf|handler|orientation|case|index|extend|parseInt|jRemoveEvent|pos|mcs|target||auto|||containerWidth||_insideOptions|prototype||stop|push|bullets|data||string|arrows|img|childNodes|distance|jGetCss|append|content|call|set|jRemove|jGetSize|scroll|animation|jFetch|touchdrag|mode|continuous|nextAngle|tagName|start|center|itemStep|backward|class|mousedrag|default|100|load|position|allSize|move_|px|transition|show|btnclick|bindEvent|lastSide|moiety|circle|jump|moveTimer|undefined|jAddClass|lastItem|firstItem|jSetCss|div||||figcaption|item||toLowerCase||||clientY|timeStamp|clientX||defined|try|style|arguments|setAttribute|parentNode|horizontal|contains|frame|changedTouches|pointerType|parseFloat|globalIndex|firstChild|on|stepDistance|jStore|catch|opacity|clearTimeout|jDelay|arr|vertical|infinite|test|fullViewedItems|loader|tap|_getItemIndex|step|enum|PI|Element|jDel|firstSide|navigator|handle|removeAttribute|getAttribute|button|oneOf|duration|lazyLoad|deltaY|deltaX|Modules|onResize|jSetOpacity|none|doneFlag||jAppendTo|||||wrapper||dragstart|Doc|array|body|parent|enable|nextPosition|canvas|jTrim|src|init|itemsFirstClones|click|J_EUID|stopDownload|Class|autoplay|mousescroll|important|magic|stopDefaults|hasOwnProperty|figure|instanceof|touchpinch|FX|getVisibleIndexes|match|reverse|dblbtnclick|scrollOnWheel|lastPosition|callback|angle|identifier|translate3d|pushToEvents|jRemoveClass|order|pow|loaded|constructor|pointerEnabled|features|display|dbltap|while|continue|webkit|sizeFirstImg|styles|J_TYPE||isMouse|filter||||state|touches|||nodeType|hide|kill|two|Scroll|MagicScroll|version|setTimeout|pause|orders|clone|mouseover|renderCarousel|replace|complete|domPrefix|listeners|drag|bottom|jGetPosition|onerror|delete|globalLength|apply|number|schema|first|padding|end|boolean|loadAll|touch|exitItems|requestAnimationFrame|indexOf|bezier|carousel|onComplete|ready|200|hold_|pause_|cubicBezier|round|cubic|radius|getDoc|_shiftContainer|trident|resize|border|activeBullet|||wheel_||floor|sin|now|offsetHeight|||jCamelize|cover|onload|messageBox|max|endItem|360|Array|IMG|margin|flow|hidden|visibility|rewind|timer|jBindAsEvent|goTo|throw|className|events|createElement|lastAngle|right|mouseup|cloneNode|timingFunction|pageX|add|isNaN|pageY|originalNodes|detach|documentElement|keyboard|overflow|absolute|_getGlobalIndex|_move|scrollReady|transitionend|uuid|MSPOINTER_TYPE_TOUCH|dragged|jGetPageXY|customEvents|queue|_calcDistance|enterItems|hashBox|visible|shift|itemsContainer||_move2|stopScroll|block|debug|_onComplete|draggable||isQueueStopped|disableEffect|J_UUID|itemsLastClones|mouseout|_sWidth|dispose|_initOnWheel|itemSettings|move|cachedCSS|render|firstItemSize|mobile|_initDragOnScroll|fromJSON|_event_prefix_|getButton|element|name|found|not|notLoaded|auto_|scale|MagicJS|captionA|update|gradientBezier|switch|insertBefore|minimum|changeClones|error|engine|disable|random|onTouchEnd|itemsVisible|correctPosition|fullScreen|byTag|ease|tooltip|onready|split|object|touchstart|touchend|oncomplete|min|prev|tm|one|tempArray|stopDistribution||itemEvent||next||threshold|dragging||searchIndex|easeFn|uaName|easing|toUpperCase|mousedown|transform|preloadItem|stopQueue|platform|MSPointerUp|onTouchStart|defaultMove|sqrt|pointerup|_handlers|_options|inline|cycles|done|alternate|timedout|showReflection|fit|targetTouches|AA|300|gecko|onStart|parseCubicBezier|nativeEvents|_event_del_|rotate|_events|previous|opera|moveSettings|containerSize|getContext|onabort|abort|flag|updateOptions|play|appendChild|onDrag|ceil|activate|domready|keydown|jHasClass|_render||action|nth|AnimationEnd|||animationstart|AnimationStart||stopWhell|linear|wheelDiff|animationend|setContainerSize|speed|continuousPause|Progress|_EVENTS_|500|toString|_timer|_unbind|_cleanup|readyState|Transition|join|storage|dblclick|hideProgress|1000|setCanvasPosition|dragend|showProgress|sizefigcaption|fromString|removeChild|startAlpha|performedOnClones|relatedTarget|pointerId|_removeClones|pointerdown|MSPointerDown|reset|pointermove|has|nodeValue|MSPointerMove|chrome|cubicBezierAtTime|checkLoadingVisibleItems|correctContainerPosition|scrollLeft|scrollTop|btnclickEvent|pStyles|pStyles_arr|tagImg|android|xhr|cancelAnimationFrame|getMatrixPosition|getRelated|classDisabled|0ms|MagicScrollExtraOptions|implement|getStorage|correctItemPosition|done2|MagicScrollMobileOptions|loopBind||||||||||||forceAnimation|Opacity|out|url|MagicScrollMobileExtraOptions|dashize|itemIndex|classHidden|wrapperPosition|createEvent|normalizeCSS|charAt|setItemStep|allNodes|off|MagicScrollOptions|beforeInit|createTextNode|_bind|lastChild|keyboardCallback|exitFullscreen|XMLHttpRequest|onprogress|callee|win|exists|onMoveStart|touchmove|onMoveEnd|coreTimeout|preloadAll|span|eventType|setPercent|setReflection|checkWholeItems|mousewheel|countTheNumberOfItems|fallback|mousemove|translateZ|checkSizes_|uaVersion|deg|_event_add_||handleMouseUp|css|onBeforeRender|_setProperties|compatMode||onTouchMove|svg|originSize|hideTimer|ban|Message|Full|getElementsByTagName|fxk|href|jGetScroll|status|text|00001|autostart||caller|addCloneContent|ifndef|onclick|checkLoadedItems|styles_arr|preloadAllFlag|getTarget|HTMLElement|showItem|deactivate|handleTouchMove|preventDefault|handleMouseDown|groupLoad|Tooltip|capable|presto|priority|calc|Number|getElementsByClassName|keyCode|concat|hideFX|typeof|maximum|previousScale|startTime|errorEventName|ignore|getBoundingClientRect|magicJS|loadedBytes|isPrimary|cssDomPrefix|slice|doc|Pltm|handleTouchEnd|mgctlbx|cssFilters|delay|deltaMode|Alpha|el_arr|https|cycle||opr|handleTouchStart|naturalWidth|disableReflection|05|stopAnimation|changeEventName|user|originheight|removeCanvas|originFontSize|QImageLoader|setItemSide|offsetTop|initBullets|onClick|setBullets|originwidth|setEvent|removeCSS|containerCssSize|registerCallback|FIGURE|_getWheelDiff|cloneFigure|_prepareClones|pagination|Effect|Function|10000px|setupArrows|0px|Options|onReady|onItemOut|onItemHover|resetZIndex|jClearEvents|checkPosition|pauseContinuous|zIndex|captionOpasity|lastItemLoad|inherit|onLazyLoad|zoom|after|depth|setupOptions|180|getImg|showCaption|Carousel|splice|indoc|entering|stopEffect|addCSS|600|caption|disableHold|Date|outside|setActiveBullet|exited|J_EXT|prevIndex|freeTouchPreload|hovered|_cleansingStyles|touchScreen||exiting|045|parseTag|jToBool|hold|03|get|addEventListener|itemCss|clientWidth|onAfterRender|webkit419|innerHTML|dispatchEvent|key_down|initEffect_|175|setMessage|Microsoft|DXImageTransform|hover|355|ios|compareDocumentPosition|stopPropagation|setProps|cancelBubble|showArrows|08|progressiveLoad|cancelFullScreen|DocumentTouch|setItemsPosition|jDefer|maxSize|request|which|onxhrerror|msExitFullscreen|requestFullScreen|hideArrows|nextSibling|parseSchema|304|999|euid|offsetWidth|easeOutCubic|fps|easeOutBack|styleFloat|easeInBack|backcompat|165|Bullets|interval|getClientXY|onreadystatechange||box|easeInCubic|getComputedStyle|easeOutQuad||easeInQuad|isReady|easeInExpo|easeOutExpo|elasticIn|easeOutSine|perspective|setOrientation|getElementById|progid|Top|Bottom|Error|xhr2|ArrowsPair|finishTime|loadBlob|Right|mjs|Left|forEach|String|timingFunctionDefault|easeInSine|PFX|bounceIn|jumpIndex|cos|onEnter|yes|onExit|showThis|inside|sheet|cssTransformProp|dragmove|v2|10px|handleMouseMove|map|cssText|_initialDistance|byClass|background|styleSheet|deleteRule|crios|_scroll|destroy|origItem|offsetLeft|removeRule|ImageLoader|pauseHover_|itemFX|rightQueue|multibackground|Moz||Object|returnValue|UUID|holder|hdn|tmp|mozCancelAnimationFrame|msc|_moveEffect||hone|od|jumpToNumber|toArray|insertRule|getTime|nativize|textnode|date|attributes|phone|stylesId|otherSize|stop_|scrollbarsWidth|relative|noimg|safari|curScale|save|wheelDelta|enabled|DOMContentLoaded|wheelDeltaY|jGetSize_|_carousel|ua|wrap|calcItemPosition|magicscroll|moz|destroyEvent|rotateX|rotateY|unbindEvent|onStop|originalClasses|detail|arrow|wheelDeltaX|blur|restore|circles|androidBrowser|backCompat|onchange|getBulletIndex|documentMode|setNewOptions|cssPrefix|firefox|getDirection|bullet|no|Webkit|setFontSize|KeyEvent|KeyboardEvent|RegExp|air|xxxx|toElement|MSPointerOut|runtime|attachEvent|collection|UIEvent|removeEventListener|gac3ac3e|xxxxxxxx|MouseEvent|isPrimaryTouch|isTouchEvent|doScroll|fromElement|regexp|xy|4xxx|getAbsoluteURL|4294967296|generateUUID|charCodeAt|jToInt|jRaiseEvent|getHashCode|toFloat|initEvent|createEventObject|rules|addRule|sort|cssRules|evaluate|setInterval|getOriginalTarget|userAgent|head|custom|fireEvent|edge|detachEvent|xxxxxxxxxxxx|yxxx|420|xpath|pointerout|fontWeight|MSPointerOver|iemobile|TransitionEvent|WebKitTransitionEvent|webkitTransitionEnd|ixi|os|palm|ob|netfront||536|midp|maemo|lge|kindle|iris|hiptop|2px|FullscreenElement|avantgo|requestFullscreen|RequestFullScreen|RequestFullscreen|FullScreen|webkitIsFullScreen|bada|fennec|fullscreenElement|blackberry|blazer|compal|elaine|ver|cssfilters|re|cancel|mozInnerScreenY|other|linux|mozRequestAnimationFrame|webkitRequestAnimationFrame|oRequestAnimationFrame|msRequestAnimationFrame|oCancelAnimationFrame|mac|webos|unknown|taintEnabled|msCancelAnimationFrame|webkitCancelRequestAnimationFrame|WebKitPoint|getBoxObjectFor|plucker|link|pocket|psp|series||||symbian|treo|up|vodafone|ActiveXObject|red|wap||windows||9999|xda|xiino|meego|msMaxTouchPoints|pointerover|jSetStyle|jGetTransitionDuration|getInnerSize|jGetFullScroll|clientTop|clientLeft|offsetParent|html|jGetRect|changeContent|innerText|enclose|replaceChild|hasChild|jGetStyle|iframe|jGetStyles|scrollWidth|srcElement|query|querySelector|fullscreenEnabled|msFullscreenEnabled|scrollHeight|jGetFullSize|DOMElement|pageYOffset|pageXOffset|clientHeight|innerHeight|innerWidth|presto925|webkitexitFullscreen|jToggleClass|maxTouchPoints|www|ontouchstart|ExitFullscreen|CancelFullScreen|Image|MSFullscreenChange|fullscreenchange|feature|MSFullscreenError|SVG11|TR|fullscreenerror|prefix|org|w3|http|currentStyle|oCancelFullScreen|getPropertyValue|lineHeight|cssFloat|float|webkitCancelFullScreen|mozCancelFullScreen|msCancelFullScreen|hasFeature|ProgressEvent|FormData|withCredentials|implementation|Width|activeElement|mmp|v3|unshift|active|change|select|submit|unload|beforeunload|readystatechange|customEventsAllowed|cloneEvents|jCopyEvents|form|Loading|keyup|100000|circle_01|circle_02|circle_03|circle_04|circle_05|circle_06|circle_07|circle_08|ShowItems|focus|keypress|pinchstart|parse|backIn|backOut|elasticOut|bounceOut|MagicToolboxTooltip|MessageBox|5000|NEGATIVE_INFINITY|POSITIVE_INFINITY|JSON|Incorrect|selectend|definition|CoverFlow|the|parameter|getJSON|isset|substring|contextmenu|DOMMouseScroll|selectstart|HTMLImageElement|count|cubicIn|fontSize|location|255|getVisibleItems|font|image|loading|drawImage|getImageData|putImageData|reflection|translateX|disabled|translateY|864|coverFlow|350|_coverFlow|01|100000000|original|calculate|Cannot|hash|continuousMove|checkEffect|bar|swap|mgctlbxN|MSC|mgctlbxV|mgctlbxL|mgctlbxP|magicsroll|white|space|nowrap|_|cssId|enter|exit|matrix3d|matrix|MAX_VALUE|0001|sizing|270|additionalTags|before|cubicOut|of|quadOut|445|roundCss|setTransition|curFrame|clearInterval|745|715|575|565||easeInOutSine|quadIn|Infinity|easeInOutQuad|455|515|955|055|675|215|easeInOutCubic|645|easeInQuart|normal|naturalHeight|685|lengthComputable|pinchupdate|delta|deltaZ|deltaFactor|000244140625|onwheel|wheel|URL|webkitURL|total|10000|static|response|537|createObjectURL|open|GET|responseType|blob|send|temporary|895|085|easeOutQuart|735|04|refresh|easeInOutBack|795|035|275|885|135|easeInOutQuint|785|easeInOutCirc|easeInOutExpo|running|075|easeOutCirc|335|easeInCirc|265||07|000001|855|easeInOutQuart|expoOut|expoIn|sineOut|easeInQuint|755|06|getInstance|sineIn|easeOutQuint'.split('|'),0,{}))
;
var Ui;
(function (Ui) {
    var ViewMode = (function () {
        function ViewMode() {
        }
        ViewMode.List = 'List';
        ViewMode.Grid = 'Grid';
        ViewMode.Swipe = 'Swipe';
        return ViewMode;
    }());
    var ListGridSwipeSwitcher = (function () {
        function ListGridSwipeSwitcher(containerSelector, gridClass, listClass, swipeClass, loadedCallback) {
            var _this = this;
            this.gridClass = gridClass;
            this.listClass = listClass;
            this.swipeClass = swipeClass;
            this.loadedCallback = loadedCallback;
            this.ViewModeCookieName = 'ViewMode';
            var self = this;
            this.listContainer = $(containerSelector)[0];
            $('#ViewSelection_Grid').click(function (e) { return _this.SwitchToGrid(e); });
            $('#ViewSelection_List').click(function (e) { return _this.SwitchToList(e); });
            $('#ViewSelection_Swipe').click(function (e) { return _this.SwitchToSwipe(e); });
            this.SetViewBasedOnCookie($.cookie(this.ViewModeCookieName));
        }
        ListGridSwipeSwitcher.prototype.SetViewBasedOnCookie = function (viewMode) {
            if (viewMode == undefined) {
                return;
            }
            if (ViewMode.Grid === viewMode) {
                this.RetrySwitchToGrid();
            }
            else if (ViewMode.Swipe === viewMode) {
                this.RetrySwitchToSwipe();
            }
            else {
                this.RetrySwitchToList();
            }
        };
        ListGridSwipeSwitcher.prototype.StoreViewInCookie = function (viewMode) {
            if (viewMode == undefined) {
                viewMode = ViewMode.List;
            }
            $.cookie(this.ViewModeCookieName, viewMode);
        };
        ListGridSwipeSwitcher.prototype.TurnAllActiveOff = function () {
            $('#ViewSelection_Grid').removeClass('active');
            $('#ViewSelection_List').removeClass('active');
            $('#ViewSelection_Swipe').removeClass('active');
        };
        ListGridSwipeSwitcher.prototype.RetrySwitchToGrid = function () {
            $('#ViewSelection_Grid').trigger('click');
        };
        ListGridSwipeSwitcher.prototype.SwitchToGrid = function (e) {
            e.preventDefault();
            this.DestroySwipe();
            if (this.SetUiToIndicateListMode('#ViewSelection_Grid', this.gridClass)) {
                this.OnComplete(ViewMode.Grid);
            }
        };
        ListGridSwipeSwitcher.prototype.OnComplete = function (viewMode) {
            this.StoreViewInCookie(viewMode);
            if (this.loadedCallback) {
                this.loadedCallback();
            }
        };
        ListGridSwipeSwitcher.prototype.RetrySwitchToList = function () {
            $('#ViewSelection_List').trigger('click');
        };
        ListGridSwipeSwitcher.prototype.SwitchToList = function (e) {
            e.preventDefault();
            this.DestroySwipe();
            if (this.SetUiToIndicateListMode('#ViewSelection_List', this.listClass)) {
                this.OnComplete(ViewMode.List);
            }
        };
        ListGridSwipeSwitcher.prototype.RetrySwitchToSwipe = function () {
            $('#ViewSelection_Swipe').trigger('click');
        };
        ListGridSwipeSwitcher.prototype.SwitchToSwipe = function (e) {
            e.preventDefault();
            if (this.SetUiToIndicateListMode('#ViewSelection_Swipe', this.swipeClass) === false) {
                return;
            }
            var self = this;
            this.OnComplete(ViewMode.Swipe);
            Outdoor.Utilities.CssManipulator.addClass(this.listContainer, 'MagicScroll');
            MagicScroll.start('category-image-scroller');
        };
        ListGridSwipeSwitcher.prototype.DestroySwipe = function () {
            MagicScroll.stop('category-image-scroller');
            Outdoor.Utilities.CssManipulator.removeClass(this.listContainer, 'MagicScroll');
        };
        ListGridSwipeSwitcher.prototype.SetUiToIndicateListMode = function (selector, activeClass) {
            var link = $(selector);
            if (link.hasClass('active')) {
                return false;
            }
            this.TurnAllActiveOff();
            link.addClass('active');
            Outdoor.Utilities.CssManipulator.removeClass(this.listContainer, this.listClass);
            Outdoor.Utilities.CssManipulator.removeClass(this.listContainer, this.gridClass);
            Outdoor.Utilities.CssManipulator.removeClass(this.listContainer, this.swipeClass);
            Outdoor.Utilities.CssManipulator.addClass(this.listContainer, activeClass);
            return true;
        };
        return ListGridSwipeSwitcher;
    }());
    Ui.ListGridSwipeSwitcher = ListGridSwipeSwitcher;
})(Ui || (Ui = {}));
//# sourceMappingURL=ListGridSwipeSwitcher.js.map;
var Outdoor;
(function (Outdoor) {
    var Utilities;
    (function (Utilities) {
        var CategoryImageAdjustor = (function () {
            function CategoryImageAdjustor() {
            }
            CategoryImageAdjustor.EnsureImageSize = function (img, width, height) {
                var url = img.src.split("?")[0] + "";
                img.src = url;
                img.height = height;
                img.width = width;
            };
            CategoryImageAdjustor.EnsureImageSizes = function (container, width, height) {
                container.find('img.c-image').each(function () { CategoryImageAdjustor.EnsureImageSize(this, width, height); });
            };
            CategoryImageAdjustor.SetImageSizesForDisplayMode = function () {
                var container = $('.c-container-root');
                if (container.hasClass('cat-gird') || container.hasClass('cat-carousel'))
                    CategoryImageAdjustor.EnsureImageSizes(container, 320, 192);
                else
                    CategoryImageAdjustor.EnsureImageSizes(container, 173, 104);
            };
            return CategoryImageAdjustor;
        }());
        Utilities.CategoryImageAdjustor = CategoryImageAdjustor;
    })(Utilities = Outdoor.Utilities || (Outdoor.Utilities = {}));
})(Outdoor || (Outdoor = {}));
//# sourceMappingURL=CategoryImageAdjustor.js.map;
function SwapToAltImage(container, previousPrefix, nextPrefix) {
    var img = container.find('.item-image:first');
    var oldImageId = img.data(previousPrefix + '-image');
    var oldImageVersion = img.data(previousPrefix + '-version');
    var oldImageSuffix = '/' + oldImageVersion + '/product/' + oldImageId + '.jpg'
    var newImageId = img.data(nextPrefix + '-image');
    var newImageVersion = img.data(nextPrefix + '-version');
    var newImageSuffix = '/' + newImageVersion + '/product/' + newImageId + '.jpg'
    var src = img.attr("src").replace(oldImageSuffix, newImageSuffix);

    img.attr("src", src);
}

function WireUpAlternateSwatchHandlers() {

    $('#ProductsContainer').on('mouseenter', '.product-color li', function () {
        var largeImage = $(this).closest('.item-row').find('.item-image').first();
        var swatch = $(this).find('img').first();
        var mainImageId = swatch.data('main-image');
        var mainImageVersion = swatch.data('main-version');
        var altImageId = swatch.data('alt-image');
        var altImageVersion = swatch.data('alt-version');
        var existingImgUrl = largeImage.attr("src");

        // Trim off the end of the current url and replace it with the new suffix by counting backwards through the slashes.
        var truncatePoint = existingImgUrl.length;
        for (var i = 3; i > 0; i--) {
            truncatePoint = existingImgUrl.lastIndexOf("/", truncatePoint - 1);
            if (truncatePoint < 0) {
                break;
            }
        }
        var mainImageUrl = existingImgUrl.substring(0, truncatePoint) + "/" + mainImageVersion + '/product/' + mainImageId + '.jpg' ;

        largeImage.data('main-image', mainImageId);
        largeImage.data('main-version', mainImageVersion);
        largeImage.data('alt-image', altImageId);
        largeImage.data('alt-version', altImageVersion);
        largeImage.attr("src", mainImageUrl);
    });
}

function WireUpProductMouseOvers() {
    if (jQuery(window).width() <= 1024)
        return;

    jQuery('.product-mouseover').hide(); // TODO: This should be handled initially via CSS on page load.

    $('#ProductsContainer').on('mouseenter', '.product-img', function () {
        jQuery(this).find('.product-mouseover').show();
        jQuery(this).find('.image img').animate({ opacity: 0.5 }, 300);
        SwapToAltImage($(this), 'main', 'alt');
    });

    $('#ProductsContainer').on('mouseleave', '.product-img', function () {
        jQuery(this).find('.product-mouseover').hide();
        jQuery(this).find('.image img').animate({ opacity: 1 }, 300);
        SwapToAltImage($(this), 'alt', 'main');
    });
}

function WireUpProductImageDraggingPrevention() {
    $('#ProductsContainer').on('dragstart', '.product-img', function (e) {
        e.preventDefault();
    });
}

function WireUpCategoryImageDraggingPrevention() {
    $('#CategoryContainer').on('dragstart', function (e) {
        e.preventDefault();
    });
}

jQuery(document).ready(function () {
    WireUpAlternateSwatchHandlers();
    WireUpProductMouseOvers();

    if ($("#ProductsContainer").is(":visible")) {
        new Ui.ListGridSwipeSwitcher('ul.c-container-root', 'product-gird', 'product-list', 'product-carousel');
        WireUpProductImageDraggingPrevention();
    }
    else {
        new Ui.ListGridSwipeSwitcher('ul.c-container-root', 'cat-gird', 'cat-list', 'cat-carousel', Outdoor.Utilities.CategoryImageAdjustor.SetImageSizesForDisplayMode);
        WireUpCategoryImageDraggingPrevention();
    }
});
;
jQuery(document).ready(function () {
    jQuery('.cat-gird li').each(function () {
        var index = jQuery(this).index();
        if ((index + 1) % 3 == 0) {
            jQuery(this).addClass('last');
        }
    });
});;

$(document).ready(function () {
    if ($('.checkout-stepform').length) {
        $('.checkout-stepform select').wrap('<div class="select-wrapper"></div>');
    }

    if ($('.basket-page').length) {
        $('.basket-page select').wrap('<div class="select-wrapper"></div>');
    }

    // Finds custom styled checkbox elements and applies CSS to them on load and change.
    var checkboxes = $(".checkbox-control input[type='checkbox']");
    if (checkboxes.length) {
        // Set the css class on load to reflect the initial state of ticked items.
        for (var i = 0; i < checkboxes.length; i++) {
            var cb = checkboxes[i];

            if (cb.checked) {
                $(cb).parent().addClass("checkbox-active");
            }
        }

        checkboxes.change(function () {
            $(this).parent().toggleClass("checkbox-active");
        })
    }

    $('.expand-content-home .js-less-more').click(function (e) {
        e.preventDefault();
        $('.expand-content-home').toggleClass('active');
        $(this).toggleClass('active');
    });

    // === Tab ===
    $('.list-tab li:first-child').addClass('active');
    $('.content-tab .item-tab:first-child').addClass('active');
    $('.list-tab a').click(function (e) {
        e.preventDefault();
        var id = $(this).attr('href');
        $('.list-tab li').removeClass('active');
        $('.content-tab .item-tab').removeClass('active');
        $(this).parent().addClass('active');
        $(id).addClass('active');
    });

    // ==== More ===
    $('.filter-checked').each(function () {
        var child = $(this).children().length;
        if (child > 6) {
            $(this).append('<span class="more-options">+ More Options</span>');
            $(this).children('li:gt(5)').hide();
        }
    });
    $('.more-options').click(function () {
        $(this).parent().children('li:gt(5)').show(200);
        $(this).hide();
    });

    // === toggle-search ==
    $('.toggle-search').click(function () {
        $('.header-search').slideToggle(200);
        $(this).toggleClass('active');
    });

    // Translate the clicks on top level menus to expansion toggles when in mobile.
    $('body').on('click', '.c-nav-1, .c-nav-2', function (e) {
        if ($('.mobile-menu').is(':visible')) {
            var expander = $(this).parent().find('.mobile-nav-category-expand:first');
            if (expander.length !== 0) { // Only prevent normal click if we have sub categories to expand, otherwise follow that link.
                e.preventDefault();
                expander.trigger('click');
            }
        }
    });

    // TODO: Following should be moved to the main menu code.
    // TODO: Check that the following handles sub sub menus.
    // The mega-menu is replaced by a burger menu in mobile. The following handles expanding the top level categories.
    $('body').on('click', '.mobile-nav-category-expand', function () {
        if ($('#menuToggle .mobile-menu').is(":visible")) {
            $(this).next().slideToggle();
            $(this).parent().toggleClass('active');
        }
    });

    // What does this do? Can we have it as part of the static markup instead of adding dynamically?
    $("#navmain .sub-nav .drop-level2,.sub-nav .drop-level3").prev('a').after('<span class="mobile-nav-category-expand"></span>');

    if ($('#ProductsContainer').length > 0) {
        // category page:

        //  $('body').append('<span class="overlay-filter"></span>');
        $('#side-category-container #TabContainer').append('<span class="close-filter"></span>');
        $(".filter-by-mb").click(function () {
            $("html").addClass("show-filter");
            var n = $("#facetTab>ul>li>div:first");
            n.is(":visible") || n.parent().find(".filterToggleArrow").trigger("click")
        }); $(".close-filter, #mobileOverlay").click(function () { $("html").removeClass("show-filter") });
        // Commented out because on mobile it causes a bug when clicking on expand, it closes it straight away.
        //$('#facetTab ul li>span').click(function () {
        //    $(this).nextAll().slideToggle(200);
        //    $(this).toggleClass('active');
        //});
        $('#facetTab ul li>label').on('click', 'input', function () {
            if ($(this).is(':checked')) {
                $(this).parent().addClass('active');
            } else {
                $(this).parent().removeClass('active');
            }
        });
    }
});

// TODO: Following are not used, clean up if Juno do not end up using them.
function openSubFilterPanel(_this) {
    $(_this).parent().parent().addClass('isOpen').parents('#side-category-container').addClass('isOpen');
}

// TODO: Following are not used, clean up if Juno do not end up using them.
function closeSubFilterPanel(_this) {
    $(_this).parents('.level0').removeClass('isOpen').parents('#side-category-container').removeClass('isOpen');
    $(_this).parent().parent().attr('style', '')
}

// offcanvas navigation -------------------------------------

// helper functions ---------------------
// http://youmightnotneedjquery.com/ - IE8+
function addClass(whichElement, className) {
    if (whichElement.classList) {
        whichElement.classList.add(className);
    } else {
        whichElement.className += ' ' + className;
    }
}

function removeClass(el, className) {
    if (el.classList) {
        el.classList.remove(className);
    } else {
        el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
    }
}

function hasParent(element, id) {
    if (element) {
        do {
            if (element.id === id) {
                return true;
            }
            if (element.nodeType === 9) {
                // root node
                break;
            }
        }
        while ((element = element.parentNode));
    }
    return false;
}

// namespace this:
var juno = {};

juno.menuToggleElem = document.getElementById("menuToggle");
if (juno.menuToggleElem) {

    juno.navigationIsRevealed = false;

    document.getElementById("mobileClose").addEventListener("click", function (e) {

        // hide navigation:
        removeClass(document.documentElement, "offCanvas");
        juno.navigationIsRevealed = false;
        juno.menuToggleElem.setAttribute('aria-expanded', false);
        if (e) {
            e.preventDefault();
        }
    }, false);


    // toggle with the menu button:
    juno.menuToggleElem.addEventListener("click", function (e) {

        juno.checkToggleNavigation();
        if (e) {
            e.preventDefault();
        }
    }, false);

    // add ARIA attributes to help:
    juno.menuToggleElem.setAttribute('aria-expanded', false);
    juno.menuToggleElem.setAttribute('aria-controls', 'navigation');

    juno.checkToggleNavigation = function () {
        if (juno.navigationIsRevealed) {
            // hide navigation:
            removeClass(document.documentElement, "offCanvas");
            juno.navigationIsRevealed = false;
            juno.menuToggleElem.setAttribute('aria-expanded', false);
        } else {
            // reveal navigation:
            addClass(document.documentElement, "offCanvas");
            juno.navigationIsRevealed = true;
            juno.menuToggleElem.setAttribute('aria-expanded', true);
            document.querySelector("#navmain").focus();
        }
    };

    juno.checkCloseNavigation = function (e) {
        if (juno.navigationIsRevealed) {
            // check it's not the menu icon itself as this will trigger independently (and would cause the event to be fired twice)
            if (e.target.id != "menuToggle") {
                // check the click isn't within the nav panel:
                if (!hasParent(e.target, 'navmain')) {
                    // hide navigation:
                    removeClass(document.documentElement, "offCanvas");
                    juno.navigationIsRevealed = false;
                    juno.menuToggleElem.setAttribute('aria-expanded', false);
                    e.preventDefault();
                }
            }
            if ($('body').hasClass('show-filter')) {
                console.log("yup");
                if (!hasParent(e.target, 'side-category-container')) {
                    // hide filters:
                    $('body').removeClass('show-filter');
                    e.preventDefault();
                }
            }
        }
    };

    // close by touching the visible part of the content:
    document.addEventListener("click", function (e) {

        juno.checkCloseNavigation(e);

    }, true);
    // double up for mobile event:
    document.addEventListener("touchend", function (e) {

        juno.checkCloseNavigation(e);

    });
    juno.swipeLeft = function () {
        if (juno.navigationIsRevealed) {
            removeClass(document.documentElement, "offCanvas");
            juno.navigationIsRevealed = false;
            juno.menuToggleElem.setAttribute('aria-expanded', false);
        }
        if ($('body').hasClass('show-filter')) {
            $('body').removeClass('show-filter');
        }
    };

    // init touch:
    if ("ontouchstart" in document.documentElement) {
        document.body.addEventListener("touchstart", function (a) {
            startPointX = a.touches[0].pageX;
            startPointY = a.touches[0].pageY;
            isScrolling = "";
            deltaX = 0;
        }, false);
        document.body.addEventListener("touchmove", function (a) {
            if (a.touches.length > 1 || a.scale && a.scale !== 1) {
                return;
            }
            deltaX = a.touches[0].pageX - startPointX;
            if (isScrolling === "") {
                isScrolling = (isScrolling || Math.abs(deltaX) < Math.abs(a.touches[0].pageY - startPointY));
            }
            if (!isScrolling) {
                a.preventDefault();
            }
        }, false);
        document.body.addEventListener("touchend", function (a) {
            if (!isScrolling) {
                if ((Math.abs(deltaX)) > 100) {
                    if (deltaX < 0) {
                        juno.swipeLeft();
                    } else {
                        // juno.swipeRight();
                    }
                }
            }
        }, false);
    }
}



;
//# sourceMappingURL=IAddress.js.map;
//# sourceMappingURL=IAddressLookupResult.js.map;
//# sourceMappingURL=ICodeStock.js.map;
//# sourceMappingURL=IColourStock.js.map;
//# sourceMappingURL=ICountry.js.map;
//# sourceMappingURL=IDeliveryService.js.map;
var Outdoor;
(function (Outdoor) {
    var Pages;
    (function (Pages) {
        var Returns;
        (function (Returns) {
            var ExchangeTypeCodes;
            (function (ExchangeTypeCodes) {
                ExchangeTypeCodes[ExchangeTypeCodes["exchangeTypeNotSet"] = undefined] = "exchangeTypeNotSet";
                ExchangeTypeCodes[ExchangeTypeCodes["exchangeTypeSame"] = 1] = "exchangeTypeSame";
                ExchangeTypeCodes[ExchangeTypeCodes["exchangeTypeDifferent"] = 2] = "exchangeTypeDifferent";
                ExchangeTypeCodes[ExchangeTypeCodes["exchangeTypeDifferentColour"] = 3] = "exchangeTypeDifferentColour";
                ExchangeTypeCodes[ExchangeTypeCodes["exchangeTypeDifferentSize"] = 4] = "exchangeTypeDifferentSize";
            })(ExchangeTypeCodes = Returns.ExchangeTypeCodes || (Returns.ExchangeTypeCodes = {}));
        })(Returns = Pages.Returns || (Pages.Returns = {}));
    })(Pages = Outdoor.Pages || (Outdoor.Pages = {}));
})(Outdoor || (Outdoor = {}));
//# sourceMappingURL=IExchangeType.js.map;
//# sourceMappingURL=IReturnProduct.js.map;
//# sourceMappingURL=IReturnReason.js.map;
//# sourceMappingURL=ISizeStock.js.map;
var Outdoor;
(function (Outdoor) {
    var Pages;
    (function (Pages) {
        var Returns;
        (function (Returns) {
            var PostalCodeLookup = (function () {
                function PostalCodeLookup() {
                }
                PostalCodeLookup.Lookup = function (searchTerm, resultsCallback, lastId) {
                    var _this = this;
                    if (lastId === void 0) { lastId = null; }
                    if (!searchTerm)
                        return;
                    var scriptUrl = this.generateFindApiUrl(searchTerm, resultsCallback, lastId);
                    var injectedScript = Outdoor.Utilities.DeferredLoader.InjectScript(scriptUrl, function () { return _this.removeScriptAfterLoading(injectedScript); });
                };
                PostalCodeLookup.RetrieveById = function (id, resultsCallback) {
                    var _this = this;
                    var scriptUrl = this.generateRetrieveUrl(null, resultsCallback, id);
                    var injectedScript = Outdoor.Utilities.DeferredLoader.InjectScript(scriptUrl, function () { return _this.removeScriptAfterLoading(injectedScript); });
                };
                PostalCodeLookup.removeScriptAfterLoading = function (script) {
                    script.parentElement.removeChild(script);
                };
                PostalCodeLookup.generateFindApiUrl = function (searchTerm, resultsCallback, container) {
                    if (container === void 0) { container = null; }
                    var url = "https://services.postcodeanywhere.co.uk/Capture/Interactive/Find/v1.00/json3ex.ws";
                    url += "?Key=" + encodeURIComponent('GU91-ZU15-HE91-CE62');
                    url += "&Text=" + encodeURIComponent(searchTerm);
                    url += "&Origin=GBR";
                    url += "&Language=en";
                    if (container !== null)
                        url += "&Container=" + encodeURIComponent(container);
                    url += "&callback=" + resultsCallback;
                    return url;
                };
                PostalCodeLookup.generateRetrieveUrl = function (searchTerm, resultsCallback, lastId) {
                    var url = "https://services.postcodeanywhere.co.uk/Capture/Interactive/Retrieve/v1.00/json3ex.ws";
                    url += "?Key=" + encodeURIComponent('GU91-ZU15-HE91-CE62');
                    url += "&Id=" + encodeURIComponent(lastId);
                    url += "&callback=" + resultsCallback;
                    return url;
                };
                return PostalCodeLookup;
            }());
            Returns.PostalCodeLookup = PostalCodeLookup;
        })(Returns = Pages.Returns || (Pages.Returns = {}));
    })(Pages = Outdoor.Pages || (Outdoor.Pages = {}));
})(Outdoor || (Outdoor = {}));
//# sourceMappingURL=PostalCodeLookup.js.map;
var Outdoor;
(function (Outdoor) {
    var Pages;
    (function (Pages) {
        var Returns;
        (function (Returns) {
            var addressModeDisplay = 'display';
            var addressModeSearch = 'search';
            var addressModeReview = 'review';
            var addressModeEdit = 'edit';
            var ReturnOrderViewModel = (function () {
                function ReturnOrderViewModel() {
                    var _this = this;
                    this.addressMode = ko.observable(addressModeDisplay);
                    this.addressSearchText = ko.observable('');
                    this.addressSearchResults = ko.observableArray();
                    this.addressSearchMessage = ko.observable('');
                    this.balance = ko.observable(0);
                    this.balanceNonGbp = ko.observable(0);
                    this.busy = ko.observable(false);
                    this.countries = ko.observableArray();
                    this.currencySymbol = ko.observable('£');
                    this.currentProductIndex = ko.observable(0);
                    this.dateOfOrder = ko.observable();
                    this.deliveryAddress = ko.observable();
                    this.deliveryServices = ko.observableArray();
                    this.deliveryStore = ko.observable('');
                    this.deliveryStores = ko.observableArray();
                    this.deliveryType = ko.observable('');
                    this.discountRemoved = ko.observable(0);
                    this.discountRemovedFormatted = ko.observable('');
                    this.errors = ko.observableArray();
                    this.itemExchangeTotal = ko.observable(0);
                    this.itemExchangeTotalFormatted = ko.observable('');
                    this.itemReturnTotal = ko.observable(0);
                    this.itemReturnTotalFormatted = ko.observable('');
                    this.itemTotal = ko.observable(0);
                    this.itemTotalFormatted = ko.observable('');
                    this.orderDate = ko.observable('');
                    this.orderPrefix = ko.observable('');
                    this.orderSuffix = ko.observable('');
                    this.pendingAddress = ko.observable();
                    this.postCode = ko.observable('');
                    this.products = ko.observableArray();
                    this.reasonsFaulty = ko.observableArray();
                    this.reasonsGood = ko.observableArray();
                    this.refundShippingAmount = ko.observable(0);
                    this.refundShippingAmountFormatted = ko.observable('');
                    this.step = ko.observable('enter-order-number');
                    this.addressSearchText
                        .extend({ rateLimit: 200, method: "notifyWhenChangesStop" })
                        .subscribe(function () { return _this.addressLookup(); });
                    this.actionedProducts = ko.computed(function () {
                        return ko.utils.arrayFilter(_this.products(), function (item) {
                            return item.action() != '';
                        });
                    });
                    this.completedProductCount = ko.computed(function () {
                        var completed = ko.utils.arrayFilter(_this.actionedProducts(), function (item) {
                            return item.stepComplete();
                        });
                        return completed.length;
                    });
                    this.currentProduct = ko.computed(function () {
                        if (_this.actionedProducts().length === 0)
                            return null;
                        var index = _this.currentProductIndex();
                        if (index >= _this.actionedProducts().length)
                            index = _this.actionedProducts().length - 1;
                        return _this.actionedProducts()[index];
                    });
                    this.deliveryService = ko.computed(function () {
                        for (var i = 0; i < _this.deliveryServices().length; i++) {
                            if (_this.deliveryType() === _this.deliveryServices()[i].deliveryType) {
                                return _this.deliveryServices()[i];
                            }
                        }
                        return null;
                    });
                    this.deliveryCost = ko.computed(function () {
                        var service = _this.deliveryService();
                        if (service == null) {
                            return 0;
                        }
                        if (_this.currencySymbol() === '£') {
                            return service.price;
                        }
                        return service.nonGbpPrice;
                    });
                    this.orderNumber = ko.pureComputed({
                        read: function () {
                            return _this.orderPrefix() + '-' + _this.orderDate() + '-' + _this.orderSuffix();
                        },
                        write: function (value) {
                            _this.orderDate('');
                            _this.orderPrefix('');
                            _this.orderSuffix('');
                            if (!value) {
                                return;
                            }
                            var split = value.split('-');
                            if (split.length !== 3) {
                                return;
                            }
                            _this.orderDate(split[1]);
                            _this.orderPrefix(split[0]);
                            _this.orderSuffix(split[2]);
                        },
                        owner: this
                    });
                    this.deliveryStore.subscribe(function (value) { return _this.SetDeliveryToStoreAddress(value); });
                    this.deliveryType.subscribe(function (value) { return _this.closeAddressEditorWhenSwitchingToStore(value); });
                    this.deliveryType.subscribe(function (previousValue) { return _this.openAddressEditorWhenSwitchingFromStore(previousValue); }, this, "beforeChange");
                    this.orderHasExchanges = ko.computed(function () {
                        for (var i = 0; i < _this.actionedProducts().length; i++) {
                            if (_this.actionedProducts()[i].showExchangeOptions())
                                return true;
                        }
                        return false;
                    });
                    this.orderTotal = ko.computed(function () {
                        if (_this.currencySymbol() === '£') {
                            return _this.balance() + _this.deliveryCost();
                        }
                        return _this.balanceNonGbp() + _this.deliveryCost();
                    });
                    this.processing = ko.computed(function () {
                        if (_this.busy())
                            return true;
                        var products = ko.utils.arrayFilter(_this.actionedProducts(), function (item) {
                            return item.processing();
                        });
                        return products.length > 0;
                    });
                    this.initialiseClientRoutes();
                    this.setOrderNumberFromQuerystring();
                }
                ReturnOrderViewModel.prototype.formatAddress = function (address, separator) {
                    if (!address)
                        return '';
                    var lines = this.splitAddress(address);
                    return lines.join(separator);
                };
                ReturnOrderViewModel.prototype.splitAddress = function (address) {
                    var lines = [];
                    if (!address)
                        return lines;
                    if (address.shipTo())
                        lines.push(address.shipTo());
                    if (address.company())
                        lines.push(address.company());
                    if (address.line1())
                        lines.push(address.line1());
                    if (address.line2())
                        lines.push(address.line2());
                    if (address.district())
                        lines.push(address.district());
                    if (address.city())
                        lines.push(address.city());
                    if (address.county())
                        lines.push(address.county());
                    if (address.countryName())
                        lines.push(address.countryName());
                    if (address.postalCode())
                        lines.push(address.postalCode());
                    return lines;
                };
                ReturnOrderViewModel.prototype.descriptionForReason = function (reasonCode, faultLocation, faultyDescription) {
                    if (reasonCode === undefined || reasonCode === '')
                        return '';
                    if (reasonCode === 'Y') {
                        return 'Fault (other): ' + faultLocation + ' / ' + faultyDescription;
                    }
                    for (var i = 0; i < this.reasonsFaulty().length; i++) {
                        if (this.reasonsFaulty()[i].reasonCode === reasonCode) {
                            return this.reasonsFaulty()[i].description;
                        }
                    }
                    for (var i = 0; i < this.reasonsGood().length; i++) {
                        if (this.reasonsGood()[i].reasonCode === reasonCode)
                            return this.reasonsGood()[i].description;
                    }
                    return '';
                };
                ReturnOrderViewModel.prototype.orderNumberLookup = function () {
                    var _this = this;
                    var constraints = {
                        OrderDate: {
                            presence: true,
                            numericality: {
                                onlyInteger: true,
                                greaterThan: 10115
                            },
                            length: { is: 6 }
                        },
                        OrderPrefix: { presence: true, format: { pattern: /O[lr]1/gi }, },
                        OrderSuffix: {
                            presence: true,
                            numericality: {
                                onlyInteger: true,
                                greaterThan: 4000
                            },
                            length: { minimum: 6, maximum: 7 }
                        },
                        PostCode: { presence: true }
                    };
                    var form = document.getElementById("returns-order-number");
                    var formValid = Outdoor.Utilities.ValidateSetup.validateForm(form, constraints);
                    if (formValid) {
                        var json = ko.toJSON({ orderNumber: this.orderNumber(), postCode: this.postCode() });
                        this.busy(true);
                        Outdoor.Utilities.HttpRequest.PostJson('/returns/lookup-order-number', json, function (data) { _this.onOrderDetailsReceived(data); }, function (data) { _this.postError(data); });
                    }
                    return false;
                };
                ReturnOrderViewModel.prototype.atFinalItemEntry = function () {
                    if (this.currentProductIndex() >= this.actionedProducts().length - 1)
                        return true;
                    return false;
                };
                ReturnOrderViewModel.prototype.allItemsEntered = function () {
                    if (this.currentProductIndex() >= this.actionedProducts().length - 1)
                        return true;
                    return false;
                };
                ReturnOrderViewModel.prototype.showReturnDetails = function (data, event) {
                    this.navigateToStep('enter-details');
                    this.currentProductIndex(0);
                };
                ;
                ReturnOrderViewModel.prototype.nextReturnItem = function () {
                    if (this.currentProduct().stepComplete() === true) {
                        this.currentProduct().returnConfirmedByUser(true);
                        var index = this.currentProductIndex();
                        if (index < this.actionedProducts().length - 1) {
                            this.currentProductIndex(index + 1);
                        }
                        else {
                            this.requestDeliveryOptions();
                        }
                    }
                    else {
                        this.currentProduct().showValidationErrors(true);
                    }
                };
                ReturnOrderViewModel.prototype.requestDeliveryOptions = function () {
                    var _this = this;
                    var json = ko.toJSON({
                        deliveryAddress: this.deliveryAddress(),
                        deliveryType: this.deliveryType(),
                        orderNumber: this.orderNumber(),
                        products: this.actionedProducts().map(function (product) {
                            return {
                                exchangePosCode: product.exchangePosCode(),
                                orderItemShardId: product.orderItemShardId,
                                returnDescription: product.reasonFaultyText,
                                returnFaultLocation: product.returnFaultLocation,
                                returnPosCode: product.posCode,
                                returnReasonCode: product.reasonCode,
                            };
                        })
                    });
                    this.busy(true);
                    Outdoor.Utilities.HttpRequest.PostJson('/returns/calculate-cost', json, function (data) { _this.onCostsReceived(data); }, function (data) { _this.postError(data); });
                };
                ReturnOrderViewModel.prototype.onCostsReceived = function (data) {
                    var json = JSON.parse(data);
                    if (!this.errorHandled(data)) {
                        this.populateDeliveryOptionsAndCosts(json);
                        this.navigateToStep('return-confirmation');
                    }
                    this.busy(false);
                };
                ReturnOrderViewModel.prototype.addressModeDisplayCanBeEdited = function () {
                    return (this.addressMode() === addressModeDisplay && !this.deliveryTypeIsStore(this.deliveryType()));
                };
                ReturnOrderViewModel.prototype.deliveryTypeIsStore = function (deliveryType) {
                    return (deliveryType === 'Store');
                };
                ReturnOrderViewModel.prototype.confirmReturn = function () {
                    var _this = this;
                    if (this.orderHasExchanges()) {
                        if (this.deliveryTypeIsStore(this.deliveryType()) && this.deliveryStore() === '') {
                            alert('You have selected collect in store but have not chosen a store for delivery.');
                            return;
                        }
                        if (!this.deliveryAddressIsValid()) {
                            alert('Please enter at least the first line and postal code for the delivery address.');
                            this.pendingAddress(this.deliveryAddress());
                            this.enterAddressEditMode();
                            return;
                        }
                    }
                    var json = ko.toJSON({
                        deliveryAddress: this.deliveryAddress(),
                        deliveryStore: this.deliveryStore(),
                        deliveryType: this.deliveryType(),
                        orderNumber: this.orderNumber(),
                        postCode: this.postCode(),
                        products: this.actionedProducts().map(function (product) {
                            return {
                                exchangePosCode: product.exchangePosCode(),
                                orderItemShardId: product.orderItemShardId,
                                returnDescription: product.reasonFaultyText,
                                returnFaultLocation: product.returnFaultLocation,
                                returnPosCode: product.posCode,
                                returnReasonCode: product.reasonCode,
                            };
                        })
                    });
                    this.busy(true);
                    Outdoor.Utilities.HttpRequest.PostJson('/returns/create-return', json, function (data) { _this.onCreateReturnReceived(data); }, function (data) { _this.postError(data); });
                };
                ReturnOrderViewModel.prototype.onCreateReturnReceived = function (data) {
                    var json = JSON.parse(data);
                    if (json.redirectUrl) {
                        window.location.replace(json.redirectUrl);
                    }
                };
                ReturnOrderViewModel.prototype.stepBackInDetails = function () {
                    if (this.currentProductIndex() === 0) {
                        this.navigateToStep('select-items');
                    }
                    else {
                        this.currentProductIndex(this.currentProductIndex() - 1);
                    }
                };
                ReturnOrderViewModel.prototype.stepBackFromConfirmation = function () {
                    this.navigateToStep('enter-details');
                };
                ReturnOrderViewModel.prototype.stepBackToSelectItems = function () {
                    this.navigateToStep('select-items');
                };
                ReturnOrderViewModel.prototype.onOrderDetailsReceived = function (data) {
                    var json = JSON.parse(data);
                    if (!this.errorHandled(data)) {
                        this.convertOrderIntoObservable(json);
                        if (json.products.length === 0) {
                            this.navigateToStep('order-unavailable');
                        }
                        else {
                            this.navigateToStep('select-items');
                        }
                    }
                    this.busy(false);
                };
                ReturnOrderViewModel.prototype.updatedProductFromList = function (list, posCode) {
                    for (var i = 0; i < list.length; i++) {
                        var updatedProduct = list[i];
                        if (updatedProduct.posCode === posCode) {
                            return updatedProduct;
                        }
                    }
                    return null;
                };
                ReturnOrderViewModel.prototype.populateDeliveryOptionsAndCosts = function (data) {
                    this.deliveryServices.removeAll();
                    for (var i = 0; i < data.deliveryServices.length; i++) {
                        this.deliveryServices.push(data.deliveryServices[i]);
                    }
                    this.deliveryStores(data.deliveryStores);
                    if (this.deliveryType() === '') {
                        this.deliveryType(data.suggestedDeliveryType);
                        if (data.originalDeliveryStore) {
                            this.deliveryStore(data.originalDeliveryStore);
                        }
                    }
                    for (var p = 0; p < this.actionedProducts().length; p++) {
                        var product_1 = this.actionedProducts()[p];
                        var originalProduct = this.updatedProductFromList(data.originalItemPrices, product_1.posCode);
                        if (originalProduct !== null) {
                            product_1.formattedPrice(originalProduct.priceFormatted);
                        }
                        if (product_1.action() === Outdoor.Pages.Returns.exchangeActionExchange) {
                            var updatedProduct = this.updatedProductFromList(data.exchangedProducts, product_1.exchangePosCode());
                            if (updatedProduct !== null) {
                                product_1.exchangePriceFormatted(updatedProduct.priceFormatted);
                                product_1.populateColours(updatedProduct.colours);
                            }
                        }
                    }
                    this.currencySymbol(data.currencySymbol);
                    this.itemExchangeTotal(data.itemExchangeTotal);
                    this.itemExchangeTotalFormatted(data.itemExchangeTotalFormatted);
                    this.itemReturnTotal(data.itemReturnTotal);
                    this.itemReturnTotalFormatted(data.itemReturnTotalFormatted);
                    this.itemTotal(data.itemTotal);
                    this.itemTotalFormatted(data.itemTotalFormatted);
                    this.discountRemoved(data.discountRemoved);
                    this.discountRemovedFormatted(data.discountRemovedFormatted);
                    this.refundShippingAmount(data.refundShippingAmount);
                    this.refundShippingAmountFormatted(data.refundShippingAmountFormatted);
                    this.balance(data.balance);
                    this.balanceNonGbp(data.balanceNonGbp);
                };
                ReturnOrderViewModel.prototype.convertOrderIntoObservable = function (json) {
                    var _this = this;
                    this.countries.removeAll();
                    for (var i = 0; i < json.countries.length; i++) {
                        this.countries.push(json.countries[i]);
                    }
                    this.dateOfOrder(json.dateOfOrder);
                    this.defaultCountryCode3 = json.defaultCountryCode3;
                    this.deliveryAddress(this.observableAddressFromJson(json.deliveryAddress));
                    this.orderNumber(json.orderNumber);
                    this.reasonsGood.removeAll();
                    for (var i = 0; i < json.reasonsGood.length; i++) {
                        this.reasonsGood.push(json.reasonsGood[i]);
                    }
                    this.reasonsFaulty.removeAll();
                    for (var i = 0; i < json.reasonsFaulty.length; i++) {
                        this.reasonsFaulty.push(json.reasonsFaulty[i]);
                    }
                    this.pendingAddress(this.observableAddressFromJson(json.deliveryAddress));
                    this.pendingAddress().countryCode3.subscribe(function () { return _this.onPendingAddressCountryChanged(); });
                    this.products.removeAll();
                    for (var i = 0; i < json.products.length; i++) {
                        var product_2 = new Returns.ReturnProduct(json.products[i], i, json.orderNumber, this.deliveryAddress().postalCode(), this.deliveryAddress().countryCode3());
                        this.products.push(product_2);
                    }
                    this.storeAddresses = json.storeAddresses;
                };
                ReturnOrderViewModel.prototype.observableAddressFromJson = function (jsonAddress) {
                    var address = {
                        addressId: jsonAddress.addressId,
                        city: ko.observable(jsonAddress.city),
                        company: ko.observable(jsonAddress.company),
                        countryCode3: ko.observable(jsonAddress.countryCode3),
                        countryName: ko.observable(jsonAddress.countryName),
                        county: ko.observable(jsonAddress.county),
                        district: ko.observable(jsonAddress.district),
                        line1: ko.observable(jsonAddress.line1),
                        line2: ko.observable(jsonAddress.line2),
                        postalCode: ko.observable(jsonAddress.postalCode),
                        shipTo: ko.observable(jsonAddress.shipTo)
                    };
                    return address;
                };
                ReturnOrderViewModel.prototype.blankAddress = function () {
                    return this.observableAddressFromJson({
                        addressId: '',
                        city: '',
                        company: '',
                        countryCode3: this.defaultCountryCode3,
                        countryName: 'United Kingdom',
                        county: '',
                        district: '',
                        line1: '',
                        line2: '',
                        postalCode: '',
                        shipTo: ''
                    });
                };
                ReturnOrderViewModel.prototype.onPendingAddressCountryChanged = function () {
                    if (this.defaultCountryCode3 !== this.pendingAddress().countryCode3() && this.addressMode() === addressModeSearch)
                        this.addressMode(addressModeEdit);
                };
                ReturnOrderViewModel.prototype.isCurrentProduct = function (index) {
                    return index === this.currentProductIndex();
                };
                ReturnOrderViewModel.prototype.postError = function (data) {
                    this.errorHandled(data);
                };
                ReturnOrderViewModel.prototype.errorHandled = function (data) {
                    var json = JSON.parse(data);
                    this.errors.removeAll();
                    if (json.errors && json.errors.length) {
                        for (var i = 0; i < json.errors.length; i++) {
                            this.errors.push(json.errors[i].message);
                        }
                    }
                    else
                        return false;
                    return true;
                };
                ReturnOrderViewModel.prototype.addressLookup = function () {
                    Returns.PostalCodeLookup.Lookup(this.addressSearchText(), "returnsvm.processAddressLookupResponse");
                };
                ReturnOrderViewModel.prototype.closeAddressEditorWhenSwitchingToStore = function (value) {
                    if (this.deliveryTypeIsStore(value)) {
                        this.addressMode(addressModeDisplay);
                        this.SetDeliveryToStoreAddress(this.deliveryStore());
                    }
                };
                ReturnOrderViewModel.prototype.openAddressEditorWhenSwitchingFromStore = function (previousValue) {
                    if (this.deliveryTypeIsStore(previousValue)) {
                        this.enterSearchAddressMode();
                        this.deliveryAddress(this.blankAddress());
                    }
                };
                ReturnOrderViewModel.prototype.SetDeliveryToStoreAddress = function (deliveryStore) {
                    if (!this.storeAddresses) {
                        return;
                    }
                    for (var i = 0; i < this.storeAddresses.length; i++) {
                        var storeAddress = this.storeAddresses[i];
                        if (storeAddress.addressId == deliveryStore) {
                            var address = this.observableAddressFromJson(storeAddress);
                            this.deliveryAddress(address);
                            this.setDeliveryAddressForAllExchanges(address.postalCode(), address.countryCode3());
                            return;
                        }
                    }
                };
                ReturnOrderViewModel.prototype.deliveryAddressIsValid = function () {
                    if (!this.orderHasExchanges()) {
                        return true;
                    }
                    if (!this.deliveryAddress().line1()) {
                        return false;
                    }
                    if (!this.deliveryAddress().postalCode()) {
                        return false;
                    }
                    return true;
                };
                ReturnOrderViewModel.prototype.processAddressLookupResponse = function (response) {
                    this.addressSearchResults.removeAll();
                    if (response.Items.length == 1 && typeof (response.Items[0].Error) != "undefined") {
                        this.addressSearchMessage(response.Items[0].Description);
                    }
                    else {
                        if (response.Items.length == 0) {
                            this.addressSearchMessage('We could not find any matching addresses.');
                        }
                        else {
                            if (response.Items.length > 10)
                                this.addressSearchMessage(response.Items.length + ' matches. Please type more of the address to refine your results.');
                            else
                                this.addressSearchMessage('');
                            for (var i = 0; i < response.Items.length; i++) {
                                var item = response.Items[i];
                                this.addressSearchResults.push({
                                    description: item.Description,
                                    id: item.Id,
                                    type: item.Type,
                                    text: item.Text
                                });
                            }
                        }
                    }
                };
                ReturnOrderViewModel.prototype.selectRetrievedAddress = function (response) {
                    var addressRow = response.Items[0];
                    var address = {
                        addressId: '',
                        city: ko.observable(addressRow.City),
                        company: ko.observable(addressRow.Company),
                        countryCode3: ko.observable(returnsvm.defaultCountryCode3),
                        countryName: ko.observable(addressRow.CountryName),
                        county: ko.observable(addressRow.Province),
                        district: ko.observable(addressRow.District),
                        line1: ko.observable(addressRow.Line1),
                        line2: ko.observable(addressRow.Line2),
                        postalCode: ko.observable(addressRow.PostalCode),
                        shipTo: ko.observable(returnsvm.deliveryAddress().shipTo())
                    };
                    returnsvm.pendingAddress(address);
                };
                ReturnOrderViewModel.prototype.selectDeliveryAddress = function (addressResult) {
                    if (addressResult.type === 'Address') {
                        Returns.PostalCodeLookup.RetrieveById(addressResult.id, "returnsvm.selectRetrievedAddress");
                        this.addressMode(addressModeReview);
                    }
                    else {
                        Returns.PostalCodeLookup.Lookup(addressResult.text, "returnsvm.processAddressLookupResponse", addressResult.id);
                    }
                    this.addressSearchResults.removeAll();
                };
                ReturnOrderViewModel.prototype.countryNameByCode3 = function (countryCode3) {
                    for (var i = 0; i < this.countries().length; i++) {
                        if (this.countries()[i].countryCode3 === countryCode3)
                            return this.countries()[i].name;
                    }
                    return '';
                };
                ReturnOrderViewModel.prototype.applyPendingAddress = function () {
                    var countryCode3 = this.pendingAddress().countryCode3();
                    this.pendingAddress().countryName(this.countryNameByCode3(countryCode3));
                    this.deliveryAddress(this.pendingAddress());
                    this.setDeliveryAddressForAllExchanges(this.deliveryAddress().postalCode(), countryCode3);
                    this.addressMode(addressModeDisplay);
                    this.requestDeliveryOptions();
                };
                ReturnOrderViewModel.prototype.enterAddressEditMode = function () {
                    this.addressMode(addressModeEdit);
                };
                ReturnOrderViewModel.prototype.enterDeliveryAddress = function () {
                    this.addressMode(addressModeEdit);
                    this.pendingAddress(this.deliveryAddress());
                };
                ReturnOrderViewModel.prototype.enterSearchAddressMode = function () {
                    if (this.defaultCountryCode3 === this.deliveryAddress().countryCode3()) {
                        this.addressSearchResults.removeAll();
                        this.addressSearchText('');
                        this.addressSearchMessage('Start typing the delivery postcode:');
                        this.addressMode(addressModeSearch);
                    }
                    else {
                        this.enterAddressEditMode();
                        this.pendingAddress(this.deliveryAddress());
                    }
                };
                ReturnOrderViewModel.prototype.removeCurrentItem = function (vm) {
                    vm.currentProduct().action('');
                    if (vm.actionedProducts().length === 0) {
                        vm.navigateToStep('select-items');
                        return;
                    }
                    this.requestDeliveryOptions();
                };
                ReturnOrderViewModel.prototype.removeItem = function (vm, item) {
                    item.action('');
                    if (vm.actionedProducts().length === 0) {
                        vm.navigateToStep('select-items');
                        return;
                    }
                    this.requestDeliveryOptions();
                };
                ReturnOrderViewModel.prototype.formatDelivery = function (deliveryService) {
                    if (deliveryService.price === 0) {
                        return deliveryService.description;
                    }
                    var ukFormat = "£" + deliveryService.price.toFixed(2);
                    if (this.currencySymbol() === '£') {
                        return deliveryService.description + " " + ukFormat;
                    }
                    var nonGbp = deliveryService.description + " " + this.currencySymbol() + deliveryService.nonGbpPrice.toFixed(2);
                    return nonGbp + " (" + ukFormat + ")";
                };
                ReturnOrderViewModel.prototype.formatPriceLine = function (price, nonGbpPrice) {
                    var ukFormat = "£" + price.toFixed(2);
                    if (this.currencySymbol() === '£') {
                        return ukFormat;
                    }
                    var nonGbp = this.currencySymbol() + nonGbpPrice.toFixed(2);
                    return nonGbp + " (" + ukFormat + ")";
                };
                ReturnOrderViewModel.prototype.formatDeliveryCost = function () {
                    var service = this.deliveryService();
                    if (service == null) {
                        return "";
                    }
                    return this.formatPriceLine(service.price, service.nonGbpPrice);
                };
                ReturnOrderViewModel.prototype.formatOrderTotal = function () {
                    var deliveryService = this.deliveryService();
                    var deliveryCost = 0, deliveryCostNonGbp = 0;
                    if (deliveryService !== null) {
                        deliveryCost = deliveryService.price;
                        deliveryCostNonGbp = deliveryService.nonGbpPrice;
                    }
                    var ukPrice = Math.abs(this.balance() + deliveryCost);
                    var nonGbpPrice = Math.abs(this.balanceNonGbp() + deliveryCostNonGbp);
                    return this.formatPriceLine(ukPrice, nonGbpPrice);
                };
                ReturnOrderViewModel.prototype.formatPrice = function (price) {
                    if (price < 0) {
                        price = Math.abs(price);
                    }
                    return "£" + price.toFixed(2);
                };
                ReturnOrderViewModel.prototype.refundTotalLabel = function () {
                    return (this.orderTotal() < 0) ? "Refund due:" : "Payment required:";
                };
                ReturnOrderViewModel.prototype.navigateToStep = function (step) {
                    location.hash = step;
                };
                ReturnOrderViewModel.prototype.colourAvailabilityText = function (item) {
                    var description = item.description;
                    if (!item.enabled()) {
                        description += ' - Out of stock in this colour';
                    }
                    if (item.formattedPrice) {
                        description += ' (' + item.formattedPrice + ')';
                    }
                    return description;
                };
                ReturnOrderViewModel.prototype.enableColours = function (option, item) {
                    if (item !== undefined) {
                        ko.applyBindingsToNode(option, { disable: !item.enabled() }, item);
                    }
                };
                ;
                ReturnOrderViewModel.prototype.sizeAvailabilityText = function (item) {
                    return item.enabled() ? item.description : item.description + ' - Out of stock in this size';
                };
                ReturnOrderViewModel.prototype.enableSizes = function (option, item) {
                    if (item !== undefined) {
                        ko.applyBindingsToNode(option, { disable: !item.enabled() }, item);
                    }
                };
                ;
                ReturnOrderViewModel.prototype.setDeliveryAddressForAllExchanges = function (deliveryPostalCode, deliveryCountryCode3) {
                    for (var i = 0; i < this.actionedProducts().length; i++) {
                        var product_3 = this.actionedProducts()[i];
                        product_3.deliveryCountryCode3 = deliveryCountryCode3;
                        product_3.deliveryPostalCode = deliveryPostalCode;
                    }
                };
                ReturnOrderViewModel.prototype.initialiseClientRoutes = function () {
                    var _this = this;
                    Sammy(function (sammyApp) {
                        sammyApp.get('#order-unavailable', function (route) {
                            _this.step('order-unavailable');
                            return false;
                        });
                        sammyApp.get('#enter-order-number', function (route) {
                            _this.step('enter-order-number');
                            return false;
                        });
                        sammyApp.get('#select-items', function (route) {
                            _this.step('select-items');
                            return false;
                        });
                        sammyApp.get('#enter-details', function (route) {
                            _this.step('enter-details');
                            return false;
                        });
                        sammyApp.get('#return-confirmation', function (route) {
                            _this.step('return-confirmation');
                            return false;
                        });
                        sammyApp.get('#', function (app, nextRoute) {
                            sammyApp.runRoute('get', '#enter-order-number');
                            return false;
                        });
                        sammyApp.notFound = function () {
                        };
                    }).run();
                };
                ReturnOrderViewModel.prototype.setOrderNumberFromQuerystring = function () {
                    var orderNumber = this.getParameterByName('orderNumber');
                    if (orderNumber) {
                        this.orderNumber(orderNumber);
                    }
                    var postcode = this.getParameterByName('postcode');
                    if (postcode) {
                        this.postCode(postcode);
                    }
                };
                ReturnOrderViewModel.prototype.getParameterByName = function (name, url) {
                    if (!url) {
                        url = window.location.href;
                    }
                    name = name.replace(/[\[\]]/g, "\\$&");
                    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
                    var results = regex.exec(url);
                    if (!results) {
                        return null;
                    }
                    ;
                    if (!results[2]) {
                        return '';
                    }
                    return decodeURIComponent(results[2].replace(/\+/g, " "));
                };
                return ReturnOrderViewModel;
            }());
            Returns.ReturnOrderViewModel = ReturnOrderViewModel;
        })(Returns = Pages.Returns || (Pages.Returns = {}));
    })(Pages = Outdoor.Pages || (Outdoor.Pages = {}));
})(Outdoor || (Outdoor = {}));
//# sourceMappingURL=ReturnOrderViewModel.js.map;
var Outdoor;
(function (Outdoor) {
    var Pages;
    (function (Pages) {
        var Returns;
        (function (Returns) {
            Returns.exchangeActionExchange = 'Exchange';
            Returns.exchangeActionRefund = 'Refund';
            var ItemIsFaultyDropdownCode = 'F';
            var ReturnProduct = (function () {
                function ReturnProduct(product, index, orderNumber, deliveryPostalCode, deliveryCountryCode3) {
                    var _this = this;
                    this.index = index;
                    this.orderNumber = orderNumber;
                    this.deliveryPostalCode = deliveryPostalCode;
                    this.deliveryCountryCode3 = deliveryCountryCode3;
                    this.action = ko.observable('');
                    this.availableColours = ko.observableArray();
                    this.availableSizes = ko.observableArray();
                    this.errors = ko.observableArray();
                    this.exchangeColour = ko.observable('');
                    this.exchangeName = ko.observable('');
                    this.exchangePriceFormatted = ko.observable('');
                    this.exchangeSize = ko.observable('');
                    this.exchangeStyleCode = ko.observable('');
                    this.exchangeType = ko.observable(Returns.ExchangeTypeCodes.exchangeTypeNotSet);
                    this.formattedPrice = ko.observable('');
                    this.isReturnableOfflineOnly = ko.observable();
                    this.lastReturnDate = ko.observable();
                    this.processing = ko.observable(false);
                    this.reasonFaultyCode = ko.observable(undefined);
                    this.reasonFaultyText = ko.observable('');
                    this.reasonGoodCode = ko.observable(undefined);
                    this.returnConfirmedByUser = ko.observable(false);
                    this.returnFaultLocation = ko.observable('');
                    this.showValidationErrors = ko.observable(false);
                    this.exchangeTypesInternal = [
                        { description: 'Replacement item', exchangeCode: Returns.ExchangeTypeCodes.exchangeTypeSame },
                        { description: 'A completely different item', exchangeCode: Returns.ExchangeTypeCodes.exchangeTypeDifferent },
                        { description: 'The same item, but a different colour', exchangeCode: Returns.ExchangeTypeCodes.exchangeTypeDifferentColour },
                        { description: 'The same item, but a different size', exchangeCode: Returns.ExchangeTypeCodes.exchangeTypeDifferentSize }
                    ];
                    this.action.subscribe(function () { return _this.onExchangeActionChanged(); });
                    this.exchangeColour.subscribe(function () { return _this.onColourChanged(); });
                    this.exchangeSize.subscribe(function () { return _this.onSizeChanged(); });
                    this.exchangeType.subscribe(function () { return _this.onExchangeTypeChanged(); });
                    this.exchangePosCode = ko.computed(function () {
                        if (_this.action() === Returns.exchangeActionRefund)
                            return "";
                        if (_this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferentColour)
                            return _this.styleCode + _this.exchangeColour() + _this.sizeCode;
                        else if (_this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferentSize)
                            return _this.styleCode + _this.colourCode + _this.exchangeSize();
                        else if (_this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferent)
                            return _this.exchangeStyleCode() + _this.exchangeColour() + _this.exchangeSize();
                        else if (_this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeSame)
                            return _this.styleCode + _this.colourCode + _this.sizeCode;
                        return "";
                    });
                    this.exchangeTypeText = ko.computed(function () { return _this.exchangeTypeTextFromCode(); });
                    this.colour = product.colour;
                    this.colourCode = product.colourCode;
                    this.colourSelectionRequired = ko.computed(function () {
                        return _this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferent || _this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferentColour;
                    });
                    this.deliveryCountryCode3 = deliveryCountryCode3;
                    this.deliveryPostalCode = deliveryPostalCode;
                    this.sizeSelectionRequired = ko.computed(function () {
                        return _this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferent || _this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferentSize;
                    });
                    this.exchangeImageUrl = ko.computed(function () { return _this.selectedExchangeImage(); });
                    this.exchangeConfigureText = ko.computed(function () {
                        var titleText = '';
                        if (_this.returnConfirmedByUser())
                            return 'Item required for exchange';
                        if (_this.exchangeSize() === undefined && _this.sizeSelectionRequired())
                            titleText = 'Please select your size below:';
                        else if (_this.exchangeColour() === undefined && _this.colourSelectionRequired())
                            titleText = 'Please select the colour below:';
                        else
                            titleText = 'Please check your selection and press the confirm button:';
                        return titleText;
                    });
                    this.exchangeTypes = ko.computed(function () {
                        return ko.utils.arrayFilter(_this.exchangeTypesInternal, function (item) {
                            return item.exchangeCode !== Returns.ExchangeTypeCodes.exchangeTypeSame || (item.exchangeCode === Returns.ExchangeTypeCodes.exchangeTypeSame && _this.reasonGoodCode() === ItemIsFaultyDropdownCode);
                        });
                    });
                    this.formattedPrice(product.formattedPrice);
                    this.formattedSizes = product.formattedSizes;
                    this.imageUrl = product.imageUrl;
                    this.index = index;
                    this.isReturnableOfflineOnly(product.isReturnableOfflineOnly);
                    this.isOutsideGoodReturnDate = product.isOutsideGoodReturnDate;
                    this.isNotReturnable = ko.computed(function () { return _this.isOutsideGoodReturnDate && _this.reasonGoodCode() !== ItemIsFaultyDropdownCode && _this.reasonGoodCode() !== undefined; });
                    this.lastReturnDate(product.lastReturnDate);
                    this.name = product.name;
                    this.orderItemShardId = product.orderReturnShardId;
                    this.orderNumber = orderNumber;
                    this.posCode = product.styleCode + product.colourCode + product.sizeCode;
                    this.price = product.price;
                    this.reasonCode = ko.computed(function () { return _this.reasonFaultyCode() === undefined ? _this.reasonGoodCode() : _this.reasonFaultyCode(); });
                    this.reasonGoodCode.subscribe(function () { return _this.reasonFaultyCode(undefined); });
                    this.readyToConfirm = ko.computed(function () { return _this.returnConfirmedByUser() === false && _this.returnDetailsCompletedByUser(); });
                    this.showColourError = ko.computed(function () { return _this.showValidationErrors() && _this.exchangeColour() === undefined; });
                    this.showConfigureExchange = ko.computed(function () { return _this.exchangeName() != ''; });
                    this.showExchangeLookup = ko.computed(function () { return _this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferent; });
                    this.showExchangeOptions = ko.computed(function () { return _this.shouldExchangeOptionsBeVisible(); });
                    this.showExchangeOptionsError = ko.computed(function () { return _this.showValidationErrors() && _this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeNotSet; });
                    this.showFaultLimitError = ko.computed(function () { return _this.showValidationErrors() && _this.returnFaultLocation().length > 99; });
                    this.showFaultLocationError = ko.computed(function () { return _this.showValidationErrors() && _this.returnFaultLocation() === ''; });
                    this.showFaultMissingError = ko.computed(function () { return _this.showValidationErrors() && _this.reasonFaultyCode() === undefined; });
                    this.showFaultOtherError = ko.computed(function () { return _this.showValidationErrors() && _this.reasonFaultyText() === ''; });
                    this.showLookupError = ko.computed(function () { return _this.showValidationErrors() && _this.exchangeStyleCode() === ''; });
                    this.showReasonCodeError = ko.computed(function () { return _this.showValidationErrors() && _this.reasonCode() === undefined; });
                    this.showSizeError = ko.computed(function () { return _this.showValidationErrors() && _this.exchangeSize() === undefined; });
                    this.sizeCode = product.sizeCode;
                    this.stepComplete = ko.computed(function () { return _this.isStepComplete(); });
                    this.styleCode = product.styleCode;
                    return this;
                }
                ReturnProduct.prototype.toggleReturnAction = function () {
                    this.returnConfirmedByUser(false);
                    if (this.action() === Returns.exchangeActionRefund)
                        this.action(Returns.exchangeActionExchange);
                    else {
                        this.action(Returns.exchangeActionRefund);
                        this.exchangeType(Returns.ExchangeTypeCodes.exchangeTypeNotSet);
                    }
                };
                ReturnProduct.prototype.exchangeTypeTextFromCode = function () {
                    for (var i = 0; i < this.exchangeTypesInternal.length; i++) {
                        if (this.exchangeTypesInternal[i].exchangeCode === this.exchangeType()) {
                            return this.exchangeTypesInternal[i].description;
                        }
                    }
                    return "Please select";
                };
                ReturnProduct.prototype.onExchangeActionChanged = function () {
                    this.exchangeColour(undefined);
                    this.exchangeName('');
                    this.exchangePriceFormatted('');
                    this.exchangeSize(undefined);
                    this.exchangeStyleCode('');
                    this.returnConfirmedByUser(false);
                    this.exchangeType(Returns.ExchangeTypeCodes.exchangeTypeNotSet);
                };
                ReturnProduct.prototype.isItemInStock = function (stockArray, code) {
                    for (var i = 0; i < stockArray.length; i++) {
                        if (stockArray[i].code === code) {
                            if (stockArray[i].inStock) {
                                return true;
                            }
                        }
                    }
                    return false;
                };
                ReturnProduct.prototype.areAnyItemsInStock = function (stockArray) {
                    for (var i = 0; i < stockArray.length; i++) {
                        if (stockArray[i].inStock) {
                            return true;
                        }
                    }
                    return false;
                };
                ReturnProduct.prototype.onColourChanged = function () {
                    var selectedColour = this.currentColourStock();
                    if (selectedColour === null) {
                        for (var i = 0; i < this.availableSizes().length; i++) {
                            this.availableSizes()[i].enabled(true);
                        }
                    }
                    else {
                        for (var i = 0; i < this.availableSizes().length; i++) {
                            var size = this.availableSizes()[i];
                            var enabled = this.isItemInStock(selectedColour.stockBySizeCode, size.sizeCode);
                            if (selectedColour.formattedPrice) {
                                this.exchangePriceFormatted(selectedColour.formattedPrice);
                            }
                            size.enabled(enabled);
                        }
                        var selectedSize = this.currentSizeStock();
                        if (selectedSize != null && selectedSize.enabled() === false)
                            this.exchangeSize(undefined);
                    }
                };
                ;
                ReturnProduct.prototype.onSizeChanged = function () {
                    var selectedSize = this.currentSizeStock();
                    if (selectedSize === null) {
                        for (var i = 0; i < this.availableColours().length; i++) {
                            this.availableColours()[i].enabled(true);
                        }
                    }
                    else {
                        for (var i = 0; i < this.availableColours().length; i++) {
                            var colour = this.availableColours()[i];
                            var enabled = this.isItemInStock(selectedSize.stockByColourCode, colour.colourCode);
                            colour.enabled(enabled);
                        }
                        var selectedColour = this.currentColourStock();
                        if (selectedColour != null && selectedColour.enabled() === false) {
                            this.exchangeColour(undefined);
                        }
                    }
                };
                ;
                ReturnProduct.prototype.LookupParams = function (styleCode, orderNumber, deliveryPostalCode, deliveryCountryCode3, sameStyle) {
                    return JSON.stringify({
                        styleCode: styleCode,
                        orderNumber: orderNumber,
                        deliveryPostalCode: deliveryPostalCode,
                        deliveryCountryCode3: deliveryCountryCode3,
                        sameStyle: sameStyle
                    });
                };
                ReturnProduct.prototype.onExchangeTypeChanged = function () {
                    var _this = this;
                    this.exchangeColour(undefined);
                    this.exchangeSize(undefined);
                    if (this.action() === Returns.exchangeActionRefund) {
                        return;
                    }
                    if (this.exchangeType() !== Returns.ExchangeTypeCodes.exchangeTypeDifferent && this.exchangeType() !== Returns.ExchangeTypeCodes.exchangeTypeNotSet) {
                        this.processing(true);
                        this.exchangeStyleCode(this.styleCode);
                        var json = this.LookupParams(this.styleCode, this.orderNumber, this.deliveryPostalCode, this.deliveryCountryCode3, true);
                        Outdoor.Utilities.HttpRequest.PostJson('/returns/lookup-style', json, function (data) {
                            _this.onStyleDetailsReceived(data);
                            if (_this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferentColour) {
                                _this.exchangeSize(_this.sizeCode);
                            }
                            else if (_this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferentSize) {
                                _this.exchangeColour(_this.colourCode);
                            }
                        }, function (data) { _this.postError(data); });
                    }
                };
                ReturnProduct.prototype.isStepComplete = function () {
                    if (this.isNotReturnable() || this.isReturnableOfflineOnly()) {
                        return false;
                    }
                    if (!this.returnDetailsCompletedByUser()) {
                        return false;
                    }
                    if (this.returnConfirmedByUser() || this.readyToConfirm()) {
                        return true;
                    }
                    return false;
                };
                ReturnProduct.prototype.styleLookup = function () {
                    var _this = this;
                    var constraints = { StyleCode: { numericality: true, presence: true, length: { is: 6 } } };
                    var form = document.getElementById("style-lookup-form");
                    var formValid = Outdoor.Utilities.ValidateSetup.validateForm(form, constraints);
                    if (formValid) {
                        this.processing(true);
                        var json = this.LookupParams(this.exchangeStyleCode(), this.orderNumber, this.deliveryPostalCode, this.deliveryCountryCode3, false);
                        Outdoor.Utilities.HttpRequest.PostJson('/returns/lookup-style', json, function (data) { _this.onStyleDetailsReceived(data); }, function (data) { _this.postError(data); });
                    }
                    else {
                        this.exchangeName('');
                        this.errors.removeAll();
                        this.errors.push('Please enter a 6 digit style code only.');
                    }
                };
                ReturnProduct.prototype.toggleReturnConfirmation = function () {
                    if (this.stepComplete() === true) {
                        this.returnConfirmedByUser(!this.returnConfirmedByUser());
                    }
                    else {
                        this.showValidationErrors(true);
                    }
                };
                ReturnProduct.prototype.onStyleDetailsReceived = function (data) {
                    var json = JSON.parse(data);
                    if (!this.errorHandled(data)) {
                        this.convertLookupIntoObservables(json);
                    }
                    if (this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeSame) {
                        if (json.styleNotFound) {
                            this.exchangeStyleCode('');
                        }
                    }
                    this.processing(false);
                };
                ReturnProduct.prototype.populateColours = function (colours) {
                    this.availableColours.removeAll();
                    for (var i = 0; i < colours.length; i++) {
                        var jsonColour = colours[i];
                        var colour = {
                            colourCode: jsonColour.colourCode,
                            description: jsonColour.description,
                            enabled: ko.observable(true),
                            formattedPrice: jsonColour.formattedPrice,
                            imageUrl: jsonColour.imageUrl,
                            price: jsonColour.price,
                            stockBySizeCode: jsonColour.stockBySizeCode
                        };
                        colour.enabled(this.areAnyItemsInStock(colour.stockBySizeCode));
                        this.availableColours.push(colour);
                    }
                };
                ReturnProduct.prototype.convertLookupIntoObservables = function (json) {
                    this.exchangeName(json.name);
                    this.exchangePriceFormatted(json.formattedPrice);
                    this.exchangeStyleCode(json.styleCode);
                    this.populateColours(json.colours);
                    this.availableSizes.removeAll();
                    for (var i = 0; i < json.sizes.length; i++) {
                        var jsonSize = json.sizes[i];
                        var size = {
                            description: jsonSize.description,
                            enabled: ko.observable(true),
                            sizeCode: jsonSize.sizeCode,
                            stockByColourCode: jsonSize.stockByColourCode
                        };
                        size.enabled(this.areAnyItemsInStock(size.stockByColourCode));
                        this.availableSizes.push(size);
                    }
                };
                ReturnProduct.prototype.postError = function (data) {
                    this.errorHandled(data);
                };
                ReturnProduct.prototype.errorHandled = function (data) {
                    var json = JSON.parse(data);
                    this.errors.removeAll();
                    if (json.errors && json.errors.length) {
                        for (var i = 0; i < json.errors.length; i++) {
                            this.errors.push(json.errors[i].message);
                        }
                    }
                    else
                        return false;
                    this.exchangeName('');
                    return true;
                };
                ReturnProduct.prototype.returnDetailsCompletedByUser = function () {
                    return this.exchangeDetailsComplete() && this.returnReasonsComplete();
                };
                ReturnProduct.prototype.returnReasonsComplete = function () {
                    if (this.reasonCode() === undefined) {
                        return false;
                    }
                    if (this.reasonGoodCode() === ItemIsFaultyDropdownCode) {
                        if (this.reasonFaultyCode() === undefined) {
                            return false;
                        }
                        if (this.reasonFaultyCode() === 'Y') {
                            if (this.reasonFaultyText() === '') {
                                return false;
                            }
                        }
                        if (this.returnFaultLocation() === '') {
                            return false;
                        }
                    }
                    return true;
                };
                ReturnProduct.prototype.exchangeDetailsComplete = function () {
                    if (this.action() === Returns.exchangeActionRefund) {
                        return true;
                    }
                    if (this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeNotSet) {
                        return false;
                    }
                    if (this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeSame) {
                        return this.exchangeStyleCode() !== '';
                    }
                    if (this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferentColour) {
                        return this.exchangeColour() !== undefined;
                    }
                    if (this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferentSize) {
                        return this.exchangeSize() !== undefined;
                    }
                    return this.exchangeColour() !== undefined && this.exchangeSize() !== undefined;
                };
                ReturnProduct.prototype.selectedExchangeImage = function () {
                    var selectedColour = this.exchangeColour();
                    for (var i = 0; i < this.availableColours().length; i++) {
                        var item = this.availableColours()[i];
                        if (selectedColour === undefined || selectedColour === item.colourCode)
                            return item.imageUrl;
                    }
                    return '';
                };
                ReturnProduct.prototype.shouldExchangeOptionsBeVisible = function () {
                    if (this.reasonCode() === undefined)
                        return false;
                    if (this.isNotReturnable())
                        return false;
                    if (this.action() === Returns.exchangeActionExchange)
                        return true;
                    return false;
                };
                ReturnProduct.prototype.currentColourStock = function () {
                    for (var i = 0; i < this.availableColours().length; i++) {
                        if (this.availableColours()[i].colourCode == this.exchangeColour())
                            return this.availableColours()[i];
                    }
                    return null;
                };
                ReturnProduct.prototype.currentSizeStock = function () {
                    for (var i = 0; i < this.availableSizes().length; i++) {
                        if (this.availableSizes()[i].sizeCode == this.exchangeSize())
                            return this.availableSizes()[i];
                    }
                    return null;
                };
                ReturnProduct.prototype.exchangeColourDescription = function () {
                    var code = this.colourCode;
                    if (this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferentColour ||
                        this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferent) {
                        code = this.exchangeColour();
                    }
                    for (var i = 0; i < this.availableColours().length; i++) {
                        if (this.availableColours()[i].colourCode == code)
                            return this.availableColours()[i].description;
                    }
                    return "";
                };
                ReturnProduct.prototype.exchangeSizeDescription = function () {
                    var code = this.sizeCode;
                    if (this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferentSize ||
                        this.exchangeType() === Returns.ExchangeTypeCodes.exchangeTypeDifferent) {
                        code = this.exchangeSize();
                    }
                    for (var i = 0; i < this.availableSizes().length; i++) {
                        if (this.availableSizes()[i].sizeCode == code)
                            return this.availableSizes()[i].description;
                    }
                    return "";
                };
                return ReturnProduct;
            }());
            Returns.ReturnProduct = ReturnProduct;
        })(Returns = Pages.Returns || (Pages.Returns = {}));
    })(Pages = Outdoor.Pages || (Outdoor.Pages = {}));
})(Outdoor || (Outdoor = {}));
//# sourceMappingURL=ReturnProduct.js.map;
var Outdoor;
(function (Outdoor) {
    var Pages;
    (function (Pages) {
        var Returns;
        (function (Returns) {
            var Initialise = (function () {
                function Initialise() {
                }
                Initialise.InitReturns = function () {
                    var viewModel = new Returns.ReturnOrderViewModel();
                    ko.components.register('enter-order-number', {
                        template: { element: 'enter-order-number-template' },
                        viewModel: { instance: viewModel }
                    });
                    ko.components.register('order-unavailable', {
                        template: { element: 'order-unavailable-template' },
                        viewModel: { instance: viewModel }
                    });
                    ko.components.register('select-items', {
                        template: { element: 'select-items-template' },
                        viewModel: { instance: viewModel }
                    });
                    ko.components.register('enter-details', {
                        template: { element: 'enter-details-template' },
                        viewModel: { instance: viewModel }
                    });
                    ko.components.register('return-confirmation', {
                        template: { element: 'return-confirmation-template' },
                        viewModel: { instance: viewModel }
                    });
                    ko.applyBindings(viewModel);
                    return viewModel;
                };
                return Initialise;
            }());
            Returns.Initialise = Initialise;
        })(Returns = Pages.Returns || (Pages.Returns = {}));
    })(Pages = Outdoor.Pages || (Outdoor.Pages = {}));
})(Outdoor || (Outdoor = {}));
//# sourceMappingURL=returns.js.map;
var ClickableSelector = (function () {
    function ClickableSelector(colours, sizes, productPage) {
        this.colours = colours;
        this.sizes = sizes;
        this.productPage = productPage;
        this.currentColourId = NaN;
        this.currentSizeCode = '';
        this.wireUpHandlers();
        this.initialiseUi();
    }
    ClickableSelector.prototype.wireUpHandlers = function () {
        this.WireUpColourChanged();
        this.WireUpSizeChanged();
        this.WireUpSizeGroupSelected();
    };
    ClickableSelector.prototype.initialiseUi = function () {
        if (this.arrayLength(this.colours) === 1) {
            this.currentColourId = parseInt(this.firstArrayElement(this.colours));
        }
        else {
            var element = document.getElementById('InitialColourId');
            this.currentColourId = parseInt(element.value);
        }
        if (!isNaN(this.currentColourId)) {
            this.setSelectedColourCss();
            if (this.arrayLength(this.sizes) === 1) {
                this.currentSizeCode = this.firstArrayElement(this.sizes);
                this.setSelectedSizeCss();
            }
        }
        this.productPage.ProductSelectionChanged(this.SelectedSizeAndColour());
        this.stockLegendContainer = document.getElementById('stock-legend-container');
    };
    ClickableSelector.prototype.arrayLength = function (arr) {
        var len = 0;
        for (var i in arr) {
            if (arr[i]) {
                len++;
            }
        }
        return len;
    };
    ClickableSelector.prototype.firstArrayElement = function (arr) {
        for (var i in arr) {
            return i;
        }
    };
    ClickableSelector.prototype.WireUpSizeChanged = function () {
        var _this = this;
        $('.c-size-selector').click(function (e) { return _this.onSizeChanged(e); });
    };
    ClickableSelector.prototype.WireUpSizeGroupSelected = function () {
        var _this = this;
        $('.c-size-group').click(function (e) { return _this.onSizeGroupChanged(e); });
    };
    ClickableSelector.prototype.WireUpColourChanged = function () {
        var _this = this;
        $('.c-colour-selector').click(function (e) { return _this.onColourChanged(e); });
    };
    ClickableSelector.prototype.SelectedSizeAndColour = function () {
        return {
            colourId: this.currentColourId,
            size: this.currentSizeCode
        };
    };
    ClickableSelector.prototype.onSizeChanged = function (e) {
        e.preventDefault();
        this.currentSizeCode = $(e.currentTarget).parent().data('size-id').toString();
        this.setSelectedSizeCss();
        this.setSelectedColourCss();
        this.updateColourStockStatus(this.currentSizeCode);
        this.productPage.ProductSelectionChanged(this.SelectedSizeAndColour());
    };
    ClickableSelector.prototype.resetSizeStockCss = function () {
        var stockText = this.cssClassAndTextForStockStatus(StockLevel.Stock_InStock);
        var sizeLis = $('#size-list >li[data-size-id]');
        sizeLis
            .removeClass('instock')
            .removeClass('discontinued')
            .removeClass('requestemail')
            .addClass(stockText.cssClass)
            .attr('alt', stockText.text);
        this.updateLegendVisibility();
    };
    ClickableSelector.prototype.updateColourStockStatus = function (selectedSize) {
        for (var colourId in this.colours) {
            var itemInfo = this.productPage.StockInfoForSizeAndColour(parseInt(colourId), selectedSize);
            if (!itemInfo) {
                continue;
            }
            var stockText = this.cssClassAndTextForStockStatus(itemInfo.availability);
            var colourLi = $('#colour-list >li[data-colour-id="' + colourId + '"]');
            colourLi
                .removeClass('instock')
                .removeClass('discontinued')
                .removeClass('requestemail')
                .addClass(stockText.cssClass)
                .attr('alt', stockText.text);
        }
        this.updateLegendVisibility();
    };
    ClickableSelector.prototype.updateLegendVisibility = function () {
        if ($('#size-list > li.requestemail > a.c-size-selector').length > 0) {
            Outdoor.Utilities.CssManipulator.removeClass(this.stockLegendContainer, 'hidden');
        }
        else {
            Outdoor.Utilities.CssManipulator.addClass(this.stockLegendContainer, 'hidden');
        }
    };
    ClickableSelector.prototype.cssClassAndTextForStockStatus = function (status) {
        if (StockLevel.Stock_InStock === status || StockLevel.Stock_LowStock === status) {
            return {
                cssClass: 'instock',
                text: 'Order Now'
            };
        }
        else if (StockLevel.Stock_Unavailable === status) {
            return {
                cssClass: 'discontinued',
                text: 'Discontinued and Sold Out'
            };
        }
        return {
            cssClass: 'requestemail',
            text: 'Out of Stock (Request Email Alert)'
        };
    };
    ClickableSelector.prototype.onSizeGroupChanged = function (e) {
        e.preventDefault();
        var currentSizeGroup = $(e.currentTarget).parent().data('size-group-id');
        $('.c-size-group').removeClass('active');
        $(e.currentTarget).addClass('active');
        var sizeLinks = $('#size-list > li > a.c-size-selector');
        for (var i = 0; i < sizeLinks.length; i++) {
            var sizeElement = $(sizeLinks[i]);
            if (currentSizeGroup === 'UK') {
                sizeElement.text(sizeElement.data('uk'));
            }
            else if (currentSizeGroup === 'EU') {
                sizeElement.text(sizeElement.data('eu'));
            }
            else if (currentSizeGroup === 'US') {
                sizeElement.text(sizeElement.data('us'));
            }
        }
    };
    ClickableSelector.prototype.onColourChanged = function (e) {
        e.preventDefault();
        this.currentColourId = $(e.currentTarget).parent().data('colour-id');
        this.productPage.FindAndClickThumbnail(this.currentColourId);
        this.setSelectedColourCss();
        this.setSelectedSizeCss();
        this.LoadSizes();
    };
    ClickableSelector.prototype.setSelectedSizeCss = function () {
        $('#size-list>li').removeClass('selected');
        if (this.currentSizeCode) {
            var sizeLi = $('#size-list >li[data-size-id="' + this.currentSizeCode + '"]');
            sizeLi.addClass('selected');
        }
    };
    ClickableSelector.prototype.setSelectedColourCss = function () {
        $('#colour-list>li').removeClass('selected');
        if (this.currentColourId) {
            var colourLi = $('#colour-list >li[data-colour-id="' + this.currentColourId + '"]');
            colourLi.addClass('selected');
        }
    };
    ClickableSelector.prototype.LoadSizes = function () {
        for (var sizeCode in this.sizes) {
            var itemInfo = this.productPage.StockInfoForSizeAndColour(this.currentColourId, sizeCode);
            if (!itemInfo) {
                continue;
            }
            var stockText = this.cssClassAndTextForStockStatus(itemInfo.availability);
            var sizeLi = $('#size-list >li[data-size-id="' + sizeCode + '"]');
            sizeLi
                .removeClass('instock')
                .removeClass('discontinued')
                .removeClass('requestemail')
                .addClass(stockText.cssClass)
                .attr('alt', stockText.text);
        }
        this.updateLegendVisibility();
        this.productPage.ProductSelectionChanged(this.SelectedSizeAndColour());
    };
    return ClickableSelector;
}());
//# sourceMappingURL=ClickableSelector.js.map;
//# sourceMappingURL=IColourSizeSelector.js.map;
var StockLevel;
(function (StockLevel) {
    StockLevel[StockLevel["Stock_NotSelected"] = 0] = "Stock_NotSelected";
    StockLevel[StockLevel["Stock_InStock"] = 1] = "Stock_InStock";
    StockLevel[StockLevel["Stock_LowStock"] = 2] = "Stock_LowStock";
    StockLevel[StockLevel["Stock_Enquiries"] = 3] = "Stock_Enquiries";
    StockLevel[StockLevel["Stock_Unavailable"] = 4] = "Stock_Unavailable";
})(StockLevel || (StockLevel = {}));
//# sourceMappingURL=StockLevel.js.map;
var ProductClass;
(function (ProductClass) {
    ProductClass[ProductClass["PhysicalProduct"] = 0] = "PhysicalProduct";
    ProductClass[ProductClass["GiftCard"] = 1] = "GiftCard";
})(ProductClass || (ProductClass = {}));
//# sourceMappingURL=ProductClass.js.map;
var Outdoor;
(function (Outdoor) {
    var Utilities;
    (function (Utilities) {
        var Browser = (function () {
            function Browser() {
            }
            Browser.IsIosDevice = function () {
                var iDevice = ['iPad', 'iPhone', 'iPod'];
                for (var i = 0; i < iDevice.length; i++) {
                    if (navigator.platform === iDevice[i])
                        return true;
                }
                return false;
            };
            Browser.IsMobileDevice = function () {
                return $('body').hasClass('mobile');
            };
            return Browser;
        }());
        Utilities.Browser = Browser;
    })(Utilities = Outdoor.Utilities || (Outdoor.Utilities = {}));
})(Outdoor || (Outdoor = {}));
//# sourceMappingURL=Browser.js.map;
/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Version 3.0.1
 *
 * Requires jQuery >= 1.2.6
 */

(function (factory) {
    if ( typeof define === 'function' && define.amd ) {
        // AMD. Register as an anonymous module.
        define(['jquery'], factory);
    } else if ( typeof exports === 'object' ) {
        // Node/CommonJS style for Browserify
        module.exports = factory;
    } else {
        // Browser globals
        factory(jQuery);
    }
}(function ($) {
    $.fn.bgiframe = function(s) {
        s = $.extend({
            top         : 'auto', // auto == borderTopWidth
            left        : 'auto', // auto == borderLeftWidth
            width       : 'auto', // auto == offsetWidth
            height      : 'auto', // auto == offsetHeight
            opacity     : true,
            src         : 'javascript:false;',
            conditional : /MSIE 6\.0/.test(navigator.userAgent) // expression or function. return false to prevent iframe insertion
        }, s);

        // wrap conditional in a function if it isn't already
        if ( !$.isFunction(s.conditional) ) {
            var condition = s.conditional;
            s.conditional = function() { return condition; };
        }

        var $iframe = $('<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
                           'style="display:block;position:absolute;z-index:-1;"/>');

        return this.each(function() {
            var $this = $(this);
            if ( s.conditional(this) === false ) { return; }
            var existing = $this.children('iframe.bgiframe');
            var $el = existing.length === 0 ? $iframe.clone() : existing;
            $el.css({
                'top': s.top == 'auto' ?
                    ((parseInt($this.css('borderTopWidth'),10)||0)*-1)+'px' : prop(s.top),
                'left': s.left == 'auto' ?
                    ((parseInt($this.css('borderLeftWidth'),10)||0)*-1)+'px' : prop(s.left),
                'width': s.width == 'auto' ? (this.offsetWidth + 'px') : prop(s.width),
                'height': s.height == 'auto' ? (this.offsetHeight + 'px') : prop(s.height),
                'opacity': s.opacity === true ? 0 : undefined
            });

            if ( existing.length === 0 ) {
                $this.prepend($el);
            }
        });
    };

    // old alias
    $.fn.bgIframe = $.fn.bgiframe;

    function prop(n) {
        return n && n.constructor === Number ? n + 'px' : n;
    }

}));
;
/*!
 * jQuery Tools v1.2.7 - The missing UI library for the Web
 * 
 * dateinput/dateinput.js
 * overlay/overlay.js
 * overlay/overlay.apple.js
 * rangeinput/rangeinput.js
 * scrollable/scrollable.js
 * scrollable/scrollable.autoscroll.js
 * scrollable/scrollable.navigator.js
 * tabs/tabs.js
 * tabs/tabs.slideshow.js
 * toolbox/toolbox.expose.js
 * toolbox/toolbox.flashembed.js
 * toolbox/toolbox.history.js
 * toolbox/toolbox.mousewheel.js
 * tooltip/tooltip.js
 * tooltip/tooltip.dynamic.js
 * tooltip/tooltip.slide.js
 * validator/validator.js
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/
 * 
 * jquery.event.wheel.js - rev 1 
 * Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
 * Liscensed under the MIT License (MIT-LICENSE.txt)
 * http://www.opensource.org/licenses/mit-license.php
 * Created: 2008-07-01 | Updated: 2008-07-14
 * 
 * -----
 * 
 */
(function(a,b){a.tools=a.tools||{version:"v1.2.7"};var c=[],d={},e,f=[75,76,38,39,74,72,40,37],g={};e=a.tools.dateinput={conf:{format:"mm/dd/yy",formatter:"default",selectors:!1,yearRange:[-5,5],lang:"en",offset:[0,0],speed:0,firstDay:0,min:b,max:b,trigger:0,toggle:0,editable:0,css:{prefix:"cal",input:"date",root:0,head:0,title:0,prev:0,next:0,month:0,year:0,days:0,body:0,weeks:0,today:0,current:0,week:0,off:0,sunday:0,focus:0,disabled:0,trigger:0}},addFormatter:function(a,b){d[a]=b},localize:function(b,c){a.each(c,function(a,b){c[a]=b.split(",")}),g[b]=c}},e.localize("en",{months:"January,February,March,April,May,June,July,August,September,October,November,December",shortMonths:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",days:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",shortDays:"Sun,Mon,Tue,Wed,Thu,Fri,Sat"});function h(a,b){return(new Date(a,b+1,0)).getDate()}function i(a,b){a=""+a,b=b||2;while(a.length<b)a="0"+a;return a}var j=a("<a/>");function k(a,b,c,e){var f=b.getDate(),h=b.getDay(),k=b.getMonth(),l=b.getFullYear(),m={d:f,dd:i(f),ddd:g[e].shortDays[h],dddd:g[e].days[h],m:k+1,mm:i(k+1),mmm:g[e].shortMonths[k],mmmm:g[e].months[k],yy:String(l).slice(2),yyyy:l},n=d[a](c,b,m,e);return j.html(n).html()}e.addFormatter("default",function(a,b,c,d){return a.replace(/d{1,4}|m{1,4}|yy(?:yy)?|"[^"]*"|'[^']*'/g,function(a){return a in c?c[a]:a})}),e.addFormatter("prefixed",function(a,b,c,d){return a.replace(/%(d{1,4}|m{1,4}|yy(?:yy)?|"[^"]*"|'[^']*')/g,function(a,b){return b in c?c[b]:a})});function l(a){return parseInt(a,10)}function m(a,b){return a.getFullYear()===b.getFullYear()&&a.getMonth()==b.getMonth()&&a.getDate()==b.getDate()}function n(a){if(a!==b){if(a.constructor==Date)return a;if(typeof a=="string"){var c=a.split("-");if(c.length==3)return new Date(l(c[0]),l(c[1])-1,l(c[2]));if(!/^-?\d+$/.test(a))return;a=l(a)}var d=new Date;d.setDate(d.getDate()+a);return d}}function o(d,e){var i=this,j=new Date,o=j.getFullYear(),p=e.css,q=g[e.lang],r=a("#"+p.root),s=r.find("#"+p.title),t,u,v,w,x,y,z=d.attr("data-value")||e.value||d.val(),A=d.attr("min")||e.min,B=d.attr("max")||e.max,C,D;A===0&&(A="0"),z=n(z)||j,A=n(A||new Date(o+e.yearRange[0],1,1)),B=n(B||new Date(o+e.yearRange[1]+1,1,-1));if(!q)throw"Dateinput: invalid language: "+e.lang;if(d.attr("type")=="date"){var D=d.clone(),E=D.wrap("<div/>").parent().html(),F=a(E.replace(/type/i,"type=text data-orig-type"));e.value&&F.val(e.value),d.replaceWith(F),d=F}d.addClass(p.input);var G=d.add(i);if(!r.length){r=a("<div><div><a/><div/><a/></div><div><div/><div/></div></div>").hide().css({position:"absolute"}).attr("id",p.root),r.children().eq(0).attr("id",p.head).end().eq(1).attr("id",p.body).children().eq(0).attr("id",p.days).end().eq(1).attr("id",p.weeks).end().end().end().find("a").eq(0).attr("id",p.prev).end().eq(1).attr("id",p.next),s=r.find("#"+p.head).find("div").attr("id",p.title);if(e.selectors){var H=a("<select/>").attr("id",p.month),I=a("<select/>").attr("id",p.year);s.html(H.add(I))}var J=r.find("#"+p.days);for(var K=0;K<7;K++)J.append(a("<span/>").text(q.shortDays[(K+e.firstDay)%7]));a("body").append(r)}e.trigger&&(t=a("<a/>").attr("href","#").addClass(p.trigger).click(function(a){e.toggle?i.toggle():i.show();return a.preventDefault()}).insertAfter(d));var L=r.find("#"+p.weeks);I=r.find("#"+p.year),H=r.find("#"+p.month);function M(b,c,e){z=b,w=b.getFullYear(),x=b.getMonth(),y=b.getDate(),e||(e=a.Event("api")),e.type=="click"&&!a.browser.msie&&d.focus(),e.type="beforeChange",G.trigger(e,[b]);e.isDefaultPrevented()||(d.val(k(c.formatter,b,c.format,c.lang)),e.type="change",G.trigger(e),d.data("date",b),i.hide(e))}function N(b){b.type="onShow",G.trigger(b),a(document).on("keydown.d",function(b){if(b.ctrlKey)return!0;var c=b.keyCode;if(c==8||c==46){d.val("");return i.hide(b)}if(c==27||c==9)return i.hide(b);if(a(f).index(c)>=0){if(!C){i.show(b);return b.preventDefault()}var e=a("#"+p.weeks+" a"),g=a("."+p.focus),h=e.index(g);g.removeClass(p.focus);if(c==74||c==40)h+=7;else if(c==75||c==38)h-=7;else if(c==76||c==39)h+=1;else if(c==72||c==37)h-=1;h>41?(i.addMonth(),g=a("#"+p.weeks+" a:eq("+(h-42)+")")):h<0?(i.addMonth(-1),g=a("#"+p.weeks+" a:eq("+(h+42)+")")):g=e.eq(h),g.addClass(p.focus);return b.preventDefault()}if(c==34)return i.addMonth();if(c==33)return i.addMonth(-1);if(c==36)return i.today();c==13&&(a(b.target).is("select")||a("."+p.focus).click());return a([16,17,18,9]).index(c)>=0}),a(document).on("click.d",function(b){var c=b.target;!a(c).parents("#"+p.root).length&&c!=d[0]&&(!t||c!=t[0])&&i.hide(b)})}a.extend(i,{show:function(b){if(!(d.attr("readonly")||d.attr("disabled")||C)){b=b||a.Event(),b.type="onBeforeShow",G.trigger(b);if(b.isDefaultPrevented())return;a.each(c,function(){this.hide()}),C=!0,H.off("change").change(function(){i.setValue(l(I.val()),l(a(this).val()))}),I.off("change").change(function(){i.setValue(l(a(this).val()),l(H.val()))}),u=r.find("#"+p.prev).off("click").click(function(a){u.hasClass(p.disabled)||i.addMonth(-1);return!1}),v=r.find("#"+p.next).off("click").click(function(a){v.hasClass(p.disabled)||i.addMonth();return!1}),i.setValue(z);var f=d.offset();/iPad/i.test(navigator.userAgent)&&(f.top-=a(window).scrollTop()),r.css({top:f.top+d.outerHeight({margins:!0})+e.offset[0],left:f.left+e.offset[1]}),e.speed?r.show(e.speed,function(){N(b)}):(r.show(),N(b));return i}},setValue:function(c,d,f){var g=l(d)>=-1?new Date(l(c),l(d),l(f==b||isNaN(f)?1:f)):c||z;g<A?g=A:g>B&&(g=B),typeof c=="string"&&(g=n(c)),c=g.getFullYear(),d=g.getMonth(),f=g.getDate(),d==-1?(d=11,c--):d==12&&(d=0,c++);if(!C){M(g,e);return i}x=d,w=c,y=f;var k=new Date(c,d,1-e.firstDay),o=k.getDay(),r=h(c,d),t=h(c,d-1),D;if(e.selectors){H.empty(),a.each(q.months,function(b,d){A<new Date(c,b+1,1)&&B>new Date(c,b,0)&&H.append(a("<option/>").html(d).attr("value",b))}),I.empty();var E=j.getFullYear();for(var F=E+e.yearRange[0];F<E+e.yearRange[1];F++)A<new Date(F+1,0,1)&&B>new Date(F,0,0)&&I.append(a("<option/>").text(F));H.val(d),I.val(c)}else s.html(q.months[d]+" "+c);L.empty(),u.add(v).removeClass(p.disabled);for(var G=o?0:-7,J,K;G<(o?42:35);G++)J=a("<a/>"),G%7===0&&(D=a("<div/>").addClass(p.week),L.append(D)),G<o?(J.addClass(p.off),K=t-o+G+1,g=new Date(c,d-1,K)):G<o+r?(K=G-o+1,g=new Date(c,d,K),m(z,g)?J.attr("id",p.current).addClass(p.focus):m(j,g)&&J.attr("id",p.today)):(J.addClass(p.off),K=G-r-o+1,g=new Date(c,d+1,K)),A&&g<A&&J.add(u).addClass(p.disabled),B&&g>B&&J.add(v).addClass(p.disabled),J.attr("href","#"+K).text(K).data("date",g),D.append(J);L.find("a").click(function(b){var c=a(this);c.hasClass(p.disabled)||(a("#"+p.current).removeAttr("id"),c.attr("id",p.current),M(c.data("date"),e,b));return!1}),p.sunday&&L.find("."+p.week).each(function(){var b=e.firstDay?7-e.firstDay:0;a(this).children().slice(b,b+1).addClass(p.sunday)});return i},setMin:function(a,b){A=n(a),b&&z<A&&i.setValue(A);return i},setMax:function(a,b){B=n(a),b&&z>B&&i.setValue(B);return i},today:function(){return i.setValue(j)},addDay:function(a){return this.setValue(w,x,y+(a||1))},addMonth:function(a){var b=x+(a||1),c=h(w,b),d=y<=c?y:c;return this.setValue(w,b,d)},addYear:function(a){return this.setValue(w+(a||1),x,y)},destroy:function(){d.add(document).off("click.d keydown.d"),r.add(t).remove(),d.removeData("dateinput").removeClass(p.input),D&&d.replaceWith(D)},hide:function(b){if(C){b=a.Event(),b.type="onHide",G.trigger(b);if(b.isDefaultPrevented())return;a(document).off("click.d keydown.d"),r.hide(),C=!1}return i},toggle:function(){return i.isOpen()?i.hide():i.show()},getConf:function(){return e},getInput:function(){return d},getCalendar:function(){return r},getValue:function(a){return a?k(e.formatter,z,a,e.lang):z},isOpen:function(){return C}}),a.each(["onBeforeShow","onShow","change","onHide"],function(b,c){a.isFunction(e[c])&&a(i).on(c,e[c]),i[c]=function(b){b&&a(i).on(c,b);return i}}),e.editable||d.on("focus.d click.d",i.show).keydown(function(b){var c=b.keyCode;if(C||a(f).index(c)<0)(c==8||c==46)&&d.val("");else{i.show(b);return b.preventDefault()}return b.shiftKey||b.ctrlKey||b.altKey||c==9?!0:b.preventDefault()}),n(d.val())&&M(z,e)}a.expr[":"].date=function(b){var c=b.getAttribute("type");return c&&c=="date"||a(b).data("dateinput")},a.fn.dateinput=function(b){if(this.data("dateinput"))return this;b=a.extend(!0,{},e.conf,b),a.each(b.css,function(a,c){!c&&a!="prefix"&&(b.css[a]=(b.css.prefix||"")+(c||a))});var d;this.each(function(){var e=new o(a(this),b);c.push(e);var f=e.getInput().data("dateinput",e);d=d?d.add(f):f});return d?d:this}})(jQuery);
(function(a){a.tools=a.tools||{version:"v1.2.7"},a.tools.overlay={addEffect:function(a,b,d){c[a]=[b,d]},conf:{close:null,closeOnClick:!0,closeOnEsc:!0,closeSpeed:"fast",effect:"default",fixed:!a.browser.msie||a.browser.version>6,left:"center",load:!1,mask:null,oneInstance:!0,speed:"normal",target:null,top:"10%"}};var b=[],c={};a.tools.overlay.addEffect("default",function(b,c){var d=this.getConf(),e=a(window);d.fixed||(b.top+=e.scrollTop(),b.left+=e.scrollLeft()),b.position=d.fixed?"fixed":"absolute",this.getOverlay().css(b).fadeIn(d.speed,c)},function(a){this.getOverlay().fadeOut(this.getConf().closeSpeed,a)});function d(d,e){var f=this,g=d.add(f),h=a(window),i,j,k,l=a.tools.expose&&(e.mask||e.expose),m=Math.random().toString().slice(10);l&&(typeof l=="string"&&(l={color:l}),l.closeOnClick=l.closeOnEsc=!1);var n=e.target||d.attr("rel");j=n?a(n):null||d;if(!j.length)throw"Could not find Overlay: "+n;d&&d.index(j)==-1&&d.click(function(a){f.load(a);return a.preventDefault()}),a.extend(f,{load:function(d){if(f.isOpened())return f;var i=c[e.effect];if(!i)throw"Overlay: cannot find effect : \""+e.effect+"\"";e.oneInstance&&a.each(b,function(){this.close(d)}),d=d||a.Event(),d.type="onBeforeLoad",g.trigger(d);if(d.isDefaultPrevented())return f;k=!0,l&&a(j).expose(l);var n=e.top,o=e.left,p=j.outerWidth({margin:!0}),q=j.outerHeight({margin:!0});typeof n=="string"&&(n=n=="center"?Math.max((h.height()-q)/2,0):parseInt(n,10)/100*h.height()),o=="center"&&(o=Math.max((h.width()-p)/2,0)),i[0].call(f,{top:n,left:o},function(){k&&(d.type="onLoad",g.trigger(d))}),l&&e.closeOnClick&&a.mask.getMask().one("click",f.close),e.closeOnClick&&a(document).on("click."+m,function(b){a(b.target).parents(j).length||f.close(b)}),e.closeOnEsc&&a(document).on("keydown."+m,function(a){a.keyCode==27&&f.close(a)});return f},close:function(b){if(!f.isOpened())return f;b=b||a.Event(),b.type="onBeforeClose",g.trigger(b);if(!b.isDefaultPrevented()){k=!1,c[e.effect][1].call(f,function(){b.type="onClose",g.trigger(b)}),a(document).off("click."+m+" keydown."+m),l&&a.mask.close();return f}},getOverlay:function(){return j},getTrigger:function(){return d},getClosers:function(){return i},isOpened:function(){return k},getConf:function(){return e}}),a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(b,c){a.isFunction(e[c])&&a(f).on(c,e[c]),f[c]=function(b){b&&a(f).on(c,b);return f}}),i=j.find(e.close||".close"),!i.length&&!e.close&&(i=a("<a class=\"close\"></a>"),j.prepend(i)),i.click(function(a){f.close(a)}),e.load&&f.load()}a.fn.overlay=function(c){var e=this.data("overlay");if(e)return e;a.isFunction(c)&&(c={onBeforeLoad:c}),c=a.extend(!0,{},a.tools.overlay.conf,c),this.each(function(){e=new d(a(this),c),b.push(e),a(this).data("overlay",e)});return c.api?e:this}})(jQuery);
(function(a){var b=a.tools.overlay,c=a(window);a.extend(b.conf,{start:{top:null,left:null},fadeInSpeed:"fast",zIndex:9999});function d(a){var b=a.offset();return{top:b.top+a.height()/2,left:b.left+a.width()/2}}var e=function(b,e){var f=this.getOverlay(),g=this.getConf(),h=this.getTrigger(),i=this,j=f.outerWidth({margin:!0}),k=f.data("img"),l=g.fixed?"fixed":"absolute";if(!k){var m=f.css("backgroundImage");if(!m)throw"background-image CSS property not set for overlay";m=m.slice(m.indexOf("(")+1,m.indexOf(")")).replace(/\"/g,""),f.css("backgroundImage","none"),k=a("<img src=\""+m+"\"/>"),k.css({border:0,display:"none"}).width(j),a("body").append(k),f.data("img",k)}var n=g.start.top||Math.round(c.height()/2),o=g.start.left||Math.round(c.width()/2);if(h){var p=d(h);n=p.top,o=p.left}g.fixed?(n-=c.scrollTop(),o-=c.scrollLeft()):(b.top+=c.scrollTop(),b.left+=c.scrollLeft()),k.css({position:"absolute",top:n,left:o,width:0,zIndex:g.zIndex}).show(),b.position=l,f.css(b),k.animate({top:b.top,left:b.left,width:j},g.speed,function(){f.css("zIndex",g.zIndex+1).fadeIn(g.fadeInSpeed,function(){i.isOpened()&&!a(this).index(f)?e.call():f.hide()})}).css("position",l)},f=function(b){var e=this.getOverlay().hide(),f=this.getConf(),g=this.getTrigger(),h=e.data("img"),i={top:f.start.top,left:f.start.left,width:0};g&&a.extend(i,d(g)),f.fixed&&h.css({position:"absolute"}).animate({top:"+="+c.scrollTop(),left:"+="+c.scrollLeft()},0),h.animate(i,f.closeSpeed,b)};b.addEffect("apple",e,f)})(jQuery);
(function(a){a.tools=a.tools||{version:"v1.2.7"};var b;b=a.tools.rangeinput={conf:{min:0,max:100,step:"any",steps:0,value:0,precision:undefined,vertical:0,keyboard:!0,progress:!1,speed:100,css:{input:"range",slider:"slider",progress:"progress",handle:"handle"}}};var c,d;a.fn.drag=function(b){document.ondragstart=function(){return!1},b=a.extend({x:!0,y:!0,drag:!0},b),c=c||a(document).on("mousedown mouseup",function(e){var f=a(e.target);if(e.type=="mousedown"&&f.data("drag")){var g=f.position(),h=e.pageX-g.left,i=e.pageY-g.top,j=!0;c.on("mousemove.drag",function(a){var c=a.pageX-h,e=a.pageY-i,g={};b.x&&(g.left=c),b.y&&(g.top=e),j&&(f.trigger("dragStart"),j=!1),b.drag&&f.css(g),f.trigger("drag",[e,c]),d=f}),e.preventDefault()}else try{d&&d.trigger("dragEnd")}finally{c.off("mousemove.drag"),d=null}});return this.data("drag",!0)};function e(a,b){var c=Math.pow(10,b);return Math.round(a*c)/c}function f(a,b){var c=parseInt(a.css(b),10);if(c)return c;var d=a[0].currentStyle;return d&&d.width&&parseInt(d.width,10)}function g(a){var b=a.data("events");return b&&b.onSlide}function h(b,c){var d=this,h=c.css,i=a("<div><div/><a href='#'/></div>").data("rangeinput",d),j,k,l,m,n;b.before(i);var o=i.addClass(h.slider).find("a").addClass(h.handle),p=i.find("div").addClass(h.progress);a.each("min,max,step,value".split(","),function(a,d){var e=b.attr(d);parseFloat(e)&&(c[d]=parseFloat(e,10))});var q=c.max-c.min,r=c.step=="any"?0:c.step,s=c.precision;s===undefined&&(s=r.toString().split("."),s=s.length===2?s[1].length:0);if(b.attr("type")=="range"){var t=b.clone().wrap("<div/>").parent().html(),u=a(t.replace(/type/i,"type=text data-orig-type"));u.val(c.value),b.replaceWith(u),b=u}b.addClass(h.input);var v=a(d).add(b),w=!0;function x(a,f,g,h){g===undefined?g=f/m*q:h&&(g-=c.min),r&&(g=Math.round(g/r)*r);if(f===undefined||r)f=g*m/q;if(isNaN(g))return d;f=Math.max(0,Math.min(f,m)),g=f/m*q;if(h||!j)g+=c.min;j&&(h?f=m-f:g=c.max-g),g=e(g,s);var i=a.type=="click";if(w&&k!==undefined&&!i){a.type="onSlide",v.trigger(a,[g,f]);if(a.isDefaultPrevented())return d}var l=i?c.speed:0,t=i?function(){a.type="change",v.trigger(a,[g])}:null;j?(o.animate({top:f},l,t),c.progress&&p.animate({height:m-f+o.height()/2},l)):(o.animate({left:f},l,t),c.progress&&p.animate({width:f+o.width()/2},l)),k=g,n=f,b.val(g);return d}a.extend(d,{getValue:function(){return k},setValue:function(b,c){y();return x(c||a.Event("api"),undefined,b,!0)},getConf:function(){return c},getProgress:function(){return p},getHandle:function(){return o},getInput:function(){return b},step:function(b,e){e=e||a.Event();var f=c.step=="any"?1:c.step;d.setValue(k+f*(b||1),e)},stepUp:function(a){return d.step(a||1)},stepDown:function(a){return d.step(-a||-1)}}),a.each("onSlide,change".split(","),function(b,e){a.isFunction(c[e])&&a(d).on(e,c[e]),d[e]=function(b){b&&a(d).on(e,b);return d}}),o.drag({drag:!1}).on("dragStart",function(){y(),w=g(a(d))||g(b)}).on("drag",function(a,c,d){if(b.is(":disabled"))return!1;x(a,j?c:d)}).on("dragEnd",function(a){a.isDefaultPrevented()||(a.type="change",v.trigger(a,[k]))}).click(function(a){return a.preventDefault()}),i.click(function(a){if(b.is(":disabled")||a.target==o[0])return a.preventDefault();y();var c=j?o.height()/2:o.width()/2;x(a,j?m-l-c+a.pageY:a.pageX-l-c)}),c.keyboard&&b.keydown(function(c){if(!b.attr("readonly")){var e=c.keyCode,f=a([75,76,38,33,39]).index(e)!=-1,g=a([74,72,40,34,37]).index(e)!=-1;if((f||g)&&!(c.shiftKey||c.altKey||c.ctrlKey)){f?d.step(e==33?10:1,c):g&&d.step(e==34?-10:-1,c);return c.preventDefault()}}}),b.blur(function(b){var c=a(this).val();c!==k&&d.setValue(c,b)}),a.extend(b[0],{stepUp:d.stepUp,stepDown:d.stepDown});function y(){j=c.vertical||f(i,"height")>f(i,"width"),j?(m=f(i,"height")-f(o,"height"),l=i.offset().top+m):(m=f(i,"width")-f(o,"width"),l=i.offset().left)}function z(){y(),d.setValue(c.value!==undefined?c.value:c.min)}z(),m||a(window).load(z)}a.expr[":"].range=function(b){var c=b.getAttribute("type");return c&&c=="range"||a(b).filter("input").data("rangeinput")},a.fn.rangeinput=function(c){if(this.data("rangeinput"))return this;c=a.extend(!0,{},b.conf,c);var d;this.each(function(){var b=new h(a(this),a.extend(!0,{},c)),e=b.getInput().data("rangeinput",b);d=d?d.add(e):e});return d?d:this}})(jQuery);
(function(a){a.tools=a.tools||{version:"v1.2.7"},a.tools.scrollable={conf:{activeClass:"active",circular:!1,clonedClass:"cloned",disabledClass:"disabled",easing:"swing",initialIndex:0,item:"> *",items:".items",keyboard:!0,mousewheel:!1,next:".next",prev:".prev",size:1,speed:400,vertical:!1,touch:!0,wheelSpeed:0}};function b(a,b){var c=parseInt(a.css(b),10);if(c)return c;var d=a[0].currentStyle;return d&&d.width&&parseInt(d.width,10)}function c(b,c){var d=a(c);return d.length<2?d:b.parent().find(c)}var d;function e(b,e){var f=this,g=b.add(f),h=b.children(),i=0,j=e.vertical;d||(d=f),h.length>1&&(h=a(e.items,b)),e.size>1&&(e.circular=!1),a.extend(f,{getConf:function(){return e},getIndex:function(){return i},getSize:function(){return f.getItems().size()},getNaviButtons:function(){return n.add(o)},getRoot:function(){return b},getItemWrap:function(){return h},getItems:function(){return h.find(e.item).not("."+e.clonedClass)},move:function(a,b){return f.seekTo(i+a,b)},next:function(a){return f.move(e.size,a)},prev:function(a){return f.move(-e.size,a)},begin:function(a){return f.seekTo(0,a)},end:function(a){return f.seekTo(f.getSize()-1,a)},focus:function(){d=f;return f},addItem:function(b){b=a(b),e.circular?(h.children().last().before(b),h.children().first().replaceWith(b.clone().addClass(e.clonedClass))):(h.append(b),o.removeClass("disabled")),g.trigger("onAddItem",[b]);return f},seekTo:function(b,c,k){b.jquery||(b*=1);if(e.circular&&b===0&&i==-1&&c!==0)return f;if(!e.circular&&b<0||b>f.getSize()||b<-1)return f;var l=b;b.jquery?b=f.getItems().index(b):l=f.getItems().eq(b);var m=a.Event("onBeforeSeek");if(!k){g.trigger(m,[b,c]);if(m.isDefaultPrevented()||!l.length)return f}var n=j?{top:-l.position().top}:{left:-l.position().left};i=b,d=f,c===undefined&&(c=e.speed),h.animate(n,c,e.easing,k||function(){g.trigger("onSeek",[b])});return f}}),a.each(["onBeforeSeek","onSeek","onAddItem"],function(b,c){a.isFunction(e[c])&&a(f).on(c,e[c]),f[c]=function(b){b&&a(f).on(c,b);return f}});if(e.circular){var k=f.getItems().slice(-1).clone().prependTo(h),l=f.getItems().eq(1).clone().appendTo(h);k.add(l).addClass(e.clonedClass),f.onBeforeSeek(function(a,b,c){if(!a.isDefaultPrevented()){if(b==-1){f.seekTo(k,c,function(){f.end(0)});return a.preventDefault()}b==f.getSize()&&f.seekTo(l,c,function(){f.begin(0)})}});var m=b.parents().add(b).filter(function(){if(a(this).css("display")==="none")return!0});m.length?(m.show(),f.seekTo(0,0,function(){}),m.hide()):f.seekTo(0,0,function(){})}var n=c(b,e.prev).click(function(a){a.stopPropagation(),f.prev()}),o=c(b,e.next).click(function(a){a.stopPropagation(),f.next()});e.circular||(f.onBeforeSeek(function(a,b){setTimeout(function(){a.isDefaultPrevented()||(n.toggleClass(e.disabledClass,b<=0),o.toggleClass(e.disabledClass,b>=f.getSize()-1))},1)}),e.initialIndex||n.addClass(e.disabledClass)),f.getSize()<2&&n.add(o).addClass(e.disabledClass),e.mousewheel&&a.fn.mousewheel&&b.mousewheel(function(a,b){if(e.mousewheel){f.move(b<0?1:-1,e.wheelSpeed||50);return!1}});if(e.touch){var p={};h[0].ontouchstart=function(a){var b=a.touches[0];p.x=b.clientX,p.y=b.clientY},h[0].ontouchmove=function(a){if(a.touches.length==1&&!h.is(":animated")){var b=a.touches[0],c=p.x-b.clientX,d=p.y-b.clientY;f[j&&d>0||!j&&c>0?"next":"prev"](),a.preventDefault()}}}e.keyboard&&a(document).on("keydown.scrollable",function(b){if(!(!e.keyboard||b.altKey||b.ctrlKey||b.metaKey||a(b.target).is(":input"))){if(e.keyboard!="static"&&d!=f)return;var c=b.keyCode;if(j&&(c==38||c==40)){f.move(c==38?-1:1);return b.preventDefault()}if(!j&&(c==37||c==39)){f.move(c==37?-1:1);return b.preventDefault()}}}),e.initialIndex&&f.seekTo(e.initialIndex,0,function(){})}a.fn.scrollable=function(b){var c=this.data("scrollable");if(c)return c;b=a.extend({},a.tools.scrollable.conf,b),this.each(function(){c=new e(a(this),b),a(this).data("scrollable",c)});return b.api?c:this}})(jQuery);
(function(a){var b=a.tools.scrollable;b.autoscroll={conf:{autoplay:!0,interval:3e3,autopause:!0}},a.fn.autoscroll=function(c){typeof c=="number"&&(c={interval:c});var d=a.extend({},b.autoscroll.conf,c),e;this.each(function(){var b=a(this).data("scrollable"),c=b.getRoot(),f,g=!1;function h(){f&&clearTimeout(f),f=setTimeout(function(){b.next()},d.interval)}b&&(e=b),b.play=function(){f||(g=!1,c.on("onSeek",h),h())},b.pause=function(){f=clearTimeout(f),c.off("onSeek",h)},b.resume=function(){g||b.play()},b.stop=function(){g=!0,b.pause()},d.autopause&&c.add(b.getNaviButtons()).hover(b.pause,b.resume),d.autoplay&&b.play()});return d.api?e:this}})(jQuery);
(function(a){var b=a.tools.scrollable;b.navigator={conf:{navi:".navi",naviItem:null,activeClass:"active",indexed:!1,idPrefix:null,history:!1}};function c(b,c){var d=a(c);return d.length<2?d:b.parent().find(c)}a.fn.navigator=function(d){typeof d=="string"&&(d={navi:d}),d=a.extend({},b.navigator.conf,d);var e;this.each(function(){var b=a(this).data("scrollable"),f=d.navi.jquery?d.navi:c(b.getRoot(),d.navi),g=b.getNaviButtons(),h=d.activeClass,i=d.history&&history.pushState,j=b.getConf().size;b&&(e=b),b.getNaviButtons=function(){return g.add(f)},i&&(history.pushState({i:0},""),a(window).on("popstate",function(a){var c=a.originalEvent.state;c&&b.seekTo(c.i)}));function k(a,c,d){b.seekTo(c),d.preventDefault(),i&&history.pushState({i:c},"")}function l(){return f.find(d.naviItem||"> *")}function m(b){var c=a("<"+(d.naviItem||"a")+"/>").click(function(c){k(a(this),b,c)});b===0&&c.addClass(h),d.indexed&&c.text(b+1),d.idPrefix&&c.attr("id",d.idPrefix+b);return c.appendTo(f)}l().length?l().each(function(b){a(this).click(function(c){k(a(this),b,c)})}):a.each(b.getItems(),function(a){a%j==0&&m(a)}),b.onBeforeSeek(function(a,b){setTimeout(function(){if(!a.isDefaultPrevented()){var c=b/j,d=l().eq(c);d.length&&l().removeClass(h).eq(c).addClass(h)}},1)}),b.onAddItem(function(a,c){var d=b.getItems().index(c);d%j==0&&m(d)})});return d.api?e:this}})(jQuery);
(function(a){a.tools=a.tools||{version:"v1.2.7"},a.tools.tabs={conf:{tabs:"a",current:"current",onBeforeClick:null,onClick:null,effect:"default",initialEffect:!1,initialIndex:0,event:"click",rotate:!1,slideUpSpeed:400,slideDownSpeed:400,history:!1},addEffect:function(a,c){b[a]=c}};var b={"default":function(a,b){this.getPanes().hide().eq(a).show(),b.call()},fade:function(a,b){var c=this.getConf(),d=c.fadeOutSpeed,e=this.getPanes();d?e.fadeOut(d):e.hide(),e.eq(a).fadeIn(c.fadeInSpeed,b)},slide:function(a,b){var c=this.getConf();this.getPanes().slideUp(c.slideUpSpeed),this.getPanes().eq(a).slideDown(c.slideDownSpeed,b)},ajax:function(a,b){this.getPanes().eq(0).load(this.getTabs().eq(a).attr("href"),b)}},c,d;a.tools.tabs.addEffect("horizontal",function(b,e){if(!c){var f=this.getPanes().eq(b),g=this.getCurrentPane();d||(d=this.getPanes().eq(0).width()),c=!0,f.show(),g.animate({width:0},{step:function(a){f.css("width",d-a)},complete:function(){a(this).hide(),e.call(),c=!1}}),g.length||(e.call(),c=!1)}});function e(c,d,e){var f=this,g=c.add(this),h=c.find(e.tabs),i=d.jquery?d:c.children(d),j;h.length||(h=c.children()),i.length||(i=c.parent().find(d)),i.length||(i=a(d)),a.extend(this,{click:function(d,i){var k=h.eq(d),l=!c.data("tabs");typeof d=="string"&&d.replace("#","")&&(k=h.filter("[href*=\""+d.replace("#","")+"\"]"),d=Math.max(h.index(k),0));if(e.rotate){var m=h.length-1;if(d<0)return f.click(m,i);if(d>m)return f.click(0,i)}if(!k.length){if(j>=0)return f;d=e.initialIndex,k=h.eq(d)}if(d===j)return f;i=i||a.Event(),i.type="onBeforeClick",g.trigger(i,[d]);if(!i.isDefaultPrevented()){var n=l?e.initialEffect&&e.effect||"default":e.effect;b[n].call(f,d,function(){j=d,i.type="onClick",g.trigger(i,[d])}),h.removeClass(e.current),k.addClass(e.current);return f}},getConf:function(){return e},getTabs:function(){return h},getPanes:function(){return i},getCurrentPane:function(){return i.eq(j)},getCurrentTab:function(){return h.eq(j)},getIndex:function(){return j},next:function(){return f.click(j+1)},prev:function(){return f.click(j-1)},destroy:function(){h.off(e.event).removeClass(e.current),i.find("a[href^=\"#\"]").off("click.T");return f}}),a.each("onBeforeClick,onClick".split(","),function(b,c){a.isFunction(e[c])&&a(f).on(c,e[c]),f[c]=function(b){b&&a(f).on(c,b);return f}}),e.history&&a.fn.history&&(a.tools.history.init(h),e.event="history"),h.each(function(b){a(this).on(e.event,function(a){f.click(b,a);return a.preventDefault()})}),i.find("a[href^=\"#\"]").on("click.T",function(b){f.click(a(this).attr("href"),b)}),location.hash&&e.tabs=="a"&&c.find("[href=\""+location.hash+"\"]").length?f.click(location.hash):(e.initialIndex===0||e.initialIndex>0)&&f.click(e.initialIndex)}a.fn.tabs=function(b,c){var d=this.data("tabs");d&&(d.destroy(),this.removeData("tabs")),a.isFunction(c)&&(c={onBeforeClick:c}),c=a.extend({},a.tools.tabs.conf,c),this.each(function(){d=new e(a(this),b,c),a(this).data("tabs",d)});return c.api?d:this}})(jQuery);
(function(a){var b;b=a.tools.tabs.slideshow={conf:{next:".forward",prev:".backward",disabledClass:"disabled",autoplay:!1,autopause:!0,interval:3e3,clickable:!0,api:!1}};function c(b,c){var d=this,e=b.add(this),f=b.data("tabs"),g,h=!0;function i(c){var d=a(c);return d.length<2?d:b.parent().find(c)}var j=i(c.next).click(function(){f.next()}),k=i(c.prev).click(function(){f.prev()});function l(){g=setTimeout(function(){f.next()},c.interval)}a.extend(d,{getTabs:function(){return f},getConf:function(){return c},play:function(){if(g)return d;var b=a.Event("onBeforePlay");e.trigger(b);if(b.isDefaultPrevented())return d;h=!1,e.trigger("onPlay"),e.on("onClick",l),l();return d},pause:function(){if(!g)return d;var b=a.Event("onBeforePause");e.trigger(b);if(b.isDefaultPrevented())return d;g=clearTimeout(g),e.trigger("onPause"),e.off("onClick",l);return d},resume:function(){h||d.play()},stop:function(){d.pause(),h=!0}}),a.each("onBeforePlay,onPlay,onBeforePause,onPause".split(","),function(b,e){a.isFunction(c[e])&&a(d).on(e,c[e]),d[e]=function(b){return a(d).on(e,b)}}),c.autopause&&f.getTabs().add(j).add(k).add(f.getPanes()).hover(d.pause,d.resume),c.autoplay&&d.play(),c.clickable&&f.getPanes().click(function(){f.next()});if(!f.getConf().rotate){var m=c.disabledClass;f.getIndex()||k.addClass(m),f.onBeforeClick(function(a,b){k.toggleClass(m,!b),j.toggleClass(m,b==f.getTabs().length-1)})}}a.fn.slideshow=function(d){var e=this.data("slideshow");if(e)return e;d=a.extend({},b.conf,d),this.each(function(){e=new c(a(this),d),a(this).data("slideshow",e)});return d.api?e:this}})(jQuery);
(function(a){a.tools=a.tools||{version:"v1.2.7"};var b;b=a.tools.expose={conf:{maskId:"exposeMask",loadSpeed:"slow",closeSpeed:"fast",closeOnClick:!0,closeOnEsc:!0,zIndex:9998,opacity:.8,startOpacity:0,color:"#fff",onLoad:null,onClose:null}};function c(){if(a.browser.msie){var b=a(document).height(),c=a(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,b-c<20?c:b]}return[a(document).width(),a(document).height()]}function d(b){if(b)return b.call(a.mask)}var e,f,g,h,i;a.mask={load:function(j,k){if(g)return this;typeof j=="string"&&(j={color:j}),j=j||h,h=j=a.extend(a.extend({},b.conf),j),e=a("#"+j.maskId),e.length||(e=a("<div/>").attr("id",j.maskId),a("body").append(e));var l=c();e.css({position:"absolute",top:0,left:0,width:l[0],height:l[1],display:"none",opacity:j.startOpacity,zIndex:j.zIndex}),j.color&&e.css("backgroundColor",j.color);if(d(j.onBeforeLoad)===!1)return this;j.closeOnEsc&&a(document).on("keydown.mask",function(b){b.keyCode==27&&a.mask.close(b)}),j.closeOnClick&&e.on("click.mask",function(b){a.mask.close(b)}),a(window).on("resize.mask",function(){a.mask.fit()}),k&&k.length&&(i=k.eq(0).css("zIndex"),a.each(k,function(){var b=a(this);/relative|absolute|fixed/i.test(b.css("position"))||b.css("position","relative")}),f=k.css({zIndex:Math.max(j.zIndex+1,i=="auto"?0:i)})),e.css({display:"block"}).fadeTo(j.loadSpeed,j.opacity,function(){a.mask.fit(),d(j.onLoad),g="full"}),g=!0;return this},close:function(){if(g){if(d(h.onBeforeClose)===!1)return this;e.fadeOut(h.closeSpeed,function(){d(h.onClose),f&&f.css({zIndex:i}),g=!1}),a(document).off("keydown.mask"),e.off("click.mask"),a(window).off("resize.mask")}return this},fit:function(){if(g){var a=c();e.css({width:a[0],height:a[1]})}},getMask:function(){return e},isLoaded:function(a){return a?g=="full":g},getConf:function(){return h},getExposed:function(){return f}},a.fn.mask=function(b){a.mask.load(b);return this},a.fn.expose=function(b){a.mask.load(b,this);return this}})(jQuery);
(function(){var a=document.all,b="http://www.adobe.com/go/getflashplayer",c=typeof jQuery=="function",d=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,e={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:!0,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:!1,cachebusting:!1};window.attachEvent&&window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){},__flash_savedUnloadHandler=function(){}});function f(a,b){if(b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function g(a,b){var c=[];for(var d in a)a.hasOwnProperty(d)&&(c[d]=b(a[d]));return c}window.flashembed=function(a,b,c){typeof a=="string"&&(a=document.getElementById(a.replace("#","")));if(a){typeof b=="string"&&(b={src:b});return new j(a,f(f({},e),b),c)}};var h=f(window.flashembed,{conf:e,getVersion:function(){var a,b;try{b=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(c){try{a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"),b=a&&a.GetVariable("$version")}catch(e){try{a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"),b=a&&a.GetVariable("$version")}catch(f){}}}b=d.exec(b);return b?[b[1],b[3]]:[0,0]},asString:function(a){if(a===null||a===undefined)return null;var b=typeof a;b=="object"&&a.push&&(b="array");switch(b){case"string":a=a.replace(new RegExp("([\"\\\\])","g"),"\\$1"),a=a.replace(/^\s?(\d+\.?\d*)%/,"$1pct");return"\""+a+"\"";case"array":return"["+g(a,function(a){return h.asString(a)}).join(",")+"]";case"function":return"\"function()\"";case"object":var c=[];for(var d in a)a.hasOwnProperty(d)&&c.push("\""+d+"\":"+h.asString(a[d]));return"{"+c.join(",")+"}"}return String(a).replace(/\s/g," ").replace(/\'/g,"\"")},getHTML:function(b,c){b=f({},b);var d="<object width=\""+b.width+"\" height=\""+b.height+"\" id=\""+b.id+"\" name=\""+b.id+"\"";b.cachebusting&&(b.src+=(b.src.indexOf("?")!=-1?"&":"?")+Math.random()),b.w3c||!a?d+=" data=\""+b.src+"\" type=\"application/x-shockwave-flash\"":d+=" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"",d+=">";if(b.w3c||a)d+="<param name=\"movie\" value=\""+b.src+"\" />";b.width=b.height=b.id=b.w3c=b.src=null,b.onFail=b.version=b.expressInstall=null;for(var e in b)b[e]&&(d+="<param name=\""+e+"\" value=\""+b[e]+"\" />");var g="";if(c){for(var i in c)if(c[i]){var j=c[i];g+=i+"="+encodeURIComponent(/function|object/.test(typeof j)?h.asString(j):j)+"&"}g=g.slice(0,-1),d+="<param name=\"flashvars\" value='"+g+"' />"}d+="</object>";return d},isSupported:function(a){return i[0]>a[0]||i[0]==a[0]&&i[1]>=a[1]}}),i=h.getVersion();function j(c,d,e){if(h.isSupported(d.version))c.innerHTML=h.getHTML(d,e);else if(d.expressInstall&&h.isSupported([6,65]))c.innerHTML=h.getHTML(f(d,{src:d.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title});else{c.innerHTML.replace(/\s/g,"")||(c.innerHTML="<h2>Flash version "+d.version+" or greater is required</h2><h3>"+(i[0]>0?"Your version is "+i:"You have no flash plugin installed")+"</h3>"+(c.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+b+"'>here</a></p>"),c.tagName=="A"&&(c.onclick=function(){location.href=b}));if(d.onFail){var g=d.onFail.call(this);typeof g=="string"&&(c.innerHTML=g)}}a&&(window[d.id]=document.getElementById(d.id)),f(this,{getRoot:function(){return c},getOptions:function(){return d},getConf:function(){return e},getApi:function(){return c.firstChild}})}c&&(jQuery.tools=jQuery.tools||{version:"v1.2.7"},jQuery.tools.flashembed={conf:e},jQuery.fn.flashembed=function(a,b){return this.each(function(){jQuery(this).data("flashembed",flashembed(this,a,b))})})})();
(function(a){var b,c,d,e;a.tools=a.tools||{version:"v1.2.7"},a.tools.history={init:function(g){e||(a.browser.msie&&a.browser.version<"8"?c||(c=a("<iframe/>").attr("src","javascript:false;").hide().get(0),a("body").append(c),setInterval(function(){var d=c.contentWindow.document,e=d.location.hash;b!==e&&a(window).trigger("hash",e)},100),f(location.hash||"#")):setInterval(function(){var c=location.hash;c!==b&&a(window).trigger("hash",c)},100),d=d?d.add(g):g,g.click(function(b){var d=a(this).attr("href");c&&f(d);if(d.slice(0,1)!="#"){location.href="#"+d;return b.preventDefault()}}),e=!0)}};function f(a){if(a){var b=c.contentWindow.document;b.open().close(),b.location.hash=a}}a(window).on("hash",function(c,e){e?d.filter(function(){var b=a(this).attr("href");return b==e||b==e.replace("#","")}).trigger("history",[e]):d.eq(0).trigger("history",[e]),b=e}),a.fn.history=function(b){a.tools.history.init(this);return this.on("history",b)}})(jQuery);
(function(a){a.fn.mousewheel=function(a){return this[a?"on":"trigger"]("wheel",a)},a.event.special.wheel={setup:function(){a.event.add(this,b,c,{})},teardown:function(){a.event.remove(this,b,c)}};var b=a.browser.mozilla?"DOMMouseScroll"+(a.browser.version<"1.9"?" mousemove":""):"mousewheel";function c(b){switch(b.type){case"mousemove":return a.extend(b.data,{clientX:b.clientX,clientY:b.clientY,pageX:b.pageX,pageY:b.pageY});case"DOMMouseScroll":a.extend(b,b.data),b.delta=-b.detail/3;break;case"mousewheel":b.delta=b.wheelDelta/120}b.type="wheel";return a.event.handle.call(this,b,b.delta)}})(jQuery);
(function(a){a.tools=a.tools||{version:"v1.2.7"},a.tools.tooltip={conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,fadeIE:!1,position:["top","center"],offset:[0,0],relative:!1,cancelDefault:!0,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,c,d){b[a]=[c,d]}};var b={toggle:[function(a){var b=this.getConf(),c=this.getTip(),d=b.opacity;d<1&&c.css({opacity:d}),c.show(),a.call()},function(a){this.getTip().hide(),a.call()}],fade:[function(b){var c=this.getConf();!a.browser.msie||c.fadeIE?this.getTip().fadeTo(c.fadeInSpeed,c.opacity,b):(this.getTip().show(),b())},function(b){var c=this.getConf();!a.browser.msie||c.fadeIE?this.getTip().fadeOut(c.fadeOutSpeed,b):(this.getTip().hide(),b())}]};function c(b,c,d){var e=d.relative?b.position().top:b.offset().top,f=d.relative?b.position().left:b.offset().left,g=d.position[0];e-=c.outerHeight()-d.offset[0],f+=b.outerWidth()+d.offset[1],/iPad/i.test(navigator.userAgent)&&(e-=a(window).scrollTop());var h=c.outerHeight()+b.outerHeight();g=="center"&&(e+=h/2),g=="bottom"&&(e+=h),g=d.position[1];var i=c.outerWidth()+b.outerWidth();g=="center"&&(f-=i/2),g=="left"&&(f-=i);return{top:e,left:f}}function d(d,e){var f=this,g=d.add(f),h,i=0,j=0,k=d.attr("title"),l=d.attr("data-tooltip"),m=b[e.effect],n,o=d.is(":input"),p=o&&d.is(":checkbox, :radio, select, :button, :submit"),q=d.attr("type"),r=e.events[q]||e.events[o?p?"widget":"input":"def"];if(!m)throw"Nonexistent effect \""+e.effect+"\"";r=r.split(/,\s*/);if(r.length!=2)throw"Tooltip: bad events configuration for "+q;d.on(r[0],function(a){clearTimeout(i),e.predelay?j=setTimeout(function(){f.show(a)},e.predelay):f.show(a)}).on(r[1],function(a){clearTimeout(j),e.delay?i=setTimeout(function(){f.hide(a)},e.delay):f.hide(a)}),k&&e.cancelDefault&&(d.removeAttr("title"),d.data("title",k)),a.extend(f,{show:function(b){if(!h){l?h=a(l):e.tip?h=a(e.tip).eq(0):k?h=a(e.layout).addClass(e.tipClass).appendTo(document.body).hide().append(k):(h=d.next(),h.length||(h=d.parent().next()));if(!h.length)throw"Cannot find tooltip for "+d}if(f.isShown())return f;h.stop(!0,!0);var o=c(d,h,e);e.tip&&h.html(d.data("title")),b=a.Event(),b.type="onBeforeShow",g.trigger(b,[o]);if(b.isDefaultPrevented())return f;o=c(d,h,e),h.css({position:"absolute",top:o.top,left:o.left}),n=!0,m[0].call(f,function(){b.type="onShow",n="full",g.trigger(b)});var p=e.events.tooltip.split(/,\s*/);h.data("__set")||(h.off(p[0]).on(p[0],function(){clearTimeout(i),clearTimeout(j)}),p[1]&&!d.is("input:not(:checkbox, :radio), textarea")&&h.off(p[1]).on(p[1],function(a){a.relatedTarget!=d[0]&&d.trigger(r[1].split(" ")[0])}),e.tip||h.data("__set",!0));return f},hide:function(c){if(!h||!f.isShown())return f;c=a.Event(),c.type="onBeforeHide",g.trigger(c);if(!c.isDefaultPrevented()){n=!1,b[e.effect][1].call(f,function(){c.type="onHide",g.trigger(c)});return f}},isShown:function(a){return a?n=="full":n},getConf:function(){return e},getTip:function(){return h},getTrigger:function(){return d}}),a.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(b,c){a.isFunction(e[c])&&a(f).on(c,e[c]),f[c]=function(b){b&&a(f).on(c,b);return f}})}a.fn.tooltip=function(b){var c=this.data("tooltip");if(c)return c;b=a.extend(!0,{},a.tools.tooltip.conf,b),typeof b.position=="string"&&(b.position=b.position.split(/,?\s/)),this.each(function(){c=new d(a(this),b),a(this).data("tooltip",c)});return b.api?c:this}})(jQuery);
(function(a){var b=a.tools.tooltip;b.dynamic={conf:{classNames:"top right bottom left"}};function c(b){var c=a(window),d=c.width()+c.scrollLeft(),e=c.height()+c.scrollTop();return[b.offset().top<=c.scrollTop(),d<=b.offset().left+b.width(),e<=b.offset().top+b.height(),c.scrollLeft()>=b.offset().left]}function d(a){var b=a.length;while(b--)if(a[b])return!1;return!0}a.fn.dynamic=function(e){typeof e=="number"&&(e={speed:e}),e=a.extend({},b.dynamic.conf,e);var f=a.extend(!0,{},e),g=e.classNames.split(/\s/),h;this.each(function(){var b=a(this).tooltip().onBeforeShow(function(b,e){var i=this.getTip(),j=this.getConf();h||(h=[j.position[0],j.position[1],j.offset[0],j.offset[1],a.extend({},j)]),a.extend(j,h[4]),j.position=[h[0],h[1]],j.offset=[h[2],h[3]],i.css({visibility:"hidden",position:"absolute",top:e.top,left:e.left}).show();var k=a.extend(!0,{},f),l=c(i);if(!d(l)){l[2]&&(a.extend(j,k.top),j.position[0]="top",i.addClass(g[0])),l[3]&&(a.extend(j,k.right),j.position[1]="right",i.addClass(g[1])),l[0]&&(a.extend(j,k.bottom),j.position[0]="bottom",i.addClass(g[2])),l[1]&&(a.extend(j,k.left),j.position[1]="left",i.addClass(g[3]));if(l[0]||l[2])j.offset[0]*=-1;if(l[1]||l[3])j.offset[1]*=-1}i.css({visibility:"visible"}).hide()});b.onBeforeShow(function(){var a=this.getConf(),b=this.getTip();setTimeout(function(){a.position=[h[0],h[1]],a.offset=[h[2],h[3]]},0)}),b.onHide(function(){var a=this.getTip();a.removeClass(e.classNames)}),ret=b});return e.api?ret:this}})(jQuery);
(function(a){var b=a.tools.tooltip;a.extend(b.conf,{direction:"up",bounce:!1,slideOffset:10,slideInSpeed:200,slideOutSpeed:200,slideFade:!a.browser.msie});var c={up:["-","top"],down:["+","top"],left:["-","left"],right:["+","left"]};b.addEffect("slide",function(a){var b=this.getConf(),d=this.getTip(),e=b.slideFade?{opacity:b.opacity}:{},f=c[b.direction]||c.up;e[f[1]]=f[0]+"="+b.slideOffset,b.slideFade&&d.css({opacity:0}),d.show().animate(e,b.slideInSpeed,a)},function(b){var d=this.getConf(),e=d.slideOffset,f=d.slideFade?{opacity:0}:{},g=c[d.direction]||c.up,h=""+g[0];d.bounce&&(h=h=="+"?"-":"+"),f[g[1]]=h+"="+e,this.getTip().animate(f,d.slideOutSpeed,function(){a(this).hide(),b.call()})})})(jQuery);
(function(a){a.tools=a.tools||{version:"v1.2.7"};var b=/\[type=([a-z]+)\]/,c=/^-?[0-9]*(\.[0-9]+)?$/,d=a.tools.dateinput,e=/^([a-z0-9_\.\-\+]+)@([\da-z\.\-]+)\.([a-z\.]{2,6})$/i,f=/^(https?:\/\/)?[\da-z\.\-]+\.[a-z\.]{2,6}[#&+_\?\/\w \.\-=]*$/i,g;g=a.tools.validator={conf:{grouped:!1,effect:"default",errorClass:"invalid",inputEvent:null,errorInputEvent:"keyup",formEvent:"submit",lang:"en",message:"<div/>",messageAttr:"data-message",messageClass:"error",offset:[0,0],position:"center right",singleError:!1,speed:"normal"},messages:{"*":{en:"Please correct this value"}},localize:function(b,c){a.each(c,function(a,c){g.messages[a]=g.messages[a]||{},g.messages[a][b]=c})},localizeFn:function(b,c){g.messages[b]=g.messages[b]||{},a.extend(g.messages[b],c)},fn:function(c,d,e){a.isFunction(d)?e=d:(typeof d=="string"&&(d={en:d}),this.messages[c.key||c]=d);var f=b.exec(c);f&&(c=i(f[1])),j.push([c,e])},addEffect:function(a,b,c){k[a]=[b,c]}};function h(b,c,d){c=a(c).first()||c;var e=b.offset().top,f=b.offset().left,g=d.position.split(/,?\s+/),h=g[0],i=g[1];e-=c.outerHeight()-d.offset[0],f+=b.outerWidth()+d.offset[1],/iPad/i.test(navigator.userAgent)&&(e-=a(window).scrollTop());var j=c.outerHeight()+b.outerHeight();h=="center"&&(e+=j/2),h=="bottom"&&(e+=j);var k=b.outerWidth();i=="center"&&(f-=(k+c.outerWidth())/2),i=="left"&&(f-=k);return{top:e,left:f}}function i(a){function b(){return this.getAttribute("type")==a}b.key="[type=\""+a+"\"]";return b}var j=[],k={"default":[function(b){var c=this.getConf();a.each(b,function(b,d){var e=d.input;e.addClass(c.errorClass);var f=e.data("msg.el");f||(f=a(c.message).addClass(c.messageClass).appendTo(document.body),e.data("msg.el",f)),f.css({visibility:"hidden"}).find("p").remove(),a.each(d.messages,function(b,c){a("<p/>").html(c).appendTo(f)}),f.outerWidth()==f.parent().width()&&f.add(f.find("p")).css({display:"inline"});var g=h(e,f,c);f.css({visibility:"visible",position:"absolute",top:g.top,left:g.left}).fadeIn(c.speed)})},function(b){var c=this.getConf();b.removeClass(c.errorClass).each(function(){var b=a(this).data("msg.el");b&&b.css({visibility:"hidden"})})}]};a.each("email,url,number".split(","),function(b,c){a.expr[":"][c]=function(a){return a.getAttribute("type")===c}}),a.fn.oninvalid=function(a){return this[a?"on":"trigger"]("OI",a)},g.fn(":email","Please enter a valid email address",function(a,b){return!b||e.test(b)}),g.fn(":url","Please enter a valid URL",function(a,b){return!b||f.test(b)}),g.fn(":number","Please enter a numeric value.",function(a,b){return c.test(b)}),g.fn("[max]","Please enter a value no larger than $1",function(a,b){if(b===""||d&&a.is(":date"))return!0;var c=a.attr("max");return parseFloat(b)<=parseFloat(c)?!0:[c]}),g.fn("[min]","Please enter a value of at least $1",function(a,b){if(b===""||d&&a.is(":date"))return!0;var c=a.attr("min");return parseFloat(b)>=parseFloat(c)?!0:[c]}),g.fn("[required]","Please complete this mandatory field.",function(a,b){if(a.is(":checkbox"))return a.is(":checked");return b}),g.fn("[pattern]",function(a,b){return b===""||(new RegExp("^"+a.attr("pattern")+"$")).test(b)}),g.fn(":radio","Please select an option.",function(b){var c=!1,d=a("[name='"+b.attr("name")+"']").each(function(b,d){a(d).is(":checked")&&(c=!0)});return c?!0:!1});function l(b,c,e){var f=this,i=c.add(f);b=b.not(":button, :image, :reset, :submit"),c.attr("novalidate","novalidate");function l(b,c,d){if(e.grouped||!b.length){var f;if(d===!1||a.isArray(d)){f=g.messages[c.key||c]||g.messages["*"],f=f[e.lang]||g.messages["*"].en;var h=f.match(/\$\d/g);h&&a.isArray(d)&&a.each(h,function(a){f=f.replace(this,d[a])})}else f=d[e.lang]||d;b.push(f)}}a.extend(f,{getConf:function(){return e},getForm:function(){return c},getInputs:function(){return b},reflow:function(){b.each(function(){var b=a(this),c=b.data("msg.el");if(c){var d=h(b,c,e);c.css({top:d.top,left:d.left})}});return f},invalidate:function(c,d){if(!d){var g=[];a.each(c,function(a,c){var d=b.filter("[name='"+a+"']");d.length&&(d.trigger("OI",[c]),g.push({input:d,messages:[c]}))}),c=g,d=a.Event()}d.type="onFail",i.trigger(d,[c]),d.isDefaultPrevented()||k[e.effect][0].call(f,c,d);return f},reset:function(c){c=c||b,c.removeClass(e.errorClass).each(function(){var b=a(this).data("msg.el");b&&(b.remove(),a(this).data("msg.el",null))}).off(e.errorInputEvent+".v");return f},destroy:function(){c.off(e.formEvent+".V reset.V"),b.off(e.inputEvent+".V change.V");return f.reset()},checkValidity:function(c,g){c=c||b,c=c.not(":disabled");var h={};c=c.filter(function(){var b=a(this).attr("name");if(!h[b]){h[b]=!0;return a(this)}});if(!c.length)return!0;g=g||a.Event(),g.type="onBeforeValidate",i.trigger(g,[c]);if(g.isDefaultPrevented())return g.result;var m=[];c.each(function(){var b=[],c=a(this).data("messages",b),h=d&&c.is(":date")?"onHide.v":e.errorInputEvent+".v";c.off(h),a.each(j,function(){var a=this,d=a[0];if(c.filter(d).length){var h=a[1].call(f,c,c.val());if(h!==!0){g.type="onBeforeFail",i.trigger(g,[c,d]);if(g.isDefaultPrevented())return!1;var j=c.attr(e.messageAttr);if(j){b=[j];return!1}l(b,d,h)}}}),b.length&&(m.push({input:c,messages:b}),c.trigger("OI",[b]),e.errorInputEvent&&c.on(h,function(a){f.checkValidity(c,a)}));if(e.singleError&&m.length)return!1});var n=k[e.effect];if(!n)throw"Validator: cannot find effect \""+e.effect+"\"";if(m.length){f.invalidate(m,g);return!1}n[1].call(f,c,g),g.type="onSuccess",i.trigger(g,[c]),c.off(e.errorInputEvent+".v");return!0}}),a.each("onBeforeValidate,onBeforeFail,onFail,onSuccess".split(","),function(b,c){a.isFunction(e[c])&&a(f).on(c,e[c]),f[c]=function(b){b&&a(f).on(c,b);return f}}),e.formEvent&&c.on(e.formEvent+".V",function(a){if(!f.checkValidity(null,a))return a.preventDefault();a.target=c,a.type=e.formEvent}),c.on("reset.V",function(){f.reset()}),b[0]&&b[0].validity&&b.each(function(){this.oninvalid=function(){return!1}}),c[0]&&(c[0].checkValidity=f.checkValidity),e.inputEvent&&b.on(e.inputEvent+".V",function(b){f.checkValidity(a(this),b)}),b.filter(":checkbox, select").filter("[required]").on("change.V",function(b){var c=a(this);(this.checked||c.is("select")&&a(this).val())&&k[e.effect][1].call(f,c,b)}),b.filter(":radio[required]").on("change.V",function(b){var c=a("[name='"+a(b.srcElement).attr("name")+"']");c!=null&&c.length!=0&&f.checkValidity(c,b)}),a(window).resize(function(){f.reflow()})}a.fn.validator=function(b){var c=this.data("validator");c&&(c.destroy(),this.removeData("validator")),b=a.extend(!0,{},g.conf,b);if(this.is("form"))return this.each(function(){var d=a(this);c=new l(d.find(":input"),d,b),d.data("validator",c)});c=new l(this,this.eq(0).closest("form"),b);return this.data("validator",c)}})(jQuery);
;
jQuery(document).ready(function () {

    /*
     * The following script handles the Description, Features, Care, Delivery & Returns
     * expanding sections in the product page / view.
     * We could optimise this by using a standard approach to expander / collapsors on
     * the site (perhaps using the bootstrap js standard).
     * */

    // If the URL has a t parameter, that will have opened a tab already.
    if (location.search.indexOf('t=') < 0) {
        // TODO: Can optimise by removing when moved to MVC. Make sure - (minus) is set on page load for correct tab.
        jQuery('.product-accordion dt').first().addClass('on');
        jQuery('.product-accordion dt').first().find('.right').html('-');
        jQuery('.product-accordion dd').first().show();
    }

    jQuery('.product-accordion dt').click(function () {
        jQuery('.product-accordion dt').removeClass('on');
        jQuery('.product-accordion dt .right').html('+');
        jQuery('.product-accordion dd').slideUp('normal');
        if (jQuery(this).next().is(':hidden') == true) {
            jQuery(this).addClass('on');
            jQuery(this).find('.right').html('-');
            jQuery(this).next().slideDown('normal').removeClass('hidden');
        }
    });
});;
jQuery(document).ready(function () {
    jQuery('.thumbs .thumbbox:first').addClass('thumbbox-active');
    jQuery('.thumbs .thumbbox').click(function () {
        jQuery('.thumbs .thumbbox').each(function () {
            jQuery(this).removeClass('thumbbox-active');
        });
        jQuery(this).addClass('thumbbox-active');
    });
});;
var MagicScrollOptions = {};
var Outdoor;
(function (Outdoor) {
    var Pages;
    (function (Pages) {
        var Product = (function () {
            function Product() {
                this.productClass = ProductClass.PhysicalProduct;
                this.lastSelectedColourId = null;
                this.priceElement = document.getElementById('item-price');
                this.priceExVatElement = document.getElementById('PriceWithoutVAT');
                this.percentageOffElement = document.getElementById('PercentageOff');
                this.styleId = parseInt(document.getElementById('StyleId').value) || 0;
                this.productClass = parseInt(document.getElementById('ProductClass').value);
                if (this.productClass === ProductClass.GiftCard) {
                    this.SetButtonState(StockLevel.Stock_InStock);
                    this.UpdateDelivery($("#SelectedProductId").val(), false);
                    this.WireUpPriceEditMonitoring();
                }
                else {
                    this.SetButtonState(StockLevel.Stock_NotSelected);
                }
                var slideCount = $('.c-thumb-image').length;
                if (slideCount <= 1) {
                    this.HideMobileImagePaging();
                }
                this.selectorUi = new ClickableSelector(Colours, Sizes, this);
                this.WireUpMobileImagePaging();
                this.WireUpThumbnailClicks();
                this.WireUpSwatchSelectors();
                this.WireUpStoreStock();
                this.WireUpBazaar();
                this.WireUpMagicScrollEvents();
                this.FocusOnColourIfPassedViaUrl();
                if ($(window).width() < 840) {
                    this.CreateRecentSlider();
                }
                $(window).resize();
            }
            Product.prototype.HideMobileImagePaging = function () {
                $('#c-previous-image').hide();
                $('#c-next-image').hide();
            };
            Product.prototype.WireUpBazaar = function () {
                var _this = this;
                window.bvCallback = function (BV) { return _this.bazaarCallback(BV); };
            };
            Product.prototype.bazaarCallback = function (BV) {
                BV.reviews.on('show', function () {
                    var tabLink = document.querySelector("BazaarReviewsTab");
                    tabLink.click();
                });
                BV.questions.on('show', function () {
                    var tabLink = document.getElementById("BazaarQAndATab");
                    tabLink.click();
                });
            };
            Product.prototype.WireUpPriceEditMonitoring = function () {
                var _this = this;
                $('#gift-voucher-price')
                    .keydown(function (e) { return _this.filterGiftCardInput(e); })
                    .keyup(function (e) { return _this.onGiftCardPriceChanged(e); });
            };
            Product.prototype.WireUpMagicScrollEvents = function () {
                var _this = this;
                MagicScrollOptions = {
                    onReady: function (elementId) {
                        if (elementId === "thumbList") {
                            if (_this.lastSelectedColourId) {
                                _this.FindAndClickThumbnail(_this.lastSelectedColourId);
                            }
                        }
                    }
                };
            };
            Product.prototype.filterGiftCardInput = function (e) {
                if (e.keyCode === 13 || e.keyCode === 46 || e.keyCode === 190) {
                    e.preventDefault();
                }
            };
            Product.prototype.onGiftCardPriceChanged = function (e) {
                var price = this.giftCardValue();
                if (price == null) {
                    this.SetButtonState(StockLevel.Stock_NotSelected);
                    return;
                }
                this.SetButtonState(StockLevel.Stock_InStock);
            };
            Product.prototype.giftCardValue = function () {
                var priceAsText = $('#gift-voucher-price').val();
                if (!$.isNumeric(priceAsText)) {
                    return null;
                }
                return parseInt(priceAsText);
            };
            Product.prototype.WireUpMobileImagePaging = function () {
                var _this = this;
                $('#c-previous-image').click(function (e) { return _this.onMobileImagePreviousClicked(e); });
                $('#c-next-image').click(function (e) { return _this.onMobileImageNextClicked(e); });
            };
            Product.prototype.WireUpThumbnailClicks = function () {
                var _this = this;
                $('.c-thumb-image').click(function (e) { return _this.onThumbImageClicked(e); });
            };
            Product.prototype.WireUpSwatchSelectors = function () {
                var _this = this;
                $('.c-swatch-selector').click(function (e) { return _this.onSwatchImageClicked(e); });
            };
            Product.prototype.WireUpStoreStock = function () {
                $('body').on('click', '.ui-widget-overlay', function (e) {
                    $('.store-stock').dialog('close');
                });
                $('body').on('click', '#StoreStockClose', function (e) {
                    $('.store-stock').dialog('close');
                });
                $('body').on('click', '#StoreStock .blockHeader', function (e) {
                    $('#StoreStock .blockContents').slideUp();
                    if ($(this).hasClass('active')) {
                        $(this).removeClass('active');
                    }
                    else {
                        $('#StoreStock .blockHeader').removeClass('active');
                        $(this).addClass('active');
                        $(this).next().slideToggle();
                    }
                });
            };
            Product.prototype.onSwatchImageClicked = function (e) {
                e.preventDefault();
                var colourId = $(e.currentTarget).data('colour-id');
                this.FindAndClickThumbnail(colourId);
            };
            Product.prototype.onThumbImageClicked = function (e) {
                e.preventDefault();
                var imgLink = $(e.target).parent();
                $('#zoomcaption').text(imgLink.data('colour')).show();
            };
            Product.prototype.onMobileImagePreviousClicked = function (e) {
                e.preventDefault();
                MagicZoom.prev('productzoom');
            };
            Product.prototype.onMobileImageNextClicked = function (e) {
                e.preventDefault();
                MagicZoom.next('productzoom');
            };
            Product.prototype.CreateRecentSlider = function () {
            };
            Product.prototype.SetButtonState = function (stockLevel, productId) {
                var _this = this;
                $("#stockAvailableMessage").text("Select size and colour above to view stock availability");
                var ButtonRef = $("#AddToBasket");
                var iconSpan = ButtonRef.find('span');
                var textElement = ButtonRef.contents().last()[0];
                var WishLinkRef = $("#AddToWishListButton");
                var checkStoreStockElement = $('#check-store-stock');
                var checkStoreStockContainer = checkStoreStockElement.parent();
                ButtonRef.unbind('click');
                checkStoreStockElement.unbind('click');
                WishLinkRef.unbind('click');
                if (StockLevel.Stock_Unavailable === stockLevel || StockLevel.Stock_Enquiries === stockLevel) {
                    ButtonRef.attr("class", "bigbtn outofstock notice");
                    checkStoreStockContainer.removeClass("available");
                    iconSpan.attr("class", "");
                    textElement.nodeValue = 'Email me when in stock';
                    ButtonRef.click(function (e) { e.preventDefault(); window.location.href = "/out-of-stock?ProductId=" + productId; return false; });
                    checkStoreStockElement.click(function (e) { return _this.onStoreStockCheckRequested(e); });
                    WishLinkRef.click(function (e) { return _this.AddSelectedToWishList(e); });
                }
                else if (StockLevel.Stock_LowStock == stockLevel || StockLevel.Stock_InStock == stockLevel) {
                    ButtonRef.attr("class", "bigbtn on");
                    checkStoreStockContainer.addClass("available");
                    iconSpan.attr("class", "icons icon-bag");
                    textElement.nodeValue = 'Add to Basket';
                    ButtonRef.click(function (e) { return _this.onAddToBasketClicked(e); });
                    checkStoreStockElement.click(function (e) { return _this.onStoreStockCheckRequested(e); });
                    WishLinkRef.click(function (e) { return _this.AddSelectedToWishList(e); });
                }
                else {
                    ButtonRef.attr("class", "bigbtn off");
                    checkStoreStockContainer.removeClass("available");
                    iconSpan.attr("class", "icons icon-bag");
                    textElement.nodeValue = 'Add to Basket';
                    ButtonRef.click(function (e) { e.preventDefault(); alert('You need to select a size and colour combination first.'); return false; });
                    checkStoreStockElement.click(function (e) { e.preventDefault(); alert('You need to select a size and colour combination first.'); return false; });
                    WishLinkRef.click(function (e) { e.preventDefault(); alert('Please select a size and colour first in order to add to your wish list.'); return false; });
                }
            };
            Product.prototype.onStoreStockCheckRequested = function (e) {
                var _this = this;
                e.preventDefault();
                var productId = $("#SelectedProductId").val();
                $('#check-store-stock').addClass("working");
                $.ajax({
                    type: "POST",
                    url: "/ws/store-stock/" + productId.toString(),
                    success: function (result) { return _this.StoreStockCheckSuccess(result); },
                    context: productId,
                    error: function (result) { return _this.StoreStockCheckFailed(result); }
                });
                return false;
            };
            Product.prototype.StoreStockCheckSuccess = function (html) {
                $('#check-store-stock').removeClass("working");
                $('<div class="store-stock" />').html(html).dialog({
                    resizable: false,
                    modal: true,
                    show: 'clip',
                    buttons: {
                        "Ok": function () {
                            $(this).dialog("close");
                        }
                    }
                });
            };
            Product.prototype.StoreStockCheckFailed = function (err) {
                $('#check-store-stock').removeClass("working");
                $('<div class="store-stock" />')
                    .html('<div id="StoreStock">'
                    + '<h2>Sorry, we could not check the store stock levels at the moment.</h2>'
                    + '<p class="bottom">Please contact the store directly to reserve stock.</p>'
                    + '<a href="#" id="StoreStockClose"><span class="lnr lnr-cross"></span></a>'
                    + '</div>')
                    .dialog({
                    resizable: false,
                    modal: true,
                    show: 'clip',
                    buttons: {
                        "Ok": function () {
                            $(this).dialog("close");
                        }
                    }
                });
            };
            Product.prototype.onAddToBasketClicked = function (e) {
                var price = null;
                var selectedProduct = this.StockInfoForCurrentSizeAndColour();
                e.preventDefault();
                if (this.productClass === ProductClass.GiftCard) {
                    var price = this.giftCardValue();
                    if (price === null) {
                        alert('Please enter a gift card value of at least £5.');
                        return false;
                    }
                }
                else {
                    price = selectedProduct.priceGbp;
                }
                this.AddToBasket(selectedProduct.productId, selectedProduct.posCode, price);
                return false;
            };
            Product.prototype.FocusOnColourIfPassedViaUrl = function () {
                var element = document.getElementById('InitialColourId');
                var colourId = parseInt(element.value);
                if (isNaN(colourId)) {
                    return;
                }
                this.FindAndClickThumbnail(colourId);
            };
            Product.prototype.findLowestSlideInfo = function (slideLinks) {
                var lowest = { caption: null, index: 999 };
                for (var i = 0; i < slideLinks.length; i++) {
                    var slideLink = $(slideLinks[i]);
                    var slideIndex = slideLink.data('image-index');
                    if (slideIndex < lowest.index) {
                        lowest.caption = slideLink.data('colour');
                        lowest.index = slideIndex;
                    }
                }
                return lowest;
            };
            Product.prototype.FindAndClickThumbnail = function (colourId) {
                var imgLinks = $(".c-colour-image-" + colourId);
                if (imgLinks.length > 0) {
                    var slideInfo = this.findLowestSlideInfo(imgLinks);
                    MagicZoom.switchTo('productzoom', slideInfo.index);
                    if ($('#thumbList').is(':visible')) {
                        var slideCount = $('.c-thumb-image').length;
                        if (slideInfo.index + 2 <= slideCount) {
                            slideInfo.index += 2;
                        }
                        this.lastSelectedColourId = colourId;
                        MagicScroll.jump('thumbList', slideInfo.index);
                    }
                    $('#zoomcaption').text(slideInfo.caption).show();
                }
            };
            Product.prototype.AddToBasket = function (productId, posCode, price) {
                var _this = this;
                var postData = { productId: productId.toString(), price: null };
                if (price) {
                    postData.price = price;
                }
                $.ajax({
                    type: "POST",
                    url: "/ws/add-item",
                    data: JSON.stringify(postData),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (result) { return _this.AddToShoppingCartSuccess(result); },
                    context: productId,
                    error: function (result) { return _this.AddToShoppingCartFailed(result); }
                });
            };
            Product.prototype.AddToShoppingCartSuccess = function (cartResult) {
                if (cartResult.errors && cartResult.errors.length > 0) {
                    alert("The product was not added;\n" + cartResult.errors.join("\n"));
                    return;
                }
                var selectedProduct = this.StockInfoForCurrentSizeAndColour();
                if (selectedProduct) {
                    var styleCode = selectedProduct.posCode.substring(0, 10) + "-" + this.styleId.toString();
                    ScarabQueue.push(['cart', [
                            { item: styleCode, price: selectedProduct.priceGbp, quantity: 1 }
                        ]]);
                    ScarabQueue.push(['go']);
                }
                basketSuccess(cartResult, this.AddToBasket, this);
            };
            Product.prototype.AddToShoppingCartFailed = function (err) {
                basketConfirmDialog.find('#PopupDialogHeader').text('Unable to Add to Basket');
                basketConfirmDialog.find('#PopupDialogTitle').text('Sorry, we couldn\'t add this item.');
                basketConfirmDialog.find("#PopupDialogSubTitle").text("");
                basketConfirmDialog.dialog('open');
            };
            Product.prototype.AddSelectedToWishList = function (e) {
                e.preventDefault();
                var target = (e.target || e.srcElement);
                if (target.nodeName === "SPAN") {
                    target = target.parentElement;
                }
                var isLoggedIn = target.getAttribute("data-is-logged-in");
                if (isLoggedIn !== "True") {
                    ShowWishlistLoginRequired();
                    return false;
                }
                var productId = $("#SelectedProductId").val();
                quickAdd.addToWishList(productId);
                return false;
            };
            Product.prototype.UpdateDelivery = function (productId, silentUpdate) {
                var _this = this;
                if (productId === 0) {
                    this.SetDeliveryText('Select the size and colour (above) to view currently available delivery options for this product.', false);
                    return;
                }
                if (!silentUpdate)
                    this.SetDeliveryText('Calculating delivery, please wait.', false);
                $.ajax({
                    type: "POST",
                    url: "/ws/delivery",
                    data: "{productId:" + productId.toString() + "}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) { return _this.UpdateDeliverySuccess(data); },
                    context: productId,
                    error: function (err) { return _this.UpdateDeliveryFailed(err); }
                });
            };
            Product.prototype.SetDeliveryText = function (text, success) {
                $("#DeliveryMessage").text(text);
                if (success)
                    $('#DeliveryTable').show();
                else
                    $("#DeliveryTable").hide();
            };
            Product.prototype.UpdateDeliverySuccess = function (shippingOptions) {
                var _this = this;
                if (shippingOptions === null || shippingOptions.length !== 3) {
                    this.SetDeliveryText('A delivery cost could not be calculated.', false);
                    HideExpressDeliveryTime();
                    return;
                }
                if (this.UpdateShippingUiRow('ShipExpressRow', 'ShipExpressChargeLabel', shippingOptions[0]))
                    ShowExpressDeliveryTime(shippingOptions[0]);
                else
                    HideExpressDeliveryTime();
                this.UpdateShippingUiRow('ShipStandardRow', 'ShipStandardChargeLabel', shippingOptions[1]);
                var economyAvailable = this.UpdateShippingUiRow('ShipEconomyRow', 'ShipEconomyChargeLabel', shippingOptions[2]);
                var freeDeliveryContainer = $('.delivery-text-container');
                if (!economyAvailable || (shippingOptions[2].formattedCharge != null && shippingOptions[2].formattedCharge.indexOf('Free') === -1)) {
                    freeDeliveryContainer.addClass('hidden');
                }
                else {
                    freeDeliveryContainer.removeClass('hidden');
                }
                this.SetDeliveryText('The delivery options for all selected items are shown below. Default delivery pricing and timescale are based on delivery to UK mainland destinations, alternative destinations can be selected on the basket page or by logging into your account.', true);
                SetDeliveryUpdateTimer(60, function () {
                    var selectedProduct = _this.StockInfoForCurrentSizeAndColour();
                    if (selectedProduct) {
                        _this.UpdateDelivery(selectedProduct.productId, false);
                    }
                });
            };
            Product.prototype.UpdateShippingUiRow = function (TableRowId, LabelId, shipOption) {
                var tableRowRef = $('#' + TableRowId);
                var labelRef = $('#' + LabelId);
                if (shipOption.formattedCharge == null || shipOption.formattedCharge == '') {
                    tableRowRef.hide();
                    labelRef.hide();
                    return false;
                }
                tableRowRef.show();
                labelRef.show();
                labelRef.text(shipOption.formattedCharge);
                tableRowRef.find('.country-description').html(shipOption.countrySpecificDescription);
                return true;
            };
            Product.prototype.UpdateDeliveryFailed = function (err) {
                this.SetDeliveryText('Sorry, we could not calculate delivery as an error occurred.', false);
                StopDeliveryUpdateTimer();
                HideExpressDeliveryTime();
            };
            Product.prototype.UpdateLinked = function (productId, styleId, colourId) {
                var _this = this;
                this.ClearLinkedProductsTab();
                this.ClearTheLookRecommendations();
                if (productId === 0 || isNaN(colourId)) {
                    return;
                }
                $("#LinkedProductsMessage").text('Checking for compatible products, please wait...');
                this.lastRequestTime = Date.now();
                var params = "{productId:" + productId.toString() + ",styleId:" + styleId.toString() + ",colourId:" + colourId + ",lastRequestTime:" + this.lastRequestTime + "}";
                $.ajax({
                    type: "POST",
                    url: "/ws/linked",
                    data: params,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (prods) { return _this.UpdateLinkedSuccess(prods); },
                    context: productId,
                    error: function (err) { return _this.UpdateLinkedFailed(err); }
                });
            };
            Product.prototype.UpdateLinkedSuccess = function (recommendations) {
                if (this.lastRequestTime !== recommendations.lastRequestTime) {
                    return;
                }
                if (recommendations === null || recommendations.compatibles.length === 0) {
                    $('#LinkedProductsMessage').text('We don\'t have any in stock compatible items for this product.');
                }
                else {
                    var compatibleProducts = $('#LinkedProductsTable');
                    for (var i = 0; i < recommendations.compatibles.length; i++) {
                        var product_1 = recommendations.compatibles[i];
                        compatibleProducts.append(this.CreateCompatibleProductHtml(product_1));
                    }
                    compatibleProducts.show();
                    $('#LinkedProductsMessage').text('Based on the selected item, these are the available accessories:');
                }
                this.ClearTheLookRecommendations();
                if (recommendations.theLook.length !== 0) {
                    MagicScroll.stop('product-complete');
                    var theLookProducts = $('#product-complete');
                    theLookProducts.empty();
                    for (var i = 0; i < recommendations.theLook.length; i++) {
                        var product_2 = recommendations.theLook[i];
                        theLookProducts.append(this.CreateTheLookProductHtml(product_2));
                    }
                    MagicScroll.refresh('product-complete');
                    MagicScroll.start('product-complete');
                    this.setTheLookVisibility(true);
                }
            };
            Product.prototype.setTheLookVisibility = function (visible) {
                var theLookContainer = $('#TheLookResults');
                if (visible)
                    theLookContainer.show();
                else
                    theLookContainer.hide();
            };
            Product.prototype.CreateCompatibleProductHtml = function (product) {
                var _this = this;
                var containingTableRow = document.createElement('tr');
                containingTableRow.className = 'related';
                var containingTableCell = document.createElement('td');
                containingTableRow.appendChild(containingTableCell);
                var titleDiv = document.createElement("div");
                titleDiv.className = 'title-box';
                var productImg = document.createElement("img");
                productImg.src = product.imageUrl;
                productImg.height = 64;
                productImg.width = 64;
                titleDiv.appendChild(productImg);
                var nameContainer = document.createElement("span");
                nameContainer.className = 'name';
                var productLink = document.createElement('a');
                productLink.href = product.styleUrl;
                productLink.innerText = product.name;
                nameContainer.appendChild(productLink);
                var productDescription = document.createElement("p");
                productDescription.className = 'bottom description';
                productDescription.innerText = product.description;
                titleDiv.appendChild(nameContainer);
                titleDiv.appendChild(productDescription);
                var controlDiv = document.createElement("div");
                controlDiv.className = 'control-box';
                this.appendHtml(controlDiv, product.formattedPrice);
                var basketLink = document.createElement('a');
                basketLink.className = 'btn';
                basketLink.onclick = function () { return _this.AddToBasket(product.productId, product.posCode, null); };
                basketLink.innerText = "Add to Basket";
                controlDiv.appendChild(basketLink);
                containingTableCell.appendChild(titleDiv);
                containingTableCell.appendChild(controlDiv);
                return containingTableRow;
            };
            Product.prototype.appendHtml = function (el, str) {
                var div = document.createElement('div');
                div.innerHTML = str;
                while (div.children.length > 0) {
                    el.appendChild(div.children[0]);
                }
            };
            Product.prototype.CreateTheLookProductHtml = function (product) {
                var containingLiRow = document.createElement('li');
                containingLiRow.className = 'item';
                var productLink = document.createElement('a');
                productLink.href = product.styleUrl;
                productLink.className = 'image';
                containingLiRow.appendChild(productLink);
                var productImg = document.createElement("img");
                productImg.src = product.imageUrl;
                productLink.appendChild(productImg);
                var productTitle = document.createElement('a');
                productTitle.href = product.styleUrl;
                productTitle.className = 'name';
                productTitle.innerText = product.name;
                containingLiRow.appendChild(productTitle);
                var priceContainer = document.createElement("p");
                priceContainer.className = 'price';
                containingLiRow.appendChild(priceContainer);
                var productPrice = document.createElement("span");
                productPrice.className = 'new-price';
                productPrice.innerHTML = product.formattedPrice;
                priceContainer.appendChild(productPrice);
                var basketLink = document.createElement('a');
                basketLink.className = 'looksAddToBasket btn';
                var selected = this.selectorUi.SelectedSizeAndColour();
                basketLink.onclick = function () { return quickAdd.showTheLook(product.styleId); };
                basketLink.innerText = "Add to Basket";
                containingLiRow.appendChild(basketLink);
                return containingLiRow;
            };
            Product.prototype.UpdateLinkedFailed = function (err) {
                $("#LinkedProductsMessage").text('Sorry, we could not find any compatible products.');
            };
            Product.prototype.ClearTheLookRecommendations = function () {
                this.setTheLookVisibility(false);
                var theLooksList = $('#product-complete');
                theLooksList.empty();
            };
            Product.prototype.ClearLinkedProductsTab = function () {
                var tableRef = $('#LinkedProductsTable');
                $("#LinkedProductsMessage").text('Select the product size and colour (above) to view currently accessories.');
                tableRef.empty();
                tableRef.hide();
            };
            Product.prototype.ProductSelectionChanged = function (selectedProduct) {
                var available = false;
                if (selectedProduct !== null) {
                    var stock = this.StockInfoForSizeAndColour(selectedProduct.colourId, selectedProduct.size);
                    if (stock) {
                        this.SetButtonState(stock.availability, stock.productId);
                        $("#stockAvailableMessage").text(stock.stockLevelMessage);
                        $("#SelectedProductId").val(stock.productId.toString());
                        this.updateUiPrices(stock, selectedProduct.colourId);
                        available = true;
                    }
                    else if (selectedProduct.colourId) {
                        var colourStock = this.StockInfoForColour(selectedProduct.colourId);
                        if (colourStock) {
                            this.updateUiPrices(colourStock, selectedProduct.colourId);
                        }
                    }
                }
                if (!available) {
                    this.SetButtonState(StockLevel.Stock_NotSelected);
                    this.ClearLinkedProductsTab();
                    $("#stockAvailableMessage").text("");
                    $("#SelectedProductId").val('0');
                }
            };
            Product.prototype.updateUiPrices = function (stock, colourId) {
                this.UpdateDelivery(stock.productId, false);
                this.UpdateLinked(stock.productId, this.styleId, colourId);
                this.FindAndClickThumbnail(colourId);
                var percentageOffHtml = '';
                if (stock.percentageSaving !== null) {
                    percentageOffHtml = stock.percentageSaving;
                }
                if (this.priceExVatElement) {
                    this.priceExVatElement.innerHTML = stock.priceExVat;
                }
                if (this.priceElement) {
                    this.priceElement.innerHTML = stock.priceHeading;
                }
                if (this.percentageOffElement) {
                    this.percentageOffElement.innerHTML = percentageOffHtml;
                    if (percentageOffHtml) {
                        Outdoor.Utilities.CssManipulator.removeClass(this.percentageOffElement, 'hidden');
                    }
                    else {
                        Outdoor.Utilities.CssManipulator.addClass(this.percentageOffElement, 'hidden');
                    }
                }
            };
            Product.prototype.endsWith = function (text, suffix) {
                return text.indexOf(suffix, text.length - suffix.length) !== -1;
            };
            ;
            Product.prototype.StockInfoForColour = function (colourId) {
                for (var key in stockInfo) {
                    if (this.endsWith(key, colourId.toString())) {
                        return stockInfo[key];
                    }
                }
                return null;
            };
            Product.prototype.StockInfoForSizeAndColour = function (colourId, size) {
                if (this.productClass === ProductClass.GiftCard) {
                    return this.firstStockItem();
                }
                return stockInfo[this.keyForStockLookup(colourId, size)];
            };
            Product.prototype.firstStockItem = function () {
                var posCode = Object.keys(stockInfo)[0];
                return stockInfo[posCode];
            };
            Product.prototype.StockInfoForCurrentSizeAndColour = function () {
                if (this.productClass === ProductClass.GiftCard) {
                    return this.firstStockItem();
                }
                var selected = this.selectorUi.SelectedSizeAndColour();
                if (selected === null) {
                    return null;
                }
                return this.StockInfoForSizeAndColour(selected.colourId, selected.size);
            };
            Product.prototype.keyForStockLookup = function (colourId, sizeCode) {
                return sizeCode.toLowerCase() + '-' + colourId;
            };
            return Product;
        }());
        Pages.Product = Product;
    })(Pages = Outdoor.Pages || (Outdoor.Pages = {}));
})(Outdoor || (Outdoor = {}));
$(document).ready(function () {
    if ($('body').hasClass('page-type-product')) {
        product = new Outdoor.Pages.Product();
    }
});
//# sourceMappingURL=Product.js.map;
//# sourceMappingURL=ProductEmail.js.map;
