/* Minification failed. Returning unminified contents.
(6442,87-88): run-time error JS1010: Expected identifier: .
(6442,87-88): run-time error JS1195: Expected expression: .
(6442,103-107): run-time error JS1034: Unmatched 'else'; no 'if' defined: else
 */
/*
	By Osvaldas Valutis, www.osvaldas.info
	Available for use under the MIT License
*/



;(function(e,t,n,r){e.fn.doubleTapToGo=function(r){if(!("ontouchstart"in t)&&!navigator.msMaxTouchPoints&&!navigator.userAgent.toLowerCase().match(/windows phone os 7/i))return false;this.each(function(){var t=false;e(this).on("click",function(n){var r=e(this);if(r[0]!=t[0]){n.preventDefault();t=r}});e(n).on("click touchstart MSPointerDown",function(n){var r=true,i=e(n.target).parents();for(var s=0;s<i.length;s++)if(i[s]==t[0])r=false;if(r)t=false})});return this}})(jQuery,window,document);;
/*!
 * Bootstrap v3.4.1 (https://getbootstrap.com/)
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under the MIT license
 */
if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");!function(t){"use strict";var e=jQuery.fn.jquery.split(" ")[0].split(".");if(e[0]<2&&e[1]<9||1==e[0]&&9==e[1]&&e[2]<1||3<e[0])throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(),function(n){"use strict";n.fn.emulateTransitionEnd=function(t){var e=!1,i=this;n(this).one("bsTransitionEnd",function(){e=!0});return setTimeout(function(){e||n(i).trigger(n.support.transition.end)},t),this},n(function(){n.support.transition=function o(){var t=document.createElement("bootstrap"),e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var i in e)if(t.style[i]!==undefined)return{end:e[i]};return!1}(),n.support.transition&&(n.event.special.bsTransitionEnd={bindType:n.support.transition.end,delegateType:n.support.transition.end,handle:function(t){if(n(t.target).is(this))return t.handleObj.handler.apply(this,arguments)}})})}(jQuery),function(s){"use strict";var e='[data-dismiss="alert"]',a=function(t){s(t).on("click",e,this.close)};a.VERSION="3.4.1",a.TRANSITION_DURATION=150,a.prototype.close=function(t){var e=s(this),i=e.attr("data-target");i||(i=(i=e.attr("href"))&&i.replace(/.*(?=#[^\s]*$)/,"")),i="#"===i?[]:i;var o=s(document).find(i);function n(){o.detach().trigger("closed.bs.alert").remove()}t&&t.preventDefault(),o.length||(o=e.closest(".alert")),o.trigger(t=s.Event("close.bs.alert")),t.isDefaultPrevented()||(o.removeClass("in"),s.support.transition&&o.hasClass("fade")?o.one("bsTransitionEnd",n).emulateTransitionEnd(a.TRANSITION_DURATION):n())};var t=s.fn.alert;s.fn.alert=function o(i){return this.each(function(){var t=s(this),e=t.data("bs.alert");e||t.data("bs.alert",e=new a(this)),"string"==typeof i&&e[i].call(t)})},s.fn.alert.Constructor=a,s.fn.alert.noConflict=function(){return s.fn.alert=t,this},s(document).on("click.bs.alert.data-api",e,a.prototype.close)}(jQuery),function(s){"use strict";var n=function(t,e){this.$element=s(t),this.options=s.extend({},n.DEFAULTS,e),this.isLoading=!1};function i(o){return this.each(function(){var t=s(this),e=t.data("bs.button"),i="object"==typeof o&&o;e||t.data("bs.button",e=new n(this,i)),"toggle"==o?e.toggle():o&&e.setState(o)})}n.VERSION="3.4.1",n.DEFAULTS={loadingText:"loading..."},n.prototype.setState=function(t){var e="disabled",i=this.$element,o=i.is("input")?"val":"html",n=i.data();t+="Text",null==n.resetText&&i.data("resetText",i[o]()),setTimeout(s.proxy(function(){i[o](null==n[t]?this.options[t]:n[t]),"loadingText"==t?(this.isLoading=!0,i.addClass(e).attr(e,e).prop(e,!0)):this.isLoading&&(this.isLoading=!1,i.removeClass(e).removeAttr(e).prop(e,!1))},this),0)},n.prototype.toggle=function(){var t=!0,e=this.$element.closest('[data-toggle="buttons"]');if(e.length){var i=this.$element.find("input");"radio"==i.prop("type")?(i.prop("checked")&&(t=!1),e.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==i.prop("type")&&(i.prop("checked")!==this.$element.hasClass("active")&&(t=!1),this.$element.toggleClass("active")),i.prop("checked",this.$element.hasClass("active")),t&&i.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var t=s.fn.button;s.fn.button=i,s.fn.button.Constructor=n,s.fn.button.noConflict=function(){return s.fn.button=t,this},s(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(t){var e=s(t.target).closest(".btn");i.call(e,"toggle"),s(t.target).is('input[type="radio"], input[type="checkbox"]')||(t.preventDefault(),e.is("input,button")?e.trigger("focus"):e.find("input:visible,button:visible").first().trigger("focus"))}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(t){s(t.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(t.type))})}(jQuery),function(p){"use strict";var c=function(t,e){this.$element=p(t),this.$indicators=this.$element.find(".carousel-indicators"),this.options=e,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",p.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",p.proxy(this.pause,this)).on("mouseleave.bs.carousel",p.proxy(this.cycle,this))};function r(n){return this.each(function(){var t=p(this),e=t.data("bs.carousel"),i=p.extend({},c.DEFAULTS,t.data(),"object"==typeof n&&n),o="string"==typeof n?n:i.slide;e||t.data("bs.carousel",e=new c(this,i)),"number"==typeof n?e.to(n):o?e[o]():i.interval&&e.pause().cycle()})}c.VERSION="3.4.1",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(t){if(!/input|textarea/i.test(t.target.tagName)){switch(t.which){case 37:this.prev();break;case 39:this.next();break;default:return}t.preventDefault()}},c.prototype.cycle=function(t){return t||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(p.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(t){return this.$items=t.parent().children(".item"),this.$items.index(t||this.$active)},c.prototype.getItemForDirection=function(t,e){var i=this.getItemIndex(e);if(("prev"==t&&0===i||"next"==t&&i==this.$items.length-1)&&!this.options.wrap)return e;var o=(i+("prev"==t?-1:1))%this.$items.length;return this.$items.eq(o)},c.prototype.to=function(t){var e=this,i=this.getItemIndex(this.$active=this.$element.find(".item.active"));if(!(t>this.$items.length-1||t<0))return this.sliding?this.$element.one("slid.bs.carousel",function(){e.to(t)}):i==t?this.pause().cycle():this.slide(i<t?"next":"prev",this.$items.eq(t))},c.prototype.pause=function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&p.support.transition&&(this.$element.trigger(p.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){if(!this.sliding)return this.slide("next")},c.prototype.prev=function(){if(!this.sliding)return this.slide("prev")},c.prototype.slide=function(t,e){var i=this.$element.find(".item.active"),o=e||this.getItemForDirection(t,i),n=this.interval,s="next"==t?"left":"right",a=this;if(o.hasClass("active"))return this.sliding=!1;var r=o[0],l=p.Event("slide.bs.carousel",{relatedTarget:r,direction:s});if(this.$element.trigger(l),!l.isDefaultPrevented()){if(this.sliding=!0,n&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var h=p(this.$indicators.children()[this.getItemIndex(o)]);h&&h.addClass("active")}var d=p.Event("slid.bs.carousel",{relatedTarget:r,direction:s});return p.support.transition&&this.$element.hasClass("slide")?(o.addClass(t),"object"==typeof o&&o.length&&o[0].offsetWidth,i.addClass(s),o.addClass(s),i.one("bsTransitionEnd",function(){o.removeClass([t,s].join(" ")).addClass("active"),i.removeClass(["active",s].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger(d)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(i.removeClass("active"),o.addClass("active"),this.sliding=!1,this.$element.trigger(d)),n&&this.cycle(),this}};var t=p.fn.carousel;p.fn.carousel=r,p.fn.carousel.Constructor=c,p.fn.carousel.noConflict=function(){return p.fn.carousel=t,this};var e=function(t){var e=p(this),i=e.attr("href");i&&(i=i.replace(/.*(?=#[^\s]+$)/,""));var o=e.attr("data-target")||i,n=p(document).find(o);if(n.hasClass("carousel")){var s=p.extend({},n.data(),e.data()),a=e.attr("data-slide-to");a&&(s.interval=!1),r.call(n,s),a&&n.data("bs.carousel").to(a),t.preventDefault()}};p(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),p(window).on("load",function(){p('[data-ride="carousel"]').each(function(){var t=p(this);r.call(t,t.data())})})}(jQuery),function(a){"use strict";var r=function(t,e){this.$element=a(t),this.options=a.extend({},r.DEFAULTS,e),this.$trigger=a('[data-toggle="collapse"][href="#'+t.id+'"],[data-toggle="collapse"][data-target="#'+t.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};function n(t){var e,i=t.attr("data-target")||(e=t.attr("href"))&&e.replace(/.*(?=#[^\s]+$)/,"");return a(document).find(i)}function l(o){return this.each(function(){var t=a(this),e=t.data("bs.collapse"),i=a.extend({},r.DEFAULTS,t.data(),"object"==typeof o&&o);!e&&i.toggle&&/show|hide/.test(o)&&(i.toggle=!1),e||t.data("bs.collapse",e=new r(this,i)),"string"==typeof o&&e[o]()})}r.VERSION="3.4.1",r.TRANSITION_DURATION=350,r.DEFAULTS={toggle:!0},r.prototype.dimension=function(){return this.$element.hasClass("width")?"width":"height"},r.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var t,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(t=e.data("bs.collapse"))&&t.transitioning)){var i=a.Event("show.bs.collapse");if(this.$element.trigger(i),!i.isDefaultPrevented()){e&&e.length&&(l.call(e,"hide"),t||e.data("bs.collapse",null));var o=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[o](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var n=function(){this.$element.removeClass("collapsing").addClass("collapse in")[o](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return n.call(this);var s=a.camelCase(["scroll",o].join("-"));this.$element.one("bsTransitionEnd",a.proxy(n,this)).emulateTransitionEnd(r.TRANSITION_DURATION)[o](this.$element[0][s])}}}},r.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var t=a.Event("hide.bs.collapse");if(this.$element.trigger(t),!t.isDefaultPrevented()){var e=this.dimension();this.$element[e](this.$element[e]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var i=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};if(!a.support.transition)return i.call(this);this.$element[e](0).one("bsTransitionEnd",a.proxy(i,this)).emulateTransitionEnd(r.TRANSITION_DURATION)}}},r.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},r.prototype.getParent=function(){return a(document).find(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(t,e){var i=a(e);this.addAriaAndCollapsedClass(n(i),i)},this)).end()},r.prototype.addAriaAndCollapsedClass=function(t,e){var i=t.hasClass("in");t.attr("aria-expanded",i),e.toggleClass("collapsed",!i).attr("aria-expanded",i)};var t=a.fn.collapse;a.fn.collapse=l,a.fn.collapse.Constructor=r,a.fn.collapse.noConflict=function(){return a.fn.collapse=t,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(t){var e=a(this);e.attr("data-target")||t.preventDefault();var i=n(e),o=i.data("bs.collapse")?"toggle":e.data();l.call(i,o)})}(jQuery),function(a){"use strict";var r='[data-toggle="dropdown"]',o=function(t){a(t).on("click.bs.dropdown",this.toggle)};function l(t){var e=t.attr("data-target");e||(e=(e=t.attr("href"))&&/#[A-Za-z]/.test(e)&&e.replace(/.*(?=#[^\s]*$)/,""));var i="#"!==e?a(document).find(e):null;return i&&i.length?i:t.parent()}function s(o){o&&3===o.which||(a(".dropdown-backdrop").remove(),a(r).each(function(){var t=a(this),e=l(t),i={relatedTarget:this};e.hasClass("open")&&(o&&"click"==o.type&&/input|textarea/i.test(o.target.tagName)&&a.contains(e[0],o.target)||(e.trigger(o=a.Event("hide.bs.dropdown",i)),o.isDefaultPrevented()||(t.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",i)))))}))}o.VERSION="3.4.1",o.prototype.toggle=function(t){var e=a(this);if(!e.is(".disabled, :disabled")){var i=l(e),o=i.hasClass("open");if(s(),!o){"ontouchstart"in document.documentElement&&!i.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",s);var n={relatedTarget:this};if(i.trigger(t=a.Event("show.bs.dropdown",n)),t.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),i.toggleClass("open").trigger(a.Event("shown.bs.dropdown",n))}return!1}},o.prototype.keydown=function(t){if(/(38|40|27|32)/.test(t.which)&&!/input|textarea/i.test(t.target.tagName)){var e=a(this);if(t.preventDefault(),t.stopPropagation(),!e.is(".disabled, :disabled")){var i=l(e),o=i.hasClass("open");if(!o&&27!=t.which||o&&27==t.which)return 27==t.which&&i.find(r).trigger("focus"),e.trigger("click");var n=i.find(".dropdown-menu li:not(.disabled):visible a");if(n.length){var s=n.index(t.target);38==t.which&&0<s&&s--,40==t.which&&s<n.length-1&&s++,~s||(s=0),n.eq(s).trigger("focus")}}}};var t=a.fn.dropdown;a.fn.dropdown=function e(i){return this.each(function(){var t=a(this),e=t.data("bs.dropdown");e||t.data("bs.dropdown",e=new o(this)),"string"==typeof i&&e[i].call(t)})},a.fn.dropdown.Constructor=o,a.fn.dropdown.noConflict=function(){return a.fn.dropdown=t,this},a(document).on("click.bs.dropdown.data-api",s).on("click.bs.dropdown.data-api",".dropdown form",function(t){t.stopPropagation()}).on("click.bs.dropdown.data-api",r,o.prototype.toggle).on("keydown.bs.dropdown.data-api",r,o.prototype.keydown).on("keydown.bs.dropdown.data-api",".dropdown-menu",o.prototype.keydown)}(jQuery),function(a){"use strict";var s=function(t,e){this.options=e,this.$body=a(document.body),this.$element=a(t),this.$dialog=this.$element.find(".modal-dialog"),this.$backdrop=null,this.isShown=null,this.originalBodyPad=null,this.scrollbarWidth=0,this.ignoreBackdropClick=!1,this.fixedContent=".navbar-fixed-top, .navbar-fixed-bottom",this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,a.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))};function r(o,n){return this.each(function(){var t=a(this),e=t.data("bs.modal"),i=a.extend({},s.DEFAULTS,t.data(),"object"==typeof o&&o);e||t.data("bs.modal",e=new s(this,i)),"string"==typeof o?e[o](n):i.show&&e.show(n)})}s.VERSION="3.4.1",s.TRANSITION_DURATION=300,s.BACKDROP_TRANSITION_DURATION=150,s.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},s.prototype.toggle=function(t){return this.isShown?this.hide():this.show(t)},s.prototype.show=function(i){var o=this,t=a.Event("show.bs.modal",{relatedTarget:i});this.$element.trigger(t),this.isShown||t.isDefaultPrevented()||(this.isShown=!0,this.checkScrollbar(),this.setScrollbar(),this.$body.addClass("modal-open"),this.escape(),this.resize(),this.$element.on("click.dismiss.bs.modal",'[data-dismiss="modal"]',a.proxy(this.hide,this)),this.$dialog.on("mousedown.dismiss.bs.modal",function(){o.$element.one("mouseup.dismiss.bs.modal",function(t){a(t.target).is(o.$element)&&(o.ignoreBackdropClick=!0)})}),this.backdrop(function(){var t=a.support.transition&&o.$element.hasClass("fade");o.$element.parent().length||o.$element.appendTo(o.$body),o.$element.show().scrollTop(0),o.adjustDialog(),t&&o.$element[0].offsetWidth,o.$element.addClass("in"),o.enforceFocus();var e=a.Event("shown.bs.modal",{relatedTarget:i});t?o.$dialog.one("bsTransitionEnd",function(){o.$element.trigger("focus").trigger(e)}).emulateTransitionEnd(s.TRANSITION_DURATION):o.$element.trigger("focus").trigger(e)}))},s.prototype.hide=function(t){t&&t.preventDefault(),t=a.Event("hide.bs.modal"),this.$element.trigger(t),this.isShown&&!t.isDefaultPrevented()&&(this.isShown=!1,this.escape(),this.resize(),a(document).off("focusin.bs.modal"),this.$element.removeClass("in").off("click.dismiss.bs.modal").off("mouseup.dismiss.bs.modal"),this.$dialog.off("mousedown.dismiss.bs.modal"),a.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",a.proxy(this.hideModal,this)).emulateTransitionEnd(s.TRANSITION_DURATION):this.hideModal())},s.prototype.enforceFocus=function(){a(document).off("focusin.bs.modal").on("focusin.bs.modal",a.proxy(function(t){document===t.target||this.$element[0]===t.target||this.$element.has(t.target).length||this.$element.trigger("focus")},this))},s.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keydown.dismiss.bs.modal",a.proxy(function(t){27==t.which&&this.hide()},this)):this.isShown||this.$element.off("keydown.dismiss.bs.modal")},s.prototype.resize=function(){this.isShown?a(window).on("resize.bs.modal",a.proxy(this.handleUpdate,this)):a(window).off("resize.bs.modal")},s.prototype.hideModal=function(){var t=this;this.$element.hide(),this.backdrop(function(){t.$body.removeClass("modal-open"),t.resetAdjustments(),t.resetScrollbar(),t.$element.trigger("hidden.bs.modal")})},s.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},s.prototype.backdrop=function(t){var e=this,i=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var o=a.support.transition&&i;if(this.$backdrop=a(document.createElement("div")).addClass("modal-backdrop "+i).appendTo(this.$body),this.$element.on("click.dismiss.bs.modal",a.proxy(function(t){this.ignoreBackdropClick?this.ignoreBackdropClick=!1:t.target===t.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus():this.hide())},this)),o&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!t)return;o?this.$backdrop.one("bsTransitionEnd",t).emulateTransitionEnd(s.BACKDROP_TRANSITION_DURATION):t()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var n=function(){e.removeBackdrop(),t&&t()};a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",n).emulateTransitionEnd(s.BACKDROP_TRANSITION_DURATION):n()}else t&&t()},s.prototype.handleUpdate=function(){this.adjustDialog()},s.prototype.adjustDialog=function(){var t=this.$element[0].scrollHeight>document.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&t?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!t?this.scrollbarWidth:""})},s.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},s.prototype.checkScrollbar=function(){var t=window.innerWidth;if(!t){var e=document.documentElement.getBoundingClientRect();t=e.right-Math.abs(e.left)}this.bodyIsOverflowing=document.body.clientWidth<t,this.scrollbarWidth=this.measureScrollbar()},s.prototype.setScrollbar=function(){var t=parseInt(this.$body.css("padding-right")||0,10);this.originalBodyPad=document.body.style.paddingRight||"";var n=this.scrollbarWidth;this.bodyIsOverflowing&&(this.$body.css("padding-right",t+n),a(this.fixedContent).each(function(t,e){var i=e.style.paddingRight,o=a(e).css("padding-right");a(e).data("padding-right",i).css("padding-right",parseFloat(o)+n+"px")}))},s.prototype.resetScrollbar=function(){this.$body.css("padding-right",this.originalBodyPad),a(this.fixedContent).each(function(t,e){var i=a(e).data("padding-right");a(e).removeData("padding-right"),e.style.paddingRight=i||""})},s.prototype.measureScrollbar=function(){var t=document.createElement("div");t.className="modal-scrollbar-measure",this.$body.append(t);var e=t.offsetWidth-t.clientWidth;return this.$body[0].removeChild(t),e};var t=a.fn.modal;a.fn.modal=r,a.fn.modal.Constructor=s,a.fn.modal.noConflict=function(){return a.fn.modal=t,this},a(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(t){var e=a(this),i=e.attr("href"),o=e.attr("data-target")||i&&i.replace(/.*(?=#[^\s]+$)/,""),n=a(document).find(o),s=n.data("bs.modal")?"toggle":a.extend({remote:!/#/.test(i)&&i},n.data(),e.data());e.is("a")&&t.preventDefault(),n.one("show.bs.modal",function(t){t.isDefaultPrevented()||n.one("hidden.bs.modal",function(){e.is(":visible")&&e.trigger("focus")})}),r.call(n,s,this)})}(jQuery),function(g){"use strict";var o=["sanitize","whiteList","sanitizeFn"],a=["background","cite","href","itemtype","longdesc","poster","src","xlink:href"],t={"*":["class","dir","id","lang","role",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},r=/^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi,l=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;function u(t,e){var i=t.nodeName.toLowerCase();if(-1!==g.inArray(i,e))return-1===g.inArray(i,a)||Boolean(t.nodeValue.match(r)||t.nodeValue.match(l));for(var o=g(e).filter(function(t,e){return e instanceof RegExp}),n=0,s=o.length;n<s;n++)if(i.match(o[n]))return!0;return!1}function n(t,e,i){if(0===t.length)return t;if(i&&"function"==typeof i)return i(t);if(!document.implementation||!document.implementation.createHTMLDocument)return t;var o=document.implementation.createHTMLDocument("sanitization");o.body.innerHTML=t;for(var n=g.map(e,function(t,e){return e}),s=g(o.body).find("*"),a=0,r=s.length;a<r;a++){var l=s[a],h=l.nodeName.toLowerCase();if(-1!==g.inArray(h,n))for(var d=g.map(l.attributes,function(t){return t}),p=[].concat(e["*"]||[],e[h]||[]),c=0,f=d.length;c<f;c++)u(d[c],p)||l.removeAttribute(d[c].nodeName);else l.parentNode.removeChild(l)}return o.body.innerHTML}var m=function(t,e){this.type=null,this.options=null,this.enabled=null,this.timeout=null,this.hoverState=null,this.$element=null,this.inState=null,this.init("tooltip",t,e)};m.VERSION="3.4.1",m.TRANSITION_DURATION=150,m.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0},sanitize:!0,sanitizeFn:null,whiteList:t},m.prototype.init=function(t,e,i){if(this.enabled=!0,this.type=t,this.$element=g(e),this.options=this.getOptions(i),this.$viewport=this.options.viewport&&g(document).find(g.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var o=this.options.trigger.split(" "),n=o.length;n--;){var s=o[n];if("click"==s)this.$element.on("click."+this.type,this.options.selector,g.proxy(this.toggle,this));else if("manual"!=s){var a="hover"==s?"mouseenter":"focusin",r="hover"==s?"mouseleave":"focusout";this.$element.on(a+"."+this.type,this.options.selector,g.proxy(this.enter,this)),this.$element.on(r+"."+this.type,this.options.selector,g.proxy(this.leave,this))}}this.options.selector?this._options=g.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},m.prototype.getDefaults=function(){return m.DEFAULTS},m.prototype.getOptions=function(t){var e=this.$element.data();for(var i in e)e.hasOwnProperty(i)&&-1!==g.inArray(i,o)&&delete e[i];return(t=g.extend({},this.getDefaults(),e,t)).delay&&"number"==typeof t.delay&&(t.delay={show:t.delay,hide:t.delay}),t.sanitize&&(t.template=n(t.template,t.whiteList,t.sanitizeFn)),t},m.prototype.getDelegateOptions=function(){var i={},o=this.getDefaults();return this._options&&g.each(this._options,function(t,e){o[t]!=e&&(i[t]=e)}),i},m.prototype.enter=function(t){var e=t instanceof this.constructor?t:g(t.currentTarget).data("bs."+this.type);if(e||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),g(t.currentTarget).data("bs."+this.type,e)),t instanceof g.Event&&(e.inState["focusin"==t.type?"focus":"hover"]=!0),e.tip().hasClass("in")||"in"==e.hoverState)e.hoverState="in";else{if(clearTimeout(e.timeout),e.hoverState="in",!e.options.delay||!e.options.delay.show)return e.show();e.timeout=setTimeout(function(){"in"==e.hoverState&&e.show()},e.options.delay.show)}},m.prototype.isInStateTrue=function(){for(var t in this.inState)if(this.inState[t])return!0;return!1},m.prototype.leave=function(t){var e=t instanceof this.constructor?t:g(t.currentTarget).data("bs."+this.type);if(e||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),g(t.currentTarget).data("bs."+this.type,e)),t instanceof g.Event&&(e.inState["focusout"==t.type?"focus":"hover"]=!1),!e.isInStateTrue()){if(clearTimeout(e.timeout),e.hoverState="out",!e.options.delay||!e.options.delay.hide)return e.hide();e.timeout=setTimeout(function(){"out"==e.hoverState&&e.hide()},e.options.delay.hide)}},m.prototype.show=function(){var t=g.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(t);var e=g.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(t.isDefaultPrevented()||!e)return;var i=this,o=this.tip(),n=this.getUID(this.type);this.setContent(),o.attr("id",n),this.$element.attr("aria-describedby",n),this.options.animation&&o.addClass("fade");var s="function"==typeof this.options.placement?this.options.placement.call(this,o[0],this.$element[0]):this.options.placement,a=/\s?auto?\s?/i,r=a.test(s);r&&(s=s.replace(a,"")||"top"),o.detach().css({top:0,left:0,display:"block"}).addClass(s).data("bs."+this.type,this),this.options.container?o.appendTo(g(document).find(this.options.container)):o.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var l=this.getPosition(),h=o[0].offsetWidth,d=o[0].offsetHeight;if(r){var p=s,c=this.getPosition(this.$viewport);s="bottom"==s&&l.bottom+d>c.bottom?"top":"top"==s&&l.top-d<c.top?"bottom":"right"==s&&l.right+h>c.width?"left":"left"==s&&l.left-h<c.left?"right":s,o.removeClass(p).addClass(s)}var f=this.getCalculatedOffset(s,l,h,d);this.applyPlacement(f,s);var u=function(){var t=i.hoverState;i.$element.trigger("shown.bs."+i.type),i.hoverState=null,"out"==t&&i.leave(i)};g.support.transition&&this.$tip.hasClass("fade")?o.one("bsTransitionEnd",u).emulateTransitionEnd(m.TRANSITION_DURATION):u()}},m.prototype.applyPlacement=function(t,e){var i=this.tip(),o=i[0].offsetWidth,n=i[0].offsetHeight,s=parseInt(i.css("margin-top"),10),a=parseInt(i.css("margin-left"),10);isNaN(s)&&(s=0),isNaN(a)&&(a=0),t.top+=s,t.left+=a,g.offset.setOffset(i[0],g.extend({using:function(t){i.css({top:Math.round(t.top),left:Math.round(t.left)})}},t),0),i.addClass("in");var r=i[0].offsetWidth,l=i[0].offsetHeight;"top"==e&&l!=n&&(t.top=t.top+n-l);var h=this.getViewportAdjustedDelta(e,t,r,l);h.left?t.left+=h.left:t.top+=h.top;var d=/top|bottom/.test(e),p=d?2*h.left-o+r:2*h.top-n+l,c=d?"offsetWidth":"offsetHeight";i.offset(t),this.replaceArrow(p,i[0][c],d)},m.prototype.replaceArrow=function(t,e,i){this.arrow().css(i?"left":"top",50*(1-t/e)+"%").css(i?"top":"left","")},m.prototype.setContent=function(){var t=this.tip(),e=this.getTitle();this.options.html?(this.options.sanitize&&(e=n(e,this.options.whiteList,this.options.sanitizeFn)),t.find(".tooltip-inner").html(e)):t.find(".tooltip-inner").text(e),t.removeClass("fade in top bottom left right")},m.prototype.hide=function(t){var e=this,i=g(this.$tip),o=g.Event("hide.bs."+this.type);function n(){"in"!=e.hoverState&&i.detach(),e.$element&&e.$element.removeAttr("aria-describedby").trigger("hidden.bs."+e.type),t&&t()}if(this.$element.trigger(o),!o.isDefaultPrevented())return i.removeClass("in"),g.support.transition&&i.hasClass("fade")?i.one("bsTransitionEnd",n).emulateTransitionEnd(m.TRANSITION_DURATION):n(),this.hoverState=null,this},m.prototype.fixTitle=function(){var t=this.$element;(t.attr("title")||"string"!=typeof t.attr("data-original-title"))&&t.attr("data-original-title",t.attr("title")||"").attr("title","")},m.prototype.hasContent=function(){return this.getTitle()},m.prototype.getPosition=function(t){var e=(t=t||this.$element)[0],i="BODY"==e.tagName,o=e.getBoundingClientRect();null==o.width&&(o=g.extend({},o,{width:o.right-o.left,height:o.bottom-o.top}));var n=window.SVGElement&&e instanceof window.SVGElement,s=i?{top:0,left:0}:n?null:t.offset(),a={scroll:i?document.documentElement.scrollTop||document.body.scrollTop:t.scrollTop()},r=i?{width:g(window).width(),height:g(window).height()}:null;return g.extend({},o,a,r,s)},m.prototype.getCalculatedOffset=function(t,e,i,o){return"bottom"==t?{top:e.top+e.height,left:e.left+e.width/2-i/2}:"top"==t?{top:e.top-o,left:e.left+e.width/2-i/2}:"left"==t?{top:e.top+e.height/2-o/2,left:e.left-i}:{top:e.top+e.height/2-o/2,left:e.left+e.width}},m.prototype.getViewportAdjustedDelta=function(t,e,i,o){var n={top:0,left:0};if(!this.$viewport)return n;var s=this.options.viewport&&this.options.viewport.padding||0,a=this.getPosition(this.$viewport);if(/right|left/.test(t)){var r=e.top-s-a.scroll,l=e.top+s-a.scroll+o;r<a.top?n.top=a.top-r:l>a.top+a.height&&(n.top=a.top+a.height-l)}else{var h=e.left-s,d=e.left+s+i;h<a.left?n.left=a.left-h:d>a.right&&(n.left=a.left+a.width-d)}return n},m.prototype.getTitle=function(){var t=this.$element,e=this.options;return t.attr("data-original-title")||("function"==typeof e.title?e.title.call(t[0]):e.title)},m.prototype.getUID=function(t){for(;t+=~~(1e6*Math.random()),document.getElementById(t););return t},m.prototype.tip=function(){if(!this.$tip&&(this.$tip=g(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},m.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},m.prototype.enable=function(){this.enabled=!0},m.prototype.disable=function(){this.enabled=!1},m.prototype.toggleEnabled=function(){this.enabled=!this.enabled},m.prototype.toggle=function(t){var e=this;t&&((e=g(t.currentTarget).data("bs."+this.type))||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),g(t.currentTarget).data("bs."+this.type,e))),t?(e.inState.click=!e.inState.click,e.isInStateTrue()?e.enter(e):e.leave(e)):e.tip().hasClass("in")?e.leave(e):e.enter(e)},m.prototype.destroy=function(){var t=this;clearTimeout(this.timeout),this.hide(function(){t.$element.off("."+t.type).removeData("bs."+t.type),t.$tip&&t.$tip.detach(),t.$tip=null,t.$arrow=null,t.$viewport=null,t.$element=null})},m.prototype.sanitizeHtml=function(t){return n(t,this.options.whiteList,this.options.sanitizeFn)};var e=g.fn.tooltip;g.fn.tooltip=function i(o){return this.each(function(){var t=g(this),e=t.data("bs.tooltip"),i="object"==typeof o&&o;!e&&/destroy|hide/.test(o)||(e||t.data("bs.tooltip",e=new m(this,i)),"string"==typeof o&&e[o]())})},g.fn.tooltip.Constructor=m,g.fn.tooltip.noConflict=function(){return g.fn.tooltip=e,this}}(jQuery),function(n){"use strict";var s=function(t,e){this.init("popover",t,e)};if(!n.fn.tooltip)throw new Error("Popover requires tooltip.js");s.VERSION="3.4.1",s.DEFAULTS=n.extend({},n.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),((s.prototype=n.extend({},n.fn.tooltip.Constructor.prototype)).constructor=s).prototype.getDefaults=function(){return s.DEFAULTS},s.prototype.setContent=function(){var t=this.tip(),e=this.getTitle(),i=this.getContent();if(this.options.html){var o=typeof i;this.options.sanitize&&(e=this.sanitizeHtml(e),"string"===o&&(i=this.sanitizeHtml(i))),t.find(".popover-title").html(e),t.find(".popover-content").children().detach().end()["string"===o?"html":"append"](i)}else t.find(".popover-title").text(e),t.find(".popover-content").children().detach().end().text(i);t.removeClass("fade top bottom left right in"),t.find(".popover-title").html()||t.find(".popover-title").hide()},s.prototype.hasContent=function(){return this.getTitle()||this.getContent()},s.prototype.getContent=function(){var t=this.$element,e=this.options;return t.attr("data-content")||("function"==typeof e.content?e.content.call(t[0]):e.content)},s.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var t=n.fn.popover;n.fn.popover=function e(o){return this.each(function(){var t=n(this),e=t.data("bs.popover"),i="object"==typeof o&&o;!e&&/destroy|hide/.test(o)||(e||t.data("bs.popover",e=new s(this,i)),"string"==typeof o&&e[o]())})},n.fn.popover.Constructor=s,n.fn.popover.noConflict=function(){return n.fn.popover=t,this}}(jQuery),function(s){"use strict";function n(t,e){this.$body=s(document.body),this.$scrollElement=s(t).is(document.body)?s(window):s(t),this.options=s.extend({},n.DEFAULTS,e),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",s.proxy(this.process,this)),this.refresh(),this.process()}function e(o){return this.each(function(){var t=s(this),e=t.data("bs.scrollspy"),i="object"==typeof o&&o;e||t.data("bs.scrollspy",e=new n(this,i)),"string"==typeof o&&e[o]()})}n.VERSION="3.4.1",n.DEFAULTS={offset:10},n.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},n.prototype.refresh=function(){var t=this,o="offset",n=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),s.isWindow(this.$scrollElement[0])||(o="position",n=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var t=s(this),e=t.data("target")||t.attr("href"),i=/^#./.test(e)&&s(e);return i&&i.length&&i.is(":visible")&&[[i[o]().top+n,e]]||null}).sort(function(t,e){return t[0]-e[0]}).each(function(){t.offsets.push(this[0]),t.targets.push(this[1])})},n.prototype.process=function(){var t,e=this.$scrollElement.scrollTop()+this.options.offset,i=this.getScrollHeight(),o=this.options.offset+i-this.$scrollElement.height(),n=this.offsets,s=this.targets,a=this.activeTarget;if(this.scrollHeight!=i&&this.refresh(),o<=e)return a!=(t=s[s.length-1])&&this.activate(t);if(a&&e<n[0])return this.activeTarget=null,this.clear();for(t=n.length;t--;)a!=s[t]&&e>=n[t]&&(n[t+1]===undefined||e<n[t+1])&&this.activate(s[t])},n.prototype.activate=function(t){this.activeTarget=t,this.clear();var e=this.selector+'[data-target="'+t+'"],'+this.selector+'[href="'+t+'"]',i=s(e).parents("li").addClass("active");i.parent(".dropdown-menu").length&&(i=i.closest("li.dropdown").addClass("active")),i.trigger("activate.bs.scrollspy")},n.prototype.clear=function(){s(this.selector).parentsUntil(this.options.target,".active").removeClass("active")};var t=s.fn.scrollspy;s.fn.scrollspy=e,s.fn.scrollspy.Constructor=n,s.fn.scrollspy.noConflict=function(){return s.fn.scrollspy=t,this},s(window).on("load.bs.scrollspy.data-api",function(){s('[data-spy="scroll"]').each(function(){var t=s(this);e.call(t,t.data())})})}(jQuery),function(r){"use strict";var a=function(t){this.element=r(t)};function e(i){return this.each(function(){var t=r(this),e=t.data("bs.tab");e||t.data("bs.tab",e=new a(this)),"string"==typeof i&&e[i]()})}a.VERSION="3.4.1",a.TRANSITION_DURATION=150,a.prototype.show=function(){var t=this.element,e=t.closest("ul:not(.dropdown-menu)"),i=t.data("target");if(i||(i=(i=t.attr("href"))&&i.replace(/.*(?=#[^\s]*$)/,"")),!t.parent("li").hasClass("active")){var o=e.find(".active:last a"),n=r.Event("hide.bs.tab",{relatedTarget:t[0]}),s=r.Event("show.bs.tab",{relatedTarget:o[0]});if(o.trigger(n),t.trigger(s),!s.isDefaultPrevented()&&!n.isDefaultPrevented()){var a=r(document).find(i);this.activate(t.closest("li"),e),this.activate(a,a.parent(),function(){o.trigger({type:"hidden.bs.tab",relatedTarget:t[0]}),t.trigger({type:"shown.bs.tab",relatedTarget:o[0]})})}}},a.prototype.activate=function(t,e,i){var o=e.find("> .active"),n=i&&r.support.transition&&(o.length&&o.hasClass("fade")||!!e.find("> .fade").length);function s(){o.removeClass("active").find("> .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),t.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),n?(t[0].offsetWidth,t.addClass("in")):t.removeClass("fade"),t.parent(".dropdown-menu").length&&t.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),i&&i()}o.length&&n?o.one("bsTransitionEnd",s).emulateTransitionEnd(a.TRANSITION_DURATION):s(),o.removeClass("in")};var t=r.fn.tab;r.fn.tab=e,r.fn.tab.Constructor=a,r.fn.tab.noConflict=function(){return r.fn.tab=t,this};var i=function(t){t.preventDefault(),e.call(r(this),"show")};r(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',i).on("click.bs.tab.data-api",'[data-toggle="pill"]',i)}(jQuery),function(l){"use strict";var h=function(t,e){this.options=l.extend({},h.DEFAULTS,e);var i=this.options.target===h.DEFAULTS.target?l(this.options.target):l(document).find(this.options.target);this.$target=i.on("scroll.bs.affix.data-api",l.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",l.proxy(this.checkPositionWithEventLoop,this)),this.$element=l(t),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};function i(o){return this.each(function(){var t=l(this),e=t.data("bs.affix"),i="object"==typeof o&&o;e||t.data("bs.affix",e=new h(this,i)),"string"==typeof o&&e[o]()})}h.VERSION="3.4.1",h.RESET="affix affix-top affix-bottom",h.DEFAULTS={offset:0,target:window},h.prototype.getState=function(t,e,i,o){var n=this.$target.scrollTop(),s=this.$element.offset(),a=this.$target.height();if(null!=i&&"top"==this.affixed)return n<i&&"top";if("bottom"==this.affixed)return null!=i?!(n+this.unpin<=s.top)&&"bottom":!(n+a<=t-o)&&"bottom";var r=null==this.affixed,l=r?n:s.top;return null!=i&&n<=i?"top":null!=o&&t-o<=l+(r?a:e)&&"bottom"},h.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(h.RESET).addClass("affix");var t=this.$target.scrollTop(),e=this.$element.offset();return this.pinnedOffset=e.top-t},h.prototype.checkPositionWithEventLoop=function(){setTimeout(l.proxy(this.checkPosition,this),1)},h.prototype.checkPosition=function(){if(this.$element.is(":visible")){var t=this.$element.height(),e=this.options.offset,i=e.top,o=e.bottom,n=Math.max(l(document).height(),l(document.body).height());"object"!=typeof e&&(o=i=e),"function"==typeof i&&(i=e.top(this.$element)),"function"==typeof o&&(o=e.bottom(this.$element));var s=this.getState(n,t,i,o);if(this.affixed!=s){null!=this.unpin&&this.$element.css("top","");var a="affix"+(s?"-"+s:""),r=l.Event(a+".bs.affix");if(this.$element.trigger(r),r.isDefaultPrevented())return;this.affixed=s,this.unpin="bottom"==s?this.getPinnedOffset():null,this.$element.removeClass(h.RESET).addClass(a).trigger(a.replace("affix","affixed")+".bs.affix")}"bottom"==s&&this.$element.offset({top:n-t-o})}};var t=l.fn.affix;l.fn.affix=i,l.fn.affix.Constructor=h,l.fn.affix.noConflict=function(){return l.fn.affix=t,this},l(window).on("load",function(){l('[data-spy="affix"]').each(function(){var t=l(this),e=t.data();e.offset=e.offset||{},null!=e.offsetBottom&&(e.offset.bottom=e.offsetBottom),null!=e.offsetTop&&(e.offset.top=e.offsetTop),i.call(t,e)})})}(jQuery);;
/*!
 * Jasny Bootstrap v3.1.3 (http://jasny.github.io/bootstrap)
 * Copyright 2012-2014 Arnold Daniels
 * Licensed under Apache-2.0 (https://github.com/jasny/bootstrap/blob/master/LICENSE)
 */
if("undefined"==typeof jQuery)throw new Error("Jasny Bootstrap's JavaScript requires jQuery");+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}void 0===a.support.transition&&(a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one(a.support.transition.end,function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b()}))}(window.jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d),this.state=null,this.placement=null,this.options.recalc&&(this.calcClone(),a(window).on("resize",a.proxy(this.recalc,this))),this.options.autohide&&a(document).on("click",a.proxy(this.autohide,this)),this.options.toggle&&this.toggle(),this.options.disablescrolling&&(this.options.disableScrolling=this.options.disablescrolling,delete this.options.disablescrolling)};b.DEFAULTS={toggle:!0,placement:"auto",autohide:!0,recalc:!0,disableScrolling:!0},b.prototype.offset=function(){switch(this.placement){case"left":case"right":return this.$element.outerWidth();case"top":case"bottom":return this.$element.outerHeight()}},b.prototype.calcPlacement=function(){function b(a,b){if("auto"===e.css(b))return a;if("auto"===e.css(a))return b;var c=parseInt(e.css(a),10),d=parseInt(e.css(b),10);return c>d?b:a}if("auto"!==this.options.placement)return void(this.placement=this.options.placement);this.$element.hasClass("in")||this.$element.css("visiblity","hidden !important").addClass("in");var c=a(window).width()/this.$element.width(),d=a(window).height()/this.$element.height(),e=this.$element;this.placement=c>=d?b("left","right"):b("top","bottom"),"hidden !important"===this.$element.css("visibility")&&this.$element.removeClass("in").css("visiblity","")},b.prototype.opposite=function(a){switch(a){case"top":return"bottom";case"left":return"right";case"bottom":return"top";case"right":return"left"}},b.prototype.getCanvasElements=function(){var b=this.options.canvas?a(this.options.canvas):this.$element,c=b.find("*").filter(function(){return"fixed"===a(this).css("position")}).not(this.options.exclude);return b.add(c)},b.prototype.slide=function(b,c,d){if(!a.support.transition){var e={};return e[this.placement]="+="+c,b.animate(e,350,d)}var f=this.placement,g=this.opposite(f);b.each(function(){"auto"!==a(this).css(f)&&a(this).css(f,(parseInt(a(this).css(f),10)||0)+c),"auto"!==a(this).css(g)&&a(this).css(g,(parseInt(a(this).css(g),10)||0)-c)}),this.$element.one(a.support.transition.end,d).emulateTransitionEnd(350)},b.prototype.disableScrolling=function(){var b=a("body").width(),c="padding-"+this.opposite(this.placement);if(void 0===a("body").data("offcanvas-style")&&a("body").data("offcanvas-style",a("body").attr("style")||""),a("body").css("overflow","hidden"),a("body").width()>b){var d=parseInt(a("body").css(c),10)+a("body").width()-b;setTimeout(function(){a("body").css(c,d)},1)}},b.prototype.show=function(){if(!this.state){var b=a.Event("show.bs.offcanvas");if(this.$element.trigger(b),!b.isDefaultPrevented()){this.state="slide-in",this.calcPlacement();var c=this.getCanvasElements(),d=this.placement,e=this.opposite(d),f=this.offset();-1!==c.index(this.$element)&&(a(this.$element).data("offcanvas-style",a(this.$element).attr("style")||""),this.$element.css(d,-1*f),this.$element.css(d)),c.addClass("canvas-sliding").each(function(){void 0===a(this).data("offcanvas-style")&&a(this).data("offcanvas-style",a(this).attr("style")||""),"static"===a(this).css("position")&&a(this).css("position","relative"),"auto"!==a(this).css(d)&&"0px"!==a(this).css(d)||"auto"!==a(this).css(e)&&"0px"!==a(this).css(e)||a(this).css(d,0)}),this.options.disableScrolling&&this.disableScrolling();var g=function(){"slide-in"==this.state&&(this.state="slid",c.removeClass("canvas-sliding").addClass("canvas-slid"),this.$element.trigger("shown.bs.offcanvas"))};setTimeout(a.proxy(function(){this.$element.addClass("in"),this.slide(c,f,a.proxy(g,this))},this),1)}}},b.prototype.hide=function(){if("slid"===this.state){var b=a.Event("hide.bs.offcanvas");if(this.$element.trigger(b),!b.isDefaultPrevented()){this.state="slide-out";var c=a(".canvas-slid"),d=(this.placement,-1*this.offset()),e=function(){"slide-out"==this.state&&(this.state=null,this.placement=null,this.$element.removeClass("in"),c.removeClass("canvas-sliding"),c.add(this.$element).add("body").each(function(){a(this).attr("style",a(this).data("offcanvas-style")).removeData("offcanvas-style")}),this.$element.trigger("hidden.bs.offcanvas"))};c.removeClass("canvas-slid").addClass("canvas-sliding"),setTimeout(a.proxy(function(){this.slide(c,d,a.proxy(e,this))},this),1)}}},b.prototype.toggle=function(){"slide-in"!==this.state&&"slide-out"!==this.state&&this["slid"===this.state?"hide":"show"]()},b.prototype.calcClone=function(){this.$calcClone=this.$element.clone().html("").addClass("offcanvas-clone").removeClass("in").appendTo(a("body"))},b.prototype.recalc=function(){if("none"!==this.$calcClone.css("display")&&("slid"===this.state||"slide-in"===this.state)){this.state=null,this.placement=null;var b=this.getCanvasElements();this.$element.removeClass("in"),b.removeClass("canvas-slid"),b.add(this.$element).add("body").each(function(){a(this).attr("style",a(this).data("offcanvas-style")).removeData("offcanvas-style")})}},b.prototype.autohide=function(b){0===a(b.target).closest(this.$element).length&&this.hide()};var c=a.fn.offcanvas;a.fn.offcanvas=function(c){return this.each(function(){var d=a(this),e=d.data("bs.offcanvas"),f=a.extend({},b.DEFAULTS,d.data(),"object"==typeof c&&c);e||d.data("bs.offcanvas",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.offcanvas.Constructor=b,a.fn.offcanvas.noConflict=function(){return a.fn.offcanvas=c,this},a(document).on("click.bs.offcanvas.data-api","[data-toggle=offcanvas]",function(b){var c,d=a(this),e=d.attr("data-target")||b.preventDefault()||(c=d.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,""),f=a(e),g=f.data("bs.offcanvas"),h=g?"toggle":d.data();b.stopPropagation(),g?g.toggle():f.offcanvas(h)})}(window.jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d),this.$element.on("click.bs.rowlink","td:not(.rowlink-skip)",a.proxy(this.click,this))};b.DEFAULTS={target:"a"},b.prototype.click=function(b){var c=a(b.currentTarget).closest("tr").find(this.options.target)[0];if(a(b.target)[0]!==c)if(b.preventDefault(),c.click)c.click();else if(document.createEvent){var d=document.createEvent("MouseEvents");d.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),c.dispatchEvent(d)}};var c=a.fn.rowlink;a.fn.rowlink=function(c){return this.each(function(){var d=a(this),e=d.data("bs.rowlink");e||d.data("bs.rowlink",e=new b(this,c))})},a.fn.rowlink.Constructor=b,a.fn.rowlink.noConflict=function(){return a.fn.rowlink=c,this},a(document).on("click.bs.rowlink.data-api",'[data-link="row"]',function(b){if(0===a(b.target).closest(".rowlink-skip").length){var c=a(this);c.data("bs.rowlink")||(c.rowlink(c.data()),a(b.target).trigger("click.bs.rowlink"))}})}(window.jQuery),+function(a){"use strict";var b=void 0!==window.orientation,c=navigator.userAgent.toLowerCase().indexOf("android")>-1,d="Microsoft Internet Explorer"==window.navigator.appName,e=function(b,d){c||(this.$element=a(b),this.options=a.extend({},e.DEFAULTS,d),this.mask=String(this.options.mask),this.init(),this.listen(),this.checkVal())};e.DEFAULTS={mask:"",placeholder:"_",definitions:{9:"[0-9]",a:"[A-Za-z]",w:"[A-Za-z0-9]","*":"."}},e.prototype.init=function(){var b=this.options.definitions,c=this.mask.length;this.tests=[],this.partialPosition=this.mask.length,this.firstNonMaskPos=null,a.each(this.mask.split(""),a.proxy(function(a,d){"?"==d?(c--,this.partialPosition=a):b[d]?(this.tests.push(new RegExp(b[d])),null===this.firstNonMaskPos&&(this.firstNonMaskPos=this.tests.length-1)):this.tests.push(null)},this)),this.buffer=a.map(this.mask.split(""),a.proxy(function(a){return"?"!=a?b[a]?this.options.placeholder:a:void 0},this)),this.focusText=this.$element.val(),this.$element.data("rawMaskFn",a.proxy(function(){return a.map(this.buffer,function(a,b){return this.tests[b]&&a!=this.options.placeholder?a:null}).join("")},this))},e.prototype.listen=function(){if(!this.$element.attr("readonly")){var b=(d?"paste":"input")+".mask";this.$element.on("unmask.bs.inputmask",a.proxy(this.unmask,this)).on("focus.bs.inputmask",a.proxy(this.focusEvent,this)).on("blur.bs.inputmask",a.proxy(this.blurEvent,this)).on("keydown.bs.inputmask",a.proxy(this.keydownEvent,this)).on("keypress.bs.inputmask",a.proxy(this.keypressEvent,this)).on(b,a.proxy(this.pasteEvent,this))}},e.prototype.caret=function(a,b){if(0!==this.$element.length){if("number"==typeof a)return b="number"==typeof b?b:a,this.$element.each(function(){if(this.setSelectionRange)this.setSelectionRange(a,b);else if(this.createTextRange){var c=this.createTextRange();c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select()}});if(this.$element[0].setSelectionRange)a=this.$element[0].selectionStart,b=this.$element[0].selectionEnd;else if(document.selection&&document.selection.createRange){var c=document.selection.createRange();a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length}return{begin:a,end:b}}},e.prototype.seekNext=function(a){for(var b=this.mask.length;++a<=b&&!this.tests[a];);return a},e.prototype.seekPrev=function(a){for(;--a>=0&&!this.tests[a];);return a},e.prototype.shiftL=function(a,b){var c=this.mask.length;if(!(0>a)){for(var d=a,e=this.seekNext(b);c>d;d++)if(this.tests[d]){if(!(c>e&&this.tests[d].test(this.buffer[e])))break;this.buffer[d]=this.buffer[e],this.buffer[e]=this.options.placeholder,e=this.seekNext(e)}this.writeBuffer(),this.caret(Math.max(this.firstNonMaskPos,a))}},e.prototype.shiftR=function(a){for(var b=this.mask.length,c=a,d=this.options.placeholder;b>c;c++)if(this.tests[c]){var e=this.seekNext(c),f=this.buffer[c];if(this.buffer[c]=d,!(b>e&&this.tests[e].test(f)))break;d=f}},e.prototype.unmask=function(){this.$element.unbind(".mask").removeData("inputmask")},e.prototype.focusEvent=function(){this.focusText=this.$element.val();var a=this.mask.length,b=this.checkVal();this.writeBuffer();var c=this,d=function(){b==a?c.caret(0,b):c.caret(b)};d(),setTimeout(d,50)},e.prototype.blurEvent=function(){this.checkVal(),this.$element.val()!==this.focusText&&this.$element.trigger("change")},e.prototype.keydownEvent=function(a){var c=a.which;if(8==c||46==c||b&&127==c){var d=this.caret(),e=d.begin,f=d.end;return f-e===0&&(e=46!=c?this.seekPrev(e):f=this.seekNext(e-1),f=46==c?this.seekNext(f):f),this.clearBuffer(e,f),this.shiftL(e,f-1),!1}return 27==c?(this.$element.val(this.focusText),this.caret(0,this.checkVal()),!1):void 0},e.prototype.keypressEvent=function(a){var b=this.mask.length,c=a.which,d=this.caret();if(a.ctrlKey||a.altKey||a.metaKey||32>c)return!0;if(c){d.end-d.begin!==0&&(this.clearBuffer(d.begin,d.end),this.shiftL(d.begin,d.end-1));var e=this.seekNext(d.begin-1);if(b>e){var f=String.fromCharCode(c);if(this.tests[e].test(f)){this.shiftR(e),this.buffer[e]=f,this.writeBuffer();var g=this.seekNext(e);this.caret(g)}}return!1}},e.prototype.pasteEvent=function(){var a=this;setTimeout(function(){a.caret(a.checkVal(!0))},0)},e.prototype.clearBuffer=function(a,b){for(var c=this.mask.length,d=a;b>d&&c>d;d++)this.tests[d]&&(this.buffer[d]=this.options.placeholder)},e.prototype.writeBuffer=function(){return this.$element.val(this.buffer.join("")).val()},e.prototype.checkVal=function(a){for(var b=this.mask.length,c=this.$element.val(),d=-1,e=0,f=0;b>e;e++)if(this.tests[e]){for(this.buffer[e]=this.options.placeholder;f++<c.length;){var g=c.charAt(f-1);if(this.tests[e].test(g)){this.buffer[e]=g,d=e;break}}if(f>c.length)break}else this.buffer[e]==c.charAt(f)&&e!=this.partialPosition&&(f++,d=e);return!a&&d+1<this.partialPosition?(this.$element.val(""),this.clearBuffer(0,b)):(a||d+1>=this.partialPosition)&&(this.writeBuffer(),a||this.$element.val(this.$element.val().substring(0,d+1))),this.partialPosition?e:this.firstNonMaskPos};var f=a.fn.inputmask;a.fn.inputmask=function(b){return this.each(function(){var c=a(this),d=c.data("bs.inputmask");d||c.data("bs.inputmask",d=new e(this,b))})},a.fn.inputmask.Constructor=e,a.fn.inputmask.noConflict=function(){return a.fn.inputmask=f,this},a(document).on("focus.bs.inputmask.data-api","[data-mask]",function(){var b=a(this);b.data("bs.inputmask")||b.inputmask(b.data())})}(window.jQuery),+function(a){"use strict";var b="Microsoft Internet Explorer"==window.navigator.appName,c=function(b,c){if(this.$element=a(b),this.$input=this.$element.find(":file"),0!==this.$input.length){this.name=this.$input.attr("name")||c.name,this.$hidden=this.$element.find('input[type=hidden][name="'+this.name+'"]'),0===this.$hidden.length&&(this.$hidden=a('<input type="hidden">').insertBefore(this.$input)),this.$preview=this.$element.find(".fileinput-preview");var d=this.$preview.css("height");"inline"!==this.$preview.css("display")&&"0px"!==d&&"none"!==d&&this.$preview.css("line-height",d),this.original={exists:this.$element.hasClass("fileinput-exists"),preview:this.$preview.html(),hiddenVal:this.$hidden.val()},this.listen()}};c.prototype.listen=function(){this.$input.on("change.bs.fileinput",a.proxy(this.change,this)),a(this.$input[0].form).on("reset.bs.fileinput",a.proxy(this.reset,this)),this.$element.find('[data-trigger="fileinput"]').on("click.bs.fileinput",a.proxy(this.trigger,this)),this.$element.find('[data-dismiss="fileinput"]').on("click.bs.fileinput",a.proxy(this.clear,this))},c.prototype.change=function(b){var c=void 0===b.target.files?b.target&&b.target.value?[{name:b.target.value.replace(/^.+\\/,"")}]:[]:b.target.files;if(b.stopPropagation(),0===c.length)return void this.clear();this.$hidden.val(""),this.$hidden.attr("name",""),this.$input.attr("name",this.name);var d=c[0];if(this.$preview.length>0&&("undefined"!=typeof d.type?d.type.match(/^image\/(gif|png|jpeg)$/):d.name.match(/\.(gif|png|jpe?g)$/i))&&"undefined"!=typeof FileReader){var e=new FileReader,f=this.$preview,g=this.$element;e.onload=function(b){var e=a("<img>");e[0].src=b.target.result,c[0].result=b.target.result,g.find(".fileinput-filename").text(d.name),"none"!=f.css("max-height")&&e.css("max-height",parseInt(f.css("max-height"),10)-parseInt(f.css("padding-top"),10)-parseInt(f.css("padding-bottom"),10)-parseInt(f.css("border-top"),10)-parseInt(f.css("border-bottom"),10)),f.html(e),g.addClass("fileinput-exists").removeClass("fileinput-new"),g.trigger("change.bs.fileinput",c)},e.readAsDataURL(d)}else this.$element.find(".fileinput-filename").text(d.name),this.$preview.text(d.name),this.$element.addClass("fileinput-exists").removeClass("fileinput-new"),this.$element.trigger("change.bs.fileinput")},c.prototype.clear=function(a){if(a&&a.preventDefault(),this.$hidden.val(""),this.$hidden.attr("name",this.name),this.$input.attr("name",""),b){var c=this.$input.clone(!0);this.$input.after(c),this.$input.remove(),this.$input=c}else this.$input.val("");this.$preview.html(""),this.$element.find(".fileinput-filename").text(""),this.$element.addClass("fileinput-new").removeClass("fileinput-exists"),void 0!==a&&(this.$input.trigger("change"),this.$element.trigger("clear.bs.fileinput"))},c.prototype.reset=function(){this.clear(),this.$hidden.val(this.original.hiddenVal),this.$preview.html(this.original.preview),this.$element.find(".fileinput-filename").text(""),this.original.exists?this.$element.addClass("fileinput-exists").removeClass("fileinput-new"):this.$element.addClass("fileinput-new").removeClass("fileinput-exists"),this.$element.trigger("reset.bs.fileinput")},c.prototype.trigger=function(a){this.$input.trigger("click"),a.preventDefault()};var d=a.fn.fileinput;a.fn.fileinput=function(b){return this.each(function(){var d=a(this),e=d.data("bs.fileinput");e||d.data("bs.fileinput",e=new c(this,b)),"string"==typeof b&&e[b]()})},a.fn.fileinput.Constructor=c,a.fn.fileinput.noConflict=function(){return a.fn.fileinput=d,this},a(document).on("click.fileinput.data-api",'[data-provides="fileinput"]',function(b){var c=a(this);if(!c.data("bs.fileinput")){c.fileinput(c.data());var d=a(b.target).closest('[data-dismiss="fileinput"],[data-trigger="fileinput"]');d.length>0&&(b.preventDefault(),d.trigger("click.bs.fileinput"))}})}(window.jQuery);;
var shopHq = {}; // Register Namespace;
(function(facebook) 
{
    facebook.initialize = function () {
        window.fbAsyncInit =
                    function () {
                        FB.init({ appId: null, status: true, cookie: true, xfbml: true });
                        FB.Event.subscribe('edge.create', function (href, widget) {
                           
                        });
                    };
        (function (d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) {
                return;
            }
            js = d.createElement(s);
            js.id = id;
            js.src = "//connect.facebook.net/en_US/all.js";
            fjs.parentNode.insertBefore(js, fjs);
        } (document, 'script', 'facebook-jssdk'));
    };

    return facebook;
})(shopHq.facebook = shopHq.facebook || {});;
window.onerror = function (msg, url, line)
{
    var suppressErrorAlert = true;
    //if(console)
    //    console.error(msg + ' url: ' + url + ' Line: ' + line);
    // Return true, suppress error alerts (like in older versions of Internet Explorer).
    return suppressErrorAlert;
};;
(function (images, $) {
    images.preLoadNavigationImages = function () {
        // Preload images
        var onAirImages = $("#divOnAir a img");

        onAirImages.each(function () {
            var img = new Image();
            img.src = $(this).attr("src").replace("_off.gif", "_on.gif");
        });

        // Add image toggle event
        onAirImages.hover(
            function () { $(this).attr("src", $(this).attr("src").replace("_off.gif", "_on.gif")); },
            function () { $(this).attr("src", $(this).attr("src").replace("_on.gif", "_off.gif")); });
    };

    images.preLoadImages = function (imageArray) {
        var img = new Image();

        $.each(imageArray, function (index, value) {
            img.src = value;
        });
    };

    images.SECURE_IMAGE_PATH = 'https://images.shophq.com/is/image/ShopHQ/';

    var mZoomDelayInMs = 75;
    var mZoomPixelIncrement = 45;
    var mZoomTargetMinPoint;
    var mZoomTargetMidPoint;
    var mZoomTargetMaxPoint;
    var imageViewerSize;
    var halfImageViewerSize;

    var mZoomLoopCounter = 0;
    var mZoomLoopCounterMax = 25;
    var mZoomTarget;

    var mFinalTopCenterPixel = 0;
    var mFinalLeftCenterPixel = 0;
    var mZoomSteps = 0;

    images.initializeImageViewer = function () {

        if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
            imageViewerSize = $("#display-image-outer-container").width();
        else
            imageViewerSize = $("#display-image-outer-container-mobile").width();

        halfImageViewerSize = imageViewerSize / 2;

        mZoomTargetMinPoint = imageViewerSize;
        mZoomTargetMidPoint = imageViewerSize;
        mZoomTargetMaxPoint = imageViewerSize;
        mZoomTarget = mZoomTargetMinPoint;
        shopHq.images.computeTargetZoomSizes();
        if (imageIsZoomable()) {
            shopHq.images.enableZoomButtons();
        }
        else {
            shopHq.images.disableZoomButtons();
            if (shopHq.product.viewModel.isOldButtonVisible() || !imageIsZoomable()) {
                $("#OldbtnReset").hide();
                $("#OldbtnZoomIn").hide();
                $("#OldbtnZoomOut").hide();
                $("#OldbtnZoomXS").hide();
            }
            $("#btnReset").hide();
            $("#btnZoomIn").hide();
            $("#btnZoomOut").hide();
            $("#btnZoomXS").hide();
        }
    }

    images.imageViewerMouseDown = function (data, event) {

        if (imageIsZoomable() == false) {
            shopHq.images.disableZoomButtons();
            return;
        }

        var startX = event.clientX, startY = event.clientY;
        var origX;
        if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
            origX = $("#display-image-inner-container").position().left, origY = $("#display-image-inner-container").position().top;
        else
            origX = $("#display-image-inner-container-mobile").position().left, origY = $("#display-image-inner-container-mobile").position().top;

        var deltaX = startX - origX, deltaY = startY - origY;

        var mouseMoved = false;

        attachMouseEvents();

        stopEventPropagation(event);

        cancelEvent(event);

        function moveHandler(e) {
            if (!e) e = window.event;   // IE 5+ 

            mouseMoved = true;

            var newLeftPixel = Math.max(minLeftPixel(), Math.min(0, e.clientX - deltaX));
            var newTopPixel = Math.max(minTopPixel(), Math.min(0, e.clientY - deltaY));
            if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
                $("#display-image-inner-container").css({ 'top': newTopPixel + 'px', 'left': newLeftPixel + 'px' });
            else
                $("#display-image-inner-container-mobile").css({ 'top': newTopPixel + 'px', 'left': newLeftPixel + 'px' });

            stopEventPropagation(e);
        }

        function upHandler(e) {
            if (mouseMoved == false) {
                var newCenterTop = 0;
                var newCenterLeft = 0;
                if (e.layerX) {
                    newCenterTop = e.layerY;
                    newCenterLeft = e.layerX;
                }
                else {
                    newCenterTop = e.offsetY;
                    newCenterLeft = e.offsetX;
                }

                zoomInAtPixel(newCenterTop, newCenterLeft);
            }
            else {
            }

            detatchMouseEvents();

            stopEventPropagation(e);
        }

        function minTopPixel() {
            if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
                return imageViewerSize - $("#display-image").height();
            else
                return imageViewerSize - $("#display-image-mobile").height();
        }

        function minLeftPixel() {
            if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
                return imageViewerSize - $("#display-image").width();
            else
                return imageViewerSize - $("#display-image-mobile").width();
        }

        function attachMouseEvents() {
            if (document.addEventListener) {   // DOM level 2
                document.addEventListener('mousemove', moveHandler, true);
                document.addEventListener('mouseup', upHandler, true);
            }
            else if (document.attachEvent) {   // IE 5+    
                if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible'))) {
                    $("#display-image-inner-container").setCapture();
                    $("#display-image-inner-container").attachEvent('onmousemove', moveHandler);
                    $("#display-image-inner-container").attachEvent('onmouseup', upHandler);
                }
                else {
                    $("#display-image-inner-container-mobile").setCapture();
                    $("#display-image-inner-container-mobile").attachEvent('onmousemove', moveHandler);
                    $("#display-image-inner-container-mobile").attachEvent('onmouseup', upHandler);
                }
            }
        }

        function detatchMouseEvents() {
            if (document.removeEventListener) {   // DOM level 2
                document.removeEventListener('mouseup', upHandler, true);
                document.removeEventListener('mousemove', moveHandler, true);
            }
            else if (document.detachEvent) {   // IE 5 +
                if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible'))) {
                    $("#display-image-inner-container").detachEvent('onmouseup', upHandler);
                    $("#display-image-inner-container").detachEvent('onmousemove', moveHandler);
                    $("#display-image-inner-container").releaseCapture();
                }
                else {
                    $("#display-image-inner-container-mobile").detachEvent('onmouseup', upHandler);
                    $("#display-image-inner-container-mobile").detachEvent('onmousemove', moveHandler);
                    $("#display-image-inner-container-mobile").releaseCapture();
                }
            }
        }

        function stopEventPropagation(e) {
            if (e.stopPropagation) {   // DOM level 2
                e.stopPropagation();
            }
            else {   // IE 5+
                e.cancelBubble = true;
            }
        }

        function cancelEvent(evt) {
            if (evt.preventDefault) {   // DOM level 2
                evt.preventDefault();
            }
            else {   // IE
                evt.returnValue = false;
            }
        }
    }

    images.zoomIn = function () {
        showZoomedImage();

        mZoomTarget = getZoomInTarget();
        mZoomLoopCounter = 0;
        setTimeout(zoomInTimerEvent, 10);
    }

    images.zoomOut = function () {
        mZoomTarget = getZoomOutTarget();
        mZoomLoopCounter = 0;
        setTimeout(zoomOutTimerEvent, 10);
    }

    images.zoomReset = function () {
        mZoomTarget = imageViewerSize;
        mZoomLoopCounter = 0;
        setTimeout(zoomOutTimerEvent, 10);
    }

    images.zoomInOutMobile = function () {
        if (shopHq.product.viewModel.isOldButtonVisible()) {
            var $button = $("#OldbtnZoomXS").find("span i.fa");
            if ($button.hasClass("fa-search-minus")) {
                this.zoomOut();
            }
            else {
                this.zoomIn();
            }
        }
        else {
            var $button = $("#btnZoomXS").find("span i.fa");
            if ($button.hasClass("fa-search-minus")) {
                this.zoomOut();
            }
            else {
                this.zoomIn();
            }
        }

    }
    images.computeTargetZoomSizes = function () {

        mZoomTargetMaxPoint = getMaxImageSize();


        var halfZoomInPixels = Math.ceil((mZoomTargetMaxPoint - mZoomTargetMinPoint) / 200) * 100;

        if (halfZoomInPixels <= 400)
            mZoomTargetMidPoint = getMaxImageSize();
        else {
            mZoomTargetMidPoint = mZoomTargetMaxPoint - halfZoomInPixels;
        }
    }

    function showZoomedImage() {

        var max = getMaxImageSize();

        shopHq.product.viewModel.setSelectedImage(shopHq.product.viewModel.selectedImage(), max, false);

    }

    function showNonZoomedImage() {
        shopHq.product.viewModel.setSelectedImage(shopHq.product.viewModel.selectedImage(), 472, false);
    }

    function getMaxImageSize() {
        return shopHq.product.viewModel.selectedMaxImageSize();
    }

    function imageIsZoomable() {
        if (mZoomTargetMaxPoint - mZoomTargetMinPoint >= 200)
            return true;
        else
            return false;
    }

    images.enableZoomButtons = function () {
        var currImageSize = getViewerImageSize();
        if (currImageSize >= getMaxImageSize())
            disableZoomInButton();

        else if (imageIsZoomable() == true) {
            enableZoomInButton();
            if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
                $("#display-image").css('cursor', 'pointer');
            else
                $("#display-image-mobile").css('cursor', 'pointer');
        }
        else
            disableZoomInButton();

        if (currImageSize <= imageViewerSize) {
            disableZoomOutButton();

        }
        else {
            enableZoomOutButton();
            if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
                $("#display-image").css('cursor', 'pointer');
            else
                $("#display-image-mobile").css('cursor', 'pointer');
        }

        if (currImageSize <= imageViewerSize)
            disableResetButton();
        else {
            enableResetButton();

            if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
                $("#display-image").css('cursor', 'pointer');
            else
                $("#display-image-mobile").css('cursor', 'pointer');
        }

        if (($("#btnZoomIn").disabled && $("#btnZoomOut").disabled && $("#btnReset").disabled) || !imageIsZoomable()) {
            $("#btnReset").hide();
            $("#btnZoomIn").hide();
            $("#btnZoomOut").hide();
            if (shopHq.product.viewModel.isOldButtonVisible()) {
                $("#OldbtnReset").hide();
                $("#OldbtnZoomIn").hide();
                $("#OldbtnZoomOut").hide();
            }
        }
        else {
            if (shopHq.product.viewModel.isOldButtonVisible()) {
                $("#OldbtnReset").show();
                $("#OldbtnZoomIn").show();
                $("#OldbtnZoomOut").show();
            }
        }
    }

    images.disableZoomButtons = function () {
        disableZoomInButton();
        disableZoomOutButton();
        disableResetButton();
    }

    function getViewerImageSize() {

        if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
            return $("#display-image").width();
        else
            return $("#display-image-mobile").width();
    }

    function getViewerTopPixel() {

        var pixel
        // if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
        //     pixel = $("#display-image-inner-container").position().top;
        // else
        pixel = $('.image').position().top;

        return -pixel;
    }

    function getViewerLeftPixel() {
        var pixel
        if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
            pixel = $("#display-image-inner-container").position().left;
        else
            pixel = $("#display-image-inner-container-mobile").position().left;

        return -pixel;
    }

    function setViewerPosition(topPixel, leftPixel) {
        if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
            $("#display-image-inner-container").css({ 'top': '-' + topPixel + 'px', 'left': '-' + leftPixel + 'px' });
        else
            $("#display-image-inner-container-mobile").css({ 'top': '-' + topPixel + 'px', 'left': '-' + leftPixel + 'px' });
    }

    function clipViewerNewLeft(newLeft, newImageSize) {
        var clippedLeft = Math.floor(newLeft);

        if (clippedLeft < 0) clippedLeft = 0;
        if (clippedLeft > newImageSize - imageViewerSize) clippedLeft = newImageSize - imageViewerSize;

        return clippedLeft;
    }

    function clipViewerNewTop(newTop, newImageSize) {
        var clippedTop = Math.floor(newTop);

        if (clippedTop < 0) clippedTop = 0;
        if (clippedTop > newImageSize - imageViewerSize) clippedTop = newImageSize - imageViewerSize;

        return clippedTop;
    }

    function clipZoomBasedOnImageSize(requestedZoom, imageSize) {
        var clippedZoom = requestedZoom;

        if (imageSize + requestedZoom > getMaxImageSize()) clippedZoom = getMaxImageSize() - imageSize;
        if (imageSize + requestedZoom < imageViewerSize) clippedZoom = imageViewerSize - imageSize;

        return clippedZoom;
    }

    function resizeImageDisplay(imageSize, topPixel, leftPixel) {
        if (($('#OldproductImageButtonGroup').is(':visible')) || ($('#productImageButtonGroup').is(':visible')))
            $("#display-image").css({ 'height': imageSize + 'px', 'width': imageSize + 'px' });
        else
            $("#display-image-mobile").css({ 'height': imageSize + 'px', 'width': imageSize + 'px' });

        var clippedTopPixel = Math.max(0, topPixel);
        var clippedLeftPixel = Math.max(0, leftPixel);
        setViewerPosition(clippedTopPixel, clippedLeftPixel);
    }

    function getZoomInTarget() {
        var target = 0;
        if (getViewerImageSize() >= mZoomTargetMidPoint)
            target = mZoomTargetMaxPoint;
        else
            target = mZoomTargetMidPoint;

        return target;
    }

    function getZoomOutTarget() {
        var target;
        if (getViewerImageSize() >= mZoomTargetMaxPoint)
            if (getViewerImageSize() == mZoomTargetMaxPoint && mZoomTargetMaxPoint == mZoomTargetMidPoint)
                target = mZoomTargetMinPoint;
            else
                target = mZoomTargetMidPoint;
        else
            target = mZoomTargetMinPoint;

        return target;
    }

    function zoomInTimerEvent() {
        if (mZoomLoopCounter++ > mZoomLoopCounterMax) return;
        if (getViewerImageSize() >= mZoomTarget) return;

        var viewerCurrentCenterTop = getViewerTopPixel() + halfImageViewerSize;
        var viewerCurrentCenterLeft = getViewerLeftPixel() + halfImageViewerSize;

        var currImageSize = getViewerImageSize();
        var actualZoom = clipZoomBasedOnImageSize(mZoomPixelIncrement, currImageSize);
        var newImageSize = currImageSize + actualZoom;

        if (actualZoom != 0) {
            var zoomInRatio = 1 + actualZoom / currImageSize;

            var newTopPixel = Math.floor(viewerCurrentCenterTop * zoomInRatio - halfImageViewerSize);
            var newLeftPixel = Math.floor(viewerCurrentCenterLeft * zoomInRatio - halfImageViewerSize);

            resizeImageDisplay(newImageSize, newTopPixel, newLeftPixel);
        }

        if (getViewerImageSize() >= mZoomTarget)
            shopHq.images.enableZoomButtons();
        else
            setTimeout(zoomInTimerEvent, mZoomDelayInMs);
    }

    function zoomOutTimerEvent() {
        if (mZoomLoopCounter++ > mZoomLoopCounterMax) return;
        if (getViewerImageSize() <= mZoomTarget) return;

        var viewerCurrentCenterTop = getViewerTopPixel() + halfImageViewerSize;
        var viewerCurrentCenterLeft = getViewerLeftPixel() + halfImageViewerSize;

        var currImageSize = getViewerImageSize();
        var actualZoom = clipZoomBasedOnImageSize(-mZoomPixelIncrement, currImageSize);
        var newImageSize = currImageSize + actualZoom;

        if (actualZoom != 0) {
            actualZoom = -actualZoom;
            var zoomInRatio = 1 + actualZoom / currImageSize;
            var zoomOutRatio = 1 / zoomInRatio;

            var clippedTopPixel = clipViewerNewTop(viewerCurrentCenterTop * zoomOutRatio - halfImageViewerSize, newImageSize);
            var clippedLeftPixel = clipViewerNewLeft(viewerCurrentCenterLeft * zoomOutRatio - halfImageViewerSize, newImageSize);

            resizeImageDisplay(newImageSize, clippedTopPixel, clippedLeftPixel);
        }

        if (getViewerImageSize() <= mZoomTarget) {
            if (getViewerImageSize() <= imageViewerSize)
                showNonZoomedImage();

            shopHq.images.enableZoomButtons();
        }
        else
            setTimeout(zoomOutTimerEvent, mZoomDelayInMs);
    }

    function zoomInAtPixel(desiredCenterTop, desiredCenterLeft) {
        if (imageIsZoomable() == false) return;

        showZoomedImage();

        var currImageSize = getViewerImageSize();
        var zoomIncrement = getZoomInTarget() - currImageSize;
        var actualZoom = clipZoomBasedOnImageSize(zoomIncrement, currImageSize);
        var newImageSize = currImageSize + actualZoom;
        var zoomInRatio = 1 + actualZoom / currImageSize;

        var finalTopPixel = desiredCenterTop * zoomInRatio - halfImageViewerSize;
        var finalLeftPixel = desiredCenterLeft * zoomInRatio - halfImageViewerSize;

        finalTopPixel = clipViewerNewLeft(finalTopPixel, newImageSize);
        finalLeftPixel = clipViewerNewLeft(finalLeftPixel, newImageSize);

        mFinalTopCenterPixel = finalTopPixel + halfImageViewerSize;
        mFinalLeftCenterPixel = finalLeftPixel + halfImageViewerSize;

        mZoomSteps = (getZoomInTarget() - currImageSize) / mZoomPixelIncrement;

        setTimeout(zoomInAtPixelTimerEvent, 10);
    }

    function zoomInAtPixelTimerEvent() {
        if (mZoomSteps <= 0) {
            shopHq.images.enableZoomButtons();
            return;
        }

        // calculate zoom ratio - current size to final size
        var currImageSize = getViewerImageSize();
        var zoomIncrement = getZoomInTarget() - currImageSize;
        var actualZoom = clipZoomBasedOnImageSize(zoomIncrement, currImageSize);
        var newImageSize = currImageSize + actualZoom;
        var zoomInRatio = 1 + actualZoom / currImageSize;
        var zoomOutRatio = 1 / zoomInRatio;

        // calculate current position at final zoom size       
        var zoomedTopCenterPixel = (getViewerTopPixel() + halfImageViewerSize) * zoomInRatio;
        var zoomedLeftCenterPixel = (getViewerLeftPixel() + halfImageViewerSize) * zoomInRatio;

        // determine number of pixels to move in this increment
        var deltaTopPixels = mFinalTopCenterPixel - zoomedTopCenterPixel;
        var deltaLeftPixels = mFinalLeftCenterPixel - zoomedLeftCenterPixel;
        deltaTopPixels = (deltaTopPixels / mZoomSteps) * zoomOutRatio;
        deltaLeftPixels = (deltaLeftPixels / mZoomSteps) * zoomOutRatio;

        // calculate new position at current zoom ratio
        var topCenterPixel = getViewerTopPixel() + halfImageViewerSize;
        var leftCenterPixel = getViewerLeftPixel() + halfImageViewerSize;

        // calculate incremental zoom ratio
        currImageSize = getViewerImageSize();
        actualZoom = clipZoomBasedOnImageSize(mZoomPixelIncrement, currImageSize);
        newImageSize = currImageSize + actualZoom;
        zoomInRatio = 1 + actualZoom / currImageSize;
        zoomOutRatio = 1 / zoomInRatio;

        // calculate new position at incremental zoom ratio
        var newZoomedTopPixel = (topCenterPixel * zoomInRatio) - halfImageViewerSize + deltaTopPixels;
        var newZoomedLeftPixel = (leftCenterPixel * zoomInRatio) - halfImageViewerSize + deltaLeftPixels;

        // move that that position & size
        resizeImageDisplay(newImageSize, newZoomedTopPixel, newZoomedLeftPixel);

        // setup for next zoom step
        mZoomSteps--;
        if (mZoomSteps > 0)
            setTimeout(zoomInAtPixelTimerEvent, mZoomDelayInMs);
        else
            shopHq.images.enableZoomButtons();
    }

    function disableZoomInButton() {
        if (shopHq.product.viewModel.isOldButtonVisible()) {
            $("#OldbtnZoomIn").css({ 'color': '#ADADAD', 'border-color': '#ADADAD' });

            $("#OldbtnZoomIn").attr({ disabled: true });
            var $button = $("#OldbtnZoomXS").find("span i.fa");
        }
        else {
            $("#btnZoomIn").attr({ disabled: true });
            var $button = $("#btnZoomXS").find("span i.fa");
        }
        //$button.removeClass("fa-search-plus").addClass("fa-search-minus");
    }

    function enableZoomInButton() {
        if (shopHq.product.viewModel.isOldButtonVisible() && $("#display-image").is(':visible')) {
            $("#OldbtnZoomIn").removeAttr('style');
            $("#OldbtnZoomIn").attr({ disabled: false });
        } else {
            $("#btnZoomIn").attr({ disabled: false });
        }
    }

    function disableZoomOutButton() {
        if (shopHq.product.viewModel.isOldButtonVisible()) {
            $("#OldbtnZoomOut").css({ 'color': '#ADADAD', 'border-color': '#ADADAD' });
            $("#OldbtnZoomOut").attr({ disabled: true });
            var $button = $("#OldbtnZoomXS").find("span i.fa");
        }
        else {
            $("#btnZoomOut").attr({ disabled: true });
            var $button = $("#btnZoomXS").find("span i.fa");
        }
        $button.removeClass("fa-search-minus").addClass("fa-search-plus");
    }

    function enableZoomOutButton() {
        if (shopHq.product.viewModel.isOldButtonVisible()) {
            $("#OldbtnZoomOut").attr("src", "/images/buttons/ZoomOut_Active.jpg");
            $("#OldbtnZoomOut").removeAttr('style');
            $("#OldbtnZoomOut").attr({ disabled: false });
        }
        $("#btnZoomOut").attr({ disabled: false });
    }

    function disableResetButton() {
        if (shopHq.product.viewModel.isOldButtonVisible()) {
            $("#OldbtnReset").css({ 'color': '#ADADAD', 'border-color': '#ADADAD' });
            $("#OldbtnReset").attr({ disabled: true });
        }
        $("#btnReset").attr({ disabled: true });
    }

    function enableResetButton() {
        if (shopHq.product.viewModel.isOldButtonVisible()) {
            $("#OldbtnReset").attr("src", "/images/buttons/Reset_Active.jpg");
            $("#OldbtnReset").removeAttr('style');
            $("#OldbtnReset").attr({ disabled: false });
        }
        $("#btnReset").attr({ disabled: false });
    }



    return images;

})(shopHq.images = shopHq.images || {}, jQuery);

;
(function (navigation, $)
{
    var activeMenu = null;

    navigation.initializeGlobalNavigation = function () {
        // Set Menu Position
        $("#globalNav>ul>li").each(function () {
            var baseName = $(this).attr("id").replace("_item", "");

            //fix for overflow of flyouts.  The 966 is to verify that the getwidth() is working correctly since it sometimes wont in safari	
            if ((document.getElementById(baseName + "_item").offsetLeft - document.getElementById("globalNav").offsetLeft) + $("#" + baseName + "_subNav").width() > $("#globalNav").width()) {
                document.getElementById(baseName + "_subNav").style.right = 0 + "px";
            }
        });;

    };

    navigation.searchForProduct = function (value) {
        if (value != null && $.trim(value) != '') {
            var re = /(\d)\s+(?=\d)/g;
            var a = $.trim(value.replace(re, '$1'));

            if (!isNaN(a)) {
                value = a;
            }
            //Remove % from search text as s_code file cannot handle 100%%25pure in url
            /*SO-144 : Search: Title of page should reflect content*/
            var searchText = value.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '');
           
            searchText = encodeURIComponent(searchText);
            searchText = searchText.split("%20").join("+");

            value = encodeURIComponent(value);
            value = value.split("%20").join("+");
  
            document.location.href = "/search/?q=" + value + "&icid=InternalSearch_Default_" + ($.trim(searchText));

        } else
            alert('Please enter a valid search term.');
    };

    navigation.footerPhoneClick = function (link) {
        if (!Modernizr.touch) {            
            return false;
        } else {
            window.location.href = link;
        }       
    };

    navigation.addKeyboardClick = function () {
        // Adds click events on enter/return and spacebar for any element with the added class
        $(".js-keyboard-click").keyup(function (event) {
            if (event.keyCode === 13 || event.keyCode === 32) {
                $(this).click();
            }
        });
    }

    return navigation;
})(shopHq.navigation = shopHq.navigation || {}, jQuery);

(function ($) {
    shopHq.navigation.addKeyboardClick();

    // jQuery Enter Key Extension function
    /* http://stackoverflow.com/questions/6524288/jquery-event-for-user-pressing-enter-in-a-textbox */
    $.fn.onEnter = function (func) {
        this.bind('keypress', function (e) {
            if (e.keyCode == 13) func.apply(this, [e]);
        });
        return this;
    };
})(jQuery);;
(function (pageUtils, $) {
    var messageDialog = null;
    var imageLoadCount = 0;
    var loadedImages = 0;

    /// This method handles page initialization tasks
    pageUtils.initialize = function () {
        $('#globalNav li:has(ul)').doubleTapToGo();  // Setup menu for iPad
        $('#searchTextResult li').doubleTapToGo();

        // Setup enter key events
        $('#txtSearchString').onEnter(function (event) {
            shopHq.navigation.searchForProduct(this.value);
            event.preventDefault();  // This is needed for IE otherwise the top search button event fires when pressing enter
        });
        $("#NewRegTextBox").keyup(function (event) {
           
            if (event.keyCode === 13) {
                $("#NewRegButton").click();
            }
        });
        $(document).on('scroll', function () {
            if ($(this).scrollTop() > 100) {
                $('.scroll-top-wrapper:hidden').stop(true, true).fadeIn();
                $('.btn-scroll-top-wrapper:hidden').stop(true, true).fadeIn();
            } else {
                $('.scroll-top-wrapper').stop(true, true).fadeOut();
                $('.btn-scroll-top-wrapper').stop(true, true).fadeOut();
            }
        });
        $('.scroll-top-wrapper').on('click', function () { shopHq.pageUtils.scrollToTop(500); });

        var overlay = document.getElementById("menu_overlay");
        if (overlay) {
            Hammer(overlay).on("swipeleft", function() { shopHq.pageUtils.toggleMobileNavMenu('swipe-close'); });
        }

        $('#mobile-global-nav').on('hidden.bs.offcanvas', function () { shopHq.pageUtils.toggleMobileNavMenu('hide'); });
        $('#mobile-global-nav').on('shown.bs.offcanvas', function () { shopHq.pageUtils.toggleMobileNavMenu('show'); });

    };

    pageUtils.loadDropdown = function (dropdown, values, selectText) {
        $(dropdown).empty(); // Clear dropdown

        $("<option/>", {
            val: "",
            text: selectText
        }).appendTo(dropdown);

        $(values).each(function () {
            $("<option/>", {
                val: this.split("|")[1],
                text: this.split("|")[0]
            }).appendTo(dropdown);
        });
    };

//MY ACCOUNT SECTION START

    pageUtils.ShowSubMenu = function () {
        $(".myaccountsubheader").show();
        $(".myaccountheader").hide();
        $(".menuheader").hide();
        $(".menuaccountheader").hide();
        $(".myaccountheader").css("transform", "translate(-100%, 0px)");
        $(".myaccountsubheader").css("transform", "translate(0px, 0px)");
        $(".myaccount-leftnav").hide();
    }

    //MANAGE SHOPHQ CARD START
    pageUtils.OpenManageCreditCard = function (focusLink) {
        if (focusLink.length > 0) {
            shopHq.account.HighlightSelectedLink(focusLink);
        }
        if (screen.width <= 767) {
            window
                .open('https://evinelive.mycreditcard.mobi/mservicegen4/login.do?subActionId=1000&clientId=shophq&accountType=generic&langId=en', '_blank', 'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
        } else {
            window.open('http://www.evinelivecreditcard.com',
                '_blank',
                'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
        }


        return false;
    }
    //MANAGE SHOPHQ CARD END

    //APPLY SHOPHQ CARD START
    pageUtils.OpenApplyCreditCard = function (applyShopHQCreditCardLink, applyShopHQCreditCardLinkMobile, focusLink) {
        if (focusLink.length > 0) {
            shopHq.account.HighlightSelectedLink(focusLink);
        }
        if (screen.width <= 767) {
            window.open(applyShopHQCreditCardLinkMobile,
                '_blank',
                'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
        } else {
            window.open(applyShopHQCreditCardLink,
                '_blank',
                'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
        }

        return false;
    }
    //APPLY SHOPHQ CARD END

    //SUBSCRIBE/UNSUBSCRIBE START
    pageUtils.OpenEmailSubscription = function (emailSubscriptionLink) {
        window.open(emailSubscriptionLink,
            '_blank',
            'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
        return false;
    }
    //SUBSCRIBE/UNSUBSCRIBE END

//MY ACCOUNT SECTION END

    var popWin = null;
    var winCount = 0;
    pageUtils.openPopWin = function(winURL, winWidth, winHeight, winFeatures, winLeft, winTop) {
        var d_winLeft = 20;  // default, pixels from screen left to window left
        var d_winTop = 20;   // default, pixels from screen top to window top
        winName = "popWin" + winCount++; //unique name for each pop-up window
        pageUtils.closePopWin();           // close any previously opened pop-up window
        if ((pageUtils.openPopWin.arguments.length >= 4) && (pageUtils.openPopWin.arguments[3].length > 0))  // any additional features?
            winFeatures = "," + winFeatures;
        else
            winFeatures = "";
        if (pageUtils.openPopWin.arguments.length == 6)  // location specified
            winFeatures += pageUtils.getLocation(winWidth, winHeight, winLeft, winTop);
        else
            winFeatures += pageUtils.getLocation(winWidth, winHeight, d_winLeft, d_winTop);
        if (winLeft > 0 && winTop > 0)
            winFeatures += ",left=" + winLeft + ",top=" + winTop;
        else
            winFeatures += ",left=0,top=0";
        popWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + winFeatures);
        if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) < 4.5)
            popWin.onunload = destroyWin;
    }

    pageUtils.closePopWin = function() {// close pop-up window if it is open 
        if (popWin != null) {
            if (!popWin.closed) {
                newWin = 1;
                popWin.close();
            }
        }
    }

    pageUtils.getLocation = function(winWidth, winHeight, winLeft, winTop) {
        return "";
    }

    pageUtils.getLocation = function (winWidth, winHeight, winLeft, winTop) {
        var winLocation = "";
        if (winLeft < 0)
            winLeft = screen.width - winWidth + winLeft;
        if (winTop < 0)
            winTop = screen.height - winHeight + winTop;
        if (winTop == "cen")
            winTop = (screen.height - winHeight) / 2 - 20;
        if (winLeft == "cen")
            winLeft = (screen.width - winWidth) / 2;
        if (winLeft > 0 & winTop > 0)
            winLocation = ",screenX=" + winLeft + ",left=" + winLeft + ",screenY=" + winTop + ",top=" + winTop;
        else
            winLocation = "";
        return winLocation;
    }

    pageUtils.toggleSection = function (expander, container) {
        var $span = $(expander).children("i:first");

        if ($span.hasClass("fa-chevron-down"))
            $span.addClass("fa-chevron-up").removeClass("fa-chevron-down");
        else
            $span.addClass("fa-chevron-down").removeClass("fa-chevron-up");

        $(container).toggle();
    };

    pageUtils.toggleNavigation = function (expander, container) {

        var $span = $(expander).children("i:first");

        if ($span.hasClass("fa-plus"))
            $span.addClass("fa-minus").removeClass("fa-plus");
        else
            $span.addClass("fa-plus").removeClass("fa-minus");

        $(container).toggle();
    };

    pageUtils.toggleMobileNavMenu = function (action) {
        if (action === 'swipe-close') {
            $("#menu_overlay").removeClass("menu_overlay_opened");
            $("#mobile-global-nav").offcanvas('toggle');
        } else if (action === 'hide') {
            $("#menu_overlay").removeClass("menu_overlay_opened");
        } else if (action == "show") {
            $("#menu_overlay").addClass("menu_overlay_opened");
        }
    }

    pageUtils.scrollToTop = function (scrollToTopTime) {
        //iPad performance can be slow for scroll to top if other JS functions are called at the same time.
        //For this reason the default behavior for this function on iPad is a immediate scroll to top.
        //This can be overriden by providing a scrollToTopTime.
        if (!scrollToTopTime) {
            if (shopHq.pageUtils.isIPad()) {
                scrollToTopTime = 0;
            }
            else {
                scrollToTopTime = 3000;
            }
        }

        $("html, body").animate({ scrollTop: 0 }, scrollToTopTime);
    };
    pageUtils.scrollToBottom = function () {
        //iPad performance can be slow for scroll to top if other JS functions are called at the same time.
        //For this reason the default behavior for this function on iPad is a immediate scroll to top.
        //This can be overriden by providing a scrollToTopTime.
        var scrollToTopTime;
            if (shopHq.pageUtils.isIPad()) {
                scrollToTopTime = 0;
            }
            else {
               scrollToTopTime = 1000;
           }
        //$('html,body').animate({
        //    scrollTop: $("#videoPlayer_NowPlayingDiv").offset().top
        //}, scrollToTopTime);
        //$(document).scrollTo('#videoPlayer_NowPlayingDiv');
        $("html, body").animate({ scrollTop: $("#videoPlayer_NowPlayingDiv").offset().top - 600 }, scrollToTopTime);
    };

    // This function is used to get the response header from the ajax response
    pageUtils.checkResponseHeader = function (jqXhr) {
        var sRedirectUrl = "";
        if (jqXhr.getResponseHeader("AjaxView") === null || jqXhr.getResponseHeader("AjaxView").toLowerCase() === 'false') {
            if (jqXhr.getResponseHeader("RedirectURL") == null) {
                sRedirectUrl = window.location.href;
            } else {
                sRedirectUrl = jqXhr.getResponseHeader("RedirectURL");
            }
        }
        return sRedirectUrl;
    };


    pageUtils.parseMoneyToString = function (n) {
        var n = n.toFixed(2); // Fix for UNSCHEDULED-581
        var t = parseInt(n / 1000);
        var h = parseInt(n - t * 1000);
        var d = Math.round((n - (t * 1000) - h) * 100);

        if (d < 1)
            d = '00';
        else if (d < 10)
            d = '0' + d;

        if (t > 0) {
            t = t + ',';
            if (h < 10)
                h = '00' + h;
            else if (h < 100)
                h = '0' + h;
        } else
            t = '';

        return t + h + '.' + d;
    };

    pageUtils.flashBackground = function (elementToFlash, flashRgb) {
        var currentBackground = $(elementToFlash).css("background-color");

        $(elementToFlash)
            .animate({ backgroundColor: 'rgb(' + flashRgb + ')' }, 500)
            .animate({ backgroundColor: 'rgb(' + currentBackground + ')' }, 500);
    };

    pageUtils.getQueryStringParameterByName = function (name) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");

        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
            results = regex.exec(location.search);

        return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    };

    pageUtils.closeMessageDialog = function () {
        messageDialog.dialog("close");
    };

    pageUtils.isIPad = function () {
        return navigator.userAgent.match(/iPad/i) !== null;
    };

    pageUtils.isIPhone = function () {
        return navigator.userAgent.match(/iPhone|iPod/i) !== null;
    };

    pageUtils.isAndroid = function () {
        return navigator.userAgent.match(/Android/i) !== null;
    };

    pageUtils.isIE11 = function () {
        //https://stackoverflow.com/questions/21825157/internet-explorer-11-detection
        return !!window.MSInputMethodContext && !!document.documentMode;
    };

    pageUtils.isFirefox = function () {
        return navigator.userAgent.match(/Firefox/i) !== null;
    };
    

    pageUtils.isKiosk = function () {
        var vars = [], hash;
        var q = document.URL.split('?')[1];
        if (q != undefined) {
            q = q.split('&');
            for (var i = 0; i < q.length; i++) {
                hash = q[i].split('=');
                vars.push(hash[1]);
                vars[hash[0]] = hash[1];
            }
        }
        var kioskLocation = (vars['device'] != undefined && vars['device'] != '') ? vars['device'] : '';

        var date = new Date();
        var minutes = 30;
        date.setTime(date.getTime() + (minutes * 60 * 1000));
        $.cookie('Kiosk', kioskLocation, { expires: date, path: '/' });

        return kioskLocation != '';
    };

    //On iPad images non-cached images may not load via a ajax call,
    //this method is a workaround that resets the images source and forces the ipad to load the image.
    pageUtils.initalizeImageRefresh = function (context, selector) {
        if (!shopHq.pageUtils.isIPad()) return;

        try {
            console.log("initalize Refresh");
            imageLoadCount = $("img", context).length;
            loadedImages = 0;
            $("img", context).one('load', { "selector": selector }, checkImageLoad);
        }
        catch (e) {
            if (console) {
                console.error(e.message);
            }
        }

    };

    function checkImageLoad(element) {
        console.log("Check Load");
        console.log("IMAGE LOAD COUNT " + loadedImages + " Total Images: " + imageLoadCount);
        loadedImages++;
        if (imageLoadCount === loadedImages) {
            shopHq.pageUtils.refreshImages(element.data.selector);
        }
    };

    //Iterates through each image found in the selector, then resets the source (to the existing value)
    //Used as a work around for image refresh during ajax loads on the the iPad
    pageUtils.refreshImages = function (selector) {
        console.log("Image Refresh");
        $(selector + " img").each(function (index, element) {
            $(element).attr("src", element.src);
        });
    };


    pageUtils.centralizeModal = function () {
        $(this).css('display', 'block');
        var $dialog = $(this).find(".modal-dialog");
        var dialogheight = ($dialog.height() < 400) ? 400 : $dialog.height();
        var offset = ($(window).height() - dialogheight) / 2;
        var bottomMargin = parseInt($dialog.css('marginBottom'), 10);

        // Make sure you don't hide the top part of the modal w/ a negative margin if it's longer than the screen height, and keep the margin equal to the bottom margin of the modal
        if (offset < bottomMargin) offset = bottomMargin;

        $dialog.css("margin-top", offset);
    };


    pageUtils.updateBackButton = function () {
        if (window.location.pathname === "/") {
            $("#mobile-navbar-back").hide();
        }
        else if (window.history && window.history.length > 1) {
            $("#mobile-navbar-back").show();
        }
        else {
            $("#mobile-navbar-back").hide();
        }
    }

    pageUtils.goBack = function () {
        if (window.history && window.history.length > 1) {
            window.history.go(-1);
            pageUtils.updateBackButton();
        }
    }

    //https://stackoverflow.com/questions/950087/how-do-i-include-a-javascript-file-in-another-javascript-file
    pageUtils.loadJS = function(url, callback)
    {
        // Adding the script tag to the head as suggested before
        var head = document.getElementsByTagName('head')[0];
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = url;

        // Fire the loading
        head.appendChild(script);

        // Then bind the event to the callback function.
        // There are several events for cross browser compatibility.
        script.onreadystatechange = callback;
        script.onload = callback;

        
    };

    pageUtils.loadCSS = function (url) {
        // Adding the script tag to the head as suggested before
        var head = document.getElementsByTagName('head')[0];

        var css = document.createElement("link");
        css.rel = "stylesheet";
        css.type = "text/css";
        css.href = url;
        
        // Fire the loading
        head.appendChild(css);
    };


    /*WishList products section starts here*/

    pageUtils.displayFromYourWishlist = function (title) {

        $.ajax("/Wishlist/GetFromYourWishlist", {
            type: 'GET',
            contentType: 'application/json'
        }).done(function (data) {

            var showCarousel = false;
            if (($("#from-your-wishlist-mobile-view").is(':visible') && data.length > 2) || data.length > 4) {
                showCarousel = true;
            }

            var row_FromYourWishlist = '<hr id="mwp_Seperator" noshade="noshade" size="1"><div id="FromYourWishlist" class="row" style="text-align:center;padding-bottom: 30px;"><div class="col-xs-12"><h2 id="mvp_Header" style="display: inline-block;font-weight:700;font-size: 30px;">'+title+'</h2></div>';
            row_FromYourWishlist += '<div>';
            
            if (showCarousel) {
                row_FromYourWishlist += '<div id="WishList-Products-prev" class="col-md-1 col-sm-1 col-xs-1 image-carousel-controls visible-xs" style="text-align: left;padding-right: 0px;padding-top: 90px;"><i class="fa fa-angle-left fa-4x"></i></div>';
                row_FromYourWishlist += '<div class="col-md-10 col-sm-10 col-xs-10" style="margin-top: 30px;">';
                row_FromYourWishlist += '<div id="WishList-Products" class="owl-carousel owl-theme">';
            }
            else {
                row_FromYourWishlist += '<div class="col-md-12 col-sm-12 col-xs-12" style="margin-top: 30px;">';
                row_FromYourWishlist += '<div id="WishList-Products">';
            }


            var productCounter = 0;



            $.each(data, function (index, product) {

                var productLink = "/Product/" + slugify(product.Topline) + "/"+ product.OfferCode+"?ColorCode="+product.ColorCode;
           
                //Put product Topline inside html tage to convert trademarks into their respective symbols to avoid character limit inconsistency.
                //Eg: "Gems of Distinction&trade; Ultimate" will convert into "Gems of Distinction™ Ultimate"
                //Start
                var row_Topline = '<div id="offerTopline" style="display:none">' + product.TopLine + '</div>';
                $("#from-your-wishlist-mobile-view").after(row_Topline);

                var OfferTopline = $("#offerTopline").text();
                $("#offerTopline").remove();
                //End

                if (typeof OfferTopline != "undefined") {
                    productCounter++;

                    if (showCarousel)
                        row_FromYourWishlist += ('<div class="col-xs-12 col-md-12 FromYourWishlist-container prodTrack" data-productlist="FromYourWishlist" data-productposition="' + productCounter + '" data-offercode="' + product.OfferCode + '" data-topline="' + product.TopLine.replace(/"/g, "'").replace(/"/g, '\'') + '">');
                    else
                        row_FromYourWishlist += ('<div class="col-xs-6 col-md-3 FromYourWishlist-container prodTrack" data-productlist="FromYourWishlist" data-productposition="' + productCounter + '" data-offercode="' + product.OfferCode + '" data-topline="' + product.TopLine.replace(/"/g, "'").replace(/"/g, '\'') + '">');

                    row_FromYourWishlist += ('<a class="blue-hover" href="' + productLink + '"><img alt="' + product.OfferCode + '" class="img-responsive" style="margin: 0 auto;width:auto;max-width:100%" src="'+product.ImagePath+'"></a>');
                    row_FromYourWishlist += ('<div style="height:25px"></div>');
                    row_FromYourWishlist += ('<div class="caption"><a class="blue-hover crossProduct" href="' + productLink + '" style="word-wrap: break-word;">' + OfferTopline.replace(/"/g, "'").replace(/"/g, '\'') + '</a></div>');
                    //row_FromYourWishlist += ('<div class="sale-price-section"><span class="sale-price-label">' + product.SalePrice.Label + ' : </span> <span class="sale-price">' + product.SalePrice.DisplayPrice + '</span></div>');
                    row_FromYourWishlist += ('</div>');

                }

            });

            row_FromYourWishlist += '</div>';
            row_FromYourWishlist += '</div>';
            if (showCarousel) {
                row_FromYourWishlist += '<div id="WishList-Products-next" class="col-md-1 col-sm-1 col-xs-1 image-carousel-controls visible-xs" style="text-align: right;padding-left: 0px;padding-top: 90px;"><i class="fa fa-angle-right fa-4x"></i></div>';
            }
            row_FromYourWishlist += '</div>';

            if (productCounter > 0) {
                $("#from-your-wishlist-mobile-view").after(row_FromYourWishlist);

                if (showCarousel) {

                    if (productCounter > 4) {//remove visible-cs css and show
                        $("#WishList-Products-prev").removeClass('visible-xs');
                        $("#WishList-Products-next").removeClass('visible-xs');

                        $("#WishList-Products-prev").show();
                        $("#WishList-Products-next").show();

                    }
                    else//add visible-cs css and show
                    {

                        $("#WishList-Products-prev").addClass('visible-xs');
                        $("#WishList-Products-next").addClass('visible-xs');

                        $("#WishList-Products-prev").show();
                        $("#WishList-Products-next").show();

                    }

                    FromYourWishlistSection();
                }
            }



        }).fail(function (error) {
            if (console)
                console.log(error);
        });
    }



    //-----------------WishList Products Carousel setup starts here-----------------//

    function FromYourWishlistSection() {
        var FromYourWishlistCarousel = $("#WishList-Products").owlCarousel({
            items: 4,
            margin: 40,
            responsive: {
                0: {
                    items: 2,
                    margin: 0
                },
                600: {
                    items: 3,
                },
                1000: {
                    items: 4
                }
            },
            loop: false,
            dots: false
        });


        $('#WishList-Products-next').click(function () {
            if (FromYourWishlistCarousel !== null) {
                FromYourWishlistCarousel.trigger('next.owl.carousel');
            }
        });

        $('#WishList-Products-prev').click(function () {
            if (FromYourWishlistCarousel !== null) {
                FromYourWishlistCarousel.trigger('prev.owl.carousel');
            }
        });

        $("#WishList-Products-prev").addClass('carousel-disable');

        $("#WishList-Products").on('initialized.owl.carousel changed.owl.carousel refreshed.owl.carousel', function (event) {

            if (!event.namespace) return;
            var carousel = event.relatedTarget,
                element = event.target,
                current = carousel.current();
            if (current == carousel.maximum()) {
                $("#WishList-Products-prev").addClass('carousel-enable');
                $("#WishList-Products-prev").removeClass('carousel-disable');
                $("#WishList-Products-next").addClass('carousel-disable');
                $("#WishList-Products-next").removeClass('carousel-enable');
            }
            else if (current == carousel.minimum()) {
                $("#WishList-Products-next").addClass('carousel-enable');
                $("#WishList-Products-next").removeClass('carousel-disable');
                $("#WishList-Products-prev").addClass('carousel-disable');
                $("#WishList-Products-prev").removeClass('carousel-enable');
            }
            else {
                $("#WishList-Products-prev").addClass('carousel-enable');
                $("#WishList-Products-prev").removeClass('carousel-disable');
                $("#WishList-Products-next").addClass('carousel-enable');
                $("#WishList-Products-next").removeClass('carousel-disable');
            }
        });



    }

    //-----------------WishList Products Carousel setup ends here-----------------//

    /*WishList Products products section ends here*/



    /*Most Wished products section starts here*/

    pageUtils.displayMostWishedProducts = function (title, days) {
        if (days == undefined) {
            days = 14;
        }
        var url = "/Wishlist/GetMostWishedProducts?days=" + days;
        $.ajax(url, {
            type: 'GET',
            contentType: 'application/json'
        }).done(function (data) {

            var showCarousel = false;
            if (($("#wishlist-mobile-view").is(':visible') && data.length > 2) || data.length > 4) {
                showCarousel = true;
            }
            if (title == undefined) {
                title = "Most Wished Items";
            }
            

            var row_MostWishedProducts = '<hr id="mwp_Seperator" noshade="noshade" size="1"><div id="mostWishedProducts" class="row" style="text-align:center;padding-bottom: 30px;"><div class="col-xs-12"><h2 style="display: inline-block;font-weight:700;font-size: 30px;">'+title+'</h2></div>';
            row_MostWishedProducts += '<div>';
            if (showCarousel) {
                row_MostWishedProducts += '<div id="most-wished-products-carousel-prev" class="col-md-1 col-sm-1 col-xs-1 image-carousel-controls visible-xs" style="text-align: left;padding-right: 0px;padding-top: 90px;"><i class="fa fa-angle-left fa-4x"></i></div>';
                row_MostWishedProducts += '<div class="col-md-10 col-sm-10 col-xs-10" style="margin-top: 30px;">';
                row_MostWishedProducts += '<div id="most-wished-products-carousel" class="owl-carousel owl-theme">';
            }
            else {
                row_MostWishedProducts += '<div class="col-md-12 col-sm-12 col-xs-12" style="margin-top: 30px;">';
                row_MostWishedProducts += '<div id="most-wished-products-carousel">';
            }


            var productCounter = 0;



            $.each(data, function (index, product) {

                var productLink = "/Product/" + slugify(product.Topline) + "/"+ product.OfferCode;

                //Put product Topline inside html tage to convert trademarks into their respective symbols to avoid character limit inconsistency.
                //Eg: "Gems of Distinction&trade; Ultimate" will convert into "Gems of Distinction™ Ultimate"
                //Start
                var row_Topline = '<div id="offerTopline" style="display:none">' + product.TopLine + '</div>';
                $("#wishlist-mobile-view").after(row_Topline);

                var OfferTopline = $("#offerTopline").text();
                $("#offerTopline").remove();
                //End

                if (typeof OfferTopline != "undefined") {
                    productCounter++;

                    if (showCarousel)
                        row_MostWishedProducts += ('<div class="col-xs-12 col-md-12 MostWishedProducts-container prodTrack" data-productlist="MostWishedProducts" data-productposition="' + productCounter + '" data-offercode="' + product.OfferCode + '" data-topline="' + product.TopLine.replace(/"/g, "'").replace(/"/g, '\'') + '">');
                    else
                        row_MostWishedProducts += ('<div class="col-xs-6 col-md-3 MostWishedProducts-container prodTrack" data-productlist="MostWishedProducts" data-productposition="' + productCounter + '" data-offercode="' + product.OfferCode + '" data-topline="' + product.TopLine.replace(/"/g, "'").replace(/"/g, '\'') + '">');

                    row_MostWishedProducts += ('<a class="blue-hover" href="' + productLink + '"><img alt="' + product.OfferCode + '" class="img-responsive" style="margin: 0 auto;width:auto;max-width:100%" src="https://s7d1.scene7.com/is/image/ShopHQ/' + product.OfferCode + '?DefaultImage=1&$150x150_jpg$"></a>');
                    row_MostWishedProducts += ('<div style="height:25px"></div>');
                    row_MostWishedProducts += ('<div class="caption"><a class="blue-hover crossProduct" href="' + productLink + '" style="word-wrap: break-word;">' + OfferTopline.replace(/"/g, "'").replace(/"/g, '\'') + '</a></div>');
                    //row_MostWishedProducts += ('<div class="sale-price-section"><span class="sale-price-label">' + product.SalePrice.Label + ' : </span> <span class="sale-price">' + product.SalePrice.DisplayPrice + '</span></div>');
                    row_MostWishedProducts += ('</div>');

                }

            });

            row_MostWishedProducts += '</div>';
            row_MostWishedProducts += '</div>';
            if (showCarousel) {
                row_MostWishedProducts += '<div id="most-wished-products-carousel-next" class="col-md-1 col-sm-1 col-xs-1 image-carousel-controls visible-xs" style="text-align: right;padding-left: 0px;padding-top: 90px;"><i class="fa fa-angle-right fa-4x"></i></div>';
            }
            row_MostWishedProducts += '</div>';

            if (productCounter > 0) {
                $("#wishlist-mobile-view").after(row_MostWishedProducts);

                if (showCarousel) {

                    if (productCounter > 4) {//remove visible-cs css and show
                        $("#most-wished-products-carousel-prev").removeClass('visible-xs');
                        $("#most-wished-products-carousel-next").removeClass('visible-xs');

                        $("#most-wished-products-carousel-prev").show();
                        $("#most-wished-products-carousel-next").show();

                    }
                    else//add visible-cs css and show
                    {

                        $("#most-wished-products-carousel-prev").addClass('visible-xs');
                        $("#most-wished-products-carousel-next").addClass('visible-xs');

                        $("#most-wished-products-carousel-prev").show();
                        $("#most-wished-products-carousel-next").show();

                    }

                    MostWishedProductsSection();
                }
            }



        }).fail(function (error) {
            if (console)
                console.log(error);
        });
    }



    //-----------------Most Wished products Carousel setup starts here-----------------//

    function MostWishedProductsSection() {
        var mostWishedProductsCarousel = $("#most-wished-products-carousel").owlCarousel({
            items: 4,
            margin: 40,
            responsive: {
                0: {
                    items: 2,
                    margin: 0
                },
                600: {
                    items: 3,
                },
                1000: {
                    items: 4
                }
            },
            loop: false,
            dots: false
        });


        $('#most-wished-products-carousel-next').click(function () {
            if (mostWishedProductsCarousel !== null) {
                mostWishedProductsCarousel.trigger('next.owl.carousel');
            }
        });

        $('#most-wished-products-carousel-prev').click(function () {
            if (mostWishedProductsCarousel !== null) {
                mostWishedProductsCarousel.trigger('prev.owl.carousel');
            }
        });

        $("#most-wished-products-carousel-prev").addClass('carousel-disable');

        $("#most-wished-products-carousel").on('initialized.owl.carousel changed.owl.carousel refreshed.owl.carousel', function (event) {

            if (!event.namespace) return;
            var carousel = event.relatedTarget,
                element = event.target,
                current = carousel.current();
            if (current == carousel.maximum()) {
                $("#most-wished-products-carousel-prev").addClass('carousel-enable');
                $("#most-wished-products-carousel-prev").removeClass('carousel-disable');
                $("#most-wished-products-carousel-next").addClass('carousel-disable');
                $("#most-wished-products-carousel-next").removeClass('carousel-enable');
            }
            else if (current == carousel.minimum()) {
                $("#most-wished-products-carousel-next").addClass('carousel-enable');
                $("#most-wished-products-carousel-next").removeClass('carousel-disable');
                $("#most-wished-products-carousel-prev").addClass('carousel-disable');
                $("#most-wished-products-carousel-prev").removeClass('carousel-enable');
            }
            else {
                $("#most-wished-products-carousel-prev").addClass('carousel-enable');
                $("#most-wished-products-carousel-prev").removeClass('carousel-disable');
                $("#most-wished-products-carousel-next").addClass('carousel-enable');
                $("#most-wished-products-carousel-next").removeClass('carousel-disable');
            }
        });



    }

    //-----------------Most Wished products Carousel setup ends here-----------------//

    /*Most Wished products section ends here*/


    /*Recently Viewed section starts here*/

    var RECENTLY_VIEWED_COOKIE = 'RViewSHOP1';

    pageUtils.addRecentlyViewedProduct = function (offerCode) {
        // This function has a dependency on jquery.cookie
        var cookie = $.cookie(RECENTLY_VIEWED_COOKIE);

        var strCookie = offerCode + '#';
        if (cookie && cookie.length > 0) {
            //Recently viewed items are stored in the cookie as a pipe-seperated list. 
            //We want to save only 10 recently viewed items in cookie.
            var products = cookie.split("|").slice(0, 10);
            var offerCodes = $.map(products, function (product) {
                return product.split("#")[0];
            });
            $.each(offerCodes, function (index, value) {
                if (value !== offerCode) {
                    strCookie += '|' + value + '#';
                }
            });

        }
        strCookie = strCookie;
        //Set Cookies with 30 days expiry
        $.cookie(RECENTLY_VIEWED_COOKIE, strCookie, { expires: 30, path: '/' });
    };

    pageUtils.displayRecentlyViewedProducts = function () {
    // TODO: somehow this is running on teh cart page and I cannot figure out how so commenting the guts of the js to hide it
    //    var cookie = $.cookie(RECENTLY_VIEWED_COOKIE);
    //    var trackingId = -10451;

    //    if (cookie && cookie.length > 0) {
    //        //Recently viewed items are stored in the cookie as a pipe-seperated list. 
    //        //We want to show only 10 recently viewed items.
    //        var products = cookie.split("|").slice(0, 10);


    //        var offerCodes = $.map(products, function (product) {
    //            return product.split("#")[0];
    //        });

    //        $.ajax("/api/Product/Description", {
    //            type: 'POST',
    //            data: JSON.stringify(offerCodes),
    //            contentType: 'application/json'
    //        }).done(function (data) {
    //            var trackingCode = trackingId + "&cm_re=Z7-_-RV" + (products.length + 1) + "-_-";

    //            var showCarousel = true;

    //            var row_RecentlyViewedProducts = '<hr/><div id="recentlyViewedProducts" class="imbz-carousel"><h2 id="rvp_Header">Your Recently Viewed Items <a class="" onclick="shopHq.pageUtils.clearRecentlyViewedProducts();">Clear All</a></h2>';
    //            row_RecentlyViewedProducts += '<div class="owl-carousel owl-theme carousel-recent-views">';

    //            var productCounter = 0;

    //            $.each(data, function (index, product) {
                   
    //                var productLink = getProductLink(product.OfferCode, product.Description, trackingCode);

    //                //Put product Description inside html tage to convert trademarks into their respective symbols to avoid character limit inconsistency.
    //                //Eg: "Gems of Distinction&trade; Ultimate" will convert into "Gems of Distinction™ Ultimate"
    //                //Start
    //                var row_Topline = '<div id="offerTopline" style="display:none">' + product.Description + '</div>';
    //                $("#rvp-mobile-view").after(row_Topline);

    //                var OfferTopline = $("#offerTopline").text();
    //                $("#offerTopline").remove();
    //                //End

    //                if (typeof OfferTopline != "undefined") {
    //                    productCounter++;

    //                    row_RecentlyViewedProducts += ('<div class="item" data-productlist="RecentlyViewedProducts" data-productposition="' + productCounter + '" data-offercode="' + product.OfferCode + '" data-topline="' + product.Description.replace(/"/g, "'").replace(/"/g, '\'') + '">');
    //                    row_RecentlyViewedProducts += ('<a href="' + productLink + '"><img alt="' + product.OfferCode + '" src="https://s7d1.scene7.com/is/image/ShopHQ/' + product.OfferCode + '?DefaultImage=1&$150x150_jpg$">');
    //                    row_RecentlyViewedProducts += ('<h3>' + OfferTopline.replace(/"/g, "'").replace(/"/g, '\'') + '</h3</a>');
    //                    row_RecentlyViewedProducts += ('</div>');

    //                }

    //            });

    //            row_RecentlyViewedProducts += '</div>';
    //            row_RecentlyViewedProducts += '</div>';

    //            if (productCounter > 0) {
    //                $("#rvp-mobile-view").after(row_RecentlyViewedProducts);

    //                RecentlyViewedProductsSection();
    //            }



    //        }).fail(function (error) {
    //            if (console)
    //                console.log(error);
    //        });
    //    }
    }

    pageUtils.clearRecentlyViewedProducts = function () {
        $.removeCookie(RECENTLY_VIEWED_COOKIE, { path: '/' });
        $("#recentlyViewedProducts").hide();
        $("#rvp_Seperator").hide();
    };


    function getProductLink(offerCode,Topline, trackingCode) {
        var oasid,
            productLink = "/Product/" + slugify(Topline) + "/" + offerCode;

        oasid = shopHq.pageUtils.getQueryStringParameterByName("oasid");
        if (oasid != "")
            productLink += "&oasid=" + oasid;

        trackingLink = "?track=" + trackingCode;

        familyId = shopHq.pageUtils.getQueryStringParameterByName("familyid") || "N";

        return productLink + trackingLink + familyId;
    }

    //-----------------Recently Viewed Products Carousel setup starts here-----------------//

    function RecentlyViewedProductsSection() {
        var recentlyViewedProductsCarousel = $("#recently-viewed-products-carousel").owlCarousel({
            items: 4,
            margin: 40,
            responsive: {
                0: {
                    items: 2,
                    margin: 0
                },
                600: {
                    items: 3,
                },
                1000: {
                    items: 4
                }
            },
            loop: false,
            dots: false
        });


        $('#recently-viewed-products-carousel-next').click(function () {
            if (recentlyViewedProductsCarousel !== null) {
                recentlyViewedProductsCarousel.trigger('next.owl.carousel');
            }
        });

        $('#recently-viewed-products-carousel-prev').click(function () {
            if (recentlyViewedProductsCarousel !== null) {
                recentlyViewedProductsCarousel.trigger('prev.owl.carousel');
            }
        });


        $("#recently-viewed-products-carousel-prev").addClass('carousel-disable');

        $("#recently-viewed-products-carousel").on('initialized.owl.carousel changed.owl.carousel refreshed.owl.carousel', function (event) {

            if (!event.namespace) return;
            var carousel = event.relatedTarget,
                element = event.target,
                current = carousel.current();
            if (current == carousel.maximum()) {
                $("#recently-viewed-products-carousel-prev").addClass('carousel-enable');
                $("#recently-viewed-products-carousel-prev").removeClass('carousel-disable');
                $("#recently-viewed-products-carousel-next").addClass('carousel-disable');
                $("#recently-viewed-products-carousel-next").removeClass('carousel-enable');
            }
            else if (current == carousel.minimum()) {
                $("#recently-viewed-products-carousel-next").addClass('carousel-enable');
                $("#recently-viewed-products-carousel-next").removeClass('carousel-disable');
                $("#recently-viewed-products-carousel-prev").addClass('carousel-disable');
                $("#recently-viewed-products-carousel-prev").removeClass('carousel-enable');
            }
            else {
                $("#recently-viewed-products-carousel-prev").addClass('carousel-enable');
                $("#recently-viewed-products-carousel-prev").removeClass('carousel-disable');
                $("#recently-viewed-products-carousel-next").addClass('carousel-enable');
                $("#recently-viewed-products-carousel-next").removeClass('carousel-disable');
            }
        });
    }

    //-----------------Recently Viewed Products Carousel setup ends here-----------------//

    /*Recently Viewed section ends here*/


    /*Recommendation Products section starts here*/

    /*Freq Bought Products section starts here*/


    pageUtils.getFreqBoughtProducts = function (offerCode, noOfItems, title, category, brand) {

        var recType = 1;

        var url = "/Product/GetRecommendationProducts?offerCode=" + offerCode + "&maxItems=" + noOfItems + "&recommendationType=" + recType;
        if (category != undefined && category != '')
            url = url + "&category=" + category;

        if (brand != undefined && brand != '')
            url = url + "&brand=" + brand;

        if (title == undefined) {
            title = "Frequently Bought Together";
        }
        var response;

        $.ajax(url, {
            type: 'GET',
            contentType: 'application/json',
            async: true,
            cache: false,
            success: function (data) {
                if (data != null && data.FrequentlyPurchasedTogether != null) {
                    response = data.FrequentlyPurchasedTogether;

                    if (response != null && response.length > 0) {
                        pageUtils.displayFreqBoughtProducts(response, title);
                    }
                }
            },
            error: function (error) {
                if (console)
                    console.log(error);
            }
        });
    }

    pageUtils.displayFreqBoughtProducts = function (data,title) {

        if (data == null || data.length == 0)
            return;

        var showCarousel = false;
        if (($("#fbp-mobile-view").is(':visible') && data.length > 2) || data.length > 4) {
            showCarousel = true;
        }

        var row_FreqBoughtProducts = '<hr id="abp_Seperator" noshade="noshade" size="1"><div id="freqBoughtProducts" class="row" style="text-align:center;padding-bottom: 30px;"><div class="col-xs-12"><h2 id="fbp_header" style="display: inline-block;font-weight:700;font-size: 30px;">'+title+'</h2></div>';
        row_FreqBoughtProducts += '<div>';
        if (showCarousel) {
            row_FreqBoughtProducts += '<div id="freq-bought-products-carousel-prev" class="col-md-1 col-sm-1 col-xs-1 image-carousel-controls visible-xs" style="text-align: left;padding-right: 0px;padding-top: 90px;"><i class="fa fa-angle-left fa-4x"></i></div>';
            row_FreqBoughtProducts += '<div class="col-md-10 col-sm-10 col-xs-10" style="margin-top: 30px;">';
            row_FreqBoughtProducts += '<div id="freq-bought-products-carousel" class="owl-carousel owl-theme">';
        }
        else {
            row_FreqBoughtProducts += '<div class="col-md-12 col-sm-12 col-xs-12" style="margin-top: 30px;">';
            row_FreqBoughtProducts += '<div id="freq-bought-products-carousel">';
        }


        var productCounter = 0;



        $.each(data, function (index, product) {

            var productLink = "/Product/" + slugify(product.Topline) +"/"+ product.OfferCode;

            //Put product Topline inside html tage to convert trademarks into their respective symbols to avoid character limit inconsistency.
            //Eg: "Gems of Distinction&trade; Ultimate" will convert into "Gems of Distinction™ Ultimate"
            //Start
            var row_Topline = '<div id="offerTopline" style="display:none">' + product.Topline + '</div>';
            $("#fbp-mobile-view").after(row_Topline);

            var OfferTopline = $("#offerTopline").text();
            $("#offerTopline").remove();
            //End

            if (typeof OfferTopline != "undefined") {
                productCounter++;

                if (showCarousel)
                    row_FreqBoughtProducts += ('<div class="col-xs-12 col-md-12 FreqBoughtProducts-container prodTrack" data-productlist="FreqPurchTogether" data-productposition="' + productCounter + '" data-offercode="' + product.OfferCode + '" data-topline="' + product.Topline.replace(/"/g, "'").replace(/"/g, '\'') + '">');
                else
                    row_FreqBoughtProducts += ('<div class="col-xs-6 col-md-3 FreqBoughtProducts-container prodTrack" data-productlist="FreqPurchTogether" data-productposition="' + productCounter + '" data-offercode="' + product.OfferCode + '" data-topline="' + product.Topline.replace(/"/g, "'").replace(/"/g, '\'') + '">');

                row_FreqBoughtProducts += ('<a class="blue-hover" href="' + productLink + '"><img alt="' + product.OfferCode + '" class="img-responsive" style="margin: 0 auto;width:auto;max-width:100%" src="https://s7d1.scene7.com/is/image/ShopHQ/' + product.OfferCode + '?DefaultImage=1&$150x150_jpg$"></a>');
                row_FreqBoughtProducts += ('<div style="height:25px"></div>');
                row_FreqBoughtProducts += ('<div class="caption"><a class="blue-hover crossProduct" href="' + productLink + '" style="word-wrap: break-word;">' + OfferTopline.replace(/"/g, "'").replace(/"/g, '\'') + '</a></div>');
                row_FreqBoughtProducts += ('<div class="sale-price-section"><span class="sale-price-label">' + product.SalePrice.Label.replace("%CNAME%","JewelryHQ Price") + ' : </span> <span class="sale-price">' + product.SalePrice.DisplayPrice + '</span></div>');
                row_FreqBoughtProducts += ('</div>');

            }

        });

        row_FreqBoughtProducts += '</div>';
        row_FreqBoughtProducts += '</div>';
        if (showCarousel) {
            row_FreqBoughtProducts += '<div id="freq-bought-products-carousel-next" class="col-md-1 col-sm-1 col-xs-1 image-carousel-controls visible-xs" style="text-align: right;padding-left: 0px;padding-top: 90px;"><i class="fa fa-angle-right fa-4x"></i></div>';
        }
        row_FreqBoughtProducts += '</div>';

        if (productCounter > 0) {
            $("#fbp-mobile-view").after(row_FreqBoughtProducts);

            if (showCarousel) {

                if (productCounter > 4) {//remove visible-cs css and show
                    $("#freq-bought-products-carousel-prev").removeClass('visible-xs');
                    $("#freq-bought-products-carousel-next").removeClass('visible-xs');

                    $("#freq-bought-products-carousel-prev").show();
                    $("#freq-bought-products-carousel-next").show();

                }
                else//add visible-cs css and show
                {

                    $("#freq-bought-products-carousel-prev").addClass('visible-xs');
                    $("#freq-bought-products-carousel-next").addClass('visible-xs');

                    $("#freq-bought-products-carousel-prev").show();
                    $("#freq-bought-products-carousel-next").show();

                }

                FreqBoughtProductsSection();

            }
        }

    }
    pageUtils.anchorAccessibility = function () {
        $('a.addQuickViewLink').each(function (index, item) {
            if ($(item).attr('href') === '#') {
                $(item).attr('href', '#shophq');
            }
        });
    }
    //-----------------Freq Bought products Carousel setup start----------------//

    function FreqBoughtProductsSection() {
        var freqBoughtProductsCarousel = $("#freq-bought-products-carousel").owlCarousel({
            items: 4,
            margin: 40,
            responsive: {
                0: {
                    items: 2,
                    margin: 0
                },
                600: {
                    items: 3,
                },
                1000: {
                    items: 4
                }
            },
            loop: false,
            dots: false
        });


        $('#freq-bought-products-carousel-next').click(function () {
            if (freqBoughtProductsCarousel !== null) {
                freqBoughtProductsCarousel.trigger('next.owl.carousel');
            }
        });

        $('#freq-bought-products-carousel-prev').click(function () {
            if (freqBoughtProductsCarousel !== null) {
                freqBoughtProductsCarousel.trigger('prev.owl.carousel');
            }
        });

        $("#freq-bought-products-carousel-prev").addClass('carousel-disable');

        $("#freq-bought-products-carousel").on('initialized.owl.carousel changed.owl.carousel refreshed.owl.carousel', function (event) {

            if (!event.namespace) return;
            var carousel = event.relatedTarget,
                element = event.target,
                current = carousel.current();
            if (current == carousel.maximum()) {
                $("#freq-bought-products-carousel-prev").addClass('carousel-enable');
                $("#freq-bought-products-carousel-prev").removeClass('carousel-disable');
                $("#freq-bought-products-carousel-next").addClass('carousel-disable');
                $("#freq-bought-products-carousel-next").removeClass('carousel-enable');
            }
            else if (current == carousel.minimum()) {
                $("#freq-bought-products-carousel-next").addClass('carousel-enable');
                $("#freq-bought-products-carousel-next").removeClass('carousel-disable');
                $("#freq-bought-products-carousel-prev").addClass('carousel-disable');
                $("#freq-bought-products-carousel-prev").removeClass('carousel-enable');
            }
            else {
                $("#freq-bought-products-carousel-prev").addClass('carousel-enable');
                $("#freq-bought-products-carousel-prev").removeClass('carousel-disable');
                $("#freq-bought-products-carousel-next").addClass('carousel-enable');
                $("#freq-bought-products-carousel-next").removeClass('carousel-disable');
            }
        });
    }

    //-----------------Freq Bought products Carousel setup end----------------//

    /*Freq Bought Products section ends here*/

    /*Also Bought Products section starts here*/

    pageUtils.getAlsoBoughtProducts = function (offerCode, noOfItems, title, category, brand) {

        var recType = 2;

        var url = "/Product/GetRecommendationProducts?offerCode=" + offerCode + "&maxItems=" + noOfItems + "&recommendationType=" + recType;
        if (category != undefined && category != '')
            url = url + "&category=" + category;

        if (brand != undefined && brand != '')
            url = url + "&brand=" + brand;


        if (title == undefined) {
            title = "Customers Also Bought";
        }
        var response;

        $.ajax(url, {
            type: 'GET',
            contentType: 'application/json',
            async: true,
            cache: false,
            success: function (data) {
                if (data != null && data.PeopleWhoBoughtAlsoBought != null) {
                    response = data.PeopleWhoBoughtAlsoBought;

                    if (response != null && response.length > 0) {
                        pageUtils.displayAlsoBoughtProducts(response, title);
                    }
                }
            },
            error: function (error) {
                if (console)
                    console.log(error);
            }
        });
    }

    pageUtils.displayAlsoBoughtProducts = function (data,title) {

        var showCarousel = false;
        if (($("#abp-mobile-view").is(':visible') && data.length > 2) || data.length > 4) {
            showCarousel = true;
        }

        var row_AlsoBoughtProducts = '<hr id="abp_Seperator" noshade="noshade" size="1"><div id="alsoBoughtProducts" class="row" style="text-align:center;padding-bottom: 30px;"><div class="col-xs-12"><h2 id="abp_header" style="display: inline-block;font-weight:700;font-size: 30px;">'+title+'</h2></div>';
        row_AlsoBoughtProducts += '<div>';
        if (showCarousel) {
            row_AlsoBoughtProducts += '<div id="also-bought-products-carousel-prev" class="col-md-1 col-sm-1 col-xs-1 image-carousel-controls visible-xs" style="text-align: left;padding-right: 0px;padding-top: 90px;"><i class="fa fa-angle-left fa-4x"></i></div>';
            row_AlsoBoughtProducts += '<div class="col-md-10 col-sm-10 col-xs-10" style="margin-top: 30px;">';
            row_AlsoBoughtProducts += '<div id="also-bought-products-carousel" class="owl-carousel owl-theme">';
        }
        else {
            row_AlsoBoughtProducts += '<div class="col-md-12 col-sm-12 col-xs-12" style="margin-top: 30px;">';
            row_AlsoBoughtProducts += '<div id="also-bought-products-carousel">';
        }


        var productCounter = 0;



        $.each(data, function (index, product) {

            var productLink = "/Product/" + slugify(product.Topline) + "/" + product.OfferCode;

            //Put product Topline inside html tage to convert trademarks into their respective symbols to avoid character limit inconsistency.
            //Eg: "Gems of Distinction&trade; Ultimate" will convert into "Gems of Distinction™ Ultimate"
            //Start
            var row_Topline = '<div id="offerTopline" style="display:none">' + product.Topline + '</div>';
            $("#abp-mobile-view").after(row_Topline);

            var OfferTopline = $("#offerTopline").text();
            $("#offerTopline").remove();
            //End

            if (typeof OfferTopline != "undefined") {
                productCounter++;

                if (showCarousel)
                    row_AlsoBoughtProducts += ('<div class="col-xs-12 col-md-12 AlsoBoughtProducts-container prodTrack" data-productlist="AlsoBought" data-productposition="' + productCounter + '" data-offercode="' + product.OfferCode + '" data-topline="' + product.Topline.replace(/"/g, "'").replace(/"/g, '\'') + '">');
                else
                    row_AlsoBoughtProducts += ('<div class="col-xs-6 col-md-3 AlsoBoughtProducts-container prodTrack" data-productlist="AlsoBought" data-productposition="' + productCounter + '" data-offercode="' + product.OfferCode + '" data-topline="' + product.Topline.replace(/"/g, "'").replace(/"/g, '\'') + '">');

                row_AlsoBoughtProducts += ('<a class="blue-hover" href="' + productLink + '"><img alt="' + product.OfferCode + '" class="img-responsive" style="margin: 0 auto;width:auto;max-width:100%" src="https://s7d1.scene7.com/is/image/ShopHQ/' + product.OfferCode + '?DefaultImage=1&$150x150_jpg$"></a>');
                row_AlsoBoughtProducts += ('<div style="height:25px"></div>');
                row_AlsoBoughtProducts += ('<div class="caption"><a class="blue-hover crossProduct" href="' + productLink + '" style="word-wrap: break-word;">' + OfferTopline.replace(/"/g, "'").replace(/"/g, '\'') + '</a></div>');
                row_AlsoBoughtProducts += ('<div class="sale-price-section"><span class="sale-price-label">' + product.SalePrice.Label.replace("%CNAME%", "JewelryHQ Price") + ' : </span> <span class="sale-price">' + product.SalePrice.DisplayPrice + '</span></div>');
                row_AlsoBoughtProducts += ('</div>');

            }

        });

        row_AlsoBoughtProducts += '</div>';
        row_AlsoBoughtProducts += '</div>';
        if (showCarousel) {
            row_AlsoBoughtProducts += '<div id="also-bought-products-carousel-next" class="col-md-1 col-sm-1 col-xs-1 image-carousel-controls visible-xs" style="text-align: right;padding-left: 0px;padding-top: 90px;"><i class="fa fa-angle-right fa-4x"></i></div>';
        }
        row_AlsoBoughtProducts += '</div>';

        if (productCounter > 0) {
            $("#abp-mobile-view").after(row_AlsoBoughtProducts);

            if (showCarousel) {

                if (productCounter > 4) {//remove visible-cs css and show
                    $("#also-bought-products-carousel-prev").removeClass('visible-xs');
                    $("#also-bought-products-carousel-next").removeClass('visible-xs');

                    $("#also-bought-products-carousel-prev").show();
                    $("#also-bought-products-carousel-next").show();

                }
                else//add visible-cs css and show
                {

                    $("#also-bought-products-carousel-prev").addClass('visible-xs');
                    $("#also-bought-products-carousel-next").addClass('visible-xs');

                    $("#also-bought-products-carousel-prev").show();
                    $("#also-bought-products-carousel-next").show();

                }

                AlsoBoughtProductsSection();

            }
        }

    }


    //-----------------Also Bought products Carousel setup start----------------//

    function AlsoBoughtProductsSection() {
        var alsoBoughtProductsCarousel = $("#also-bought-products-carousel").owlCarousel({
            items: 4,
            margin: 40,
            responsive: {
                0: {
                    items: 2,
                    margin: 0
                },
                600: {
                    items: 3,
                },
                1000: {
                    items: 4
                }
            },
            loop: false,
            dots: false
        });


        $('#also-bought-products-carousel-next').click(function () {
            if (alsoBoughtProductsCarousel !== null) {
                alsoBoughtProductsCarousel.trigger('next.owl.carousel');
            }
        });

        $('#also-bought-products-carousel-prev').click(function () {
            if (alsoBoughtProductsCarousel !== null) {
                alsoBoughtProductsCarousel.trigger('prev.owl.carousel');
            }
        });

        $("#also-bought-products-carousel-prev").addClass('carousel-disable');

        $("#also-bought-products-carousel").on('initialized.owl.carousel changed.owl.carousel refreshed.owl.carousel', function (event) {

            if (!event.namespace) return;
            var carousel = event.relatedTarget,
                element = event.target,
                current = carousel.current();
            if (current == carousel.maximum()) {
                $("#also-bought-products-carousel-prev").addClass('carousel-enable');
                $("#also-bought-products-carousel-prev").removeClass('carousel-disable');
                $("#also-bought-products-carousel-next").addClass('carousel-disable');
                $("#also-bought-products-carousel-next").removeClass('carousel-enable');
            }
            else if (current == carousel.minimum()) {
                $("#also-bought-products-carousel-next").addClass('carousel-enable');
                $("#also-bought-products-carousel-next").removeClass('carousel-disable');
                $("#also-bought-products-carousel-prev").addClass('carousel-disable');
                $("#also-bought-products-carousel-prev").removeClass('carousel-enable');
            }
            else {
                $("#also-bought-products-carousel-prev").addClass('carousel-enable');
                $("#also-bought-products-carousel-prev").removeClass('carousel-disable');
                $("#also-bought-products-carousel-next").addClass('carousel-enable');
                $("#also-bought-products-carousel-next").removeClass('carousel-disable');
            }
        });
    }

    //-----------------Also Bought products Carousel setup end----------------//

    /*Also Bought Products section ends here*/


    /*Also Viewed Products section starts here*/

    pageUtils.getAlsoViewedProducts = function (offerCode, noOfItems, title, category, brand) {

        var recType = 3;

        var url = "/Product/GetRecommendationProducts?offerCode=" + offerCode + "&maxItems=" + noOfItems + "&recommendationType=" + recType;
        if (category != undefined && category != '')
            url = url + "&category=" + category;

        if (brand != undefined && brand != '')
            url = url + "&brand=" + brand;


        if (title == undefined) {
            title = "Customers Also Viewed";
        }
        var response;

        $.ajax(url, {
            type: 'GET',
            contentType: 'application/json',
            async: true,
            cache: false,
            success: function (data) {
                if (data != null && data.PeopleWhoViewedAlsoViewed != null) {
                    response = data.PeopleWhoViewedAlsoViewed;

                    if (response != null && response.length > 0) {
                        pageUtils.displayAlsoViewedProducts(response, title);
                    }
                }
            },
            error: function (error) {
                if (console)
                    console.log(error);
            }
        });
    }

    pageUtils.displayAlsoViewedProducts = function (data,title) {

        var showCarousel = false;
        if (($("#avp-mobile-view").is(':visible') && data.length > 2) || data.length > 4) {
            showCarousel = true;
        }

        var row_AlsoViewedProducts = '<hr id="avp_Seperator" noshade="noshade" size="1"><div id="alsoViewedProducts" class="row" style="text-align:center;padding-bottom: 30px;"><div class="col-xs-12"><h2 id="avp_header" style="display: inline-block;font-weight:700;font-size: 30px;">'+title+'</h2></div>';
        row_AlsoViewedProducts += '<div>';
        if (showCarousel) {
            row_AlsoViewedProducts += '<div id="also-viewed-products-carousel-prev" class="col-md-1 col-sm-1 col-xs-1 image-carousel-controls visible-xs" style="text-align: left;padding-right: 0px;padding-top: 90px;"><i class="fa fa-angle-left fa-4x"></i></div>';
            row_AlsoViewedProducts += '<div class="col-md-10 col-sm-10 col-xs-10" style="margin-top: 30px;">';
            row_AlsoViewedProducts += '<div id="also-viewed-products-carousel" class="owl-carousel owl-theme">';
        }
        else {
            row_AlsoViewedProducts += '<div class="col-md-12 col-sm-12 col-xs-12" style="margin-top: 30px;">';
            row_AlsoViewedProducts += '<div id="also-viewed-products-carousel">';
        }


        var productCounter = 0;



        $.each(data, function (index, product) {

            var productLink = "/Product/" + slugify(product.Topline) + "/"+ product.OfferCode;

            //Put product Topline inside html tage to convert trademarks into their respective symbols to avoid character limit inconsistency.
            //Eg: "Gems of Distinction&trade; Ultimate" will convert into "Gems of Distinction™ Ultimate"
            //Start
            var row_Topline = '<div id="offerTopline" style="display:none">' + product.Topline + '</div>';
            $("#avp-mobile-view").after(row_Topline);

            var OfferTopline = $("#offerTopline").text();
            $("#offerTopline").remove();
            //End

            if (typeof OfferTopline != "undefined") {
                productCounter++;

                if (showCarousel)
                    row_AlsoViewedProducts += ('<div class="col-xs-12 col-md-12 AlsoViewedProducts-container prodTrack" data-productlist="AlsoViewed" data-productposition="' + productCounter + '" data-offercode="' + product.OfferCode + '" data-topline="' + product.Topline.replace(/"/g, "'").replace(/"/g, '\'') + '">');
                else
                    row_AlsoViewedProducts += ('<div class="col-xs-6 col-md-3 AlsoViewedProducts-container prodTrack" data-productlist="AlsoViewed" data-productposition="' + productCounter + '" data-offercode="' + product.OfferCode + '" data-topline="' + product.Topline.replace(/"/g, "'").replace(/"/g, '\'') + '">');

                row_AlsoViewedProducts += ('<a class="blue-hover" href="' + productLink + '"><img alt="' + product.OfferCode + '" class="img-responsive" style="margin: 0 auto;width:auto;max-width:100%" src="https://s7d1.scene7.com/is/image/ShopHQ/' + product.OfferCode + '?DefaultImage=1&$150x150_jpg$"></a>');
                row_AlsoViewedProducts += ('<div style="height:25px"></div>');
                row_AlsoViewedProducts += ('<div class="caption"><a class="blue-hover crossProduct" href="' + productLink + '" style="word-wrap: break-word;">' + OfferTopline.replace(/"/g, "'").replace(/"/g, '\'') + '</a></div>');
                row_AlsoViewedProducts += ('<div class="sale-price-section"><span class="sale-price-label">' + product.SalePrice.Label.replace("%CNAME%", "JewelryHQ Price")  + ' : </span> <span class="sale-price">' + product.SalePrice.DisplayPrice + '</span></div>');
                row_AlsoViewedProducts += ('</div>');

            }

        });

        row_AlsoViewedProducts += '</div>';
        row_AlsoViewedProducts += '</div>';
        if (showCarousel) {
            row_AlsoViewedProducts += '<div id="also-viewed-products-carousel-next" class="col-md-1 col-sm-1 col-xs-1 image-carousel-controls visible-xs" style="text-align: right;padding-left: 0px;padding-top: 90px;"><i class="fa fa-angle-right fa-4x"></i></div>';
        }
        row_AlsoViewedProducts += '</div>';

        if (productCounter > 0) {
            $("#avp-mobile-view").after(row_AlsoViewedProducts);

            if (showCarousel) {

                if (productCounter > 4) {//remove visible-cs css and show
                    $("#also-viewed-products-carousel-prev").removeClass('visible-xs');
                    $("#also-viewed-products-carousel-next").removeClass('visible-xs');

                    $("#also-viewed-products-carousel-prev").show();
                    $("#also-viewed-products-carousel-next").show();

                }
                else//add visible-cs css and show
                {

                    $("#also-viewed-products-carousel-prev").addClass('visible-xs');
                    $("#also-viewed-products-carousel-next").addClass('visible-xs');

                    $("#also-viewed-products-carousel-prev").show();
                    $("#also-viewed-products-carousel-next").show();

                }

                AlsoViewedProductsSection();
            }
        }

    }


    //-----------------Also Viewed products Carousel setup start----------------//

    function AlsoViewedProductsSection() {
        var alsoViewedProductsCarousel = $("#also-viewed-products-carousel").owlCarousel({
            items: 4,
            margin: 40,
            responsive: {
                0: {
                    items: 2,
                    margin: 0
                },
                600: {
                    items: 3,
                },
                1000: {
                    items: 4
                }
            },
            loop: false,
            dots: false
        });


        $('#also-viewed-products-carousel-next').click(function () {
            if (alsoViewedProductsCarousel !== null) {
                alsoViewedProductsCarousel.trigger('next.owl.carousel');
            }
        });

        $('#also-viewed-products-carousel-prev').click(function () {
            if (alsoViewedProductsCarousel !== null) {
                alsoViewedProductsCarousel.trigger('prev.owl.carousel');
            }
        });

        $("#also-viewed-products-carousel-prev").addClass('carousel-disable');

        $("#also-viewed-products-carousel").on('initialized.owl.carousel changed.owl.carousel refreshed.owl.carousel', function (event) {

            if (!event.namespace) return;
            var carousel = event.relatedTarget,
                element = event.target,
                current = carousel.current();
            if (current == carousel.maximum()) {
                $("#also-viewed-products-carousel-prev").addClass('carousel-enable');
                $("#also-viewed-products-carousel-prev").removeClass('carousel-disable');
                $("#also-viewed-products-carousel-next").addClass('carousel-disable');
                $("#also-viewed-products-carousel-next").removeClass('carousel-enable');
            }
            else if (current == carousel.minimum()) {
                $("#also-viewed-products-carousel-next").addClass('carousel-enable');
                $("#also-viewed-products-carousel-next").removeClass('carousel-disable');
                $("#also-viewed-products-carousel-prev").addClass('carousel-disable');
                $("#also-viewed-products-carousel-prev").removeClass('carousel-enable');
            }
            else {
                $("#also-viewed-products-carousel-prev").addClass('carousel-enable');
                $("#also-viewed-products-carousel-prev").removeClass('carousel-disable');
                $("#also-viewed-products-carousel-next").addClass('carousel-enable');
                $("#also-viewed-products-carousel-next").removeClass('carousel-disable');
            }
        });
    }

    //-----------------Also Viewed products Carousel setup end----------------//

    /*Also Viewed Products section ends here*/


    /*Recommendation Products section ends here*/

    function slugify(str) {
        if (str !== undefined && str !== null) {
            str = str.replace(/^\s+|\s+$/g, ''); // trim
            str = str.toLowerCase();

            // remove accents, swap ñ for n, etc
            var from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;";
            var to = "aaaaaeeeeeiiiiooooouuuunc------";
            for (var i = 0, l = from.length; i < l; i++) {
                str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
            }

            str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
                .replace(/\s+/g, '-') // collapse whitespace and replace by -
                .replace(/-+/g, '-'); // collapse dashes

        }
        return str;
    }

    return pageUtils;
})(shopHq.pageUtils = shopHq.pageUtils || {}, jQuery);

$(document).on('show.bs.modal', '.modal', shopHq.pageUtils.centralizeModal);
$(window).on("resize", function () {
    if ($('.modal:visible') !== null && $('.modal:visible') !== undefined && $('.modal:visible').length > 0) {
        $('.modal:visible').each(shopHq.pageUtils.centralizeModal);
    }
});
;
(function(services, $)
{
	services.subscribeToNewsletter = function (emailSignupLink,email)
	{
	    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

		if(filter.test(email))
		{
		    var url = emailSignupLink.replace('{0}', email);
		    window.open(url,
            '_blank',
            'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
		}
	};
	return services;

})(shopHq.services = shopHq.services || {}, jQuery);;
/*! http://mths.be/placeholder v2.0.7 by @mathias */
;(function(f,h,$){var a='placeholder' in h.createElement('input'),d='placeholder' in h.createElement('textarea'),i=$.fn,c=$.valHooks,k,j;if(a&&d){j=i.placeholder=function(){return this};j.input=j.textarea=true}else{j=i.placeholder=function(){var l=this;l.filter((a?'textarea':':input')+'[placeholder]').not('.placeholder').bind({'focus.placeholder':b,'blur.placeholder':e}).data('placeholder-enabled',true).trigger('blur.placeholder');return l};j.input=a;j.textarea=d;k={get:function(m){var l=$(m);return l.data('placeholder-enabled')&&l.hasClass('placeholder')?'':m.value},set:function(m,n){var l=$(m);if(!l.data('placeholder-enabled')){return m.value=n}if(n==''){m.value=n;if(m!=h.activeElement){e.call(m)}}else{if(l.hasClass('placeholder')){b.call(m,true,n)||(m.value=n)}else{m.value=n}}return l}};a||(c.input=k);d||(c.textarea=k);$(function(){$(h).delegate('form','submit.placeholder',function(){var l=$('.placeholder',this).each(b);setTimeout(function(){l.each(e)},10)})});$(f).bind('beforeunload.placeholder',function(){$('.placeholder').each(function(){this.value=''})})}function g(m){var l={},n=/^jQuery\d+$/;$.each(m.attributes,function(p,o){if(o.specified&&!n.test(o.name)){l[o.name]=o.value}});return l}function b(m,n){var l=this,o=$(l);if(l.value==o.attr('placeholder')&&o.hasClass('placeholder')){if(o.data('placeholder-password')){o=o.hide().next().show().attr('id',o.removeAttr('id').data('placeholder-id'));if(m===true){return o[0].value=n}o.focus()}else{l.value='';o.removeClass('placeholder');l==h.activeElement&&l.select()}}}function e(){var q,l=this,p=$(l),m=p,o=this.id;if(l.value==''){if(l.type=='password'){if(!p.data('placeholder-textinput')){try{q=p.clone().attr({type:'text'})}catch(n){q=$('<input>').attr($.extend(g(this),{type:'text'}))}q.removeAttr('name').data({'placeholder-password':true,'placeholder-id':o}).bind('focus.placeholder',b);p.data({'placeholder-textinput':q,'placeholder-id':o}).before(q)}p=p.removeAttr('id').hide().prev().attr('id',o).show()}p.addClass('placeholder');p[0].value=p.attr('placeholder')}else{p.removeClass('placeholder')}}}(this,document,jQuery));;
/*!
 * jQuery Cookie Plugin v1.4.0
 * https://github.com/carhartl/jquery-cookie
 *
 * Copyright 2013 Klaus Hartl
 * Released under the MIT license
 */
(function (factory) {
	if (typeof define === 'function' && define.amd) {
		// AMD. Register as anonymous module.
		define(['jquery'], factory);
	} else {
		// Browser globals.
		factory(jQuery);
	}
}(function ($) {

	var pluses = /\+/g;

	function encode(s) {
		return config.raw ? s : encodeURIComponent(s);
	}

	function decode(s) {
		return config.raw ? s : decodeURIComponent(s);
	}

	function stringifyCookieValue(value) {
		return encode(config.json ? JSON.stringify(value) : String(value));
	}

	function parseCookieValue(s) {
		if (s.indexOf('"') === 0) {
			// This is a quoted cookie as according to RFC2068, unescape...
			s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
		}

		try {
			// Replace server-side written pluses with spaces.
			// If we can't decode the cookie, ignore it, it's unusable.
			s = decodeURIComponent(s.replace(pluses, ' '));
		} catch(e) {
			return;
		}

		try {
			// If we can't parse the cookie, ignore it, it's unusable.
			return config.json ? JSON.parse(s) : s;
		} catch(e) {}
	}

	function read(s, converter) {
		var value = config.raw ? s : parseCookieValue(s);
		return $.isFunction(converter) ? converter(value) : value;
	}

	var config = $.cookie = function (key, value, options) {

		// Write
		if (value !== undefined && !$.isFunction(value)) {
			options = $.extend({}, config.defaults, options);

			if (typeof options.expires === 'number') {
				var days = options.expires, t = options.expires = new Date();
				t.setDate(t.getDate() + days);
			}

			return (document.cookie = [
				encode(key), '=', stringifyCookieValue(value),
				options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
				options.path    ? '; path=' + options.path : '',
				options.domain  ? '; domain=' + options.domain : '',
				options.secure  ? '; secure' : ''
			].join(''));
		}

		// Read

		var result = key ? undefined : {};

		// To prevent the for loop in the first place assign an empty array
		// in case there are no cookies at all. Also prevents odd result when
		// calling $.cookie().
		var cookies = document.cookie ? document.cookie.split('; ') : [];

		for (var i = 0, l = cookies.length; i < l; i++) {
			var parts = cookies[i].split('=');
			var name = decode(parts.shift());
			var cookie = parts.join('=');

			if (key && key === name) {
				// If second argument (value) is a function it's a converter...
				result = read(cookie, value);
				break;
			}

			// Prevent storing a cookie that we couldn't decode.
			if (!key && (cookie = read(cookie)) !== undefined) {
				result[name] = cookie;
			}
		}

		return result;
	};

	config.defaults = {};

	$.removeCookie = function (key, options) {
		if ($.cookie(key) !== undefined) {
			// Must not alter options, thus extending a fresh object...
			$.cookie(key, '', $.extend({}, options, { expires: -1 }));
			return true;
		}
		return false;
	};

}));
;
// http://spin.js.org/#v2.3.2
!function(a,b){"object"==typeof module&&module.exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Spinner=b()}(this,function(){"use strict";function a(a,b){var c,d=document.createElement(a||"div");for(c in b)d[c]=b[c];return d}function b(a){for(var b=1,c=arguments.length;c>b;b++)a.appendChild(arguments[b]);return a}function c(a,b,c,d){var e=["opacity",b,~~(100*a),c,d].join("-"),f=.01+c/d*100,g=Math.max(1-(1-a)/b*(100-f),a),h=j.substring(0,j.indexOf("Animation")).toLowerCase(),i=h&&"-"+h+"-"||"";return m[e]||(k.insertRule("@"+i+"keyframes "+e+"{0%{opacity:"+g+"}"+f+"%{opacity:"+a+"}"+(f+.01)+"%{opacity:1}"+(f+b)%100+"%{opacity:"+a+"}100%{opacity:"+g+"}}",k.cssRules.length),m[e]=1),e}function d(a,b){var c,d,e=a.style;if(b=b.charAt(0).toUpperCase()+b.slice(1),void 0!==e[b])return b;for(d=0;d<l.length;d++)if(c=l[d]+b,void 0!==e[c])return c}function e(a,b){for(var c in b)a.style[d(a,c)||c]=b[c];return a}function f(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)void 0===a[d]&&(a[d]=c[d])}return a}function g(a,b){return"string"==typeof a?a:a[b%a.length]}function h(a){this.opts=f(a||{},h.defaults,n)}function i(){function c(b,c){return a("<"+b+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',c)}k.addRule(".spin-vml","behavior:url(#default#VML)"),h.prototype.lines=function(a,d){function f(){return e(c("group",{coordsize:k+" "+k,coordorigin:-j+" "+-j}),{width:k,height:k})}function h(a,h,i){b(m,b(e(f(),{rotation:360/d.lines*a+"deg",left:~~h}),b(e(c("roundrect",{arcsize:d.corners}),{width:j,height:d.scale*d.width,left:d.scale*d.radius,top:-d.scale*d.width>>1,filter:i}),c("fill",{color:g(d.color,a),opacity:d.opacity}),c("stroke",{opacity:0}))))}var i,j=d.scale*(d.length+d.width),k=2*d.scale*j,l=-(d.width+d.length)*d.scale*2+"px",m=e(f(),{position:"absolute",top:l,left:l});if(d.shadow)for(i=1;i<=d.lines;i++)h(i,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(i=1;i<=d.lines;i++)h(i);return b(a,m)},h.prototype.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d<e.childNodes.length&&(e=e.childNodes[b+d],e=e&&e.firstChild,e=e&&e.firstChild,e&&(e.opacity=c))}}var j,k,l=["webkit","Moz","ms","O"],m={},n={lines:12,length:7,width:5,radius:10,scale:1,corners:1,color:"#000",opacity:.25,rotate:0,direction:1,speed:1,trail:100,fps:20,zIndex:2e9,className:"spinner",top:"50%",left:"50%",shadow:!1,hwaccel:!1,position:"absolute"};if(h.defaults={},f(h.prototype,{spin:function(b){this.stop();var c=this,d=c.opts,f=c.el=a(null,{className:d.className});if(e(f,{position:d.position,width:0,zIndex:d.zIndex,left:d.left,top:d.top}),b&&b.insertBefore(f,b.firstChild||null),f.setAttribute("role","progressbar"),c.lines(f,c.opts),!j){var g,h=0,i=(d.lines-1)*(1-d.direction)/2,k=d.fps,l=k/d.speed,m=(1-d.opacity)/(l*d.trail/100),n=l/d.lines;!function o(){h++;for(var a=0;a<d.lines;a++)g=Math.max(1-(h+(d.lines-a)*n)%l*m,d.opacity),c.opacity(f,a*d.direction+i,g,d);c.timeout=c.el&&setTimeout(o,~~(1e3/k))}()}return c},stop:function(){var a=this.el;return a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=void 0),this},lines:function(d,f){function h(b,c){return e(a(),{position:"absolute",width:f.scale*(f.length+f.width)+"px",height:f.scale*f.width+"px",background:b,boxShadow:c,transformOrigin:"left",transform:"rotate("+~~(360/f.lines*k+f.rotate)+"deg) translate("+f.scale*f.radius+"px,0)",borderRadius:(f.corners*f.scale*f.width>>1)+"px"})}for(var i,k=0,l=(f.lines-1)*(1-f.direction)/2;k<f.lines;k++)i=e(a(),{position:"absolute",top:1+~(f.scale*f.width/2)+"px",transform:f.hwaccel?"translate3d(0,0,0)":"",opacity:f.opacity,animation:j&&c(f.opacity,f.trail,l+k*f.direction,f.lines)+" "+1/f.speed+"s linear infinite"}),f.shadow&&b(i,e(h("#000","0 0 4px #000"),{top:"2px"})),b(d,b(i,h(g(f.color,k),"0 0 1px rgba(0,0,0,.1)")));return d},opacity:function(a,b,c){b<a.childNodes.length&&(a.childNodes[b].style.opacity=c)}}),"undefined"!=typeof document){k=function(){var c=a("style",{type:"text/css"});return b(document.getElementsByTagName("head")[0],c),c.sheet||c.styleSheet}();var o=e(a("group"),{behavior:"url(#default#VML)"});!d(o,"transform")&&o.adj?i():j=d(o,"animation")}return h});
;
/**
 * Copyright (c) 2011-2014 Felix Gnass
 * Licensed under the MIT license
 * http://spin.js.org/
 */

/*

Basic Usage:
============

$('#el').spin() // Creates a default Spinner using the text color of #el.
$('#el').spin({ ... }) // Creates a Spinner using the provided options.

$('#el').spin(false) // Stops and removes the spinner.

Using Presets:
==============

$('#el').spin('small') // Creates a 'small' Spinner using the text color of #el.
$('#el').spin('large', '#fff') // Creates a 'large' white Spinner.

Adding a custom preset:
=======================

$.fn.spin.presets.flower = {
  lines:   9
, length: 10
, width:  20
, radius:  0
}

$('#el').spin('flower', 'red')

*/

; (function (factory) {

    if (typeof exports == 'object') {
        // CommonJS
        factory(require('jquery'), require('spin.js'));
    } else if (typeof define == 'function' && define.amd) {
        // AMD, register as anonymous module
        define(['jquery', 'spin'], factory)
    } else {
        // Browser globals
        if (!window.Spinner) throw new Error('Spin.js not present');
        factory(window.jQuery, window.Spinner);
    }

}(function ($, Spinner) {

    //var overlay = $('<div class="spin-overlay"></div>');
    $.fn.spin = function (opts, color) {
        $('#spinner-overlay').hide();
        return this.each(function() {
            var $this = $(this), data = $this.data();

            if (data.spinner) {
                data.spinner.stop();
                delete data.spinner;
            }

            if (opts !== false) {
                opts = $.extend(
                    { color: color || $this.css('color') }, $.fn.spin.presets[opts] || opts
                );
                data.spinner = new Spinner(opts).spin(this);
                $('#spinner-overlay').show();
            }
        });
    }

    $.fn.spin.presets = {
        tiny: { lines: 8, length: 2, width: 2, radius: 3 }
    , small: { lines: 8, length: 4, width: 3, radius: 5 }
    , large: { lines: 10, length: 8, width: 4, radius: 8 }
    }

}));
;
/*!
 * Knockout JavaScript library v3.5.1
 * (c) The Knockout.js team - http://knockoutjs.com/
 * License: MIT (http://www.opensource.org/licenses/mit-license.php)
 */

(function() {(function(n){var A=this||(0,eval)("this"),w=A.document,R=A.navigator,v=A.jQuery,H=A.JSON;v||"undefined"===typeof jQuery||(v=jQuery);(function(n){"function"===typeof define&&define.amd?define(["exports","require"],n):"object"===typeof exports&&"object"===typeof module?n(module.exports||exports):n(A.ko={})})(function(S,T){function K(a,c){return null===a||typeof a in W?a===c:!1}function X(b,c){var d;return function(){d||(d=a.a.setTimeout(function(){d=n;b()},c))}}function Y(b,c){var d;return function(){clearTimeout(d);
d=a.a.setTimeout(b,c)}}function Z(a,c){c&&"change"!==c?"beforeChange"===c?this.pc(a):this.gb(a,c):this.qc(a)}function aa(a,c){null!==c&&c.s&&c.s()}function ba(a,c){var d=this.qd,e=d[r];e.ra||(this.Qb&&this.mb[c]?(d.uc(c,a,this.mb[c]),this.mb[c]=null,--this.Qb):e.I[c]||d.uc(c,a,e.J?{da:a}:d.$c(a)),a.Ja&&a.gd())}var a="undefined"!==typeof S?S:{};a.b=function(b,c){for(var d=b.split("."),e=a,f=0;f<d.length-1;f++)e=e[d[f]];e[d[d.length-1]]=c};a.L=function(a,c,d){a[c]=d};a.version="3.5.1";a.b("version",
a.version);a.options={deferUpdates:!1,useOnlyNativeEvents:!1,foreachHidesDestroyed:!1};a.a=function(){function b(a,b){for(var c in a)f.call(a,c)&&b(c,a[c])}function c(a,b){if(b)for(var c in b)f.call(b,c)&&(a[c]=b[c]);return a}function d(a,b){a.__proto__=b;return a}function e(b,c,d,e){var l=b[c].match(q)||[];a.a.D(d.match(q),function(b){a.a.Na(l,b,e)});b[c]=l.join(" ")}var f=Object.prototype.hasOwnProperty,g={__proto__:[]}instanceof Array,h="function"===typeof Symbol,m={},k={};m[R&&/Firefox\/2/i.test(R.userAgent)?
"KeyboardEvent":"UIEvents"]=["keyup","keydown","keypress"];m.MouseEvents="click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave".split(" ");b(m,function(a,b){if(b.length)for(var c=0,d=b.length;c<d;c++)k[b[c]]=a});var l={propertychange:!0},p=w&&function(){for(var a=3,b=w.createElement("div"),c=b.getElementsByTagName("i");b.innerHTML="\x3c!--[if gt IE "+ ++a+"]><i></i><![endif]--\x3e",c[0];);return 4<a?a:n}(),q=/\S+/g,t;return{Jc:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],
D:function(a,b,c){for(var d=0,e=a.length;d<e;d++)b.call(c,a[d],d,a)},A:"function"==typeof Array.prototype.indexOf?function(a,b){return Array.prototype.indexOf.call(a,b)}:function(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1},Lb:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(b.call(c,a[d],d,a))return a[d];return n},Pa:function(b,c){var d=a.a.A(b,c);0<d?b.splice(d,1):0===d&&b.shift()},wc:function(b){var c=[];b&&a.a.D(b,function(b){0>a.a.A(c,b)&&c.push(b)});return c},Mb:function(a,
b,c){var d=[];if(a)for(var e=0,l=a.length;e<l;e++)d.push(b.call(c,a[e],e));return d},jb:function(a,b,c){var d=[];if(a)for(var e=0,l=a.length;e<l;e++)b.call(c,a[e],e)&&d.push(a[e]);return d},Nb:function(a,b){if(b instanceof Array)a.push.apply(a,b);else for(var c=0,d=b.length;c<d;c++)a.push(b[c]);return a},Na:function(b,c,d){var e=a.a.A(a.a.bc(b),c);0>e?d&&b.push(c):d||b.splice(e,1)},Ba:g,extend:c,setPrototypeOf:d,Ab:g?d:c,P:b,Ga:function(a,b,c){if(!a)return a;var d={},e;for(e in a)f.call(a,e)&&(d[e]=
b.call(c,a[e],e,a));return d},Tb:function(b){for(;b.firstChild;)a.removeNode(b.firstChild)},Yb:function(b){b=a.a.la(b);for(var c=(b[0]&&b[0].ownerDocument||w).createElement("div"),d=0,e=b.length;d<e;d++)c.appendChild(a.oa(b[d]));return c},Ca:function(b,c){for(var d=0,e=b.length,l=[];d<e;d++){var k=b[d].cloneNode(!0);l.push(c?a.oa(k):k)}return l},va:function(b,c){a.a.Tb(b);if(c)for(var d=0,e=c.length;d<e;d++)b.appendChild(c[d])},Xc:function(b,c){var d=b.nodeType?[b]:b;if(0<d.length){for(var e=d[0],
l=e.parentNode,k=0,f=c.length;k<f;k++)l.insertBefore(c[k],e);k=0;for(f=d.length;k<f;k++)a.removeNode(d[k])}},Ua:function(a,b){if(a.length){for(b=8===b.nodeType&&b.parentNode||b;a.length&&a[0].parentNode!==b;)a.splice(0,1);for(;1<a.length&&a[a.length-1].parentNode!==b;)a.length--;if(1<a.length){var c=a[0],d=a[a.length-1];for(a.length=0;c!==d;)a.push(c),c=c.nextSibling;a.push(d)}}return a},Zc:function(a,b){7>p?a.setAttribute("selected",b):a.selected=b},Db:function(a){return null===a||a===n?"":a.trim?
a.trim():a.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},Ud:function(a,b){a=a||"";return b.length>a.length?!1:a.substring(0,b.length)===b},vd:function(a,b){if(a===b)return!0;if(11===a.nodeType)return!1;if(b.contains)return b.contains(1!==a.nodeType?a.parentNode:a);if(b.compareDocumentPosition)return 16==(b.compareDocumentPosition(a)&16);for(;a&&a!=b;)a=a.parentNode;return!!a},Sb:function(b){return a.a.vd(b,b.ownerDocument.documentElement)},kd:function(b){return!!a.a.Lb(b,a.a.Sb)},R:function(a){return a&&
a.tagName&&a.tagName.toLowerCase()},Ac:function(b){return a.onError?function(){try{return b.apply(this,arguments)}catch(c){throw a.onError&&a.onError(c),c;}}:b},setTimeout:function(b,c){return setTimeout(a.a.Ac(b),c)},Gc:function(b){setTimeout(function(){a.onError&&a.onError(b);throw b;},0)},B:function(b,c,d){var e=a.a.Ac(d);d=l[c];if(a.options.useOnlyNativeEvents||d||!v)if(d||"function"!=typeof b.addEventListener)if("undefined"!=typeof b.attachEvent){var k=function(a){e.call(b,a)},f="on"+c;b.attachEvent(f,
k);a.a.K.za(b,function(){b.detachEvent(f,k)})}else throw Error("Browser doesn't support addEventListener or attachEvent");else b.addEventListener(c,e,!1);else t||(t="function"==typeof v(b).on?"on":"bind"),v(b)[t](c,e)},Fb:function(b,c){if(!b||!b.nodeType)throw Error("element must be a DOM node when calling triggerEvent");var d;"input"===a.a.R(b)&&b.type&&"click"==c.toLowerCase()?(d=b.type,d="checkbox"==d||"radio"==d):d=!1;if(a.options.useOnlyNativeEvents||!v||d)if("function"==typeof w.createEvent)if("function"==
typeof b.dispatchEvent)d=w.createEvent(k[c]||"HTMLEvents"),d.initEvent(c,!0,!0,A,0,0,0,0,0,!1,!1,!1,!1,0,b),b.dispatchEvent(d);else throw Error("The supplied element doesn't support dispatchEvent");else if(d&&b.click)b.click();else if("undefined"!=typeof b.fireEvent)b.fireEvent("on"+c);else throw Error("Browser doesn't support triggering events");else v(b).trigger(c)},f:function(b){return a.O(b)?b():b},bc:function(b){return a.O(b)?b.v():b},Eb:function(b,c,d){var l;c&&("object"===typeof b.classList?
(l=b.classList[d?"add":"remove"],a.a.D(c.match(q),function(a){l.call(b.classList,a)})):"string"===typeof b.className.baseVal?e(b.className,"baseVal",c,d):e(b,"className",c,d))},Bb:function(b,c){var d=a.a.f(c);if(null===d||d===n)d="";var e=a.h.firstChild(b);!e||3!=e.nodeType||a.h.nextSibling(e)?a.h.va(b,[b.ownerDocument.createTextNode(d)]):e.data=d;a.a.Ad(b)},Yc:function(a,b){a.name=b;if(7>=p)try{var c=a.name.replace(/[&<>'"]/g,function(a){return"&#"+a.charCodeAt(0)+";"});a.mergeAttributes(w.createElement("<input name='"+
c+"'/>"),!1)}catch(d){}},Ad:function(a){9<=p&&(a=1==a.nodeType?a:a.parentNode,a.style&&(a.style.zoom=a.style.zoom))},wd:function(a){if(p){var b=a.style.width;a.style.width=0;a.style.width=b}},Pd:function(b,c){b=a.a.f(b);c=a.a.f(c);for(var d=[],e=b;e<=c;e++)d.push(e);return d},la:function(a){for(var b=[],c=0,d=a.length;c<d;c++)b.push(a[c]);return b},Da:function(a){return h?Symbol(a):a},Zd:6===p,$d:7===p,W:p,Lc:function(b,c){for(var d=a.a.la(b.getElementsByTagName("input")).concat(a.a.la(b.getElementsByTagName("textarea"))),
e="string"==typeof c?function(a){return a.name===c}:function(a){return c.test(a.name)},l=[],k=d.length-1;0<=k;k--)e(d[k])&&l.push(d[k]);return l},Nd:function(b){return"string"==typeof b&&(b=a.a.Db(b))?H&&H.parse?H.parse(b):(new Function("return "+b))():null},hc:function(b,c,d){if(!H||!H.stringify)throw Error("Cannot find JSON.stringify(). Some browsers (e.g., IE < 8) don't support it natively, but you can overcome this by adding a script reference to json2.js, downloadable from http://www.json.org/json2.js");
return H.stringify(a.a.f(b),c,d)},Od:function(c,d,e){e=e||{};var l=e.params||{},k=e.includeFields||this.Jc,f=c;if("object"==typeof c&&"form"===a.a.R(c))for(var f=c.action,h=k.length-1;0<=h;h--)for(var g=a.a.Lc(c,k[h]),m=g.length-1;0<=m;m--)l[g[m].name]=g[m].value;d=a.a.f(d);var p=w.createElement("form");p.style.display="none";p.action=f;p.method="post";for(var q in d)c=w.createElement("input"),c.type="hidden",c.name=q,c.value=a.a.hc(a.a.f(d[q])),p.appendChild(c);b(l,function(a,b){var c=w.createElement("input");
c.type="hidden";c.name=a;c.value=b;p.appendChild(c)});w.body.appendChild(p);e.submitter?e.submitter(p):p.submit();setTimeout(function(){p.parentNode.removeChild(p)},0)}}}();a.b("utils",a.a);a.b("utils.arrayForEach",a.a.D);a.b("utils.arrayFirst",a.a.Lb);a.b("utils.arrayFilter",a.a.jb);a.b("utils.arrayGetDistinctValues",a.a.wc);a.b("utils.arrayIndexOf",a.a.A);a.b("utils.arrayMap",a.a.Mb);a.b("utils.arrayPushAll",a.a.Nb);a.b("utils.arrayRemoveItem",a.a.Pa);a.b("utils.cloneNodes",a.a.Ca);a.b("utils.createSymbolOrString",
a.a.Da);a.b("utils.extend",a.a.extend);a.b("utils.fieldsIncludedWithJsonPost",a.a.Jc);a.b("utils.getFormFields",a.a.Lc);a.b("utils.objectMap",a.a.Ga);a.b("utils.peekObservable",a.a.bc);a.b("utils.postJson",a.a.Od);a.b("utils.parseJson",a.a.Nd);a.b("utils.registerEventHandler",a.a.B);a.b("utils.stringifyJson",a.a.hc);a.b("utils.range",a.a.Pd);a.b("utils.toggleDomNodeCssClass",a.a.Eb);a.b("utils.triggerEvent",a.a.Fb);a.b("utils.unwrapObservable",a.a.f);a.b("utils.objectForEach",a.a.P);a.b("utils.addOrRemoveItem",
a.a.Na);a.b("utils.setTextContent",a.a.Bb);a.b("unwrap",a.a.f);Function.prototype.bind||(Function.prototype.bind=function(a){var c=this;if(1===arguments.length)return function(){return c.apply(a,arguments)};var d=Array.prototype.slice.call(arguments,1);return function(){var e=d.slice(0);e.push.apply(e,arguments);return c.apply(a,e)}});a.a.g=new function(){var b=0,c="__ko__"+(new Date).getTime(),d={},e,f;a.a.W?(e=function(a,e){var f=a[c];if(!f||"null"===f||!d[f]){if(!e)return n;f=a[c]="ko"+b++;d[f]=
{}}return d[f]},f=function(a){var b=a[c];return b?(delete d[b],a[c]=null,!0):!1}):(e=function(a,b){var d=a[c];!d&&b&&(d=a[c]={});return d},f=function(a){return a[c]?(delete a[c],!0):!1});return{get:function(a,b){var c=e(a,!1);return c&&c[b]},set:function(a,b,c){(a=e(a,c!==n))&&(a[b]=c)},Ub:function(a,b,c){a=e(a,!0);return a[b]||(a[b]=c)},clear:f,Z:function(){return b++ +c}}};a.b("utils.domData",a.a.g);a.b("utils.domData.clear",a.a.g.clear);a.a.K=new function(){function b(b,c){var d=a.a.g.get(b,e);
d===n&&c&&(d=[],a.a.g.set(b,e,d));return d}function c(c){var e=b(c,!1);if(e)for(var e=e.slice(0),k=0;k<e.length;k++)e[k](c);a.a.g.clear(c);a.a.K.cleanExternalData(c);g[c.nodeType]&&d(c.childNodes,!0)}function d(b,d){for(var e=[],l,f=0;f<b.length;f++)if(!d||8===b[f].nodeType)if(c(e[e.length]=l=b[f]),b[f]!==l)for(;f--&&-1==a.a.A(e,b[f]););}var e=a.a.g.Z(),f={1:!0,8:!0,9:!0},g={1:!0,9:!0};return{za:function(a,c){if("function"!=typeof c)throw Error("Callback must be a function");b(a,!0).push(c)},yb:function(c,
d){var f=b(c,!1);f&&(a.a.Pa(f,d),0==f.length&&a.a.g.set(c,e,n))},oa:function(b){a.u.G(function(){f[b.nodeType]&&(c(b),g[b.nodeType]&&d(b.getElementsByTagName("*")))});return b},removeNode:function(b){a.oa(b);b.parentNode&&b.parentNode.removeChild(b)},cleanExternalData:function(a){v&&"function"==typeof v.cleanData&&v.cleanData([a])}}};a.oa=a.a.K.oa;a.removeNode=a.a.K.removeNode;a.b("cleanNode",a.oa);a.b("removeNode",a.removeNode);a.b("utils.domNodeDisposal",a.a.K);a.b("utils.domNodeDisposal.addDisposeCallback",
a.a.K.za);a.b("utils.domNodeDisposal.removeDisposeCallback",a.a.K.yb);(function(){var b=[0,"",""],c=[1,"<table>","</table>"],d=[3,"<table><tbody><tr>","</tr></tbody></table>"],e=[1,"<select multiple='multiple'>","</select>"],f={thead:c,tbody:c,tfoot:c,tr:[2,"<table><tbody>","</tbody></table>"],td:d,th:d,option:e,optgroup:e},g=8>=a.a.W;a.a.ua=function(c,d){var e;if(v)if(v.parseHTML)e=v.parseHTML(c,d)||[];else{if((e=v.clean([c],d))&&e[0]){for(var l=e[0];l.parentNode&&11!==l.parentNode.nodeType;)l=l.parentNode;
l.parentNode&&l.parentNode.removeChild(l)}}else{(e=d)||(e=w);var l=e.parentWindow||e.defaultView||A,p=a.a.Db(c).toLowerCase(),q=e.createElement("div"),t;t=(p=p.match(/^(?:\x3c!--.*?--\x3e\s*?)*?<([a-z]+)[\s>]/))&&f[p[1]]||b;p=t[0];t="ignored<div>"+t[1]+c+t[2]+"</div>";"function"==typeof l.innerShiv?q.appendChild(l.innerShiv(t)):(g&&e.body.appendChild(q),q.innerHTML=t,g&&q.parentNode.removeChild(q));for(;p--;)q=q.lastChild;e=a.a.la(q.lastChild.childNodes)}return e};a.a.Md=function(b,c){var d=a.a.ua(b,
c);return d.length&&d[0].parentElement||a.a.Yb(d)};a.a.fc=function(b,c){a.a.Tb(b);c=a.a.f(c);if(null!==c&&c!==n)if("string"!=typeof c&&(c=c.toString()),v)v(b).html(c);else for(var d=a.a.ua(c,b.ownerDocument),e=0;e<d.length;e++)b.appendChild(d[e])}})();a.b("utils.parseHtmlFragment",a.a.ua);a.b("utils.setHtml",a.a.fc);a.aa=function(){function b(c,e){if(c)if(8==c.nodeType){var f=a.aa.Uc(c.nodeValue);null!=f&&e.push({ud:c,Kd:f})}else if(1==c.nodeType)for(var f=0,g=c.childNodes,h=g.length;f<h;f++)b(g[f],
e)}var c={};return{Xb:function(a){if("function"!=typeof a)throw Error("You can only pass a function to ko.memoization.memoize()");var b=(4294967296*(1+Math.random())|0).toString(16).substring(1)+(4294967296*(1+Math.random())|0).toString(16).substring(1);c[b]=a;return"\x3c!--[ko_memo:"+b+"]--\x3e"},bd:function(a,b){var f=c[a];if(f===n)throw Error("Couldn't find any memo with ID "+a+". Perhaps it's already been unmemoized.");try{return f.apply(null,b||[]),!0}finally{delete c[a]}},cd:function(c,e){var f=
[];b(c,f);for(var g=0,h=f.length;g<h;g++){var m=f[g].ud,k=[m];e&&a.a.Nb(k,e);a.aa.bd(f[g].Kd,k);m.nodeValue="";m.parentNode&&m.parentNode.removeChild(m)}},Uc:function(a){return(a=a.match(/^\[ko_memo\:(.*?)\]$/))?a[1]:null}}}();a.b("memoization",a.aa);a.b("memoization.memoize",a.aa.Xb);a.b("memoization.unmemoize",a.aa.bd);a.b("memoization.parseMemoText",a.aa.Uc);a.b("memoization.unmemoizeDomNodeAndDescendants",a.aa.cd);a.na=function(){function b(){if(f)for(var b=f,c=0,d;h<f;)if(d=e[h++]){if(h>b){if(5E3<=
++c){h=f;a.a.Gc(Error("'Too much recursion' after processing "+c+" task groups."));break}b=f}try{d()}catch(p){a.a.Gc(p)}}}function c(){b();h=f=e.length=0}var d,e=[],f=0,g=1,h=0;A.MutationObserver?d=function(a){var b=w.createElement("div");(new MutationObserver(a)).observe(b,{attributes:!0});return function(){b.classList.toggle("foo")}}(c):d=w&&"onreadystatechange"in w.createElement("script")?function(a){var b=w.createElement("script");b.onreadystatechange=function(){b.onreadystatechange=null;w.documentElement.removeChild(b);
b=null;a()};w.documentElement.appendChild(b)}:function(a){setTimeout(a,0)};return{scheduler:d,zb:function(b){f||a.na.scheduler(c);e[f++]=b;return g++},cancel:function(a){a=a-(g-f);a>=h&&a<f&&(e[a]=null)},resetForTesting:function(){var a=f-h;h=f=e.length=0;return a},Sd:b}}();a.b("tasks",a.na);a.b("tasks.schedule",a.na.zb);a.b("tasks.runEarly",a.na.Sd);a.Ta={throttle:function(b,c){b.throttleEvaluation=c;var d=null;return a.$({read:b,write:function(e){clearTimeout(d);d=a.a.setTimeout(function(){b(e)},
c)}})},rateLimit:function(a,c){var d,e,f;"number"==typeof c?d=c:(d=c.timeout,e=c.method);a.Hb=!1;f="function"==typeof e?e:"notifyWhenChangesStop"==e?Y:X;a.ub(function(a){return f(a,d,c)})},deferred:function(b,c){if(!0!==c)throw Error("The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled.");b.Hb||(b.Hb=!0,b.ub(function(c){var e,f=!1;return function(){if(!f){a.na.cancel(e);e=a.na.zb(c);try{f=!0,b.notifySubscribers(n,"dirty")}finally{f=
!1}}}}))},notify:function(a,c){a.equalityComparer="always"==c?null:K}};var W={undefined:1,"boolean":1,number:1,string:1};a.b("extenders",a.Ta);a.ic=function(b,c,d){this.da=b;this.lc=c;this.mc=d;this.Ib=!1;this.fb=this.Jb=null;a.L(this,"dispose",this.s);a.L(this,"disposeWhenNodeIsRemoved",this.l)};a.ic.prototype.s=function(){this.Ib||(this.fb&&a.a.K.yb(this.Jb,this.fb),this.Ib=!0,this.mc(),this.da=this.lc=this.mc=this.Jb=this.fb=null)};a.ic.prototype.l=function(b){this.Jb=b;a.a.K.za(b,this.fb=this.s.bind(this))};
a.T=function(){a.a.Ab(this,D);D.qb(this)};var D={qb:function(a){a.U={change:[]};a.sc=1},subscribe:function(b,c,d){var e=this;d=d||"change";var f=new a.ic(e,c?b.bind(c):b,function(){a.a.Pa(e.U[d],f);e.hb&&e.hb(d)});e.Qa&&e.Qa(d);e.U[d]||(e.U[d]=[]);e.U[d].push(f);return f},notifySubscribers:function(b,c){c=c||"change";"change"===c&&this.Gb();if(this.Wa(c)){var d="change"===c&&this.ed||this.U[c].slice(0);try{a.u.xc();for(var e=0,f;f=d[e];++e)f.Ib||f.lc(b)}finally{a.u.end()}}},ob:function(){return this.sc},
Dd:function(a){return this.ob()!==a},Gb:function(){++this.sc},ub:function(b){var c=this,d=a.O(c),e,f,g,h,m;c.gb||(c.gb=c.notifySubscribers,c.notifySubscribers=Z);var k=b(function(){c.Ja=!1;d&&h===c&&(h=c.nc?c.nc():c());var a=f||m&&c.sb(g,h);m=f=e=!1;a&&c.gb(g=h)});c.qc=function(a,b){b&&c.Ja||(m=!b);c.ed=c.U.change.slice(0);c.Ja=e=!0;h=a;k()};c.pc=function(a){e||(g=a,c.gb(a,"beforeChange"))};c.rc=function(){m=!0};c.gd=function(){c.sb(g,c.v(!0))&&(f=!0)}},Wa:function(a){return this.U[a]&&this.U[a].length},
Bd:function(b){if(b)return this.U[b]&&this.U[b].length||0;var c=0;a.a.P(this.U,function(a,b){"dirty"!==a&&(c+=b.length)});return c},sb:function(a,c){return!this.equalityComparer||!this.equalityComparer(a,c)},toString:function(){return"[object Object]"},extend:function(b){var c=this;b&&a.a.P(b,function(b,e){var f=a.Ta[b];"function"==typeof f&&(c=f(c,e)||c)});return c}};a.L(D,"init",D.qb);a.L(D,"subscribe",D.subscribe);a.L(D,"extend",D.extend);a.L(D,"getSubscriptionsCount",D.Bd);a.a.Ba&&a.a.setPrototypeOf(D,
Function.prototype);a.T.fn=D;a.Qc=function(a){return null!=a&&"function"==typeof a.subscribe&&"function"==typeof a.notifySubscribers};a.b("subscribable",a.T);a.b("isSubscribable",a.Qc);a.S=a.u=function(){function b(a){d.push(e);e=a}function c(){e=d.pop()}var d=[],e,f=0;return{xc:b,end:c,cc:function(b){if(e){if(!a.Qc(b))throw Error("Only subscribable things can act as dependencies");e.od.call(e.pd,b,b.fd||(b.fd=++f))}},G:function(a,d,e){try{return b(),a.apply(d,e||[])}finally{c()}},qa:function(){if(e)return e.o.qa()},
Va:function(){if(e)return e.o.Va()},Ya:function(){if(e)return e.Ya},o:function(){if(e)return e.o}}}();a.b("computedContext",a.S);a.b("computedContext.getDependenciesCount",a.S.qa);a.b("computedContext.getDependencies",a.S.Va);a.b("computedContext.isInitial",a.S.Ya);a.b("computedContext.registerDependency",a.S.cc);a.b("ignoreDependencies",a.Yd=a.u.G);var I=a.a.Da("_latestValue");a.ta=function(b){function c(){if(0<arguments.length)return c.sb(c[I],arguments[0])&&(c.ya(),c[I]=arguments[0],c.xa()),this;
a.u.cc(c);return c[I]}c[I]=b;a.a.Ba||a.a.extend(c,a.T.fn);a.T.fn.qb(c);a.a.Ab(c,F);a.options.deferUpdates&&a.Ta.deferred(c,!0);return c};var F={equalityComparer:K,v:function(){return this[I]},xa:function(){this.notifySubscribers(this[I],"spectate");this.notifySubscribers(this[I])},ya:function(){this.notifySubscribers(this[I],"beforeChange")}};a.a.Ba&&a.a.setPrototypeOf(F,a.T.fn);var G=a.ta.Ma="__ko_proto__";F[G]=a.ta;a.O=function(b){if((b="function"==typeof b&&b[G])&&b!==F[G]&&b!==a.o.fn[G])throw Error("Invalid object that looks like an observable; possibly from another Knockout instance");
return!!b};a.Za=function(b){return"function"==typeof b&&(b[G]===F[G]||b[G]===a.o.fn[G]&&b.Nc)};a.b("observable",a.ta);a.b("isObservable",a.O);a.b("isWriteableObservable",a.Za);a.b("isWritableObservable",a.Za);a.b("observable.fn",F);a.L(F,"peek",F.v);a.L(F,"valueHasMutated",F.xa);a.L(F,"valueWillMutate",F.ya);a.Ha=function(b){b=b||[];if("object"!=typeof b||!("length"in b))throw Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");b=a.ta(b);a.a.Ab(b,
a.Ha.fn);return b.extend({trackArrayChanges:!0})};a.Ha.fn={remove:function(b){for(var c=this.v(),d=[],e="function"!=typeof b||a.O(b)?function(a){return a===b}:b,f=0;f<c.length;f++){var g=c[f];if(e(g)){0===d.length&&this.ya();if(c[f]!==g)throw Error("Array modified during remove; cannot remove item");d.push(g);c.splice(f,1);f--}}d.length&&this.xa();return d},removeAll:function(b){if(b===n){var c=this.v(),d=c.slice(0);this.ya();c.splice(0,c.length);this.xa();return d}return b?this.remove(function(c){return 0<=
a.a.A(b,c)}):[]},destroy:function(b){var c=this.v(),d="function"!=typeof b||a.O(b)?function(a){return a===b}:b;this.ya();for(var e=c.length-1;0<=e;e--){var f=c[e];d(f)&&(f._destroy=!0)}this.xa()},destroyAll:function(b){return b===n?this.destroy(function(){return!0}):b?this.destroy(function(c){return 0<=a.a.A(b,c)}):[]},indexOf:function(b){var c=this();return a.a.A(c,b)},replace:function(a,c){var d=this.indexOf(a);0<=d&&(this.ya(),this.v()[d]=c,this.xa())},sorted:function(a){var c=this().slice(0);
return a?c.sort(a):c.sort()},reversed:function(){return this().slice(0).reverse()}};a.a.Ba&&a.a.setPrototypeOf(a.Ha.fn,a.ta.fn);a.a.D("pop push reverse shift sort splice unshift".split(" "),function(b){a.Ha.fn[b]=function(){var a=this.v();this.ya();this.zc(a,b,arguments);var d=a[b].apply(a,arguments);this.xa();return d===a?this:d}});a.a.D(["slice"],function(b){a.Ha.fn[b]=function(){var a=this();return a[b].apply(a,arguments)}});a.Pc=function(b){return a.O(b)&&"function"==typeof b.remove&&"function"==
typeof b.push};a.b("observableArray",a.Ha);a.b("isObservableArray",a.Pc);a.Ta.trackArrayChanges=function(b,c){function d(){function c(){if(m){var d=[].concat(b.v()||[]),e;if(b.Wa("arrayChange")){if(!f||1<m)f=a.a.Pb(k,d,b.Ob);e=f}k=d;f=null;m=0;e&&e.length&&b.notifySubscribers(e,"arrayChange")}}e?c():(e=!0,h=b.subscribe(function(){++m},null,"spectate"),k=[].concat(b.v()||[]),f=null,g=b.subscribe(c))}b.Ob={};c&&"object"==typeof c&&a.a.extend(b.Ob,c);b.Ob.sparse=!0;if(!b.zc){var e=!1,f=null,g,h,m=0,
k,l=b.Qa,p=b.hb;b.Qa=function(a){l&&l.call(b,a);"arrayChange"===a&&d()};b.hb=function(a){p&&p.call(b,a);"arrayChange"!==a||b.Wa("arrayChange")||(g&&g.s(),h&&h.s(),h=g=null,e=!1,k=n)};b.zc=function(b,c,d){function l(a,b,c){return k[k.length]={status:a,value:b,index:c}}if(e&&!m){var k=[],p=b.length,g=d.length,h=0;switch(c){case "push":h=p;case "unshift":for(c=0;c<g;c++)l("added",d[c],h+c);break;case "pop":h=p-1;case "shift":p&&l("deleted",b[h],h);break;case "splice":c=Math.min(Math.max(0,0>d[0]?p+d[0]:
d[0]),p);for(var p=1===g?p:Math.min(c+(d[1]||0),p),g=c+g-2,h=Math.max(p,g),U=[],L=[],n=2;c<h;++c,++n)c<p&&L.push(l("deleted",b[c],c)),c<g&&U.push(l("added",d[n],c));a.a.Kc(L,U);break;default:return}f=k}}}};var r=a.a.Da("_state");a.o=a.$=function(b,c,d){function e(){if(0<arguments.length){if("function"===typeof f)f.apply(g.nb,arguments);else throw Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");return this}g.ra||
a.u.cc(e);(g.ka||g.J&&e.Xa())&&e.ha();return g.X}"object"===typeof b?d=b:(d=d||{},b&&(d.read=b));if("function"!=typeof d.read)throw Error("Pass a function that returns the value of the ko.computed");var f=d.write,g={X:n,sa:!0,ka:!0,rb:!1,jc:!1,ra:!1,wb:!1,J:!1,Wc:d.read,nb:c||d.owner,l:d.disposeWhenNodeIsRemoved||d.l||null,Sa:d.disposeWhen||d.Sa,Rb:null,I:{},V:0,Ic:null};e[r]=g;e.Nc="function"===typeof f;a.a.Ba||a.a.extend(e,a.T.fn);a.T.fn.qb(e);a.a.Ab(e,C);d.pure?(g.wb=!0,g.J=!0,a.a.extend(e,da)):
d.deferEvaluation&&a.a.extend(e,ea);a.options.deferUpdates&&a.Ta.deferred(e,!0);g.l&&(g.jc=!0,g.l.nodeType||(g.l=null));g.J||d.deferEvaluation||e.ha();g.l&&e.ja()&&a.a.K.za(g.l,g.Rb=function(){e.s()});return e};var C={equalityComparer:K,qa:function(){return this[r].V},Va:function(){var b=[];a.a.P(this[r].I,function(a,d){b[d.Ka]=d.da});return b},Vb:function(b){if(!this[r].V)return!1;var c=this.Va();return-1!==a.a.A(c,b)?!0:!!a.a.Lb(c,function(a){return a.Vb&&a.Vb(b)})},uc:function(a,c,d){if(this[r].wb&&
c===this)throw Error("A 'pure' computed must not be called recursively");this[r].I[a]=d;d.Ka=this[r].V++;d.La=c.ob()},Xa:function(){var a,c,d=this[r].I;for(a in d)if(Object.prototype.hasOwnProperty.call(d,a)&&(c=d[a],this.Ia&&c.da.Ja||c.da.Dd(c.La)))return!0},Jd:function(){this.Ia&&!this[r].rb&&this.Ia(!1)},ja:function(){var a=this[r];return a.ka||0<a.V},Rd:function(){this.Ja?this[r].ka&&(this[r].sa=!0):this.Hc()},$c:function(a){if(a.Hb){var c=a.subscribe(this.Jd,this,"dirty"),d=a.subscribe(this.Rd,
this);return{da:a,s:function(){c.s();d.s()}}}return a.subscribe(this.Hc,this)},Hc:function(){var b=this,c=b.throttleEvaluation;c&&0<=c?(clearTimeout(this[r].Ic),this[r].Ic=a.a.setTimeout(function(){b.ha(!0)},c)):b.Ia?b.Ia(!0):b.ha(!0)},ha:function(b){var c=this[r],d=c.Sa,e=!1;if(!c.rb&&!c.ra){if(c.l&&!a.a.Sb(c.l)||d&&d()){if(!c.jc){this.s();return}}else c.jc=!1;c.rb=!0;try{e=this.zd(b)}finally{c.rb=!1}return e}},zd:function(b){var c=this[r],d=!1,e=c.wb?n:!c.V,d={qd:this,mb:c.I,Qb:c.V};a.u.xc({pd:d,
od:ba,o:this,Ya:e});c.I={};c.V=0;var f=this.yd(c,d);c.V?d=this.sb(c.X,f):(this.s(),d=!0);d&&(c.J?this.Gb():this.notifySubscribers(c.X,"beforeChange"),c.X=f,this.notifySubscribers(c.X,"spectate"),!c.J&&b&&this.notifySubscribers(c.X),this.rc&&this.rc());e&&this.notifySubscribers(c.X,"awake");return d},yd:function(b,c){try{var d=b.Wc;return b.nb?d.call(b.nb):d()}finally{a.u.end(),c.Qb&&!b.J&&a.a.P(c.mb,aa),b.sa=b.ka=!1}},v:function(a){var c=this[r];(c.ka&&(a||!c.V)||c.J&&this.Xa())&&this.ha();return c.X},
ub:function(b){a.T.fn.ub.call(this,b);this.nc=function(){this[r].J||(this[r].sa?this.ha():this[r].ka=!1);return this[r].X};this.Ia=function(a){this.pc(this[r].X);this[r].ka=!0;a&&(this[r].sa=!0);this.qc(this,!a)}},s:function(){var b=this[r];!b.J&&b.I&&a.a.P(b.I,function(a,b){b.s&&b.s()});b.l&&b.Rb&&a.a.K.yb(b.l,b.Rb);b.I=n;b.V=0;b.ra=!0;b.sa=!1;b.ka=!1;b.J=!1;b.l=n;b.Sa=n;b.Wc=n;this.Nc||(b.nb=n)}},da={Qa:function(b){var c=this,d=c[r];if(!d.ra&&d.J&&"change"==b){d.J=!1;if(d.sa||c.Xa())d.I=null,d.V=
0,c.ha()&&c.Gb();else{var e=[];a.a.P(d.I,function(a,b){e[b.Ka]=a});a.a.D(e,function(a,b){var e=d.I[a],m=c.$c(e.da);m.Ka=b;m.La=e.La;d.I[a]=m});c.Xa()&&c.ha()&&c.Gb()}d.ra||c.notifySubscribers(d.X,"awake")}},hb:function(b){var c=this[r];c.ra||"change"!=b||this.Wa("change")||(a.a.P(c.I,function(a,b){b.s&&(c.I[a]={da:b.da,Ka:b.Ka,La:b.La},b.s())}),c.J=!0,this.notifySubscribers(n,"asleep"))},ob:function(){var b=this[r];b.J&&(b.sa||this.Xa())&&this.ha();return a.T.fn.ob.call(this)}},ea={Qa:function(a){"change"!=
a&&"beforeChange"!=a||this.v()}};a.a.Ba&&a.a.setPrototypeOf(C,a.T.fn);var N=a.ta.Ma;C[N]=a.o;a.Oc=function(a){return"function"==typeof a&&a[N]===C[N]};a.Fd=function(b){return a.Oc(b)&&b[r]&&b[r].wb};a.b("computed",a.o);a.b("dependentObservable",a.o);a.b("isComputed",a.Oc);a.b("isPureComputed",a.Fd);a.b("computed.fn",C);a.L(C,"peek",C.v);a.L(C,"dispose",C.s);a.L(C,"isActive",C.ja);a.L(C,"getDependenciesCount",C.qa);a.L(C,"getDependencies",C.Va);a.xb=function(b,c){if("function"===typeof b)return a.o(b,
c,{pure:!0});b=a.a.extend({},b);b.pure=!0;return a.o(b,c)};a.b("pureComputed",a.xb);(function(){function b(a,f,g){g=g||new d;a=f(a);if("object"!=typeof a||null===a||a===n||a instanceof RegExp||a instanceof Date||a instanceof String||a instanceof Number||a instanceof Boolean)return a;var h=a instanceof Array?[]:{};g.save(a,h);c(a,function(c){var d=f(a[c]);switch(typeof d){case "boolean":case "number":case "string":case "function":h[c]=d;break;case "object":case "undefined":var l=g.get(d);h[c]=l!==
n?l:b(d,f,g)}});return h}function c(a,b){if(a instanceof Array){for(var c=0;c<a.length;c++)b(c);"function"==typeof a.toJSON&&b("toJSON")}else for(c in a)b(c)}function d(){this.keys=[];this.values=[]}a.ad=function(c){if(0==arguments.length)throw Error("When calling ko.toJS, pass the object you want to convert.");return b(c,function(b){for(var c=0;a.O(b)&&10>c;c++)b=b();return b})};a.toJSON=function(b,c,d){b=a.ad(b);return a.a.hc(b,c,d)};d.prototype={constructor:d,save:function(b,c){var d=a.a.A(this.keys,
b);0<=d?this.values[d]=c:(this.keys.push(b),this.values.push(c))},get:function(b){b=a.a.A(this.keys,b);return 0<=b?this.values[b]:n}}})();a.b("toJS",a.ad);a.b("toJSON",a.toJSON);a.Wd=function(b,c,d){function e(c){var e=a.xb(b,d).extend({ma:"always"}),h=e.subscribe(function(a){a&&(h.s(),c(a))});e.notifySubscribers(e.v());return h}return"function"!==typeof Promise||c?e(c.bind(d)):new Promise(e)};a.b("when",a.Wd);(function(){a.w={M:function(b){switch(a.a.R(b)){case "option":return!0===b.__ko__hasDomDataOptionValue__?
a.a.g.get(b,a.c.options.$b):7>=a.a.W?b.getAttributeNode("value")&&b.getAttributeNode("value").specified?b.value:b.text:b.value;case "select":return 0<=b.selectedIndex?a.w.M(b.options[b.selectedIndex]):n;default:return b.value}},cb:function(b,c,d){switch(a.a.R(b)){case "option":"string"===typeof c?(a.a.g.set(b,a.c.options.$b,n),"__ko__hasDomDataOptionValue__"in b&&delete b.__ko__hasDomDataOptionValue__,b.value=c):(a.a.g.set(b,a.c.options.$b,c),b.__ko__hasDomDataOptionValue__=!0,b.value="number"===
typeof c?c:"");break;case "select":if(""===c||null===c)c=n;for(var e=-1,f=0,g=b.options.length,h;f<g;++f)if(h=a.w.M(b.options[f]),h==c||""===h&&c===n){e=f;break}if(d||0<=e||c===n&&1<b.size)b.selectedIndex=e,6===a.a.W&&a.a.setTimeout(function(){b.selectedIndex=e},0);break;default:if(null===c||c===n)c="";b.value=c}}}})();a.b("selectExtensions",a.w);a.b("selectExtensions.readValue",a.w.M);a.b("selectExtensions.writeValue",a.w.cb);a.m=function(){function b(b){b=a.a.Db(b);123===b.charCodeAt(0)&&(b=b.slice(1,
-1));b+="\n,";var c=[],d=b.match(e),p,q=[],h=0;if(1<d.length){for(var x=0,B;B=d[x];++x){var u=B.charCodeAt(0);if(44===u){if(0>=h){c.push(p&&q.length?{key:p,value:q.join("")}:{unknown:p||q.join("")});p=h=0;q=[];continue}}else if(58===u){if(!h&&!p&&1===q.length){p=q.pop();continue}}else if(47===u&&1<B.length&&(47===B.charCodeAt(1)||42===B.charCodeAt(1)))continue;else 47===u&&x&&1<B.length?(u=d[x-1].match(f))&&!g[u[0]]&&(b=b.substr(b.indexOf(B)+1),d=b.match(e),x=-1,B="/"):40===u||123===u||91===u?++h:
41===u||125===u||93===u?--h:p||q.length||34!==u&&39!==u||(B=B.slice(1,-1));q.push(B)}if(0<h)throw Error("Unbalanced parentheses, braces, or brackets");}return c}var c=["true","false","null","undefined"],d=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i,e=RegExp("\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|`(?:\\\\.|[^`])*`|/\\*(?:[^*]|\\*+[^*/])*\\*+/|//.*\n|/(?:\\\\.|[^/])+/w*|[^\\s:,/][^,\"'`{}()/:[\\]]*[^\\s,\"'`{}()/:[\\]]|[^\\s]","g"),f=/[\])"'A-Za-z0-9_$]+$/,g={"in":1,"return":1,"typeof":1},
h={};return{Ra:[],wa:h,ac:b,vb:function(e,f){function l(b,e){var f;if(!x){var k=a.getBindingHandler(b);if(k&&k.preprocess&&!(e=k.preprocess(e,b,l)))return;if(k=h[b])f=e,0<=a.a.A(c,f)?f=!1:(k=f.match(d),f=null===k?!1:k[1]?"Object("+k[1]+")"+k[2]:f),k=f;k&&q.push("'"+("string"==typeof h[b]?h[b]:b)+"':function(_z){"+f+"=_z}")}g&&(e="function(){return "+e+" }");p.push("'"+b+"':"+e)}f=f||{};var p=[],q=[],g=f.valueAccessors,x=f.bindingParams,B="string"===typeof e?b(e):e;a.a.D(B,function(a){l(a.key||a.unknown,
a.value)});q.length&&l("_ko_property_writers","{"+q.join(",")+" }");return p.join(",")},Id:function(a,b){for(var c=0;c<a.length;c++)if(a[c].key==b)return!0;return!1},eb:function(b,c,d,e,f){if(b&&a.O(b))!a.Za(b)||f&&b.v()===e||b(e);else if((b=c.get("_ko_property_writers"))&&b[d])b[d](e)}}}();a.b("expressionRewriting",a.m);a.b("expressionRewriting.bindingRewriteValidators",a.m.Ra);a.b("expressionRewriting.parseObjectLiteral",a.m.ac);a.b("expressionRewriting.preProcessBindings",a.m.vb);a.b("expressionRewriting._twoWayBindings",
a.m.wa);a.b("jsonExpressionRewriting",a.m);a.b("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",a.m.vb);(function(){function b(a){return 8==a.nodeType&&g.test(f?a.text:a.nodeValue)}function c(a){return 8==a.nodeType&&h.test(f?a.text:a.nodeValue)}function d(d,e){for(var f=d,h=1,g=[];f=f.nextSibling;){if(c(f)&&(a.a.g.set(f,k,!0),h--,0===h))return g;g.push(f);b(f)&&h++}if(!e)throw Error("Cannot find closing comment tag to match: "+d.nodeValue);return null}function e(a,b){var c=d(a,b);return c?
0<c.length?c[c.length-1].nextSibling:a.nextSibling:null}var f=w&&"\x3c!--test--\x3e"===w.createComment("test").text,g=f?/^\x3c!--\s*ko(?:\s+([\s\S]+))?\s*--\x3e$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,h=f?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,m={ul:!0,ol:!0},k="__ko_matchedEndComment__";a.h={ea:{},childNodes:function(a){return b(a)?d(a):a.childNodes},Ea:function(c){if(b(c)){c=a.h.childNodes(c);for(var d=0,e=c.length;d<e;d++)a.removeNode(c[d])}else a.a.Tb(c)},va:function(c,d){if(b(c)){a.h.Ea(c);for(var e=
c.nextSibling,f=0,k=d.length;f<k;f++)e.parentNode.insertBefore(d[f],e)}else a.a.va(c,d)},Vc:function(a,c){var d;b(a)?(d=a.nextSibling,a=a.parentNode):d=a.firstChild;d?c!==d&&a.insertBefore(c,d):a.appendChild(c)},Wb:function(c,d,e){e?(e=e.nextSibling,b(c)&&(c=c.parentNode),e?d!==e&&c.insertBefore(d,e):c.appendChild(d)):a.h.Vc(c,d)},firstChild:function(a){if(b(a))return!a.nextSibling||c(a.nextSibling)?null:a.nextSibling;if(a.firstChild&&c(a.firstChild))throw Error("Found invalid end comment, as the first child of "+
a);return a.firstChild},nextSibling:function(d){b(d)&&(d=e(d));if(d.nextSibling&&c(d.nextSibling)){var f=d.nextSibling;if(c(f)&&!a.a.g.get(f,k))throw Error("Found end comment without a matching opening comment, as child of "+d);return null}return d.nextSibling},Cd:b,Vd:function(a){return(a=(f?a.text:a.nodeValue).match(g))?a[1]:null},Sc:function(d){if(m[a.a.R(d)]){var f=d.firstChild;if(f){do if(1===f.nodeType){var k;k=f.firstChild;var h=null;if(k){do if(h)h.push(k);else if(b(k)){var g=e(k,!0);g?k=
g:h=[k]}else c(k)&&(h=[k]);while(k=k.nextSibling)}if(k=h)for(h=f.nextSibling,g=0;g<k.length;g++)h?d.insertBefore(k[g],h):d.appendChild(k[g])}while(f=f.nextSibling)}}}}})();a.b("virtualElements",a.h);a.b("virtualElements.allowedBindings",a.h.ea);a.b("virtualElements.emptyNode",a.h.Ea);a.b("virtualElements.insertAfter",a.h.Wb);a.b("virtualElements.prepend",a.h.Vc);a.b("virtualElements.setDomNodeChildren",a.h.va);(function(){a.ga=function(){this.nd={}};a.a.extend(a.ga.prototype,{nodeHasBindings:function(b){switch(b.nodeType){case 1:return null!=
b.getAttribute("data-bind")||a.j.getComponentNameForNode(b);case 8:return a.h.Cd(b);default:return!1}},getBindings:function(b,c){var d=this.getBindingsString(b,c),d=d?this.parseBindingsString(d,c,b):null;return a.j.tc(d,b,c,!1)},getBindingAccessors:function(b,c){var d=this.getBindingsString(b,c),d=d?this.parseBindingsString(d,c,b,{valueAccessors:!0}):null;return a.j.tc(d,b,c,!0)},getBindingsString:function(b){switch(b.nodeType){case 1:return b.getAttribute("data-bind");case 8:return a.h.Vd(b);default:return null}},
parseBindingsString:function(b,c,d,e){try{var f=this.nd,g=b+(e&&e.valueAccessors||""),h;if(!(h=f[g])){var m,k="with($context){with($data||{}){return{"+a.m.vb(b,e)+"}}}";m=new Function("$context","$element",k);h=f[g]=m}return h(c,d)}catch(l){throw l.message="Unable to parse bindings.\nBindings value: "+b+"\nMessage: "+l.message,l;}}});a.ga.instance=new a.ga})();a.b("bindingProvider",a.ga);(function(){function b(b){var c=(b=a.a.g.get(b,z))&&b.N;c&&(b.N=null,c.Tc())}function c(c,d,e){this.node=c;this.yc=
d;this.kb=[];this.H=!1;d.N||a.a.K.za(c,b);e&&e.N&&(e.N.kb.push(c),this.Kb=e)}function d(a){return function(){return a}}function e(a){return a()}function f(b){return a.a.Ga(a.u.G(b),function(a,c){return function(){return b()[c]}})}function g(b,c,e){return"function"===typeof b?f(b.bind(null,c,e)):a.a.Ga(b,d)}function h(a,b){return f(this.getBindings.bind(this,a,b))}function m(b,c){var d=a.h.firstChild(c);if(d){var e,f=a.ga.instance,l=f.preprocessNode;if(l){for(;e=d;)d=a.h.nextSibling(e),l.call(f,e);
d=a.h.firstChild(c)}for(;e=d;)d=a.h.nextSibling(e),k(b,e)}a.i.ma(c,a.i.H)}function k(b,c){var d=b,e=1===c.nodeType;e&&a.h.Sc(c);if(e||a.ga.instance.nodeHasBindings(c))d=p(c,null,b).bindingContextForDescendants;d&&!u[a.a.R(c)]&&m(d,c)}function l(b){var c=[],d={},e=[];a.a.P(b,function ca(f){if(!d[f]){var k=a.getBindingHandler(f);k&&(k.after&&(e.push(f),a.a.D(k.after,function(c){if(b[c]){if(-1!==a.a.A(e,c))throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+e.join(", "));
ca(c)}}),e.length--),c.push({key:f,Mc:k}));d[f]=!0}});return c}function p(b,c,d){var f=a.a.g.Ub(b,z,{}),k=f.hd;if(!c){if(k)throw Error("You cannot apply bindings multiple times to the same element.");f.hd=!0}k||(f.context=d);f.Zb||(f.Zb={});var g;if(c&&"function"!==typeof c)g=c;else{var p=a.ga.instance,q=p.getBindingAccessors||h,m=a.$(function(){if(g=c?c(d,b):q.call(p,b,d)){if(d[t])d[t]();if(d[B])d[B]()}return g},null,{l:b});g&&m.ja()||(m=null)}var x=d,u;if(g){var J=function(){return a.a.Ga(m?m():
g,e)},r=m?function(a){return function(){return e(m()[a])}}:function(a){return g[a]};J.get=function(a){return g[a]&&e(r(a))};J.has=function(a){return a in g};a.i.H in g&&a.i.subscribe(b,a.i.H,function(){var c=(0,g[a.i.H])();if(c){var d=a.h.childNodes(b);d.length&&c(d,a.Ec(d[0]))}});a.i.pa in g&&(x=a.i.Cb(b,d),a.i.subscribe(b,a.i.pa,function(){var c=(0,g[a.i.pa])();c&&a.h.firstChild(b)&&c(b)}));f=l(g);a.a.D(f,function(c){var d=c.Mc.init,e=c.Mc.update,f=c.key;if(8===b.nodeType&&!a.h.ea[f])throw Error("The binding '"+
f+"' cannot be used with virtual elements");try{"function"==typeof d&&a.u.G(function(){var a=d(b,r(f),J,x.$data,x);if(a&&a.controlsDescendantBindings){if(u!==n)throw Error("Multiple bindings ("+u+" and "+f+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");u=f}}),"function"==typeof e&&a.$(function(){e(b,r(f),J,x.$data,x)},null,{l:b})}catch(k){throw k.message='Unable to process binding "'+f+": "+g[f]+'"\nMessage: '+k.message,
k;}})}f=u===n;return{shouldBindDescendants:f,bindingContextForDescendants:f&&x}}function q(b,c){return b&&b instanceof a.fa?b:new a.fa(b,n,n,c)}var t=a.a.Da("_subscribable"),x=a.a.Da("_ancestorBindingInfo"),B=a.a.Da("_dataDependency");a.c={};var u={script:!0,textarea:!0,template:!0};a.getBindingHandler=function(b){return a.c[b]};var J={};a.fa=function(b,c,d,e,f){function k(){var b=p?h():h,f=a.a.f(b);c?(a.a.extend(l,c),x in c&&(l[x]=c[x])):(l.$parents=[],l.$root=f,l.ko=a);l[t]=q;g?f=l.$data:(l.$rawData=
b,l.$data=f);d&&(l[d]=f);e&&e(l,c,f);if(c&&c[t]&&!a.S.o().Vb(c[t]))c[t]();m&&(l[B]=m);return l.$data}var l=this,g=b===J,h=g?n:b,p="function"==typeof h&&!a.O(h),q,m=f&&f.dataDependency;f&&f.exportDependencies?k():(q=a.xb(k),q.v(),q.ja()?q.equalityComparer=null:l[t]=n)};a.fa.prototype.createChildContext=function(b,c,d,e){!e&&c&&"object"==typeof c&&(e=c,c=e.as,d=e.extend);if(c&&e&&e.noChildContext){var f="function"==typeof b&&!a.O(b);return new a.fa(J,this,null,function(a){d&&d(a);a[c]=f?b():b},e)}return new a.fa(b,
this,c,function(a,b){a.$parentContext=b;a.$parent=b.$data;a.$parents=(b.$parents||[]).slice(0);a.$parents.unshift(a.$parent);d&&d(a)},e)};a.fa.prototype.extend=function(b,c){return new a.fa(J,this,null,function(c){a.a.extend(c,"function"==typeof b?b(c):b)},c)};var z=a.a.g.Z();c.prototype.Tc=function(){this.Kb&&this.Kb.N&&this.Kb.N.sd(this.node)};c.prototype.sd=function(b){a.a.Pa(this.kb,b);!this.kb.length&&this.H&&this.Cc()};c.prototype.Cc=function(){this.H=!0;this.yc.N&&!this.kb.length&&(this.yc.N=
null,a.a.K.yb(this.node,b),a.i.ma(this.node,a.i.pa),this.Tc())};a.i={H:"childrenComplete",pa:"descendantsComplete",subscribe:function(b,c,d,e,f){var k=a.a.g.Ub(b,z,{});k.Fa||(k.Fa=new a.T);f&&f.notifyImmediately&&k.Zb[c]&&a.u.G(d,e,[b]);return k.Fa.subscribe(d,e,c)},ma:function(b,c){var d=a.a.g.get(b,z);if(d&&(d.Zb[c]=!0,d.Fa&&d.Fa.notifySubscribers(b,c),c==a.i.H))if(d.N)d.N.Cc();else if(d.N===n&&d.Fa&&d.Fa.Wa(a.i.pa))throw Error("descendantsComplete event not supported for bindings on this node");
},Cb:function(b,d){var e=a.a.g.Ub(b,z,{});e.N||(e.N=new c(b,e,d[x]));return d[x]==e?d:d.extend(function(a){a[x]=e})}};a.Td=function(b){return(b=a.a.g.get(b,z))&&b.context};a.ib=function(b,c,d){1===b.nodeType&&a.h.Sc(b);return p(b,c,q(d))};a.ld=function(b,c,d){d=q(d);return a.ib(b,g(c,d,b),d)};a.Oa=function(a,b){1!==b.nodeType&&8!==b.nodeType||m(q(a),b)};a.vc=function(a,b,c){!v&&A.jQuery&&(v=A.jQuery);if(2>arguments.length){if(b=w.body,!b)throw Error("ko.applyBindings: could not find document.body; has the document been loaded?");
}else if(!b||1!==b.nodeType&&8!==b.nodeType)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");k(q(a,c),b)};a.Dc=function(b){return!b||1!==b.nodeType&&8!==b.nodeType?n:a.Td(b)};a.Ec=function(b){return(b=a.Dc(b))?b.$data:n};a.b("bindingHandlers",a.c);a.b("bindingEvent",a.i);a.b("bindingEvent.subscribe",a.i.subscribe);a.b("bindingEvent.startPossiblyAsyncContentBinding",a.i.Cb);a.b("applyBindings",a.vc);a.b("applyBindingsToDescendants",a.Oa);
a.b("applyBindingAccessorsToNode",a.ib);a.b("applyBindingsToNode",a.ld);a.b("contextFor",a.Dc);a.b("dataFor",a.Ec)})();(function(b){function c(c,e){var k=Object.prototype.hasOwnProperty.call(f,c)?f[c]:b,l;k?k.subscribe(e):(k=f[c]=new a.T,k.subscribe(e),d(c,function(b,d){var e=!(!d||!d.synchronous);g[c]={definition:b,Gd:e};delete f[c];l||e?k.notifySubscribers(b):a.na.zb(function(){k.notifySubscribers(b)})}),l=!0)}function d(a,b){e("getConfig",[a],function(c){c?e("loadComponent",[a,c],function(a){b(a,
c)}):b(null,null)})}function e(c,d,f,l){l||(l=a.j.loaders.slice(0));var g=l.shift();if(g){var q=g[c];if(q){var t=!1;if(q.apply(g,d.concat(function(a){t?f(null):null!==a?f(a):e(c,d,f,l)}))!==b&&(t=!0,!g.suppressLoaderExceptions))throw Error("Component loaders must supply values by invoking the callback, not by returning values synchronously.");}else e(c,d,f,l)}else f(null)}var f={},g={};a.j={get:function(d,e){var f=Object.prototype.hasOwnProperty.call(g,d)?g[d]:b;f?f.Gd?a.u.G(function(){e(f.definition)}):
a.na.zb(function(){e(f.definition)}):c(d,e)},Bc:function(a){delete g[a]},oc:e};a.j.loaders=[];a.b("components",a.j);a.b("components.get",a.j.get);a.b("components.clearCachedDefinition",a.j.Bc)})();(function(){function b(b,c,d,e){function g(){0===--B&&e(h)}var h={},B=2,u=d.template;d=d.viewModel;u?f(c,u,function(c){a.j.oc("loadTemplate",[b,c],function(a){h.template=a;g()})}):g();d?f(c,d,function(c){a.j.oc("loadViewModel",[b,c],function(a){h[m]=a;g()})}):g()}function c(a,b,d){if("function"===typeof b)d(function(a){return new b(a)});
else if("function"===typeof b[m])d(b[m]);else if("instance"in b){var e=b.instance;d(function(){return e})}else"viewModel"in b?c(a,b.viewModel,d):a("Unknown viewModel value: "+b)}function d(b){switch(a.a.R(b)){case "script":return a.a.ua(b.text);case "textarea":return a.a.ua(b.value);case "template":if(e(b.content))return a.a.Ca(b.content.childNodes)}return a.a.Ca(b.childNodes)}function e(a){return A.DocumentFragment?a instanceof DocumentFragment:a&&11===a.nodeType}function f(a,b,c){"string"===typeof b.require?
T||A.require?(T||A.require)([b.require],function(a){a&&"object"===typeof a&&a.Xd&&a["default"]&&(a=a["default"]);c(a)}):a("Uses require, but no AMD loader is present"):c(b)}function g(a){return function(b){throw Error("Component '"+a+"': "+b);}}var h={};a.j.register=function(b,c){if(!c)throw Error("Invalid configuration for "+b);if(a.j.tb(b))throw Error("Component "+b+" is already registered");h[b]=c};a.j.tb=function(a){return Object.prototype.hasOwnProperty.call(h,a)};a.j.unregister=function(b){delete h[b];
a.j.Bc(b)};a.j.Fc={getConfig:function(b,c){c(a.j.tb(b)?h[b]:null)},loadComponent:function(a,c,d){var e=g(a);f(e,c,function(c){b(a,e,c,d)})},loadTemplate:function(b,c,f){b=g(b);if("string"===typeof c)f(a.a.ua(c));else if(c instanceof Array)f(c);else if(e(c))f(a.a.la(c.childNodes));else if(c.element)if(c=c.element,A.HTMLElement?c instanceof HTMLElement:c&&c.tagName&&1===c.nodeType)f(d(c));else if("string"===typeof c){var h=w.getElementById(c);h?f(d(h)):b("Cannot find element with ID "+c)}else b("Unknown element type: "+
c);else b("Unknown template value: "+c)},loadViewModel:function(a,b,d){c(g(a),b,d)}};var m="createViewModel";a.b("components.register",a.j.register);a.b("components.isRegistered",a.j.tb);a.b("components.unregister",a.j.unregister);a.b("components.defaultLoader",a.j.Fc);a.j.loaders.push(a.j.Fc);a.j.dd=h})();(function(){function b(b,e){var f=b.getAttribute("params");if(f){var f=c.parseBindingsString(f,e,b,{valueAccessors:!0,bindingParams:!0}),f=a.a.Ga(f,function(c){return a.o(c,null,{l:b})}),g=a.a.Ga(f,
function(c){var e=c.v();return c.ja()?a.o({read:function(){return a.a.f(c())},write:a.Za(e)&&function(a){c()(a)},l:b}):e});Object.prototype.hasOwnProperty.call(g,"$raw")||(g.$raw=f);return g}return{$raw:{}}}a.j.getComponentNameForNode=function(b){var c=a.a.R(b);if(a.j.tb(c)&&(-1!=c.indexOf("-")||"[object HTMLUnknownElement]"==""+b||8>=a.a.W&&b.tagName===c))return c};a.j.tc=function(c,e,f,g){if(1===e.nodeType){var h=a.j.getComponentNameForNode(e);if(h){c=c||{};if(c.component)throw Error('Cannot use the "component" binding on a custom element matching a component');
var m={name:h,params:b(e,f)};c.component=g?function(){return m}:m}}return c};var c=new a.ga;9>a.a.W&&(a.j.register=function(a){return function(b){return a.apply(this,arguments)}}(a.j.register),w.createDocumentFragment=function(b){return function(){var c=b(),f=a.j.dd,g;for(g in f);return c}}(w.createDocumentFragment))})();(function(){function b(b,c,d){c=c.template;if(!c)throw Error("Component '"+b+"' has no template");b=a.a.Ca(c);a.h.va(d,b)}function c(a,b,c){var d=a.createViewModel;return d?d.call(a,
b,c):b}var d=0;a.c.component={init:function(e,f,g,h,m){function k(){var a=l&&l.dispose;"function"===typeof a&&a.call(l);q&&q.s();p=l=q=null}var l,p,q,t=a.a.la(a.h.childNodes(e));a.h.Ea(e);a.a.K.za(e,k);a.o(function(){var g=a.a.f(f()),h,u;"string"===typeof g?h=g:(h=a.a.f(g.name),u=a.a.f(g.params));if(!h)throw Error("No component name specified");var n=a.i.Cb(e,m),z=p=++d;a.j.get(h,function(d){if(p===z){k();if(!d)throw Error("Unknown component '"+h+"'");b(h,d,e);var f=c(d,u,{element:e,templateNodes:t});
d=n.createChildContext(f,{extend:function(a){a.$component=f;a.$componentTemplateNodes=t}});f&&f.koDescendantsComplete&&(q=a.i.subscribe(e,a.i.pa,f.koDescendantsComplete,f));l=f;a.Oa(d,e)}})},null,{l:e});return{controlsDescendantBindings:!0}}};a.h.ea.component=!0})();var V={"class":"className","for":"htmlFor"};a.c.attr={update:function(b,c){var d=a.a.f(c())||{};a.a.P(d,function(c,d){d=a.a.f(d);var g=c.indexOf(":"),g="lookupNamespaceURI"in b&&0<g&&b.lookupNamespaceURI(c.substr(0,g)),h=!1===d||null===
d||d===n;h?g?b.removeAttributeNS(g,c):b.removeAttribute(c):d=d.toString();8>=a.a.W&&c in V?(c=V[c],h?b.removeAttribute(c):b[c]=d):h||(g?b.setAttributeNS(g,c,d):b.setAttribute(c,d));"name"===c&&a.a.Yc(b,h?"":d)})}};(function(){a.c.checked={after:["value","attr"],init:function(b,c,d){function e(){var e=b.checked,f=g();if(!a.S.Ya()&&(e||!m&&!a.S.qa())){var k=a.u.G(c);if(l){var q=p?k.v():k,z=t;t=f;z!==f?e&&(a.a.Na(q,f,!0),a.a.Na(q,z,!1)):a.a.Na(q,f,e);p&&a.Za(k)&&k(q)}else h&&(f===n?f=e:e||(f=n)),a.m.eb(k,
d,"checked",f,!0)}}function f(){var d=a.a.f(c()),e=g();l?(b.checked=0<=a.a.A(d,e),t=e):b.checked=h&&e===n?!!d:g()===d}var g=a.xb(function(){if(d.has("checkedValue"))return a.a.f(d.get("checkedValue"));if(q)return d.has("value")?a.a.f(d.get("value")):b.value}),h="checkbox"==b.type,m="radio"==b.type;if(h||m){var k=c(),l=h&&a.a.f(k)instanceof Array,p=!(l&&k.push&&k.splice),q=m||l,t=l?g():n;m&&!b.name&&a.c.uniqueName.init(b,function(){return!0});a.o(e,null,{l:b});a.a.B(b,"click",e);a.o(f,null,{l:b});
k=n}}};a.m.wa.checked=!0;a.c.checkedValue={update:function(b,c){b.value=a.a.f(c())}}})();a.c["class"]={update:function(b,c){var d=a.a.Db(a.a.f(c()));a.a.Eb(b,b.__ko__cssValue,!1);b.__ko__cssValue=d;a.a.Eb(b,d,!0)}};a.c.css={update:function(b,c){var d=a.a.f(c());null!==d&&"object"==typeof d?a.a.P(d,function(c,d){d=a.a.f(d);a.a.Eb(b,c,d)}):a.c["class"].update(b,c)}};a.c.enable={update:function(b,c){var d=a.a.f(c());d&&b.disabled?b.removeAttribute("disabled"):d||b.disabled||(b.disabled=!0)}};a.c.disable=
{update:function(b,c){a.c.enable.update(b,function(){return!a.a.f(c())})}};a.c.event={init:function(b,c,d,e,f){var g=c()||{};a.a.P(g,function(g){"string"==typeof g&&a.a.B(b,g,function(b){var k,l=c()[g];if(l){try{var p=a.a.la(arguments);e=f.$data;p.unshift(e);k=l.apply(e,p)}finally{!0!==k&&(b.preventDefault?b.preventDefault():b.returnValue=!1)}!1===d.get(g+"Bubble")&&(b.cancelBubble=!0,b.stopPropagation&&b.stopPropagation())}})})}};a.c.foreach={Rc:function(b){return function(){var c=b(),d=a.a.bc(c);
if(!d||"number"==typeof d.length)return{foreach:c,templateEngine:a.ba.Ma};a.a.f(c);return{foreach:d.data,as:d.as,noChildContext:d.noChildContext,includeDestroyed:d.includeDestroyed,afterAdd:d.afterAdd,beforeRemove:d.beforeRemove,afterRender:d.afterRender,beforeMove:d.beforeMove,afterMove:d.afterMove,templateEngine:a.ba.Ma}}},init:function(b,c){return a.c.template.init(b,a.c.foreach.Rc(c))},update:function(b,c,d,e,f){return a.c.template.update(b,a.c.foreach.Rc(c),d,e,f)}};a.m.Ra.foreach=!1;a.h.ea.foreach=
!0;a.c.hasfocus={init:function(b,c,d){function e(e){b.__ko_hasfocusUpdating=!0;var f=b.ownerDocument;if("activeElement"in f){var g;try{g=f.activeElement}catch(l){g=f.body}e=g===b}f=c();a.m.eb(f,d,"hasfocus",e,!0);b.__ko_hasfocusLastValue=e;b.__ko_hasfocusUpdating=!1}var f=e.bind(null,!0),g=e.bind(null,!1);a.a.B(b,"focus",f);a.a.B(b,"focusin",f);a.a.B(b,"blur",g);a.a.B(b,"focusout",g);b.__ko_hasfocusLastValue=!1},update:function(b,c){var d=!!a.a.f(c());b.__ko_hasfocusUpdating||b.__ko_hasfocusLastValue===
d||(d?b.focus():b.blur(),!d&&b.__ko_hasfocusLastValue&&b.ownerDocument.body.focus(),a.u.G(a.a.Fb,null,[b,d?"focusin":"focusout"]))}};a.m.wa.hasfocus=!0;a.c.hasFocus=a.c.hasfocus;a.m.wa.hasFocus="hasfocus";a.c.html={init:function(){return{controlsDescendantBindings:!0}},update:function(b,c){a.a.fc(b,c())}};(function(){function b(b,d,e){a.c[b]={init:function(b,c,h,m,k){var l,p,q={},t,x,n;if(d){m=h.get("as");var u=h.get("noChildContext");n=!(m&&u);q={as:m,noChildContext:u,exportDependencies:n}}x=(t=
"render"==h.get("completeOn"))||h.has(a.i.pa);a.o(function(){var h=a.a.f(c()),m=!e!==!h,u=!p,r;if(n||m!==l){x&&(k=a.i.Cb(b,k));if(m){if(!d||n)q.dataDependency=a.S.o();r=d?k.createChildContext("function"==typeof h?h:c,q):a.S.qa()?k.extend(null,q):k}u&&a.S.qa()&&(p=a.a.Ca(a.h.childNodes(b),!0));m?(u||a.h.va(b,a.a.Ca(p)),a.Oa(r,b)):(a.h.Ea(b),t||a.i.ma(b,a.i.H));l=m}},null,{l:b});return{controlsDescendantBindings:!0}}};a.m.Ra[b]=!1;a.h.ea[b]=!0}b("if");b("ifnot",!1,!0);b("with",!0)})();a.c.let={init:function(b,
c,d,e,f){c=f.extend(c);a.Oa(c,b);return{controlsDescendantBindings:!0}}};a.h.ea.let=!0;var Q={};a.c.options={init:function(b){if("select"!==a.a.R(b))throw Error("options binding applies only to SELECT elements");for(;0<b.length;)b.remove(0);return{controlsDescendantBindings:!0}},update:function(b,c,d){function e(){return a.a.jb(b.options,function(a){return a.selected})}function f(a,b,c){var d=typeof b;return"function"==d?b(a):"string"==d?a[b]:c}function g(c,d){if(x&&l)a.i.ma(b,a.i.H);else if(t.length){var e=
0<=a.a.A(t,a.w.M(d[0]));a.a.Zc(d[0],e);x&&!e&&a.u.G(a.a.Fb,null,[b,"change"])}}var h=b.multiple,m=0!=b.length&&h?b.scrollTop:null,k=a.a.f(c()),l=d.get("valueAllowUnset")&&d.has("value"),p=d.get("optionsIncludeDestroyed");c={};var q,t=[];l||(h?t=a.a.Mb(e(),a.w.M):0<=b.selectedIndex&&t.push(a.w.M(b.options[b.selectedIndex])));k&&("undefined"==typeof k.length&&(k=[k]),q=a.a.jb(k,function(b){return p||b===n||null===b||!a.a.f(b._destroy)}),d.has("optionsCaption")&&(k=a.a.f(d.get("optionsCaption")),null!==
k&&k!==n&&q.unshift(Q)));var x=!1;c.beforeRemove=function(a){b.removeChild(a)};k=g;d.has("optionsAfterRender")&&"function"==typeof d.get("optionsAfterRender")&&(k=function(b,c){g(0,c);a.u.G(d.get("optionsAfterRender"),null,[c[0],b!==Q?b:n])});a.a.ec(b,q,function(c,e,g){g.length&&(t=!l&&g[0].selected?[a.w.M(g[0])]:[],x=!0);e=b.ownerDocument.createElement("option");c===Q?(a.a.Bb(e,d.get("optionsCaption")),a.w.cb(e,n)):(g=f(c,d.get("optionsValue"),c),a.w.cb(e,a.a.f(g)),c=f(c,d.get("optionsText"),g),
a.a.Bb(e,c));return[e]},c,k);if(!l){var B;h?B=t.length&&e().length<t.length:B=t.length&&0<=b.selectedIndex?a.w.M(b.options[b.selectedIndex])!==t[0]:t.length||0<=b.selectedIndex;B&&a.u.G(a.a.Fb,null,[b,"change"])}(l||a.S.Ya())&&a.i.ma(b,a.i.H);a.a.wd(b);m&&20<Math.abs(m-b.scrollTop)&&(b.scrollTop=m)}};a.c.options.$b=a.a.g.Z();a.c.selectedOptions={init:function(b,c,d){function e(){var e=c(),f=[];a.a.D(b.getElementsByTagName("option"),function(b){b.selected&&f.push(a.w.M(b))});a.m.eb(e,d,"selectedOptions",
f)}function f(){var d=a.a.f(c()),e=b.scrollTop;d&&"number"==typeof d.length&&a.a.D(b.getElementsByTagName("option"),function(b){var c=0<=a.a.A(d,a.w.M(b));b.selected!=c&&a.a.Zc(b,c)});b.scrollTop=e}if("select"!=a.a.R(b))throw Error("selectedOptions binding applies only to SELECT elements");var g;a.i.subscribe(b,a.i.H,function(){g?e():(a.a.B(b,"change",e),g=a.o(f,null,{l:b}))},null,{notifyImmediately:!0})},update:function(){}};a.m.wa.selectedOptions=!0;a.c.style={update:function(b,c){var d=a.a.f(c()||
{});a.a.P(d,function(c,d){d=a.a.f(d);if(null===d||d===n||!1===d)d="";if(v)v(b).css(c,d);else if(/^--/.test(c))b.style.setProperty(c,d);else{c=c.replace(/-(\w)/g,function(a,b){return b.toUpperCase()});var g=b.style[c];b.style[c]=d;d===g||b.style[c]!=g||isNaN(d)||(b.style[c]=d+"px")}})}};a.c.submit={init:function(b,c,d,e,f){if("function"!=typeof c())throw Error("The value for a submit binding must be a function");a.a.B(b,"submit",function(a){var d,e=c();try{d=e.call(f.$data,b)}finally{!0!==d&&(a.preventDefault?
a.preventDefault():a.returnValue=!1)}})}};a.c.text={init:function(){return{controlsDescendantBindings:!0}},update:function(b,c){a.a.Bb(b,c())}};a.h.ea.text=!0;(function(){if(A&&A.navigator){var b=function(a){if(a)return parseFloat(a[1])},c=A.navigator.userAgent,d,e,f,g,h;(d=A.opera&&A.opera.version&&parseInt(A.opera.version()))||(h=b(c.match(/Edge\/([^ ]+)$/)))||b(c.match(/Chrome\/([^ ]+)/))||(e=b(c.match(/Version\/([^ ]+) Safari/)))||(f=b(c.match(/Firefox\/([^ ]+)/)))||(g=a.a.W||b(c.match(/MSIE ([^ ]+)/)))||
(g=b(c.match(/rv:([^ )]+)/)))}if(8<=g&&10>g)var m=a.a.g.Z(),k=a.a.g.Z(),l=function(b){var c=this.activeElement;(c=c&&a.a.g.get(c,k))&&c(b)},p=function(b,c){var d=b.ownerDocument;a.a.g.get(d,m)||(a.a.g.set(d,m,!0),a.a.B(d,"selectionchange",l));a.a.g.set(b,k,c)};a.c.textInput={init:function(b,c,k){function l(c,d){a.a.B(b,c,d)}function m(){var d=a.a.f(c());if(null===d||d===n)d="";L!==n&&d===L?a.a.setTimeout(m,4):b.value!==d&&(y=!0,b.value=d,y=!1,v=b.value)}function r(){w||(L=b.value,w=a.a.setTimeout(z,
4))}function z(){clearTimeout(w);L=w=n;var d=b.value;v!==d&&(v=d,a.m.eb(c(),k,"textInput",d))}var v=b.value,w,L,A=9==a.a.W?r:z,y=!1;g&&l("keypress",z);11>g&&l("propertychange",function(a){y||"value"!==a.propertyName||A(a)});8==g&&(l("keyup",z),l("keydown",z));p&&(p(b,A),l("dragend",r));(!g||9<=g)&&l("input",A);5>e&&"textarea"===a.a.R(b)?(l("keydown",r),l("paste",r),l("cut",r)):11>d?l("keydown",r):4>f?(l("DOMAutoComplete",z),l("dragdrop",z),l("drop",z)):h&&"number"===b.type&&l("keydown",r);l("change",
z);l("blur",z);a.o(m,null,{l:b})}};a.m.wa.textInput=!0;a.c.textinput={preprocess:function(a,b,c){c("textInput",a)}}})();a.c.uniqueName={init:function(b,c){if(c()){var d="ko_unique_"+ ++a.c.uniqueName.rd;a.a.Yc(b,d)}}};a.c.uniqueName.rd=0;a.c.using={init:function(b,c,d,e,f){var g;d.has("as")&&(g={as:d.get("as"),noChildContext:d.get("noChildContext")});c=f.createChildContext(c,g);a.Oa(c,b);return{controlsDescendantBindings:!0}}};a.h.ea.using=!0;a.c.value={init:function(b,c,d){var e=a.a.R(b),f="input"==
e;if(!f||"checkbox"!=b.type&&"radio"!=b.type){var g=[],h=d.get("valueUpdate"),m=!1,k=null;h&&("string"==typeof h?g=[h]:g=a.a.wc(h),a.a.Pa(g,"change"));var l=function(){k=null;m=!1;var e=c(),f=a.w.M(b);a.m.eb(e,d,"value",f)};!a.a.W||!f||"text"!=b.type||"off"==b.autocomplete||b.form&&"off"==b.form.autocomplete||-1!=a.a.A(g,"propertychange")||(a.a.B(b,"propertychange",function(){m=!0}),a.a.B(b,"focus",function(){m=!1}),a.a.B(b,"blur",function(){m&&l()}));a.a.D(g,function(c){var d=l;a.a.Ud(c,"after")&&
(d=function(){k=a.w.M(b);a.a.setTimeout(l,0)},c=c.substring(5));a.a.B(b,c,d)});var p;p=f&&"file"==b.type?function(){var d=a.a.f(c());null===d||d===n||""===d?b.value="":a.u.G(l)}:function(){var f=a.a.f(c()),g=a.w.M(b);if(null!==k&&f===k)a.a.setTimeout(p,0);else if(f!==g||g===n)"select"===e?(g=d.get("valueAllowUnset"),a.w.cb(b,f,g),g||f===a.w.M(b)||a.u.G(l)):a.w.cb(b,f)};if("select"===e){var q;a.i.subscribe(b,a.i.H,function(){q?d.get("valueAllowUnset")?p():l():(a.a.B(b,"change",l),q=a.o(p,null,{l:b}))},
null,{notifyImmediately:!0})}else a.a.B(b,"change",l),a.o(p,null,{l:b})}else a.ib(b,{checkedValue:c})},update:function(){}};a.m.wa.value=!0;a.c.visible={update:function(b,c){var d=a.a.f(c()),e="none"!=b.style.display;d&&!e?b.style.display="":!d&&e&&(b.style.display="none")}};a.c.hidden={update:function(b,c){a.c.visible.update(b,function(){return!a.a.f(c())})}};(function(b){a.c[b]={init:function(c,d,e,f,g){return a.c.event.init.call(this,c,function(){var a={};a[b]=d();return a},e,f,g)}}})("click");
a.ca=function(){};a.ca.prototype.renderTemplateSource=function(){throw Error("Override renderTemplateSource");};a.ca.prototype.createJavaScriptEvaluatorBlock=function(){throw Error("Override createJavaScriptEvaluatorBlock");};a.ca.prototype.makeTemplateSource=function(b,c){if("string"==typeof b){c=c||w;var d=c.getElementById(b);if(!d)throw Error("Cannot find template with ID "+b);return new a.C.F(d)}if(1==b.nodeType||8==b.nodeType)return new a.C.ia(b);throw Error("Unknown template type: "+b);};a.ca.prototype.renderTemplate=
function(a,c,d,e){a=this.makeTemplateSource(a,e);return this.renderTemplateSource(a,c,d,e)};a.ca.prototype.isTemplateRewritten=function(a,c){return!1===this.allowTemplateRewriting?!0:this.makeTemplateSource(a,c).data("isRewritten")};a.ca.prototype.rewriteTemplate=function(a,c,d){a=this.makeTemplateSource(a,d);c=c(a.text());a.text(c);a.data("isRewritten",!0)};a.b("templateEngine",a.ca);a.kc=function(){function b(b,c,d,h){b=a.m.ac(b);for(var m=a.m.Ra,k=0;k<b.length;k++){var l=b[k].key;if(Object.prototype.hasOwnProperty.call(m,
l)){var p=m[l];if("function"===typeof p){if(l=p(b[k].value))throw Error(l);}else if(!p)throw Error("This template engine does not support the '"+l+"' binding within its templates");}}d="ko.__tr_ambtns(function($context,$element){return(function(){return{ "+a.m.vb(b,{valueAccessors:!0})+" } })()},'"+d.toLowerCase()+"')";return h.createJavaScriptEvaluatorBlock(d)+c}var c=/(<([a-z]+\d*)(?:\s+(?!data-bind\s*=\s*)[a-z0-9\-]+(?:=(?:\"[^\"]*\"|\'[^\']*\'|[^>]*))?)*\s+)data-bind\s*=\s*(["'])([\s\S]*?)\3/gi,
d=/\x3c!--\s*ko\b\s*([\s\S]*?)\s*--\x3e/g;return{xd:function(b,c,d){c.isTemplateRewritten(b,d)||c.rewriteTemplate(b,function(b){return a.kc.Ld(b,c)},d)},Ld:function(a,f){return a.replace(c,function(a,c,d,e,l){return b(l,c,d,f)}).replace(d,function(a,c){return b(c,"\x3c!-- ko --\x3e","#comment",f)})},md:function(b,c){return a.aa.Xb(function(d,h){var m=d.nextSibling;m&&m.nodeName.toLowerCase()===c&&a.ib(m,b,h)})}}}();a.b("__tr_ambtns",a.kc.md);(function(){a.C={};a.C.F=function(b){if(this.F=b){var c=
a.a.R(b);this.ab="script"===c?1:"textarea"===c?2:"template"==c&&b.content&&11===b.content.nodeType?3:4}};a.C.F.prototype.text=function(){var b=1===this.ab?"text":2===this.ab?"value":"innerHTML";if(0==arguments.length)return this.F[b];var c=arguments[0];"innerHTML"===b?a.a.fc(this.F,c):this.F[b]=c};var b=a.a.g.Z()+"_";a.C.F.prototype.data=function(c){if(1===arguments.length)return a.a.g.get(this.F,b+c);a.a.g.set(this.F,b+c,arguments[1])};var c=a.a.g.Z();a.C.F.prototype.nodes=function(){var b=this.F;
if(0==arguments.length){var e=a.a.g.get(b,c)||{},f=e.lb||(3===this.ab?b.content:4===this.ab?b:n);if(!f||e.jd){var g=this.text();g&&g!==e.bb&&(f=a.a.Md(g,b.ownerDocument),a.a.g.set(b,c,{lb:f,bb:g,jd:!0}))}return f}e=arguments[0];this.ab!==n&&this.text("");a.a.g.set(b,c,{lb:e})};a.C.ia=function(a){this.F=a};a.C.ia.prototype=new a.C.F;a.C.ia.prototype.constructor=a.C.ia;a.C.ia.prototype.text=function(){if(0==arguments.length){var b=a.a.g.get(this.F,c)||{};b.bb===n&&b.lb&&(b.bb=b.lb.innerHTML);return b.bb}a.a.g.set(this.F,
c,{bb:arguments[0]})};a.b("templateSources",a.C);a.b("templateSources.domElement",a.C.F);a.b("templateSources.anonymousTemplate",a.C.ia)})();(function(){function b(b,c,d){var e;for(c=a.h.nextSibling(c);b&&(e=b)!==c;)b=a.h.nextSibling(e),d(e,b)}function c(c,d){if(c.length){var e=c[0],f=c[c.length-1],g=e.parentNode,h=a.ga.instance,m=h.preprocessNode;if(m){b(e,f,function(a,b){var c=a.previousSibling,d=m.call(h,a);d&&(a===e&&(e=d[0]||b),a===f&&(f=d[d.length-1]||c))});c.length=0;if(!e)return;e===f?c.push(e):
(c.push(e,f),a.a.Ua(c,g))}b(e,f,function(b){1!==b.nodeType&&8!==b.nodeType||a.vc(d,b)});b(e,f,function(b){1!==b.nodeType&&8!==b.nodeType||a.aa.cd(b,[d])});a.a.Ua(c,g)}}function d(a){return a.nodeType?a:0<a.length?a[0]:null}function e(b,e,f,h,m){m=m||{};var n=(b&&d(b)||f||{}).ownerDocument,B=m.templateEngine||g;a.kc.xd(f,B,n);f=B.renderTemplate(f,h,m,n);if("number"!=typeof f.length||0<f.length&&"number"!=typeof f[0].nodeType)throw Error("Template engine must return an array of DOM nodes");n=!1;switch(e){case "replaceChildren":a.h.va(b,
f);n=!0;break;case "replaceNode":a.a.Xc(b,f);n=!0;break;case "ignoreTargetNode":break;default:throw Error("Unknown renderMode: "+e);}n&&(c(f,h),m.afterRender&&a.u.G(m.afterRender,null,[f,h[m.as||"$data"]]),"replaceChildren"==e&&a.i.ma(b,a.i.H));return f}function f(b,c,d){return a.O(b)?b():"function"===typeof b?b(c,d):b}var g;a.gc=function(b){if(b!=n&&!(b instanceof a.ca))throw Error("templateEngine must inherit from ko.templateEngine");g=b};a.dc=function(b,c,h,m,t){h=h||{};if((h.templateEngine||g)==
n)throw Error("Set a template engine before calling renderTemplate");t=t||"replaceChildren";if(m){var x=d(m);return a.$(function(){var g=c&&c instanceof a.fa?c:new a.fa(c,null,null,null,{exportDependencies:!0}),n=f(b,g.$data,g),g=e(m,t,n,g,h);"replaceNode"==t&&(m=g,x=d(m))},null,{Sa:function(){return!x||!a.a.Sb(x)},l:x&&"replaceNode"==t?x.parentNode:x})}return a.aa.Xb(function(d){a.dc(b,c,h,d,"replaceNode")})};a.Qd=function(b,d,g,h,m){function x(b,c){a.u.G(a.a.ec,null,[h,b,u,g,r,c]);a.i.ma(h,a.i.H)}
function r(a,b){c(b,v);g.afterRender&&g.afterRender(b,a);v=null}function u(a,c){v=m.createChildContext(a,{as:z,noChildContext:g.noChildContext,extend:function(a){a.$index=c;z&&(a[z+"Index"]=c)}});var d=f(b,a,v);return e(h,"ignoreTargetNode",d,v,g)}var v,z=g.as,w=!1===g.includeDestroyed||a.options.foreachHidesDestroyed&&!g.includeDestroyed;if(w||g.beforeRemove||!a.Pc(d))return a.$(function(){var b=a.a.f(d)||[];"undefined"==typeof b.length&&(b=[b]);w&&(b=a.a.jb(b,function(b){return b===n||null===b||
!a.a.f(b._destroy)}));x(b)},null,{l:h});x(d.v());var A=d.subscribe(function(a){x(d(),a)},null,"arrayChange");A.l(h);return A};var h=a.a.g.Z(),m=a.a.g.Z();a.c.template={init:function(b,c){var d=a.a.f(c());if("string"==typeof d||"name"in d)a.h.Ea(b);else if("nodes"in d){d=d.nodes||[];if(a.O(d))throw Error('The "nodes" option must be a plain, non-observable array.');var e=d[0]&&d[0].parentNode;e&&a.a.g.get(e,m)||(e=a.a.Yb(d),a.a.g.set(e,m,!0));(new a.C.ia(b)).nodes(e)}else if(d=a.h.childNodes(b),0<d.length)e=
a.a.Yb(d),(new a.C.ia(b)).nodes(e);else throw Error("Anonymous template defined, but no template content was provided");return{controlsDescendantBindings:!0}},update:function(b,c,d,e,f){var g=c();c=a.a.f(g);d=!0;e=null;"string"==typeof c?c={}:(g="name"in c?c.name:b,"if"in c&&(d=a.a.f(c["if"])),d&&"ifnot"in c&&(d=!a.a.f(c.ifnot)),d&&!g&&(d=!1));"foreach"in c?e=a.Qd(g,d&&c.foreach||[],c,b,f):d?(d=f,"data"in c&&(d=f.createChildContext(c.data,{as:c.as,noChildContext:c.noChildContext,exportDependencies:!0})),
e=a.dc(g,d,c,b)):a.h.Ea(b);f=e;(c=a.a.g.get(b,h))&&"function"==typeof c.s&&c.s();a.a.g.set(b,h,!f||f.ja&&!f.ja()?n:f)}};a.m.Ra.template=function(b){b=a.m.ac(b);return 1==b.length&&b[0].unknown||a.m.Id(b,"name")?null:"This template engine does not support anonymous templates nested within its templates"};a.h.ea.template=!0})();a.b("setTemplateEngine",a.gc);a.b("renderTemplate",a.dc);a.a.Kc=function(a,c,d){if(a.length&&c.length){var e,f,g,h,m;for(e=f=0;(!d||e<d)&&(h=a[f]);++f){for(g=0;m=c[g];++g)if(h.value===
m.value){h.moved=m.index;m.moved=h.index;c.splice(g,1);e=g=0;break}e+=g}}};a.a.Pb=function(){function b(b,d,e,f,g){var h=Math.min,m=Math.max,k=[],l,p=b.length,q,n=d.length,r=n-p||1,v=p+n+1,u,w,z;for(l=0;l<=p;l++)for(w=u,k.push(u=[]),z=h(n,l+r),q=m(0,l-1);q<=z;q++)u[q]=q?l?b[l-1]===d[q-1]?w[q-1]:h(w[q]||v,u[q-1]||v)+1:q+1:l+1;h=[];m=[];r=[];l=p;for(q=n;l||q;)n=k[l][q]-1,q&&n===k[l][q-1]?m.push(h[h.length]={status:e,value:d[--q],index:q}):l&&n===k[l-1][q]?r.push(h[h.length]={status:f,value:b[--l],index:l}):
(--q,--l,g.sparse||h.push({status:"retained",value:d[q]}));a.a.Kc(r,m,!g.dontLimitMoves&&10*p);return h.reverse()}return function(a,d,e){e="boolean"===typeof e?{dontLimitMoves:e}:e||{};a=a||[];d=d||[];return a.length<d.length?b(a,d,"added","deleted",e):b(d,a,"deleted","added",e)}}();a.b("utils.compareArrays",a.a.Pb);(function(){function b(b,c,d,h,m){var k=[],l=a.$(function(){var l=c(d,m,a.a.Ua(k,b))||[];0<k.length&&(a.a.Xc(k,l),h&&a.u.G(h,null,[d,l,m]));k.length=0;a.a.Nb(k,l)},null,{l:b,Sa:function(){return!a.a.kd(k)}});
return{Y:k,$:l.ja()?l:n}}var c=a.a.g.Z(),d=a.a.g.Z();a.a.ec=function(e,f,g,h,m,k){function l(b){y={Aa:b,pb:a.ta(w++)};v.push(y);r||F.push(y)}function p(b){y=t[b];w!==y.pb.v()&&D.push(y);y.pb(w++);a.a.Ua(y.Y,e);v.push(y)}function q(b,c){if(b)for(var d=0,e=c.length;d<e;d++)a.a.D(c[d].Y,function(a){b(a,d,c[d].Aa)})}f=f||[];"undefined"==typeof f.length&&(f=[f]);h=h||{};var t=a.a.g.get(e,c),r=!t,v=[],u=0,w=0,z=[],A=[],C=[],D=[],F=[],y,I=0;if(r)a.a.D(f,l);else{if(!k||t&&t._countWaitingForRemove){var E=
a.a.Mb(t,function(a){return a.Aa});k=a.a.Pb(E,f,{dontLimitMoves:h.dontLimitMoves,sparse:!0})}for(var E=0,G,H,K;G=k[E];E++)switch(H=G.moved,K=G.index,G.status){case "deleted":for(;u<K;)p(u++);H===n&&(y=t[u],y.$&&(y.$.s(),y.$=n),a.a.Ua(y.Y,e).length&&(h.beforeRemove&&(v.push(y),I++,y.Aa===d?y=null:C.push(y)),y&&z.push.apply(z,y.Y)));u++;break;case "added":for(;w<K;)p(u++);H!==n?(A.push(v.length),p(H)):l(G.value)}for(;w<f.length;)p(u++);v._countWaitingForRemove=I}a.a.g.set(e,c,v);q(h.beforeMove,D);a.a.D(z,
h.beforeRemove?a.oa:a.removeNode);var M,O,P;try{P=e.ownerDocument.activeElement}catch(N){}if(A.length)for(;(E=A.shift())!=n;){y=v[E];for(M=n;E;)if((O=v[--E].Y)&&O.length){M=O[O.length-1];break}for(f=0;u=y.Y[f];M=u,f++)a.h.Wb(e,u,M)}for(E=0;y=v[E];E++){y.Y||a.a.extend(y,b(e,g,y.Aa,m,y.pb));for(f=0;u=y.Y[f];M=u,f++)a.h.Wb(e,u,M);!y.Ed&&m&&(m(y.Aa,y.Y,y.pb),y.Ed=!0,M=y.Y[y.Y.length-1])}P&&e.ownerDocument.activeElement!=P&&P.focus();q(h.beforeRemove,C);for(E=0;E<C.length;++E)C[E].Aa=d;q(h.afterMove,D);
q(h.afterAdd,F)}})();a.b("utils.setDomNodeChildrenFromArrayMapping",a.a.ec);a.ba=function(){this.allowTemplateRewriting=!1};a.ba.prototype=new a.ca;a.ba.prototype.constructor=a.ba;a.ba.prototype.renderTemplateSource=function(b,c,d,e){if(c=(9>a.a.W?0:b.nodes)?b.nodes():null)return a.a.la(c.cloneNode(!0).childNodes);b=b.text();return a.a.ua(b,e)};a.ba.Ma=new a.ba;a.gc(a.ba.Ma);a.b("nativeTemplateEngine",a.ba);(function(){a.$a=function(){var a=this.Hd=function(){if(!v||!v.tmpl)return 0;try{if(0<=v.tmpl.tag.tmpl.open.toString().indexOf("__"))return 2}catch(a){}return 1}();
this.renderTemplateSource=function(b,e,f,g){g=g||w;f=f||{};if(2>a)throw Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.");var h=b.data("precompiled");h||(h=b.text()||"",h=v.template(null,"{{ko_with $item.koBindingContext}}"+h+"{{/ko_with}}"),b.data("precompiled",h));b=[e.$data];e=v.extend({koBindingContext:e},f.templateOptions);e=v.tmpl(h,b,e);e.appendTo(g.createElement("div"));v.fragments={};return e};this.createJavaScriptEvaluatorBlock=function(a){return"{{ko_code ((function() { return "+
a+" })()) }}"};this.addTemplate=function(a,b){w.write("<script type='text/html' id='"+a+"'>"+b+"\x3c/script>")};0<a&&(v.tmpl.tag.ko_code={open:"__.push($1 || '');"},v.tmpl.tag.ko_with={open:"with($1) {",close:"} "})};a.$a.prototype=new a.ca;a.$a.prototype.constructor=a.$a;var b=new a.$a;0<b.Hd&&a.gc(b);a.b("jqueryTmplTemplateEngine",a.$a)})()})})();})();
;
/// Knockout Mapping plugin v2.4.0
/// (c) 2013 Steven Sanderson, Roy Jacobs - http://knockoutjs.com/
/// License: MIT (http://www.opensource.org/licenses/mit-license.php)
(function(d){"function"===typeof require&&"object"===typeof exports&&"object"===typeof module?d(require("knockout"),exports):"function"===typeof define&&define.amd?define(["knockout","exports"],d):d(ko,ko.mapping={})})(function(d,f){function y(b,c){var a,e;for(e in c)if(c.hasOwnProperty(e)&&c[e])if(a=f.getType(b[e]),e&&b[e]&&"array"!==a&&"string"!==a)y(b[e],c[e]);else if("array"===f.getType(b[e])&&"array"===f.getType(c[e])){a=b;for(var d=e,l=b[e],n=c[e],t={},g=l.length-1;0<=g;--g)t[l[g]]=l[g];for(g=
n.length-1;0<=g;--g)t[n[g]]=n[g];l=[];n=void 0;for(n in t)l.push(t[n]);a[d]=l}else b[e]=c[e]}function E(b,c){var a={};y(a,b);y(a,c);return a}function z(b,c){for(var a=E({},b),d=L.length-1;0<=d;d--){var f=L[d];a[f]&&(a[""]instanceof Object||(a[""]={}),a[""][f]=a[f],delete a[f])}c&&(a.ignore=h(c.ignore,a.ignore),a.include=h(c.include,a.include),a.copy=h(c.copy,a.copy),a.observe=h(c.observe,a.observe));a.ignore=h(a.ignore,j.ignore);a.include=h(a.include,j.include);a.copy=h(a.copy,j.copy);a.observe=h(a.observe,
j.observe);a.mappedProperties=a.mappedProperties||{};a.copiedProperties=a.copiedProperties||{};return a}function h(b,c){"array"!==f.getType(b)&&(b="undefined"===f.getType(b)?[]:[b]);"array"!==f.getType(c)&&(c="undefined"===f.getType(c)?[]:[c]);return d.utils.arrayGetDistinctValues(b.concat(c))}function F(b,c,a,e,k,l,n){var t="array"===f.getType(d.utils.unwrapObservable(c));l=l||"";if(f.isMapped(b)){var g=d.utils.unwrapObservable(b)[p];a=E(g,a)}var j=n||k,h=function(){return a[e]&&a[e].create instanceof
Function},x=function(b){var f=G,g=d.dependentObservable;d.dependentObservable=function(a,b,c){c=c||{};a&&"object"==typeof a&&(c=a);var e=c.deferEvaluation,M=!1;c.deferEvaluation=!0;a=new H(a,b,c);if(!e){var g=a,e=d.dependentObservable;d.dependentObservable=H;a=d.isWriteableObservable(g);d.dependentObservable=e;a=H({read:function(){M||(d.utils.arrayRemoveItem(f,g),M=!0);return g.apply(g,arguments)},write:a&&function(a){return g(a)},deferEvaluation:!0});f.push(a)}return a};d.dependentObservable.fn=
H.fn;d.computed=d.dependentObservable;b=d.utils.unwrapObservable(k)instanceof Array?a[e].create({data:b||c,parent:j,skip:N}):a[e].create({data:b||c,parent:j});d.dependentObservable=g;d.computed=d.dependentObservable;return b},u=function(){return a[e]&&a[e].update instanceof Function},v=function(b,f){var g={data:f||c,parent:j,target:d.utils.unwrapObservable(b)};d.isWriteableObservable(b)&&(g.observable=b);return a[e].update(g)};if(n=I.get(c))return n;e=e||"";if(t){var t=[],s=!1,m=function(a){return a};
a[e]&&a[e].key&&(m=a[e].key,s=!0);d.isObservable(b)||(b=d.observableArray([]),b.mappedRemove=function(a){var c="function"==typeof a?a:function(b){return b===m(a)};return b.remove(function(a){return c(m(a))})},b.mappedRemoveAll=function(a){var c=C(a,m);return b.remove(function(a){return-1!=d.utils.arrayIndexOf(c,m(a))})},b.mappedDestroy=function(a){var c="function"==typeof a?a:function(b){return b===m(a)};return b.destroy(function(a){return c(m(a))})},b.mappedDestroyAll=function(a){var c=C(a,m);return b.destroy(function(a){return-1!=
d.utils.arrayIndexOf(c,m(a))})},b.mappedIndexOf=function(a){var c=C(b(),m);a=m(a);return d.utils.arrayIndexOf(c,a)},b.mappedCreate=function(a){if(-1!==b.mappedIndexOf(a))throw Error("There already is an object with the key that you specified.");var c=h()?x(a):a;u()&&(a=v(c,a),d.isWriteableObservable(c)?c(a):c=a);b.push(c);return c});n=C(d.utils.unwrapObservable(b),m).sort();g=C(c,m);s&&g.sort();s=d.utils.compareArrays(n,g);n={};var J,A=d.utils.unwrapObservable(c),y={},z=!0,g=0;for(J=A.length;g<J;g++){var r=
m(A[g]);if(void 0===r||r instanceof Object){z=!1;break}y[r]=A[g]}var A=[],B=0,g=0;for(J=s.length;g<J;g++){var r=s[g],q,w=l+"["+g+"]";switch(r.status){case "added":var D=z?y[r.value]:K(d.utils.unwrapObservable(c),r.value,m);q=F(void 0,D,a,e,b,w,k);h()||(q=d.utils.unwrapObservable(q));w=O(d.utils.unwrapObservable(c),D,n);q===N?B++:A[w-B]=q;n[w]=!0;break;case "retained":D=z?y[r.value]:K(d.utils.unwrapObservable(c),r.value,m);q=K(b,r.value,m);F(q,D,a,e,b,w,k);w=O(d.utils.unwrapObservable(c),D,n);A[w]=
q;n[w]=!0;break;case "deleted":q=K(b,r.value,m)}t.push({event:r.status,item:q})}b(A);a[e]&&a[e].arrayChanged&&d.utils.arrayForEach(t,function(b){a[e].arrayChanged(b.event,b.item)})}else if(P(c)){b=d.utils.unwrapObservable(b);if(!b){if(h())return s=x(),u()&&(s=v(s)),s;if(u())return v(s);b={}}u()&&(b=v(b));I.save(c,b);if(u())return b;Q(c,function(e){var f=l.length?l+"."+e:e;if(-1==d.utils.arrayIndexOf(a.ignore,f))if(-1!=d.utils.arrayIndexOf(a.copy,f))b[e]=c[e];else if("object"!=typeof c[e]&&"array"!=
typeof c[e]&&0<a.observe.length&&-1==d.utils.arrayIndexOf(a.observe,f))b[e]=c[e],a.copiedProperties[f]=!0;else{var g=I.get(c[e]),k=F(b[e],c[e],a,e,b,f,b),g=g||k;if(0<a.observe.length&&-1==d.utils.arrayIndexOf(a.observe,f))b[e]=g(),a.copiedProperties[f]=!0;else{if(d.isWriteableObservable(b[e]))b[e](d.utils.unwrapObservable(g));else g=void 0===b[e]?g:d.utils.unwrapObservable(g),b[e]=g;a.mappedProperties[f]=!0}}})}else switch(f.getType(c)){case "function":u()?d.isWriteableObservable(c)?(c(v(c)),b=c):
b=v(c):b=c;break;default:if(d.isWriteableObservable(b))return q=u()?v(b):d.utils.unwrapObservable(c),b(q),q;h()||u();b=h()?x():d.observable(d.utils.unwrapObservable(c));u()&&b(v(b))}return b}function O(b,c,a){for(var e=0,d=b.length;e<d;e++)if(!0!==a[e]&&b[e]===c)return e;return null}function R(b,c){var a;c&&(a=c(b));"undefined"===f.getType(a)&&(a=b);return d.utils.unwrapObservable(a)}function K(b,c,a){b=d.utils.unwrapObservable(b);for(var e=0,f=b.length;e<f;e++){var l=b[e];if(R(l,a)===c)return l}throw Error("When calling ko.update*, the key '"+
c+"' was not found!");}function C(b,c){return d.utils.arrayMap(d.utils.unwrapObservable(b),function(a){return c?R(a,c):a})}function Q(b,c){if("array"===f.getType(b))for(var a=0;a<b.length;a++)c(a);else for(a in b)c(a)}function P(b){var c=f.getType(b);return("object"===c||"array"===c)&&null!==b}function T(){var b=[],c=[];this.save=function(a,e){var f=d.utils.arrayIndexOf(b,a);0<=f?c[f]=e:(b.push(a),c.push(e))};this.get=function(a){a=d.utils.arrayIndexOf(b,a);return 0<=a?c[a]:void 0}}function S(){var b=
{},c=function(a){var c;try{c=a}catch(d){c="$$$"}a=b[c];void 0===a&&(a=new T,b[c]=a);return a};this.save=function(a,b){c(a).save(a,b)};this.get=function(a){return c(a).get(a)}}var p="__ko_mapping__",H=d.dependentObservable,B=0,G,I,L=["create","update","key","arrayChanged"],N={},x={include:["_destroy"],ignore:[],copy:[],observe:[]},j=x;f.isMapped=function(b){return(b=d.utils.unwrapObservable(b))&&b[p]};f.fromJS=function(b){if(0==arguments.length)throw Error("When calling ko.fromJS, pass the object you want to convert.");
try{B++||(G=[],I=new S);var c,a;2==arguments.length&&(arguments[1][p]?a=arguments[1]:c=arguments[1]);3==arguments.length&&(c=arguments[1],a=arguments[2]);a&&(c=E(c,a[p]));c=z(c);var e=F(a,b,c);a&&(e=a);if(!--B)for(;G.length;){var d=G.pop();d&&d()}e[p]=E(e[p],c);return e}catch(f){throw B=0,f;}};f.fromJSON=function(b){var c=d.utils.parseJson(b);arguments[0]=c;return f.fromJS.apply(this,arguments)};f.updateFromJS=function(){throw Error("ko.mapping.updateFromJS, use ko.mapping.fromJS instead. Please note that the order of parameters is different!");
};f.updateFromJSON=function(){throw Error("ko.mapping.updateFromJSON, use ko.mapping.fromJSON instead. Please note that the order of parameters is different!");};f.toJS=function(b,c){j||f.resetDefaultOptions();if(0==arguments.length)throw Error("When calling ko.mapping.toJS, pass the object you want to convert.");if("array"!==f.getType(j.ignore))throw Error("ko.mapping.defaultOptions().ignore should be an array.");if("array"!==f.getType(j.include))throw Error("ko.mapping.defaultOptions().include should be an array.");
if("array"!==f.getType(j.copy))throw Error("ko.mapping.defaultOptions().copy should be an array.");c=z(c,b[p]);return f.visitModel(b,function(a){return d.utils.unwrapObservable(a)},c)};f.toJSON=function(b,c){var a=f.toJS(b,c);return d.utils.stringifyJson(a)};f.defaultOptions=function(){if(0<arguments.length)j=arguments[0];else return j};f.resetDefaultOptions=function(){j={include:x.include.slice(0),ignore:x.ignore.slice(0),copy:x.copy.slice(0)}};f.getType=function(b){if(b&&"object"===typeof b){if(b.constructor===
Date)return"date";if(b.constructor===Array)return"array"}return typeof b};f.visitModel=function(b,c,a){a=a||{};a.visitedObjects=a.visitedObjects||new S;var e,k=d.utils.unwrapObservable(b);if(P(k))a=z(a,k[p]),c(b,a.parentName),e="array"===f.getType(k)?[]:{};else return c(b,a.parentName);a.visitedObjects.save(b,e);var l=a.parentName;Q(k,function(b){if(!(a.ignore&&-1!=d.utils.arrayIndexOf(a.ignore,b))){var j=k[b],g=a,h=l||"";"array"===f.getType(k)?l&&(h+="["+b+"]"):(l&&(h+="."),h+=b);g.parentName=h;
if(!(-1===d.utils.arrayIndexOf(a.copy,b)&&-1===d.utils.arrayIndexOf(a.include,b)&&k[p]&&k[p].mappedProperties&&!k[p].mappedProperties[b]&&k[p].copiedProperties&&!k[p].copiedProperties[b]&&"array"!==f.getType(k)))switch(f.getType(d.utils.unwrapObservable(j))){case "object":case "array":case "undefined":g=a.visitedObjects.get(j);e[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:e[b]=c(j,a.parentName)}}});return e}});
;
/*! Hammer.JS - v2.0.8 - 2016-04-23
 * http://hammerjs.github.io/
 *
 * Copyright (c) 2016 Jorik Tangelder;
 * Licensed under the MIT license */
(function(window, document, exportName, undefined) {
  'use strict';

var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
var TEST_ELEMENT = document.createElement('div');

var TYPE_FUNCTION = 'function';

var round = Math.round;
var abs = Math.abs;
var now = Date.now;

/**
 * set a timeout with a given scope
 * @param {Function} fn
 * @param {Number} timeout
 * @param {Object} context
 * @returns {number}
 */
function setTimeoutContext(fn, timeout, context) {
    return setTimeout(bindFn(fn, context), timeout);
}

/**
 * if the argument is an array, we want to execute the fn on each entry
 * if it aint an array we don't want to do a thing.
 * this is used by all the methods that accept a single and array argument.
 * @param {*|Array} arg
 * @param {String} fn
 * @param {Object} [context]
 * @returns {Boolean}
 */
function invokeArrayArg(arg, fn, context) {
    if (Array.isArray(arg)) {
        each(arg, context[fn], context);
        return true;
    }
    return false;
}

/**
 * walk objects and arrays
 * @param {Object} obj
 * @param {Function} iterator
 * @param {Object} context
 */
function each(obj, iterator, context) {
    var i;

    if (!obj) {
        return;
    }

    if (obj.forEach) {
        obj.forEach(iterator, context);
    } else if (obj.length !== undefined) {
        i = 0;
        while (i < obj.length) {
            iterator.call(context, obj[i], i, obj);
            i++;
        }
    } else {
        for (i in obj) {
            obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
        }
    }
}

/**
 * wrap a method with a deprecation warning and stack trace
 * @param {Function} method
 * @param {String} name
 * @param {String} message
 * @returns {Function} A new function wrapping the supplied method.
 */
function deprecate(method, name, message) {
    var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
    return function() {
        var e = new Error('get-stack-trace');
        var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '')
            .replace(/^\s+at\s+/gm, '')
            .replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') : 'Unknown Stack Trace';

        var log = window.console && (window.console.warn || window.console.log);
        if (log) {
            log.call(window.console, deprecationMessage, stack);
        }
        return method.apply(this, arguments);
    };
}

/**
 * extend object.
 * means that properties in dest will be overwritten by the ones in src.
 * @param {Object} target
 * @param {...Object} objects_to_assign
 * @returns {Object} target
 */
var assign;
if (typeof Object.assign !== 'function') {
    assign = function assign(target) {
        if (target === undefined || target === null) {
            throw new TypeError('Cannot convert undefined or null to object');
        }

        var output = Object(target);
        for (var index = 1; index < arguments.length; index++) {
            var source = arguments[index];
            if (source !== undefined && source !== null) {
                for (var nextKey in source) {
                    if (source.hasOwnProperty(nextKey)) {
                        output[nextKey] = source[nextKey];
                    }
                }
            }
        }
        return output;
    };
} else {
    assign = Object.assign;
}

/**
 * extend object.
 * means that properties in dest will be overwritten by the ones in src.
 * @param {Object} dest
 * @param {Object} src
 * @param {Boolean} [merge=false]
 * @returns {Object} dest
 */
var extend = deprecate(function extend(dest, src, merge) {
    var keys = Object.keys(src);
    var i = 0;
    while (i < keys.length) {
        if (!merge || (merge && dest[keys[i]] === undefined)) {
            dest[keys[i]] = src[keys[i]];
        }
        i++;
    }
    return dest;
}, 'extend', 'Use `assign`.');

/**
 * merge the values from src in the dest.
 * means that properties that exist in dest will not be overwritten by src
 * @param {Object} dest
 * @param {Object} src
 * @returns {Object} dest
 */
var merge = deprecate(function merge(dest, src) {
    return extend(dest, src, true);
}, 'merge', 'Use `assign`.');

/**
 * simple class inheritance
 * @param {Function} child
 * @param {Function} base
 * @param {Object} [properties]
 */
function inherit(child, base, properties) {
    var baseP = base.prototype,
        childP;

    childP = child.prototype = Object.create(baseP);
    childP.constructor = child;
    childP._super = baseP;

    if (properties) {
        assign(childP, properties);
    }
}

/**
 * simple function bind
 * @param {Function} fn
 * @param {Object} context
 * @returns {Function}
 */
function bindFn(fn, context) {
    return function boundFn() {
        return fn.apply(context, arguments);
    };
}

/**
 * let a boolean value also be a function that must return a boolean
 * this first item in args will be used as the context
 * @param {Boolean|Function} val
 * @param {Array} [args]
 * @returns {Boolean}
 */
function boolOrFn(val, args) {
    if (typeof val == TYPE_FUNCTION) {
        return val.apply(args ? args[0] || undefined : undefined, args);
    }
    return val;
}

/**
 * use the val2 when val1 is undefined
 * @param {*} val1
 * @param {*} val2
 * @returns {*}
 */
function ifUndefined(val1, val2) {
    return (val1 === undefined) ? val2 : val1;
}

/**
 * addEventListener with multiple events at once
 * @param {EventTarget} target
 * @param {String} types
 * @param {Function} handler
 */
function addEventListeners(target, types, handler) {
    each(splitStr(types), function(type) {
        target.addEventListener(type, handler, false);
    });
}

/**
 * removeEventListener with multiple events at once
 * @param {EventTarget} target
 * @param {String} types
 * @param {Function} handler
 */
function removeEventListeners(target, types, handler) {
    each(splitStr(types), function(type) {
        target.removeEventListener(type, handler, false);
    });
}

/**
 * find if a node is in the given parent
 * @method hasParent
 * @param {HTMLElement} node
 * @param {HTMLElement} parent
 * @return {Boolean} found
 */
function hasParent(node, parent) {
    while (node) {
        if (node == parent) {
            return true;
        }
        node = node.parentNode;
    }
    return false;
}

/**
 * small indexOf wrapper
 * @param {String} str
 * @param {String} find
 * @returns {Boolean} found
 */
function inStr(str, find) {
    return str.indexOf(find) > -1;
}

/**
 * split string on whitespace
 * @param {String} str
 * @returns {Array} words
 */
function splitStr(str) {
    return str.trim().split(/\s+/g);
}

/**
 * find if a array contains the object using indexOf or a simple polyFill
 * @param {Array} src
 * @param {String} find
 * @param {String} [findByKey]
 * @return {Boolean|Number} false when not found, or the index
 */
function inArray(src, find, findByKey) {
    if (src.indexOf && !findByKey) {
        return src.indexOf(find);
    } else {
        var i = 0;
        while (i < src.length) {
            if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) {
                return i;
            }
            i++;
        }
        return -1;
    }
}

/**
 * convert array-like objects to real arrays
 * @param {Object} obj
 * @returns {Array}
 */
function toArray(obj) {
    return Array.prototype.slice.call(obj, 0);
}

/**
 * unique array with objects based on a key (like 'id') or just by the array's value
 * @param {Array} src [{id:1},{id:2},{id:1}]
 * @param {String} [key]
 * @param {Boolean} [sort=False]
 * @returns {Array} [{id:1},{id:2}]
 */
function uniqueArray(src, key, sort) {
    var results = [];
    var values = [];
    var i = 0;

    while (i < src.length) {
        var val = key ? src[i][key] : src[i];
        if (inArray(values, val) < 0) {
            results.push(src[i]);
        }
        values[i] = val;
        i++;
    }

    if (sort) {
        if (!key) {
            results = results.sort();
        } else {
            results = results.sort(function sortUniqueArray(a, b) {
                return a[key] > b[key];
            });
        }
    }

    return results;
}

/**
 * get the prefixed property
 * @param {Object} obj
 * @param {String} property
 * @returns {String|Undefined} prefixed
 */
function prefixed(obj, property) {
    var prefix, prop;
    var camelProp = property[0].toUpperCase() + property.slice(1);

    var i = 0;
    while (i < VENDOR_PREFIXES.length) {
        prefix = VENDOR_PREFIXES[i];
        prop = (prefix) ? prefix + camelProp : property;

        if (prop in obj) {
            return prop;
        }
        i++;
    }
    return undefined;
}

/**
 * get a unique id
 * @returns {number} uniqueId
 */
var _uniqueId = 1;
function uniqueId() {
    return _uniqueId++;
}

/**
 * get the window object of an element
 * @param {HTMLElement} element
 * @returns {DocumentView|Window}
 */
function getWindowForElement(element) {
    var doc = element.ownerDocument || element;
    return (doc.defaultView || doc.parentWindow || window);
}

var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;

var SUPPORT_TOUCH = ('ontouchstart' in window);
var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined;
var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);

var INPUT_TYPE_TOUCH = 'touch';
var INPUT_TYPE_PEN = 'pen';
var INPUT_TYPE_MOUSE = 'mouse';
var INPUT_TYPE_KINECT = 'kinect';

var COMPUTE_INTERVAL = 25;

var INPUT_START = 1;
var INPUT_MOVE = 2;
var INPUT_END = 4;
var INPUT_CANCEL = 8;

var DIRECTION_NONE = 1;
var DIRECTION_LEFT = 2;
var DIRECTION_RIGHT = 4;
var DIRECTION_UP = 8;
var DIRECTION_DOWN = 16;

var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;

var PROPS_XY = ['x', 'y'];
var PROPS_CLIENT_XY = ['clientX', 'clientY'];

/**
 * create new input type manager
 * @param {Manager} manager
 * @param {Function} callback
 * @returns {Input}
 * @constructor
 */
function Input(manager, callback) {
    var self = this;
    this.manager = manager;
    this.callback = callback;
    this.element = manager.element;
    this.target = manager.options.inputTarget;

    // smaller wrapper around the handler, for the scope and the enabled state of the manager,
    // so when disabled the input events are completely bypassed.
    this.domHandler = function(ev) {
        if (boolOrFn(manager.options.enable, [manager])) {
            self.handler(ev);
        }
    };

    this.init();

}

Input.prototype = {
    /**
     * should handle the inputEvent data and trigger the callback
     * @virtual
     */
    handler: function() { },

    /**
     * bind the events
     */
    init: function() {
        this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
        this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
        this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
    },

    /**
     * unbind the events
     */
    destroy: function() {
        this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
        this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
        this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
    }
};

/**
 * create new input type manager
 * called by the Manager constructor
 * @param {Hammer} manager
 * @returns {Input}
 */
function createInputInstance(manager) {
    var Type;
    var inputClass = manager.options.inputClass;

    if (inputClass) {
        Type = inputClass;
    } else if (SUPPORT_POINTER_EVENTS) {
        Type = PointerEventInput;
    } else if (SUPPORT_ONLY_TOUCH) {
        Type = TouchInput;
    } else if (!SUPPORT_TOUCH) {
        Type = MouseInput;
    } else {
        Type = TouchMouseInput;
    }
    return new (Type)(manager, inputHandler);
}

/**
 * handle input events
 * @param {Manager} manager
 * @param {String} eventType
 * @param {Object} input
 */
function inputHandler(manager, eventType, input) {
    var pointersLen = input.pointers.length;
    var changedPointersLen = input.changedPointers.length;
    var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
    var isFinal = (eventType & (INPUT_END | INPUT_CANCEL) && (pointersLen - changedPointersLen === 0));

    input.isFirst = !!isFirst;
    input.isFinal = !!isFinal;

    if (isFirst) {
        manager.session = {};
    }

    // source event is the normalized value of the domEvents
    // like 'touchstart, mouseup, pointerdown'
    input.eventType = eventType;

    // compute scale, rotation etc
    computeInputData(manager, input);

    // emit secret event
    manager.emit('hammer.input', input);

    manager.recognize(input);
    manager.session.prevInput = input;
}

/**
 * extend the data with some usable properties like scale, rotate, velocity etc
 * @param {Object} manager
 * @param {Object} input
 */
function computeInputData(manager, input) {
    var session = manager.session;
    var pointers = input.pointers;
    var pointersLength = pointers.length;

    // store the first input to calculate the distance and direction
    if (!session.firstInput) {
        session.firstInput = simpleCloneInputData(input);
    }

    // to compute scale and rotation we need to store the multiple touches
    if (pointersLength > 1 && !session.firstMultiple) {
        session.firstMultiple = simpleCloneInputData(input);
    } else if (pointersLength === 1) {
        session.firstMultiple = false;
    }

    var firstInput = session.firstInput;
    var firstMultiple = session.firstMultiple;
    var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;

    var center = input.center = getCenter(pointers);
    input.timeStamp = now();
    input.deltaTime = input.timeStamp - firstInput.timeStamp;

    input.angle = getAngle(offsetCenter, center);
    input.distance = getDistance(offsetCenter, center);

    computeDeltaXY(session, input);
    input.offsetDirection = getDirection(input.deltaX, input.deltaY);

    var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
    input.overallVelocityX = overallVelocity.x;
    input.overallVelocityY = overallVelocity.y;
    input.overallVelocity = (abs(overallVelocity.x) > abs(overallVelocity.y)) ? overallVelocity.x : overallVelocity.y;

    input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
    input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;

    input.maxPointers = !session.prevInput ? input.pointers.length : ((input.pointers.length >
        session.prevInput.maxPointers) ? input.pointers.length : session.prevInput.maxPointers);

    computeIntervalInputData(session, input);

    // find the correct target
    var target = manager.element;
    if (hasParent(input.srcEvent.target, target)) {
        target = input.srcEvent.target;
    }
    input.target = target;
}

function computeDeltaXY(session, input) {
    var center = input.center;
    var offset = session.offsetDelta || {};
    var prevDelta = session.prevDelta || {};
    var prevInput = session.prevInput || {};

    if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
        prevDelta = session.prevDelta = {
            x: prevInput.deltaX || 0,
            y: prevInput.deltaY || 0
        };

        offset = session.offsetDelta = {
            x: center.x,
            y: center.y
        };
    }

    input.deltaX = prevDelta.x + (center.x - offset.x);
    input.deltaY = prevDelta.y + (center.y - offset.y);
}

/**
 * velocity is calculated every x ms
 * @param {Object} session
 * @param {Object} input
 */
function computeIntervalInputData(session, input) {
    var last = session.lastInterval || input,
        deltaTime = input.timeStamp - last.timeStamp,
        velocity, velocityX, velocityY, direction;

    if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
        var deltaX = input.deltaX - last.deltaX;
        var deltaY = input.deltaY - last.deltaY;

        var v = getVelocity(deltaTime, deltaX, deltaY);
        velocityX = v.x;
        velocityY = v.y;
        velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
        direction = getDirection(deltaX, deltaY);

        session.lastInterval = input;
    } else {
        // use latest velocity info if it doesn't overtake a minimum period
        velocity = last.velocity;
        velocityX = last.velocityX;
        velocityY = last.velocityY;
        direction = last.direction;
    }

    input.velocity = velocity;
    input.velocityX = velocityX;
    input.velocityY = velocityY;
    input.direction = direction;
}

/**
 * create a simple clone from the input used for storage of firstInput and firstMultiple
 * @param {Object} input
 * @returns {Object} clonedInputData
 */
function simpleCloneInputData(input) {
    // make a simple copy of the pointers because we will get a reference if we don't
    // we only need clientXY for the calculations
    var pointers = [];
    var i = 0;
    while (i < input.pointers.length) {
        pointers[i] = {
            clientX: round(input.pointers[i].clientX),
            clientY: round(input.pointers[i].clientY)
        };
        i++;
    }

    return {
        timeStamp: now(),
        pointers: pointers,
        center: getCenter(pointers),
        deltaX: input.deltaX,
        deltaY: input.deltaY
    };
}

/**
 * get the center of all the pointers
 * @param {Array} pointers
 * @return {Object} center contains `x` and `y` properties
 */
function getCenter(pointers) {
    var pointersLength = pointers.length;

    // no need to loop when only one touch
    if (pointersLength === 1) {
        return {
            x: round(pointers[0].clientX),
            y: round(pointers[0].clientY)
        };
    }

    var x = 0, y = 0, i = 0;
    while (i < pointersLength) {
        x += pointers[i].clientX;
        y += pointers[i].clientY;
        i++;
    }

    return {
        x: round(x / pointersLength),
        y: round(y / pointersLength)
    };
}

/**
 * calculate the velocity between two points. unit is in px per ms.
 * @param {Number} deltaTime
 * @param {Number} x
 * @param {Number} y
 * @return {Object} velocity `x` and `y`
 */
function getVelocity(deltaTime, x, y) {
    return {
        x: x / deltaTime || 0,
        y: y / deltaTime || 0
    };
}

/**
 * get the direction between two points
 * @param {Number} x
 * @param {Number} y
 * @return {Number} direction
 */
function getDirection(x, y) {
    if (x === y) {
        return DIRECTION_NONE;
    }

    if (abs(x) >= abs(y)) {
        return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
    }
    return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
}

/**
 * calculate the absolute distance between two points
 * @param {Object} p1 {x, y}
 * @param {Object} p2 {x, y}
 * @param {Array} [props] containing x and y keys
 * @return {Number} distance
 */
function getDistance(p1, p2, props) {
    if (!props) {
        props = PROPS_XY;
    }
    var x = p2[props[0]] - p1[props[0]],
        y = p2[props[1]] - p1[props[1]];

    return Math.sqrt((x * x) + (y * y));
}

/**
 * calculate the angle between two coordinates
 * @param {Object} p1
 * @param {Object} p2
 * @param {Array} [props] containing x and y keys
 * @return {Number} angle
 */
function getAngle(p1, p2, props) {
    if (!props) {
        props = PROPS_XY;
    }
    var x = p2[props[0]] - p1[props[0]],
        y = p2[props[1]] - p1[props[1]];
    return Math.atan2(y, x) * 180 / Math.PI;
}

/**
 * calculate the rotation degrees between two pointersets
 * @param {Array} start array of pointers
 * @param {Array} end array of pointers
 * @return {Number} rotation
 */
function getRotation(start, end) {
    return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
}

/**
 * calculate the scale factor between two pointersets
 * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
 * @param {Array} start array of pointers
 * @param {Array} end array of pointers
 * @return {Number} scale
 */
function getScale(start, end) {
    return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
}

var MOUSE_INPUT_MAP = {
    mousedown: INPUT_START,
    mousemove: INPUT_MOVE,
    mouseup: INPUT_END
};

var MOUSE_ELEMENT_EVENTS = 'mousedown';
var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';

/**
 * Mouse events input
 * @constructor
 * @extends Input
 */
function MouseInput() {
    this.evEl = MOUSE_ELEMENT_EVENTS;
    this.evWin = MOUSE_WINDOW_EVENTS;

    this.pressed = false; // mousedown state

    Input.apply(this, arguments);
}

inherit(MouseInput, Input, {
    /**
     * handle mouse events
     * @param {Object} ev
     */
    handler: function MEhandler(ev) {
        var eventType = MOUSE_INPUT_MAP[ev.type];

        // on start we want to have the left mouse button down
        if (eventType & INPUT_START && ev.button === 0) {
            this.pressed = true;
        }

        if (eventType & INPUT_MOVE && ev.which !== 1) {
            eventType = INPUT_END;
        }

        // mouse must be down
        if (!this.pressed) {
            return;
        }

        if (eventType & INPUT_END) {
            this.pressed = false;
        }

        this.callback(this.manager, eventType, {
            pointers: [ev],
            changedPointers: [ev],
            pointerType: INPUT_TYPE_MOUSE,
            srcEvent: ev
        });
    }
});

var POINTER_INPUT_MAP = {
    pointerdown: INPUT_START,
    pointermove: INPUT_MOVE,
    pointerup: INPUT_END,
    pointercancel: INPUT_CANCEL,
    pointerout: INPUT_CANCEL
};

// in IE10 the pointer types is defined as an enum
var IE10_POINTER_TYPE_ENUM = {
    2: INPUT_TYPE_TOUCH,
    3: INPUT_TYPE_PEN,
    4: INPUT_TYPE_MOUSE,
    5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
};

var POINTER_ELEMENT_EVENTS = 'pointerdown';
var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';

// IE10 has prefixed support, and case-sensitive
if (window.MSPointerEvent && !window.PointerEvent) {
    POINTER_ELEMENT_EVENTS = 'MSPointerDown';
    POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
}

/**
 * Pointer events input
 * @constructor
 * @extends Input
 */
function PointerEventInput() {
    this.evEl = POINTER_ELEMENT_EVENTS;
    this.evWin = POINTER_WINDOW_EVENTS;

    Input.apply(this, arguments);

    this.store = (this.manager.session.pointerEvents = []);
}

inherit(PointerEventInput, Input, {
    /**
     * handle mouse events
     * @param {Object} ev
     */
    handler: function PEhandler(ev) {
        var store = this.store;
        var removePointer = false;

        var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
        var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
        var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;

        var isTouch = (pointerType == INPUT_TYPE_TOUCH);

        // get index of the event in the store
        var storeIndex = inArray(store, ev.pointerId, 'pointerId');

        // start and mouse must be down
        if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
            if (storeIndex < 0) {
                store.push(ev);
                storeIndex = store.length - 1;
            }
        } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
            removePointer = true;
        }

        // it not found, so the pointer hasn't been down (so it's probably a hover)
        if (storeIndex < 0) {
            return;
        }

        // update the event in the store
        store[storeIndex] = ev;

        this.callback(this.manager, eventType, {
            pointers: store,
            changedPointers: [ev],
            pointerType: pointerType,
            srcEvent: ev
        });

        if (removePointer) {
            // remove from the store
            store.splice(storeIndex, 1);
        }
    }
});

var SINGLE_TOUCH_INPUT_MAP = {
    touchstart: INPUT_START,
    touchmove: INPUT_MOVE,
    touchend: INPUT_END,
    touchcancel: INPUT_CANCEL
};

var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';

/**
 * Touch events input
 * @constructor
 * @extends Input
 */
function SingleTouchInput() {
    this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
    this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
    this.started = false;

    Input.apply(this, arguments);
}

inherit(SingleTouchInput, Input, {
    handler: function TEhandler(ev) {
        var type = SINGLE_TOUCH_INPUT_MAP[ev.type];

        // should we handle the touch events?
        if (type === INPUT_START) {
            this.started = true;
        }

        if (!this.started) {
            return;
        }

        var touches = normalizeSingleTouches.call(this, ev, type);

        // when done, reset the started state
        if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
            this.started = false;
        }

        this.callback(this.manager, type, {
            pointers: touches[0],
            changedPointers: touches[1],
            pointerType: INPUT_TYPE_TOUCH,
            srcEvent: ev
        });
    }
});

/**
 * @this {TouchInput}
 * @param {Object} ev
 * @param {Number} type flag
 * @returns {undefined|Array} [all, changed]
 */
function normalizeSingleTouches(ev, type) {
    var all = toArray(ev.touches);
    var changed = toArray(ev.changedTouches);

    if (type & (INPUT_END | INPUT_CANCEL)) {
        all = uniqueArray(all.concat(changed), 'identifier', true);
    }

    return [all, changed];
}

var TOUCH_INPUT_MAP = {
    touchstart: INPUT_START,
    touchmove: INPUT_MOVE,
    touchend: INPUT_END,
    touchcancel: INPUT_CANCEL
};

var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';

/**
 * Multi-user touch events input
 * @constructor
 * @extends Input
 */
function TouchInput() {
    this.evTarget = TOUCH_TARGET_EVENTS;
    this.targetIds = {};

    Input.apply(this, arguments);
}

inherit(TouchInput, Input, {
    handler: function MTEhandler(ev) {
        var type = TOUCH_INPUT_MAP[ev.type];
        var touches = getTouches.call(this, ev, type);
        if (!touches) {
            return;
        }

        this.callback(this.manager, type, {
            pointers: touches[0],
            changedPointers: touches[1],
            pointerType: INPUT_TYPE_TOUCH,
            srcEvent: ev
        });
    }
});

/**
 * @this {TouchInput}
 * @param {Object} ev
 * @param {Number} type flag
 * @returns {undefined|Array} [all, changed]
 */
function getTouches(ev, type) {
    var allTouches = toArray(ev.touches);
    var targetIds = this.targetIds;

    // when there is only one touch, the process can be simplified
    if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
        targetIds[allTouches[0].identifier] = true;
        return [allTouches, allTouches];
    }

    var i,
        targetTouches,
        changedTouches = toArray(ev.changedTouches),
        changedTargetTouches = [],
        target = this.target;

    // get target touches from touches
    targetTouches = allTouches.filter(function(touch) {
        return hasParent(touch.target, target);
    });

    // collect touches
    if (type === INPUT_START) {
        i = 0;
        while (i < targetTouches.length) {
            targetIds[targetTouches[i].identifier] = true;
            i++;
        }
    }

    // filter changed touches to only contain touches that exist in the collected target ids
    i = 0;
    while (i < changedTouches.length) {
        if (targetIds[changedTouches[i].identifier]) {
            changedTargetTouches.push(changedTouches[i]);
        }

        // cleanup removed touches
        if (type & (INPUT_END | INPUT_CANCEL)) {
            delete targetIds[changedTouches[i].identifier];
        }
        i++;
    }

    if (!changedTargetTouches.length) {
        return;
    }

    return [
        // merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
        uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true),
        changedTargetTouches
    ];
}

/**
 * Combined touch and mouse input
 *
 * Touch has a higher priority then mouse, and while touching no mouse events are allowed.
 * This because touch devices also emit mouse events while doing a touch.
 *
 * @constructor
 * @extends Input
 */

var DEDUP_TIMEOUT = 2500;
var DEDUP_DISTANCE = 25;

function TouchMouseInput() {
    Input.apply(this, arguments);

    var handler = bindFn(this.handler, this);
    this.touch = new TouchInput(this.manager, handler);
    this.mouse = new MouseInput(this.manager, handler);

    this.primaryTouch = null;
    this.lastTouches = [];
}

inherit(TouchMouseInput, Input, {
    /**
     * handle mouse and touch events
     * @param {Hammer} manager
     * @param {String} inputEvent
     * @param {Object} inputData
     */
    handler: function TMEhandler(manager, inputEvent, inputData) {
        var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH),
            isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);

        if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
            return;
        }

        // when we're in a touch event, record touches to  de-dupe synthetic mouse event
        if (isTouch) {
            recordTouches.call(this, inputEvent, inputData);
        } else if (isMouse && isSyntheticEvent.call(this, inputData)) {
            return;
        }

        this.callback(manager, inputEvent, inputData);
    },

    /**
     * remove the event listeners
     */
    destroy: function destroy() {
        this.touch.destroy();
        this.mouse.destroy();
    }
});

function recordTouches(eventType, eventData) {
    if (eventType & INPUT_START) {
        this.primaryTouch = eventData.changedPointers[0].identifier;
        setLastTouch.call(this, eventData);
    } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
        setLastTouch.call(this, eventData);
    }
}

function setLastTouch(eventData) {
    var touch = eventData.changedPointers[0];

    if (touch.identifier === this.primaryTouch) {
        var lastTouch = {x: touch.clientX, y: touch.clientY};
        this.lastTouches.push(lastTouch);
        var lts = this.lastTouches;
        var removeLastTouch = function() {
            var i = lts.indexOf(lastTouch);
            if (i > -1) {
                lts.splice(i, 1);
            }
        };
        setTimeout(removeLastTouch, DEDUP_TIMEOUT);
    }
}

function isSyntheticEvent(eventData) {
    var x = eventData.srcEvent.clientX, y = eventData.srcEvent.clientY;
    for (var i = 0; i < this.lastTouches.length; i++) {
        var t = this.lastTouches[i];
        var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y);
        if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
            return true;
        }
    }
    return false;
}

var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;

// magical touchAction value
var TOUCH_ACTION_COMPUTE = 'compute';
var TOUCH_ACTION_AUTO = 'auto';
var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
var TOUCH_ACTION_NONE = 'none';
var TOUCH_ACTION_PAN_X = 'pan-x';
var TOUCH_ACTION_PAN_Y = 'pan-y';
var TOUCH_ACTION_MAP = getTouchActionProps();

/**
 * Touch Action
 * sets the touchAction property or uses the js alternative
 * @param {Manager} manager
 * @param {String} value
 * @constructor
 */
function TouchAction(manager, value) {
    this.manager = manager;
    this.set(value);
}

TouchAction.prototype = {
    /**
     * set the touchAction value on the element or enable the polyfill
     * @param {String} value
     */
    set: function(value) {
        // find out the touch-action by the event handlers
        if (value == TOUCH_ACTION_COMPUTE) {
            value = this.compute();
        }

        if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
            this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
        }
        this.actions = value.toLowerCase().trim();
    },

    /**
     * just re-set the touchAction value
     */
    update: function() {
        this.set(this.manager.options.touchAction);
    },

    /**
     * compute the value for the touchAction property based on the recognizer's settings
     * @returns {String} value
     */
    compute: function() {
        var actions = [];
        each(this.manager.recognizers, function(recognizer) {
            if (boolOrFn(recognizer.options.enable, [recognizer])) {
                actions = actions.concat(recognizer.getTouchAction());
            }
        });
        return cleanTouchActions(actions.join(' '));
    },

    /**
     * this method is called on each input cycle and provides the preventing of the browser behavior
     * @param {Object} input
     */
    preventDefaults: function(input) {
        var srcEvent = input.srcEvent;
        var direction = input.offsetDirection;

        // if the touch action did prevented once this session
        if (this.manager.session.prevented) {
            srcEvent.preventDefault();
            return;
        }

        var actions = this.actions;
        var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
        var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
        var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];

        if (hasNone) {
            //do not prevent defaults if this is a tap gesture

            var isTapPointer = input.pointers.length === 1;
            var isTapMovement = input.distance < 2;
            var isTapTouchTime = input.deltaTime < 250;

            if (isTapPointer && isTapMovement && isTapTouchTime) {
                return;
            }
        }

        if (hasPanX && hasPanY) {
            // `pan-x pan-y` means browser handles all scrolling/panning, do not prevent
            return;
        }

        if (hasNone ||
            (hasPanY && direction & DIRECTION_HORIZONTAL) ||
            (hasPanX && direction & DIRECTION_VERTICAL)) {
            return this.preventSrc(srcEvent);
        }
    },

    /**
     * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
     * @param {Object} srcEvent
     */
    preventSrc: function(srcEvent) {
        this.manager.session.prevented = true;
        srcEvent.preventDefault();
    }
};

/**
 * when the touchActions are collected they are not a valid value, so we need to clean things up. *
 * @param {String} actions
 * @returns {*}
 */
function cleanTouchActions(actions) {
    // none
    if (inStr(actions, TOUCH_ACTION_NONE)) {
        return TOUCH_ACTION_NONE;
    }

    var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
    var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);

    // if both pan-x and pan-y are set (different recognizers
    // for different directions, e.g. horizontal pan but vertical swipe?)
    // we need none (as otherwise with pan-x pan-y combined none of these
    // recognizers will work, since the browser would handle all panning
    if (hasPanX && hasPanY) {
        return TOUCH_ACTION_NONE;
    }

    // pan-x OR pan-y
    if (hasPanX || hasPanY) {
        return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
    }

    // manipulation
    if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
        return TOUCH_ACTION_MANIPULATION;
    }

    return TOUCH_ACTION_AUTO;
}

function getTouchActionProps() {
    if (!NATIVE_TOUCH_ACTION) {
        return false;
    }
    var touchMap = {};
    var cssSupports = window.CSS && window.CSS.supports;
    ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function(val) {

        // If css.supports is not supported but there is native touch-action assume it supports
        // all values. This is the case for IE 10 and 11.
        touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
    });
    return touchMap;
}

/**
 * Recognizer flow explained; *
 * All recognizers have the initial state of POSSIBLE when a input session starts.
 * The definition of a input session is from the first input until the last input, with all it's movement in it. *
 * Example session for mouse-input: mousedown -> mousemove -> mouseup
 *
 * On each recognizing cycle (see Manager.recognize) the .recognize() method is executed
 * which determines with state it should be.
 *
 * If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to
 * POSSIBLE to give it another change on the next cycle.
 *
 *               Possible
 *                  |
 *            +-----+---------------+
 *            |                     |
 *      +-----+-----+               |
 *      |           |               |
 *   Failed      Cancelled          |
 *                          +-------+------+
 *                          |              |
 *                      Recognized       Began
 *                                         |
 *                                      Changed
 *                                         |
 *                                  Ended/Recognized
 */
var STATE_POSSIBLE = 1;
var STATE_BEGAN = 2;
var STATE_CHANGED = 4;
var STATE_ENDED = 8;
var STATE_RECOGNIZED = STATE_ENDED;
var STATE_CANCELLED = 16;
var STATE_FAILED = 32;

/**
 * Recognizer
 * Every recognizer needs to extend from this class.
 * @constructor
 * @param {Object} options
 */
function Recognizer(options) {
    this.options = assign({}, this.defaults, options || {});

    this.id = uniqueId();

    this.manager = null;

    // default is enable true
    this.options.enable = ifUndefined(this.options.enable, true);

    this.state = STATE_POSSIBLE;

    this.simultaneous = {};
    this.requireFail = [];
}

Recognizer.prototype = {
    /**
     * @virtual
     * @type {Object}
     */
    defaults: {},

    /**
     * set options
     * @param {Object} options
     * @return {Recognizer}
     */
    set: function(options) {
        assign(this.options, options);

        // also update the touchAction, in case something changed about the directions/enabled state
        this.manager && this.manager.touchAction.update();
        return this;
    },

    /**
     * recognize simultaneous with an other recognizer.
     * @param {Recognizer} otherRecognizer
     * @returns {Recognizer} this
     */
    recognizeWith: function(otherRecognizer) {
        if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
            return this;
        }

        var simultaneous = this.simultaneous;
        otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
        if (!simultaneous[otherRecognizer.id]) {
            simultaneous[otherRecognizer.id] = otherRecognizer;
            otherRecognizer.recognizeWith(this);
        }
        return this;
    },

    /**
     * drop the simultaneous link. it doesnt remove the link on the other recognizer.
     * @param {Recognizer} otherRecognizer
     * @returns {Recognizer} this
     */
    dropRecognizeWith: function(otherRecognizer) {
        if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
            return this;
        }

        otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
        delete this.simultaneous[otherRecognizer.id];
        return this;
    },

    /**
     * recognizer can only run when an other is failing
     * @param {Recognizer} otherRecognizer
     * @returns {Recognizer} this
     */
    requireFailure: function(otherRecognizer) {
        if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
            return this;
        }

        var requireFail = this.requireFail;
        otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
        if (inArray(requireFail, otherRecognizer) === -1) {
            requireFail.push(otherRecognizer);
            otherRecognizer.requireFailure(this);
        }
        return this;
    },

    /**
     * drop the requireFailure link. it does not remove the link on the other recognizer.
     * @param {Recognizer} otherRecognizer
     * @returns {Recognizer} this
     */
    dropRequireFailure: function(otherRecognizer) {
        if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
            return this;
        }

        otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
        var index = inArray(this.requireFail, otherRecognizer);
        if (index > -1) {
            this.requireFail.splice(index, 1);
        }
        return this;
    },

    /**
     * has require failures boolean
     * @returns {boolean}
     */
    hasRequireFailures: function() {
        return this.requireFail.length > 0;
    },

    /**
     * if the recognizer can recognize simultaneous with an other recognizer
     * @param {Recognizer} otherRecognizer
     * @returns {Boolean}
     */
    canRecognizeWith: function(otherRecognizer) {
        return !!this.simultaneous[otherRecognizer.id];
    },

    /**
     * You should use `tryEmit` instead of `emit` directly to check
     * that all the needed recognizers has failed before emitting.
     * @param {Object} input
     */
    emit: function(input) {
        var self = this;
        var state = this.state;

        function emit(event) {
            self.manager.emit(event, input);
        }

        // 'panstart' and 'panmove'
        if (state < STATE_ENDED) {
            emit(self.options.event + stateStr(state));
        }

        emit(self.options.event); // simple 'eventName' events

        if (input.additionalEvent) { // additional event(panleft, panright, pinchin, pinchout...)
            emit(input.additionalEvent);
        }

        // panend and pancancel
        if (state >= STATE_ENDED) {
            emit(self.options.event + stateStr(state));
        }
    },

    /**
     * Check that all the require failure recognizers has failed,
     * if true, it emits a gesture event,
     * otherwise, setup the state to FAILED.
     * @param {Object} input
     */
    tryEmit: function(input) {
        if (this.canEmit()) {
            return this.emit(input);
        }
        // it's failing anyway
        this.state = STATE_FAILED;
    },

    /**
     * can we emit?
     * @returns {boolean}
     */
    canEmit: function() {
        var i = 0;
        while (i < this.requireFail.length) {
            if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
                return false;
            }
            i++;
        }
        return true;
    },

    /**
     * update the recognizer
     * @param {Object} inputData
     */
    recognize: function(inputData) {
        // make a new copy of the inputData
        // so we can change the inputData without messing up the other recognizers
        var inputDataClone = assign({}, inputData);

        // is is enabled and allow recognizing?
        if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
            this.reset();
            this.state = STATE_FAILED;
            return;
        }

        // reset when we've reached the end
        if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
            this.state = STATE_POSSIBLE;
        }

        this.state = this.process(inputDataClone);

        // the recognizer has recognized a gesture
        // so trigger an event
        if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
            this.tryEmit(inputDataClone);
        }
    },

    /**
     * return the state of the recognizer
     * the actual recognizing happens in this method
     * @virtual
     * @param {Object} inputData
     * @returns {Const} STATE
     */
    process: function(inputData) { }, // jshint ignore:line

    /**
     * return the preferred touch-action
     * @virtual
     * @returns {Array}
     */
    getTouchAction: function() { },

    /**
     * called when the gesture isn't allowed to recognize
     * like when another is being recognized or it is disabled
     * @virtual
     */
    reset: function() { }
};

/**
 * get a usable string, used as event postfix
 * @param {Const} state
 * @returns {String} state
 */
function stateStr(state) {
    if (state & STATE_CANCELLED) {
        return 'cancel';
    } else if (state & STATE_ENDED) {
        return 'end';
    } else if (state & STATE_CHANGED) {
        return 'move';
    } else if (state & STATE_BEGAN) {
        return 'start';
    }
    return '';
}

/**
 * direction cons to string
 * @param {Const} direction
 * @returns {String}
 */
function directionStr(direction) {
    if (direction == DIRECTION_DOWN) {
        return 'down';
    } else if (direction == DIRECTION_UP) {
        return 'up';
    } else if (direction == DIRECTION_LEFT) {
        return 'left';
    } else if (direction == DIRECTION_RIGHT) {
        return 'right';
    }
    return '';
}

/**
 * get a recognizer by name if it is bound to a manager
 * @param {Recognizer|String} otherRecognizer
 * @param {Recognizer} recognizer
 * @returns {Recognizer}
 */
function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
    var manager = recognizer.manager;
    if (manager) {
        return manager.get(otherRecognizer);
    }
    return otherRecognizer;
}

/**
 * This recognizer is just used as a base for the simple attribute recognizers.
 * @constructor
 * @extends Recognizer
 */
function AttrRecognizer() {
    Recognizer.apply(this, arguments);
}

inherit(AttrRecognizer, Recognizer, {
    /**
     * @namespace
     * @memberof AttrRecognizer
     */
    defaults: {
        /**
         * @type {Number}
         * @default 1
         */
        pointers: 1
    },

    /**
     * Used to check if it the recognizer receives valid input, like input.distance > 10.
     * @memberof AttrRecognizer
     * @param {Object} input
     * @returns {Boolean} recognized
     */
    attrTest: function(input) {
        var optionPointers = this.options.pointers;
        return optionPointers === 0 || input.pointers.length === optionPointers;
    },

    /**
     * Process the input and return the state for the recognizer
     * @memberof AttrRecognizer
     * @param {Object} input
     * @returns {*} State
     */
    process: function(input) {
        var state = this.state;
        var eventType = input.eventType;

        var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
        var isValid = this.attrTest(input);

        // on cancel input and we've recognized before, return STATE_CANCELLED
        if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
            return state | STATE_CANCELLED;
        } else if (isRecognized || isValid) {
            if (eventType & INPUT_END) {
                return state | STATE_ENDED;
            } else if (!(state & STATE_BEGAN)) {
                return STATE_BEGAN;
            }
            return state | STATE_CHANGED;
        }
        return STATE_FAILED;
    }
});

/**
 * Pan
 * Recognized when the pointer is down and moved in the allowed direction.
 * @constructor
 * @extends AttrRecognizer
 */
function PanRecognizer() {
    AttrRecognizer.apply(this, arguments);

    this.pX = null;
    this.pY = null;
}

inherit(PanRecognizer, AttrRecognizer, {
    /**
     * @namespace
     * @memberof PanRecognizer
     */
    defaults: {
        event: 'pan',
        threshold: 10,
        pointers: 1,
        direction: DIRECTION_ALL
    },

    getTouchAction: function() {
        var direction = this.options.direction;
        var actions = [];
        if (direction & DIRECTION_HORIZONTAL) {
            actions.push(TOUCH_ACTION_PAN_Y);
        }
        if (direction & DIRECTION_VERTICAL) {
            actions.push(TOUCH_ACTION_PAN_X);
        }
        return actions;
    },

    directionTest: function(input) {
        var options = this.options;
        var hasMoved = true;
        var distance = input.distance;
        var direction = input.direction;
        var x = input.deltaX;
        var y = input.deltaY;

        // lock to axis?
        if (!(direction & options.direction)) {
            if (options.direction & DIRECTION_HORIZONTAL) {
                direction = (x === 0) ? DIRECTION_NONE : (x < 0) ? DIRECTION_LEFT : DIRECTION_RIGHT;
                hasMoved = x != this.pX;
                distance = Math.abs(input.deltaX);
            } else {
                direction = (y === 0) ? DIRECTION_NONE : (y < 0) ? DIRECTION_UP : DIRECTION_DOWN;
                hasMoved = y != this.pY;
                distance = Math.abs(input.deltaY);
            }
        }
        input.direction = direction;
        return hasMoved && distance > options.threshold && direction & options.direction;
    },

    attrTest: function(input) {
        return AttrRecognizer.prototype.attrTest.call(this, input) &&
            (this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input)));
    },

    emit: function(input) {

        this.pX = input.deltaX;
        this.pY = input.deltaY;

        var direction = directionStr(input.direction);

        if (direction) {
            input.additionalEvent = this.options.event + direction;
        }
        this._super.emit.call(this, input);
    }
});

/**
 * Pinch
 * Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
 * @constructor
 * @extends AttrRecognizer
 */
function PinchRecognizer() {
    AttrRecognizer.apply(this, arguments);
}

inherit(PinchRecognizer, AttrRecognizer, {
    /**
     * @namespace
     * @memberof PinchRecognizer
     */
    defaults: {
        event: 'pinch',
        threshold: 0,
        pointers: 2
    },

    getTouchAction: function() {
        return [TOUCH_ACTION_NONE];
    },

    attrTest: function(input) {
        return this._super.attrTest.call(this, input) &&
            (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
    },

    emit: function(input) {
        if (input.scale !== 1) {
            var inOut = input.scale < 1 ? 'in' : 'out';
            input.additionalEvent = this.options.event + inOut;
        }
        this._super.emit.call(this, input);
    }
});

/**
 * Press
 * Recognized when the pointer is down for x ms without any movement.
 * @constructor
 * @extends Recognizer
 */
function PressRecognizer() {
    Recognizer.apply(this, arguments);

    this._timer = null;
    this._input = null;
}

inherit(PressRecognizer, Recognizer, {
    /**
     * @namespace
     * @memberof PressRecognizer
     */
    defaults: {
        event: 'press',
        pointers: 1,
        time: 251, // minimal time of the pointer to be pressed
        threshold: 9 // a minimal movement is ok, but keep it low
    },

    getTouchAction: function() {
        return [TOUCH_ACTION_AUTO];
    },

    process: function(input) {
        var options = this.options;
        var validPointers = input.pointers.length === options.pointers;
        var validMovement = input.distance < options.threshold;
        var validTime = input.deltaTime > options.time;

        this._input = input;

        // we only allow little movement
        // and we've reached an end event, so a tap is possible
        if (!validMovement || !validPointers || (input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime)) {
            this.reset();
        } else if (input.eventType & INPUT_START) {
            this.reset();
            this._timer = setTimeoutContext(function() {
                this.state = STATE_RECOGNIZED;
                this.tryEmit();
            }, options.time, this);
        } else if (input.eventType & INPUT_END) {
            return STATE_RECOGNIZED;
        }
        return STATE_FAILED;
    },

    reset: function() {
        clearTimeout(this._timer);
    },

    emit: function(input) {
        if (this.state !== STATE_RECOGNIZED) {
            return;
        }

        if (input && (input.eventType & INPUT_END)) {
            this.manager.emit(this.options.event + 'up', input);
        } else {
            this._input.timeStamp = now();
            this.manager.emit(this.options.event, this._input);
        }
    }
});

/**
 * Rotate
 * Recognized when two or more pointer are moving in a circular motion.
 * @constructor
 * @extends AttrRecognizer
 */
function RotateRecognizer() {
    AttrRecognizer.apply(this, arguments);
}

inherit(RotateRecognizer, AttrRecognizer, {
    /**
     * @namespace
     * @memberof RotateRecognizer
     */
    defaults: {
        event: 'rotate',
        threshold: 0,
        pointers: 2
    },

    getTouchAction: function() {
        return [TOUCH_ACTION_NONE];
    },

    attrTest: function(input) {
        return this._super.attrTest.call(this, input) &&
            (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
    }
});

/**
 * Swipe
 * Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
 * @constructor
 * @extends AttrRecognizer
 */
function SwipeRecognizer() {
    AttrRecognizer.apply(this, arguments);
}

inherit(SwipeRecognizer, AttrRecognizer, {
    /**
     * @namespace
     * @memberof SwipeRecognizer
     */
    defaults: {
        event: 'swipe',
        threshold: 10,
        velocity: 0.3,
        direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
        pointers: 1
    },

    getTouchAction: function() {
        return PanRecognizer.prototype.getTouchAction.call(this);
    },

    attrTest: function(input) {
        var direction = this.options.direction;
        var velocity;

        if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
            velocity = input.overallVelocity;
        } else if (direction & DIRECTION_HORIZONTAL) {
            velocity = input.overallVelocityX;
        } else if (direction & DIRECTION_VERTICAL) {
            velocity = input.overallVelocityY;
        }

        return this._super.attrTest.call(this, input) &&
            direction & input.offsetDirection &&
            input.distance > this.options.threshold &&
            input.maxPointers == this.options.pointers &&
            abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
    },

    emit: function(input) {
        var direction = directionStr(input.offsetDirection);
        if (direction) {
            this.manager.emit(this.options.event + direction, input);
        }

        this.manager.emit(this.options.event, input);
    }
});

/**
 * A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
 * between the given interval and position. The delay option can be used to recognize multi-taps without firing
 * a single tap.
 *
 * The eventData from the emitted event contains the property `tapCount`, which contains the amount of
 * multi-taps being recognized.
 * @constructor
 * @extends Recognizer
 */
function TapRecognizer() {
    Recognizer.apply(this, arguments);

    // previous time and center,
    // used for tap counting
    this.pTime = false;
    this.pCenter = false;

    this._timer = null;
    this._input = null;
    this.count = 0;
}

inherit(TapRecognizer, Recognizer, {
    /**
     * @namespace
     * @memberof PinchRecognizer
     */
    defaults: {
        event: 'tap',
        pointers: 1,
        taps: 1,
        interval: 300, // max time between the multi-tap taps
        time: 250, // max time of the pointer to be down (like finger on the screen)
        threshold: 9, // a minimal movement is ok, but keep it low
        posThreshold: 10 // a multi-tap can be a bit off the initial position
    },

    getTouchAction: function() {
        return [TOUCH_ACTION_MANIPULATION];
    },

    process: function(input) {
        var options = this.options;

        var validPointers = input.pointers.length === options.pointers;
        var validMovement = input.distance < options.threshold;
        var validTouchTime = input.deltaTime < options.time;

        this.reset();

        if ((input.eventType & INPUT_START) && (this.count === 0)) {
            return this.failTimeout();
        }

        // we only allow little movement
        // and we've reached an end event, so a tap is possible
        if (validMovement && validTouchTime && validPointers) {
            if (input.eventType != INPUT_END) {
                return this.failTimeout();
            }

            var validInterval = this.pTime ? (input.timeStamp - this.pTime < options.interval) : true;
            var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;

            this.pTime = input.timeStamp;
            this.pCenter = input.center;

            if (!validMultiTap || !validInterval) {
                this.count = 1;
            } else {
                this.count += 1;
            }

            this._input = input;

            // if tap count matches we have recognized it,
            // else it has began recognizing...
            var tapCount = this.count % options.taps;
            if (tapCount === 0) {
                // no failing requirements, immediately trigger the tap event
                // or wait as long as the multitap interval to trigger
                if (!this.hasRequireFailures()) {
                    return STATE_RECOGNIZED;
                } else {
                    this._timer = setTimeoutContext(function() {
                        this.state = STATE_RECOGNIZED;
                        this.tryEmit();
                    }, options.interval, this);
                    return STATE_BEGAN;
                }
            }
        }
        return STATE_FAILED;
    },

    failTimeout: function() {
        this._timer = setTimeoutContext(function() {
            this.state = STATE_FAILED;
        }, this.options.interval, this);
        return STATE_FAILED;
    },

    reset: function() {
        clearTimeout(this._timer);
    },

    emit: function() {
        if (this.state == STATE_RECOGNIZED) {
            this._input.tapCount = this.count;
            this.manager.emit(this.options.event, this._input);
        }
    }
});

/**
 * Simple way to create a manager with a default set of recognizers.
 * @param {HTMLElement} element
 * @param {Object} [options]
 * @constructor
 */
function Hammer(element, options) {
    options = options || {};
    options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
    return new Manager(element, options);
}

/**
 * @const {string}
 */
Hammer.VERSION = '2.0.8';

/**
 * default settings
 * @namespace
 */
Hammer.defaults = {
    /**
     * set if DOM events are being triggered.
     * But this is slower and unused by simple implementations, so disabled by default.
     * @type {Boolean}
     * @default false
     */
    domEvents: false,

    /**
     * The value for the touchAction property/fallback.
     * When set to `compute` it will magically set the correct value based on the added recognizers.
     * @type {String}
     * @default compute
     */
    touchAction: TOUCH_ACTION_COMPUTE,

    /**
     * @type {Boolean}
     * @default true
     */
    enable: true,

    /**
     * EXPERIMENTAL FEATURE -- can be removed/changed
     * Change the parent input target element.
     * If Null, then it is being set the to main element.
     * @type {Null|EventTarget}
     * @default null
     */
    inputTarget: null,

    /**
     * force an input class
     * @type {Null|Function}
     * @default null
     */
    inputClass: null,

    /**
     * Default recognizer setup when calling `Hammer()`
     * When creating a new Manager these will be skipped.
     * @type {Array}
     */
    preset: [
        // RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
        [RotateRecognizer, {enable: false}],
        [PinchRecognizer, {enable: false}, ['rotate']],
        [SwipeRecognizer, {direction: DIRECTION_HORIZONTAL}],
        [PanRecognizer, {direction: DIRECTION_HORIZONTAL}, ['swipe']],
        [TapRecognizer],
        [TapRecognizer, {event: 'doubletap', taps: 2}, ['tap']],
        [PressRecognizer]
    ],

    /**
     * Some CSS properties can be used to improve the working of Hammer.
     * Add them to this method and they will be set when creating a new Manager.
     * @namespace
     */
    cssProps: {
        /**
         * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
         * @type {String}
         * @default 'none'
         */
        userSelect: 'none',

        /**
         * Disable the Windows Phone grippers when pressing an element.
         * @type {String}
         * @default 'none'
         */
        touchSelect: 'none',

        /**
         * Disables the default callout shown when you touch and hold a touch target.
         * On iOS, when you touch and hold a touch target such as a link, Safari displays
         * a callout containing information about the link. This property allows you to disable that callout.
         * @type {String}
         * @default 'none'
         */
        touchCallout: 'none',

        /**
         * Specifies whether zooming is enabled. Used by IE10>
         * @type {String}
         * @default 'none'
         */
        contentZooming: 'none',

        /**
         * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
         * @type {String}
         * @default 'none'
         */
        userDrag: 'none',

        /**
         * Overrides the highlight color shown when the user taps a link or a JavaScript
         * clickable element in iOS. This property obeys the alpha value, if specified.
         * @type {String}
         * @default 'rgba(0,0,0,0)'
         */
        tapHighlightColor: 'rgba(0,0,0,0)'
    }
};

var STOP = 1;
var FORCED_STOP = 2;

/**
 * Manager
 * @param {HTMLElement} element
 * @param {Object} [options]
 * @constructor
 */
function Manager(element, options) {
    this.options = assign({}, Hammer.defaults, options || {});

    this.options.inputTarget = this.options.inputTarget || element;

    this.handlers = {};
    this.session = {};
    this.recognizers = [];
    this.oldCssProps = {};

    this.element = element;
    this.input = createInputInstance(this);
    this.touchAction = new TouchAction(this, this.options.touchAction);

    toggleCssProps(this, true);

    each(this.options.recognizers, function(item) {
        var recognizer = this.add(new (item[0])(item[1]));
        item[2] && recognizer.recognizeWith(item[2]);
        item[3] && recognizer.requireFailure(item[3]);
    }, this);
}

Manager.prototype = {
    /**
     * set options
     * @param {Object} options
     * @returns {Manager}
     */
    set: function(options) {
        assign(this.options, options);

        // Options that need a little more setup
        if (options.touchAction) {
            this.touchAction.update();
        }
        if (options.inputTarget) {
            // Clean up existing event listeners and reinitialize
            this.input.destroy();
            this.input.target = options.inputTarget;
            this.input.init();
        }
        return this;
    },

    /**
     * stop recognizing for this session.
     * This session will be discarded, when a new [input]start event is fired.
     * When forced, the recognizer cycle is stopped immediately.
     * @param {Boolean} [force]
     */
    stop: function(force) {
        this.session.stopped = force ? FORCED_STOP : STOP;
    },

    /**
     * run the recognizers!
     * called by the inputHandler function on every movement of the pointers (touches)
     * it walks through all the recognizers and tries to detect the gesture that is being made
     * @param {Object} inputData
     */
    recognize: function(inputData) {
        var session = this.session;
        if (session.stopped) {
            return;
        }

        // run the touch-action polyfill
        this.touchAction.preventDefaults(inputData);

        var recognizer;
        var recognizers = this.recognizers;

        // this holds the recognizer that is being recognized.
        // so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED
        // if no recognizer is detecting a thing, it is set to `null`
        var curRecognizer = session.curRecognizer;

        // reset when the last recognizer is recognized
        // or when we're in a new session
        if (!curRecognizer || (curRecognizer && curRecognizer.state & STATE_RECOGNIZED)) {
            curRecognizer = session.curRecognizer = null;
        }

        var i = 0;
        while (i < recognizers.length) {
            recognizer = recognizers[i];

            // find out if we are allowed try to recognize the input for this one.
            // 1.   allow if the session is NOT forced stopped (see the .stop() method)
            // 2.   allow if we still haven't recognized a gesture in this session, or the this recognizer is the one
            //      that is being recognized.
            // 3.   allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.
            //      this can be setup with the `recognizeWith()` method on the recognizer.
            if (session.stopped !== FORCED_STOP && ( // 1
                    !curRecognizer || recognizer == curRecognizer || // 2
                    recognizer.canRecognizeWith(curRecognizer))) { // 3
                recognizer.recognize(inputData);
            } else {
                recognizer.reset();
            }

            // if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the
            // current active recognizer. but only if we don't already have an active recognizer
            if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
                curRecognizer = session.curRecognizer = recognizer;
            }
            i++;
        }
    },

    /**
     * get a recognizer by its event name.
     * @param {Recognizer|String} recognizer
     * @returns {Recognizer|Null}
     */
    get: function(recognizer) {
        if (recognizer instanceof Recognizer) {
            return recognizer;
        }

        var recognizers = this.recognizers;
        for (var i = 0; i < recognizers.length; i++) {
            if (recognizers[i].options.event == recognizer) {
                return recognizers[i];
            }
        }
        return null;
    },

    /**
     * add a recognizer to the manager
     * existing recognizers with the same event name will be removed
     * @param {Recognizer} recognizer
     * @returns {Recognizer|Manager}
     */
    add: function(recognizer) {
        if (invokeArrayArg(recognizer, 'add', this)) {
            return this;
        }

        // remove existing
        var existing = this.get(recognizer.options.event);
        if (existing) {
            this.remove(existing);
        }

        this.recognizers.push(recognizer);
        recognizer.manager = this;

        this.touchAction.update();
        return recognizer;
    },

    /**
     * remove a recognizer by name or instance
     * @param {Recognizer|String} recognizer
     * @returns {Manager}
     */
    remove: function(recognizer) {
        if (invokeArrayArg(recognizer, 'remove', this)) {
            return this;
        }

        recognizer = this.get(recognizer);

        // let's make sure this recognizer exists
        if (recognizer) {
            var recognizers = this.recognizers;
            var index = inArray(recognizers, recognizer);

            if (index !== -1) {
                recognizers.splice(index, 1);
                this.touchAction.update();
            }
        }

        return this;
    },

    /**
     * bind event
     * @param {String} events
     * @param {Function} handler
     * @returns {EventEmitter} this
     */
    on: function(events, handler) {
        if (events === undefined) {
            return;
        }
        if (handler === undefined) {
            return;
        }

        var handlers = this.handlers;
        each(splitStr(events), function(event) {
            handlers[event] = handlers[event] || [];
            handlers[event].push(handler);
        });
        return this;
    },

    /**
     * unbind event, leave emit blank to remove all handlers
     * @param {String} events
     * @param {Function} [handler]
     * @returns {EventEmitter} this
     */
    off: function(events, handler) {
        if (events === undefined) {
            return;
        }

        var handlers = this.handlers;
        each(splitStr(events), function(event) {
            if (!handler) {
                delete handlers[event];
            } else {
                handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
            }
        });
        return this;
    },

    /**
     * emit event to the listeners
     * @param {String} event
     * @param {Object} data
     */
    emit: function(event, data) {
        // we also want to trigger dom events
        if (this.options.domEvents) {
            triggerDomEvent(event, data);
        }

        // no handlers, so skip it all
        var handlers = this.handlers[event] && this.handlers[event].slice();
        if (!handlers || !handlers.length) {
            return;
        }

        data.type = event;
        data.preventDefault = function() {
            data.srcEvent.preventDefault();
        };

        var i = 0;
        while (i < handlers.length) {
            handlers[i](data);
            i++;
        }
    },

    /**
     * destroy the manager and unbinds all events
     * it doesn't unbind dom events, that is the user own responsibility
     */
    destroy: function() {
        this.element && toggleCssProps(this, false);

        this.handlers = {};
        this.session = {};
        this.input.destroy();
        this.element = null;
    }
};

/**
 * add/remove the css properties as defined in manager.options.cssProps
 * @param {Manager} manager
 * @param {Boolean} add
 */
function toggleCssProps(manager, add) {
    var element = manager.element;
    if (!element.style) {
        return;
    }
    var prop;
    each(manager.options.cssProps, function(value, name) {
        prop = prefixed(element.style, name);
        if (add) {
            manager.oldCssProps[prop] = element.style[prop];
            element.style[prop] = value;
        } else {
            element.style[prop] = manager.oldCssProps[prop] || '';
        }
    });
    if (!add) {
        manager.oldCssProps = {};
    }
}

/**
 * trigger dom event
 * @param {String} event
 * @param {Object} data
 */
function triggerDomEvent(event, data) {
    var gestureEvent = document.createEvent('Event');
    gestureEvent.initEvent(event, true, true);
    gestureEvent.gesture = data;
    data.target.dispatchEvent(gestureEvent);
}

assign(Hammer, {
    INPUT_START: INPUT_START,
    INPUT_MOVE: INPUT_MOVE,
    INPUT_END: INPUT_END,
    INPUT_CANCEL: INPUT_CANCEL,

    STATE_POSSIBLE: STATE_POSSIBLE,
    STATE_BEGAN: STATE_BEGAN,
    STATE_CHANGED: STATE_CHANGED,
    STATE_ENDED: STATE_ENDED,
    STATE_RECOGNIZED: STATE_RECOGNIZED,
    STATE_CANCELLED: STATE_CANCELLED,
    STATE_FAILED: STATE_FAILED,

    DIRECTION_NONE: DIRECTION_NONE,
    DIRECTION_LEFT: DIRECTION_LEFT,
    DIRECTION_RIGHT: DIRECTION_RIGHT,
    DIRECTION_UP: DIRECTION_UP,
    DIRECTION_DOWN: DIRECTION_DOWN,
    DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
    DIRECTION_VERTICAL: DIRECTION_VERTICAL,
    DIRECTION_ALL: DIRECTION_ALL,

    Manager: Manager,
    Input: Input,
    TouchAction: TouchAction,

    TouchInput: TouchInput,
    MouseInput: MouseInput,
    PointerEventInput: PointerEventInput,
    TouchMouseInput: TouchMouseInput,
    SingleTouchInput: SingleTouchInput,

    Recognizer: Recognizer,
    AttrRecognizer: AttrRecognizer,
    Tap: TapRecognizer,
    Pan: PanRecognizer,
    Swipe: SwipeRecognizer,
    Pinch: PinchRecognizer,
    Rotate: RotateRecognizer,
    Press: PressRecognizer,

    on: addEventListeners,
    off: removeEventListeners,
    each: each,
    merge: merge,
    extend: extend,
    assign: assign,
    inherit: inherit,
    bindFn: bindFn,
    prefixed: prefixed
});

// this prevents errors when Hammer is loaded in the presence of an AMD
//  style loader but by script tag, not by the loader.
var freeGlobal = (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {})); // jshint ignore:line
freeGlobal.Hammer = Hammer;

if (typeof define === 'function' && define.amd) {
    define(function() {
        return Hammer;
    });
} else if (typeof module != 'undefined' && module.exports) {
    module.exports = Hammer;
} else {
    window[exportName] = Hammer;
}

})(window, document, 'Hammer');
;
(function (searchMultiComplete, $) {
    searchMultiComplete.autocompleteUrl = null;
    searchMultiComplete.searchServiceUrl = null;
    searchMultiComplete.minCharacters = null;
    searchMultiComplete.searchArray = [];
    searchMultiComplete.CloseDialog = function () {
        $('#search-multiComplete-dialog').removeAttr('style');
        $('#search-multiComplete-dialog').attr('style', 'display:none');
        $("#search-button").removeAttr('style');
        $("#search-button").attr('style', 'display:block');
        $("#search-close-button").removeAttr('style');
        $("#search-close-button").attr('style', 'display:none');
        searchMultiComplete.viewModel.close();

    };
    //#region Autocomplete
    var defaults = {
        account: "",
        autocomplete: true,
        sayt: false,
        searchDomain: "",
        inputElement: "",
        inputFormElement: "",
        delay: 150,
        minLength: 4,
        maxResults: 10,
        browserAutocomplete: false,
        submitOnSelect: true,
        queryCaseSensitive: false,
        startsWith: false,
        highlightWords: true,
        highlightWordsBegin: false,
        header: "",
        footer: ""
    };
    $.fn.Autocomplete = function (s) {
        var searchTerm;
        s = $.extend(defaults, s);
        // Extend Autocomplete to allow for highlighting words
        $.extend($.ui.autocomplete.prototype, {

            highlightMatches: function (q, t) {
                if (s.highlightWords || s.highlightWordsBegin) {
                    var st = (s.highlightWordsBegin) ? "^" : "";
                    var re = new RegExp("(" + st + q + ")", "i");
                    t = t.replace(re, "<b>" + "$1" + "</b>");
                }
                return t;

            }

        });
        var _ops = {

            getAutocompleteRequest: function (s, query) {
                return searchMultiComplete.autocompleteUrl + "/jsonp?q=" + encodeURIComponent(query) + "&max_results=10&callback=?";

            },
            source: function (request, response) {
                if (!request.term) {
                    request.term = "";
                }
                else {
                    // var a = Regex.Replace(q, @"(?<=\d)\p{Zs}(?=\d)", "").Trim();
                    //var a = $.trim(request.term.replace("?<=\d)\p{Zs}(?=\d)", ""));

                    var re = /(\d)\s+(?=\d)/g;
                    var a = $.trim(request.term.replace(re, '$1'));

                    if (!isNaN(a)) {
                        request.term = a;
                    }
                }
                var req = this.options.getAutocompleteRequest(s, request.term);
                if (request.term) {
                    searchTerm = request.term;
                    var o = this;

                    $.getJSON(req, function (data, txt, req) {
                        //data = JSON.parse(data);
                        var matcher = null;
                        var matchcase = (o.options.queryCaseSensitive) ? "" : "i";
                        var res = 0;
                        var max = (s.maxResults) ? s.maxResults : 10;


                        if (s.startsWith) {
                            matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex(request.term), matchcase);
                        }
                        else {
                            matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), matchcase);

                        }

                        response($.map(data, function (item) {
                            if (matcher.test(item) && res < max) {
                                res++;
                                var disLabel;

                                disLabel = o.highlightMatches(request.term, item);

                                var url;
                                var regex = new RegExp("^\[0-9]{3}-\[0-9]{3}$");

                                if (regex.test(item))
                                    url = "/Product/" + item + "?icid=InternalSearch_AutoSearch_" + item;
                                else {
                                    //Remove % from search text as s_code file cannot handle 100%%25pure in url
                                    var searchText = item.split("%").join("");
                                    searchText = encodeURIComponent(searchText);
                                    searchText = searchText.split("%20").join("+");

                                    var value = encodeURIComponent(item);
                                    value = value.split("%20").join("+");
                                    url = "/search/?q=" + value + "&icid=InternalSearch_AutoSearch_" + searchText;
                                }
                                return {
                                    label: item,
                                    value: url,
                                    displayLabel: disLabel
                                };

                            }
                        }));

                    }).done(function (data) {

                        if (data.length == 0) {
                            $('#search-multiComplete-dialog').removeAttr('style');
                            $('#search-multiComplete-dialog').attr('style', 'display:none');
                            $("#search-button").removeAttr('style');
                            $("#search-button").attr('style', 'display:block');
                            $("#search-close-button").removeAttr('style');
                            $("#search-close-button").attr('style', 'display:none');
                        } else {
                            $("#searchTextResult ul a").dotdotdot({ height: 20 });
                        }
                    }).fail(function () {
                        $('#search-multiComplete-dialog').removeAttr('style');
                        $('#search-multiComplete-dialog').attr('style', 'display:none');
                        $("#search-button").removeAttr('style');
                        $("#search-button").attr('style', 'display:block');
                        $("#search-close-button").removeAttr('style');
                        $("#search-close-button").attr('style', 'display:none');
                    });
                }

            },
            open: function (event, ui) {

                if (event.keyCode != 40 && event.keyCode != 38) {
                    var acdiv = ".ui-autocomplete.ui-menu.ui-widget.ui-widget-content.ui-corner-all";
                    $(acdiv + " > li:first").prepend(s.header);
                    $(acdiv + " > li:last").append(s.footer);

                    // Autocomplete uses text() method, fix any escaped > <
                    $(acdiv + " li").each(function () {
                        t = $(this).find("a").html();
                        t = t.replace(/\&lt;b\&gt;/g, "<b>");
                        t = t.replace(/\&lt;\/b\&gt;/g, "</b>");
                        $(this).find("a").html(t);
                    });
                    $("#searchTextResult ul a").dotdotdot({ height: 20 });
                }

                $("#search-multiComplete-dialog").removeAttr('style');
                $("#search-multiComplete-dialog").attr('style', 'display:block');
                $("#search-button").removeAttr('style');
                $("#search-button").attr('style', 'display:none');
                $("#search-close-button").removeAttr('style');
                $("#search-close-button").attr('style', 'display:block');
                $('#txtSearchString').off('blur');
                $('.ui-autocomplete-input').focus();
                $('.ui-autocomplete-input').on("click", function () {
                    var term = $('#txtSearchString').val();
                    if (term == "watch")
                        term = "Watch";
                    if (searchMultiComplete.searchArray[term] === undefined || searchMultiComplete.searchArray[term] === null) {
                        shopHq.searchMultiComplete.viewModel.GetProductData(term);

                        $("#searchBoxRightArray").removeAttr("style");
                        $("#searchBoxRightArray").attr("style", "display:none");
                        $("#searchBoxRight").removeAttr("style");
                        $("#searchBoxRight").attr("style", "display:block");

                    } else {
                        $("#searchBoxRightArray").html(searchMultiComplete.searchArray[term]);

                        $("#searchBoxRight").removeAttr("style");
                        $("#searchBoxRight").attr("style", "display:none");
                        $("#searchBoxRightArray").removeAttr("style");
                        $("#searchBoxRightArray").attr("style", "display:block");
                    }
                    $("#searchBoxRight ul a").dotdotdot({ height: 45 });
                    $("#searchTextResult ul a").dotdotdot({ height: 20 });
                });
                $('#searchTextResult ul').removeAttr('style');
            },
            select: function (event, ui) {
                window.location.href = ui.item.value;
                event.preventDefault();
                return false;
            },

            search: function (event, ui) {
                var term = $('#txtSearchString').val();
                //to prevent firefox issue of watch event will have to modify later
                if (term == "watch") {
                    term = "Watch";
                }
                if (searchMultiComplete.searchArray[term] === undefined || searchMultiComplete.searchArray[term] === null) {
                    shopHq.searchMultiComplete.viewModel.GetProductData(term);
                    $("#searchBoxRightArray").removeAttr("style");
                    $("#searchBoxRightArray").attr("style", "display:none");
                    $("#searchBoxRight").removeAttr("style");
                    $("#searchBoxRight").attr("style", "display:block");

                } else {
                    $("#searchBoxRightArray").html(searchMultiComplete.searchArray[term]);

                    $("#searchBoxRight").removeAttr("style");
                    $("#searchBoxRight").attr("style", "display:none");
                    $("#searchBoxRightArray").removeAttr("style");
                    $("#searchBoxRightArray").attr("style", "display:block");
                }
                $("#searchBoxRight ul a").dotdotdot({ height: 45 });
                $("#searchTextResult ul a").dotdotdot({ height: 20 });
                $('#txtSearchString').on('blur');
                return s.autocomplete;

            },
            close: function (event, ui) {
                if ($("#txtSearchString").length < shopHq.searchMultiComplete.minCharacters) {
                    searchMultiComplete.viewModel.close();
                }

                $('#txtSearchString').on('blur');
            },
            focus: function (event, ui) {
                if (screen.width <= 767) { //iphone doesn't work with focus so just go to results for all xs viewports
                    window.location.href = ui.item.value;
                    event.preventDefault();
                    return false;
                }


                if (ui.item.label == "watch") {
                    ui.item.label = "Watch";
                }
                if (searchMultiComplete.searchArray[ui.item.label] === undefined || searchMultiComplete.searchArray[ui.item.label] === null) {
                    shopHq.searchMultiComplete.viewModel.GetProductData(ui.item.label);

                    $("#searchBoxRightArray").removeAttr("style");
                    $("#searchBoxRightArray").attr("style", "display:none");
                    $("#searchBoxRight").removeAttr("style");
                    $("#searchBoxRight").attr("style", "display:block");

                } else {
                    $("#searchBoxRightArray").html(searchMultiComplete.searchArray[ui.item.label]);

                    $("#searchBoxRight").removeAttr("style");
                    $("#searchBoxRight").attr("style", "display:none");
                    $("#searchBoxRightArray").removeAttr("style");
                    $("#searchBoxRightArray").attr("style", "display,block");
                }
                $("#searchBoxRight ul a").dotdotdot({ height: 45 });
                $("#searchTextResult ul a").dotdotdot({ height: 20 });
                event.preventDefault();
            }
        };
        _ops = $.extend(_ops, s);
        $.extend($.ui.autocomplete.prototype.options, _ops);
        return this.autocomplete(s);
    };

    //// #end region
    //#region Products 
    searchMultiComplete.viewModel = null;
    searchMultiComplete.SearchMultiCompleteViewModel = function () {
        var self = this;
        self.searchTitle = ko.observable();
        self.Products = ko.observableArray();
        self.Categories = ko.observableArray();
        self.Brands = ko.observableArray();
        self.dotdotdot = null;

        self.GetProductData = function (text) {
            var url = searchMultiComplete.searchServiceUrl + '/jsonp?q=' + encodeURIComponent(text) + '&callback=?';
            $.ajax({
                type: 'GET',
                contentType: "application/json",
                url: url,
                dataType: 'jsonp'
            }).done(function (data) {
                self.searchTitle('Top Results for "' + text + '"');
                self.Products.removeAll();
                self.Categories.removeAll();
                self.Brands.removeAll();
                $.each(data.resultsets, function (i, value) {
                    if (value.name == "default") {
                        $.each(value.results, function (k, res) {
                            var newResult = results(res, text);
                            self.Products.push(newResult);
                        });
                    }
                });
                var brandCheck = "false";
                var n = 0;
                $.each(data.facets, function (i, value) {
                    if (value.label == "Category") {
                        $.each(value.values, function (k, res) {
                            $.each(res.children, function (j, cat2) {
                                var newResult = facets(res.value, cat2.value, text);
                                self.Categories.push(newResult);
                                n++;
                                if (n >= 6) {
                                    return false;
                                }
                                return true;
                            });
                            if (n >= 6) {
                                return false;
                            }
                            return true;
                        });
                    }
                    if (brandCheck == "false") {
                        if (value.label == "Brand") {
                            $.each(value.values.slice(0, 6), function (j, brand) {
                                var newBrand = brands(brand, text);
                                self.Brands.push(newBrand);
                                brandCheck = "true";
                            });

                        }
                    }
                });

                searchMultiComplete.searchArray[text] = $("#searchBoxRight").html();
            }).fail(function (xhr, textStatus, errorThrown) {
                if (console)
                    console.log(errorThrown);
                searchMultiComplete.viewModel.close();
            }).always(function () {

            });

            return false;
        };

        self.close = function close() {
            $('#search-multiComplete-dialog').removeAttr('style');
            $('#search-multiComplete-dialog').attr('style', 'display:none');
            $("#search-button").removeAttr('style');
            $("#search-button").attr('style', 'display:block');
            $("#search-close-button").removeAttr('style');
            $("#search-close-button").attr('style', 'display:none');
            self.Products.removeAll();
            self.Categories.removeAll();
            self.Brands.removeAll();
            self.searchTitle('');
        };
        //#end region
        //#region Private methods 
        function results(data, text) {
            if (data.Title == null || data.Title == undefined) {
                self.title = "Title";
            } else {
                self.title = data.Title;
            }
            self.title = decodeURIComponent(encodeURIComponent(self.title));
            var div = document.createElement('div');
            div.innerHTML = self.title;
            self.title = div.firstChild.nodeValue;

            if (data.ImgSmall == null || data.ImgSmall == undefined) {
                self.imgLink = shopHq.images.SECURE_IMAGE_PATH + "no_product_100x100.GIF";
            } else {
                var image = data.ImgSmall.substring(data.ImgSmall.indexOf(data.OfferCode));
                self.imgLink = shopHq.images.SECURE_IMAGE_PATH + image;
            }


            if (data.OfferCode == null || data.OfferCode == undefined) {
                data.OfferCode = '';
            } else {
                self.Url = '/Product/' + slugify(data.Title) + "/" + data.OfferCode;
            }

            self.Url = self.Url + "?icid=InternalSearch_Product_" + data.OfferCode + "_" + toUrlEncodeSpecialChars(text);
            if (data.PriceHandle == null || data.PriceHandle == undefined) {
                self.PriceLabel = "ShopHQ Price";
            } else {
                self.PriceLabel = data.PriceHandle;
            }
            if (data.OfferPriceLow == null || data.OfferPriceLow == undefined)
                data.OfferPriceLow = "0.00";
            if (data.OfferPriceHigh == null || data.OfferPriceHigh == undefined)
                data.OfferPriceHigh = "0.00";
            if (data.OfferPriceLow != data.OfferPriceHigh)
                self.Price = '$' + data.OfferPriceLow + " - $" + data.OfferPriceHigh;
            else
                self.Price = '$' + data.OfferPriceLow;
            return self;
        };
        function slugify(str) {
            if (str !== undefined && str !== null) {
                str = str.replace(/^\s+|\s+$/g, ''); // trim
                str = str.toLowerCase();

                // remove accents, swap ñ for n, etc
                var from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;";
                var to = "aaaaaeeeeeiiiiooooouuuunc------";
                for (var i = 0, l = from.length; i < l; i++) {
                    str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
                }

                str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
                    .replace(/\s+/g, '-') // collapse whitespace and replace by -
                    .replace(/-+/g, '-'); // collapse dashes

            }
            return str;
        }
        function facets(data, cat2, text) {
            if (data == null)
                data = '';
            if (cat2 == null)
                cat2 = '';
            self.category = data + ' - ' + cat2;
            var urlCat = toUrlEncodeSpecialChars(cat2).toLowerCase();
            var urlData = toUrlEncodeSpecialChars(data).toLowerCase();
            value = encodeURIComponent(text);
            value = value.split("%20").join("+");
            self.Url = '/search/?q=' + value + '&r=' + urlData + '&r=' + urlCat + "&icid=InternalSearch_Category_" + urlData + '-' + urlCat;
            return self;
        }
        function brands(data, text) {
            if (data.value == null || data.value == undefined)
                data.value = '';
            if (data.value != '') {
                data.value = data.value.split('Â®').join('®');
                self.brand = data.value.split('â„¢').join('™');
            } else {
                self.brand = data.value;
            }
            value = encodeURIComponent(text);
            value = value.split("%20").join("+");
            var urlBrand = toUrlEncodeSpecialChars(data.value).toLowerCase();
            self.url = '/search/?q=' + value + '&r=' + urlBrand + "&icid=InternalSearch_Brand_" + urlBrand;
            return self;
        }

    };

    function toUrlEncodeSpecialChars(text) {
        text = text.split("%").join('');
        text = text.split("'").join('');
        text = text.split('-').join('=');
        text = text.split('é').join('-e-');
        text = text.split(',').join('-c-');
        text = text.split('&').join('-and-');
        text = text.split('/').join('slash-');
        text = text.split('=').join('-');
        text = text.split(' ').join('-');
        return text;
    }

    // #end region

    //Settings for autocomplete
    var settings = {
        searchDomain: "",
        inputElement: "input#txtSearchString",
        inputFormElement: "",
        delay: 300,
        minLength: 4,
        maxResults: 10,
        browserAutocomplete: false,
        queryCaseSensitive: false,
        startsWith: false,
        searchOnSelect: true,
        zindex: 100,
        header: "",
        footer: "",
        appendTo: "#searchTextResult"
    };

    $(function () {
        let searchBoxRight = document.getElementById('searchBoxRight');
        shopHq.searchMultiComplete.viewModel = new shopHq.searchMultiComplete.SearchMultiCompleteViewModel();
        if (searchBoxRight) {
            ko.applyBindings(searchMultiComplete.viewModel, document.getElementById('searchBoxRight'));
        }
        settings.minLength = shopHq.searchMultiComplete.minCharacters;

        if ($(settings.inputElement)[0]) {
            $(settings.inputElement).Autocomplete(settings)
                .data("ui-autocomplete")._renderItem = function (ul, item) {
                    return $("<li></li>").data("item.autocomplete", item)
                        .append("<a> <label style='display:none'>" + item.label + "</label>" + item.displayLabel + "</a>")
                        .appendTo(ul);
                };
        }
    });

    return searchMultiComplete;
})(shopHq.searchMultiComplete = shopHq.searchMultiComplete || {}, jQuery);;
/*
 *	jQuery dotdotdot 1.6.12
 *
 *	Copyright (c) Fred Heusschen
 *	www.frebsite.nl
 *
 *	Plugin website:
 *	dotdotdot.frebsite.nl
 *
 *	Dual licensed under the MIT and GPL licenses.
 *	http://en.wikipedia.org/wiki/MIT_License
 *	http://en.wikipedia.org/wiki/GNU_General_Public_License
 */
!function(t,e){function n(t,e,n){var r=t.children(),o=!1;t.empty();for(var i=0,d=r.length;d>i;i++){var l=r.eq(i);if(t.append(l),n&&t.append(n),a(t,e)){l.remove(),o=!0;break}n&&n.detach()}return o}function r(e,n,i,d,l){var s=!1,c="table, thead, tbody, tfoot, tr, col, colgroup, object, embed, param, ol, ul, dl, blockquote, select, optgroup, option, textarea, script, style",u="script";return e.contents().detach().each(function(){var h=this,f=t(h);if("undefined"==typeof h||3==h.nodeType&&0==t.trim(h.data).length)return!0;if(f.is(u))e.append(f);else{if(s)return!0;e.append(f),l&&e[e.is(c)?"after":"append"](l),a(i,d)&&(s=3==h.nodeType?o(f,n,i,d,l):r(f,n,i,d,l),s||(f.detach(),s=!0)),s||l&&l.detach()}}),s}function o(e,n,r,o,d){var c=e[0];if(!c)return!1;var h=s(c),f=-1!==h.indexOf(" ")?" ":"　",p="letter"==o.wrap?"":f,g=h.split(p),v=-1,w=-1,b=0,y=g.length-1;for(o.fallbackToLetter&&0==b&&0==y&&(p="",g=h.split(p),y=g.length-1);y>=b&&(0!=b||0!=y);){var m=Math.floor((b+y)/2);if(m==w)break;w=m,l(c,g.slice(0,w+1).join(p)+o.ellipsis),a(r,o)?(y=w,o.fallbackToLetter&&0==b&&0==y&&(p="",g=g[0].split(p),v=-1,w=-1,b=0,y=g.length-1)):(v=w,b=w)}if(-1==v||1==g.length&&0==g[0].length){var x=e.parent();e.detach();var T=d&&d.closest(x).length?d.length:0;x.contents().length>T?c=u(x.contents().eq(-1-T),n):(c=u(x,n,!0),T||x.detach()),c&&(h=i(s(c),o),l(c,h),T&&d&&t(c).parent().append(d))}else h=i(g.slice(0,v+1).join(p),o),l(c,h);return!0}function a(t,e){return t.innerHeight()>e.maxHeight}function i(e,n){for(;t.inArray(e.slice(-1),n.lastCharacter.remove)>-1;)e=e.slice(0,-1);return t.inArray(e.slice(-1),n.lastCharacter.noEllipsis)<0&&(e+=n.ellipsis),e}function d(t){return{width:t.innerWidth(),height:t.innerHeight()}}function l(t,e){t.innerText?t.innerText=e:t.nodeValue?t.nodeValue=e:t.textContent&&(t.textContent=e)}function s(t){return t.innerText?t.innerText:t.nodeValue?t.nodeValue:t.textContent?t.textContent:""}function c(t){do t=t.previousSibling;while(t&&1!==t.nodeType&&3!==t.nodeType);return t}function u(e,n,r){var o,a=e&&e[0];if(a){if(!r){if(3===a.nodeType)return a;if(t.trim(e.text()))return u(e.contents().last(),n)}for(o=c(a);!o;){if(e=e.parent(),e.is(n)||!e.length)return!1;o=c(e[0])}if(o)return u(t(o),n)}return!1}function h(e,n){return e?"string"==typeof e?(e=t(e,n),e.length?e:!1):e.jquery?e:!1:!1}function f(t){for(var e=t.innerHeight(),n=["paddingTop","paddingBottom"],r=0,o=n.length;o>r;r++){var a=parseInt(t.css(n[r]),10);isNaN(a)&&(a=0),e-=a}return e}if(!t.fn.dotdotdot){t.fn.dotdotdot=function(e){if(0==this.length)return t.fn.dotdotdot.debug('No element found for "'+this.selector+'".'),this;if(this.length>1)return this.each(function(){t(this).dotdotdot(e)});var o=this;o.data("dotdotdot")&&o.trigger("destroy.dot"),o.data("dotdotdot-style",o.attr("style")||""),o.css("word-wrap","break-word"),"nowrap"===o.css("white-space")&&o.css("white-space","normal"),o.bind_events=function(){return o.bind("update.dot",function(e,d){e.preventDefault(),e.stopPropagation(),l.maxHeight="number"==typeof l.height?l.height:f(o),l.maxHeight+=l.tolerance,"undefined"!=typeof d&&(("string"==typeof d||d instanceof HTMLElement)&&(d=t("<div />").append(d).contents()),d instanceof t&&(i=d)),g=o.wrapInner('<div class="dotdotdot" />').children(),g.contents().detach().end().append(i.clone(!0)).find("br").replaceWith("  <br />  ").end().css({height:"auto",width:"auto",border:"none",padding:0,margin:0});var c=!1,u=!1;return s.afterElement&&(c=s.afterElement.clone(!0),c.show(),s.afterElement.detach()),a(g,l)&&(u="children"==l.wrap?n(g,l,c):r(g,o,g,l,c)),g.replaceWith(g.contents()),g=null,t.isFunction(l.callback)&&l.callback.call(o[0],u,i),s.isTruncated=u,u}).bind("isTruncated.dot",function(t,e){return t.preventDefault(),t.stopPropagation(),"function"==typeof e&&e.call(o[0],s.isTruncated),s.isTruncated}).bind("originalContent.dot",function(t,e){return t.preventDefault(),t.stopPropagation(),"function"==typeof e&&e.call(o[0],i),i}).bind("destroy.dot",function(t){t.preventDefault(),t.stopPropagation(),o.unwatch().unbind_events().contents().detach().end().append(i).attr("style",o.data("dotdotdot-style")||"").data("dotdotdot",!1)}),o},o.unbind_events=function(){return o.unbind(".dot"),o},o.watch=function(){if(o.unwatch(),"window"==l.watch){var e=t(window),n=e.width(),r=e.height();e.bind("resize.dot"+s.dotId,function(){n==e.width()&&r==e.height()&&l.windowResizeFix||(n=e.width(),r=e.height(),u&&clearInterval(u),u=setTimeout(function(){o.trigger("update.dot")},10))})}else c=d(o),u=setInterval(function(){var t=d(o);(c.width!=t.width||c.height!=t.height)&&(o.trigger("update.dot"),c=d(o))},100);return o},o.unwatch=function(){return t(window).unbind("resize.dot"+s.dotId),u&&clearInterval(u),o};var i=o.contents(),l=t.extend(!0,{},t.fn.dotdotdot.defaults,e),s={},c={},u=null,g=null;return l.lastCharacter.remove instanceof Array||(l.lastCharacter.remove=t.fn.dotdotdot.defaultArrays.lastCharacter.remove),l.lastCharacter.noEllipsis instanceof Array||(l.lastCharacter.noEllipsis=t.fn.dotdotdot.defaultArrays.lastCharacter.noEllipsis),s.afterElement=h(l.after,o),s.isTruncated=!1,s.dotId=p++,o.data("dotdotdot",!0).bind_events().trigger("update.dot"),l.watch&&o.watch(),o},t.fn.dotdotdot.defaults={ellipsis:"... ",wrap:"word",fallbackToLetter:!0,lastCharacter:{},tolerance:0,callback:null,after:null,height:null,watch:!1,windowResizeFix:!0},t.fn.dotdotdot.defaultArrays={lastCharacter:{remove:[" ","　",",",";",".","!","?"],noEllipsis:[]}},t.fn.dotdotdot.debug=function(){};var p=1,g=t.fn.html;t.fn.html=function(n){return n!=e&&!t.isFunction(n)&&this.data("dotdotdot")?this.trigger("update",[n]):g.apply(this,arguments)};var v=t.fn.text;t.fn.text=function(n){return n!=e&&!t.isFunction(n)&&this.data("dotdotdot")?(n=t("<div />").text(n).html(),this.trigger("update",[n])):v.apply(this,arguments)}}}(jQuery);;
var cnb_pageTitle = '';
var cnb_currentPageURL = window.location.href;
let cnb_URLParams = new URLSearchParams(window.location.search);
var cnb_mainPageType = '';
var cnb_mainPageName = '';
var cnb_staticPageName = '';
var cnb_classIndicator = '';
var cnb_overrideLeftNav = cnb_URLParams.has('leftNav');
var cnb_leftNavParamValue = '' + cnb_URLParams.get('leftNav');
var cnb_overrideRefPageName = cnb_URLParams.has('referringPageName');
var cnb_refPageNameParamValue = '' + cnb_URLParams.get('referringPageName');
var cnb_thisPageFileName = window.location.href.split('/').pop().split('#')[0].split('?')[0];
var cnb_pageSignifierSeparator = cnb_thisPageFileName.indexOf('-');
var cnb_pageFileNameSuffixLocation = cnb_thisPageFileName.indexOf('.');
var cnb_staticPageTypeIndicator = cnb_thisPageFileName.slice(0, cnb_pageSignifierSeparator);
var cnb_staticPageFileName = cnb_thisPageFileName.substr(0, cnb_pageFileNameSuffixLocation);

/* ######################################## */
/* ### Remove MegaNav for Checkout Flow ### */
let cnb_thisPageMetaDesc = '' + $('meta[name="description"]').attr('content');
cnb_thisPageMetaDesc = cnb_thisPageMetaDesc.toLowerCase();
if (cnb_thisPageMetaDesc.indexOf('checkout') != -1) {
    $('#cnb-megaNav, #cnb-staticPageBreadcrumbing, #cnb_permaBanner, #cnb-statusSearch').hide();
}
/* ### Remove MegaNav for Checkout Flow ### */
/* ######################################## */

$(function () {
    /* ############################################################################ */
    /* ### Capture Page Title for Breadcrumbing & Prepend Store Name Afterwards ### */
    cnb_pageTitle = $('title').text();
    $('title').prepend('Christopher & Banks - ');
    /* ### Capture Page Title for Breadcrumbing & Prepend Store Name Afterwards ### */
    /* ############################################################################ */

    /* ########################################## */
    /* ### Static/Landing Page Identification ### */
    var cnb_mainPageClassPresence = typeof $('#cnb-mainPageContent').attr('class');

    if (cnb_mainPageClassPresence === 'undefined') {
        $('#cnb-mainPageContent').addClass('cnb-stdPage');
    }
    var cnb_mainPageClasses = $('#cnb-mainPageContent').attr('class').split(' ');
    for (i = 0; i < cnb_mainPageClasses.length; i++) {
        cnb_classIndicator = 'cnb-pageType-';
        if (cnb_mainPageClasses[i].indexOf(cnb_classIndicator) != -1) {
            cnb_currLength = cnb_classIndicator.length;
            cnb_mainPageType = cnb_mainPageClasses[i];
            cnb_mainPageType = cnb_mainPageType.slice(cnb_currLength);
        }
        cnb_classIndicator = 'cnb-pageName-';
        if (cnb_mainPageClasses[i].indexOf(cnb_classIndicator) != -1) {
            cnb_currLength = cnb_classIndicator.length;
            cnb_mainPageName = cnb_mainPageClasses[i];
            cnb_mainPageName = cnb_mainPageName.slice(cnb_currLength);
        }
        cnb_classIndicator = 'cnb-staticPageName-';
        if (cnb_mainPageClasses[i].indexOf(cnb_classIndicator) != -1) {
            cnb_currLength = cnb_classIndicator.length;
            cnb_staticPageName = cnb_mainPageClasses[i];
            cnb_staticPageName = cnb_staticPageName.slice(cnb_currLength);
        }
        if (cnb_staticPageName === '') {
            // not a static page.
            $('#cnb-mainPageContent').removeClass(cnb_classIndicator + 'XXStaticPageNameXX');
        }
    }

    /* URL Overrides for testing: leftNav=true and referringPageName=leftNavLink_payment */
    if ((cnb_overrideLeftNav) && (cnb_leftNavParamValue === 'true')) {
        cnb_mainPageType = 'leftNavPage';
    }
    if ((cnb_overrideRefPageName) && (cnb_refPageNameParamValue != '')) {
        cnb_staticPageName = cnb_refPageNameParamValue;
    }

    /* console.log('cnb_mainPageType: ' + cnb_mainPageType + ' ... cnb_mainPageName: ' + cnb_mainPageName + ' ... cnb_staticPageName: ' + cnb_staticPageName); */
    /* ### Static/Landing Page Identification ### */
    /* ########################################## */

    /* ##################################################### */
    /* ### BEGIN Static Landing Pages - Breadcrumb Links ### */
    var cnb_staticPageType = '';
    var cnb_staticPageTypeName = '';
    var cnb_staticPageTypeLink = '';
    var cnb_staticPageName = cnb_pageTitle;

    switch (cnb_staticPageTypeIndicator) {
        case 'cs':
            cnb_staticPageType = 'customerService';
            cnb_staticPageTypeName = 'Customer Service';
            cnb_staticPageTypeLink = '/p/landing/cs/cs-overview?dt=3';
            break;
        case 'faq':
            cnb_staticPageType = 'faq';
            cnb_staticPageTypeName = 'FAQs';
            cnb_staticPageTypeLink = '/p/landing/faq/faq-overview?dt=3';
            break;
        case 'abt':
            cnb_staticPageType = 'aboutCompany';
            cnb_staticPageTypeName = 'About Christopher & Banks';
            cnb_staticPageTypeLink = '/p/landing/abt/abt-ourHistory?dt=3';
            break;
        case 'plc':
            cnb_staticPageType = 'companyPolicy';
            cnb_staticPageTypeName = 'Policies';
            cnb_staticPageTypeLink = '/p/landing/plc/plc-security?dt=3';
            break;
        default:
            cnb_staticPageType = 'landing';
            cnb_staticPageTypeName = cnb_pageTitle;
    }

    if (cnb_staticPageTypeLink === '') {
        // no section link exists. do not use href; use name.
        var cnb_enteredLink = cnb_staticPageTypeLink;
        cnb_staticPageTypeLink = 'name="' + cnb_enteredLink + '"';
    } else {
        var cnb_enteredLink = cnb_staticPageTypeLink;
        cnb_staticPageTypeLink = 'href="' + cnb_enteredLink + '"';
    }

    let cnb_addedBreadcrumbs = '<span class="cnb-breadcrumbLink"><a ' + cnb_staticPageTypeLink + '>' + cnb_staticPageTypeName + '</a></span>';

    if (cnb_staticPageTypeLink === '') {
        cnb_addedBreadcrumbs = '<span class="cnb-breadcrumbLink"><strong>' + cnb_staticPageName + '</strong></span>';
    }
    if (cnb_staticPageType === 'landing') {
        cnb_addedBreadcrumbs = '<span class="cnb-breadcrumbLink"><strong>' + cnb_staticPageTypeName + '</strong></span>';
    }
    if (cnb_thisPageFileName.indexOf('overview') != -1) {
        // If you are already on an overview page, don't link to itself in the breadcrumbing.
        cnb_addedBreadcrumbs = '<span class="cnb-breadcrumbLink"><strong>' + cnb_staticPageTypeName + '</strong></span>';
    }
    if (cnb_staticPageTypeName != cnb_pageTitle) {
        // Not a one-off landing page; On a landing page that's part of a recognized section. Need to add specific page name to breadcrumbing.
        cnb_addedBreadcrumbs = cnb_addedBreadcrumbs + '<span class="cnb-breadcrumbLink"><strong>' + cnb_staticPageName + '</strong></span>';
    }
    $('#cnb-generalBreadcrumbing').append(cnb_addedBreadcrumbs);
    /* ###  END Static Landing Pages - Breadcrumb Links  ### */
    /* ##################################################### */

    var cnb_openOrClose_popUpWindow;

    /* ############################### */
    /* ### BEGIN MegaNav Hide/Show ### */
    function tabletMobile() {
        var isTabletMobile = false;
        var currPageWidth = $(window).width();
        if (currPageWidth <= 767) {
            isTabletMobile = true;
        }
        return isTabletMobile;
    }

    if (tabletMobile()) {
        $('#cnb-megaNav > .cnb-navLinks > li').click(function (event) {
            if ($(event.target).hasClass("cnb-hasSubNav")) {
                event.preventDefault();
                $(this).find('.cnb-hasSubNav').toggleClass('cnb-open');
                $(this).find('i.fa.fa-plus').toggleClass('fa-minus');
            }
        });
    }
    $('#cnb-intermittentLeftNav').clone().attr('id', 'cnb-intermittentLeftNavMobile').appendTo($('#cnb-megaNav')).parents('#cnb-megaNav').find('.cnb-collapsibleNavigationButton').click(function () {
        $('#cnb-intermittentLeftNavMobile').toggleClass('cnb-mobileOpen');
    });
    $('#cnb-megaNav .cnb-collapsibleNavigationButton').click(function () {
        $(this).toggleClass('cnb-mobileOpen');
    });
    /* ###  END MegaNav Hide/Show  ### */
    /* ############################### */

    /* ##################################### */
    /* ### BEGIN Pop-Up Window Hide/Show ### */
    function adjustSlideDownWindowAndBlocker(clickRequest, slidingWindowObject) {
        var cnb_thisID = $(slidingWindowObject).attr('id');
        var cnb_thisClass = $(slidingWindowObject).attr('class');
        var cnb_windowBlockerVisible = false;
        var cnb_dropWindowsVisible = false;
        var cnb_assumedClickRequest = ''

        if (clickRequest != '') {
            cnb_assumedClickRequest = clickRequest;
        }
        $('.cnb-slideDownWindow').each(function () {
            if ($(this).is(':visible')) {
                cnb_dropWindowsVisible = true;
                cnb_assumedClickRequest = 'close';
            }
        });
        $('.cnb-windowBlocker').each(function () {
            if ($(this).is(':visible')) {
                cnb_windowBlockerVisible = true;
            }
        });

        if ((cnb_assumedClickRequest === 'close') || (cnb_assumedClickRequest === 'closeAll')) {
            if (cnb_windowBlockerVisible || cnb_dropWindowsVisible) {
                $('.cnb-slideDownWindow').slideUp(400, function () {
                    $('.cnb-slideDownWindow.cnb-disclaimerPopup').remove();
                    $('.cnb-windowBlocker').hide();
                });
                $('.fa-minus').removeClass('fa-minus').addClass('fa-plus');
            }
        } else {
            if (!cnb_windowBlockerVisible || !cnb_dropWindowsVisible) {
                $('#' + cnb_thisID).find('.fa-plus').removeClass('fa-plus').addClass('fa-minus');
                $('.cnb-windowBlocker').show();
                $(slidingWindowObject).find('.cnb-slideDownWindow').slideDown(400);
            }
        }
    }
    $('.cnb-windowBlocker').click(function () {
        cnb_openOrClose_popUpWindow = 'closeAll';
        adjustSlideDownWindowAndBlocker(cnb_openOrClose_popUpWindow, $(this));
    });
    /* ###  END Pop-Up Window Hide/Show  ### */
    /* ##################################### */

    /* #################################### */
    /* ### BEGIN Perma-Banner Hide/Show ### */
    $('#cnb-permaBanner').click(function () {
        cnb_openOrClose_popUpWindow = '';
        if ($(this).find('.cnb-slideDownWindow').first().is(':visible')) {
            cnb_openOrClose_popUpWindow = 'close';
        } else {
            cnb_openOrClose_popUpWindow = 'open';
        }
        adjustSlideDownWindowAndBlocker(cnb_openOrClose_popUpWindow, $(this));
    });
    /* ###  END Perma-Banner Hide/Show  ### */
    /* #################################### */

    /* ####################################### */
    /* ### BEGIN Side-Nav Select Hide/Show ### */
    if (cnb_mainPageType === 'leftNavPage') {
        $('#cnb-intermittentLeftNav').addClass('cnb-present').removeClass('cnb-notPresent');
    }
    $('#cnb-intermittentLeftNav a.cnb-nav').each(function () {
        cnb_thisText = $(this).text().replace(/\W/g, '').toLowerCase();
        cnb_thisLinkName = 'leftNavLink_' + cnb_thisText;
        $(this).removeClass('cnb-specificClassForLink').addClass('cnb-leftNavLink_' + cnb_thisText);
        // if cnb_staticPageName equals cnb_thisLinkName then highlight that left-nav link
        if (cnb_thisLinkName === cnb_staticPageName) {
            $(this).addClass('cnb-activeLinkedPage');
        } else {
            $(this).removeClass('cnb-activeLinkedPage');
        }
    }).parents('dd').find('.cnb-activeLinkedPage').each(function () {
        $(this).parents('section.cnb-subSectionNav').first().addClass('cnb-openSubNav').prev('a').addClass('cnb-open').find('.fa-plus').removeClass('fa-plus').addClass('fa-minus');
    });

    function hideShowLeftNav(objectToHideShow) {
        /* hide/show left nav options that have sub-nav */
        cnb_thisObjectsClasses = $(objectToHideShow).attr('class');
        if (cnb_thisObjectsClasses.indexOf('cnb-open') != -1) {
            /* clicked menu-header is already open */
            $(objectToHideShow).removeClass('cnb-open').find('.fa').addClass('fa-plus').removeClass('fa-minus').parents('a.cnb-hasSubNav').next('.cnb-subSectionNav').removeClass('cnb-openSubNav');
        } else {
            /* clicked menu-header is closed */
            $(objectToHideShow).addClass('cnb-open').find('.fa').addClass('fa-minus').removeClass('fa-plus').parents('a.cnb-hasSubNav').next('.cnb-subSectionNav').addClass('cnb-openSubNav');
        }
    }

    $('#cnb-intermittentLeftNav a.cnb-hasSubNav').click(function (event) {
        hideShowLeftNav($(this));
        event.preventDefault();
    });
    /* ###  END Side-Nav Select Hide/Show  ### */
    /* ####################################### */

    /* ############################################# */
    /* ### BEGIN Perma-Banner Hide/Show Rotation ### */
    var cnb_totalPermaBanners;
    var cnb_visiblePermaBanners;
    var cnb_activePermaBanner;
    var cnb_activePermaBannerPosition;
    var cnb_nextPermaBanner;

    function setUpPermaBanner() {
        cnb_totalPermaBanners = $('#cnb-permaBanner .cnb-slideContent').length;
        if (cnb_totalPermaBanners === 0) {
            $('#cnb-permaBanner').append('<span class="cnb-slideContent cnb-show">Welcome to Christopher &amp; Banks</span>');
            cnb_totalPermaBanners = 1;
        }
        cnb_visiblePermaBanners = $('#cnb-permaBanner .cnb-slideContent.cnb-show').length;
        if (cnb_visiblePermaBanners > 0) {
            $('#cnb-permaBanner .cnb-slideContent.cnb-show').removeClass('cnb-show');
            $('#cnb-permaBanner .cnb-slideContent.cnb-show').first().fadeIn().addClass('cnb-show');
        } else if (cnb_visiblePermaBanners === 0) {
            $('#cnb-permaBanner .cnb-slideContent').first().fadeIn().addClass('cnb-show');
        }
        cnb_activePermaBanner = $('#cnb-permaBanner .cnb-slideContent.cnb-show');
        cnb_activePermaBannerPosition = $('#cnb-permaBanner .cnb-slideContent.cnb-show').index() - 1;
        if (cnb_activePermaBannerPosition < (cnb_totalPermaBanners - 1)) {
            cnb_nextPermaBanner = $(cnb_activePermaBanner).next('.cnb-slideContent');
        } else {
            cnb_nextPermaBanner = $('#cnb-permaBanner .cnb-slideContent').first();
        }
        $(cnb_nextPermaBanner).addClass('cnb-next');
    }

    function permaBannerSwap() {
        $(cnb_activePermaBanner).fadeOut(1000).promise().done(function () {
            $(cnb_activePermaBanner).removeClass('cnb-show');
            setTimeout(300);
            $(cnb_nextPermaBanner).fadeIn(1000).promise().done(function () {
                $(cnb_nextPermaBanner).addClass('cnb-show').removeClass('cnb-next');
            });
        });
        cnb_activePermaBanner = $('#cnb-permaBanner .cnb-slideContent.cnb-show');
        cnb_activePermaBannerPosition = $('#cnb-permaBanner .cnb-slideContent.cnb-show').index() - 1;
        if (cnb_activePermaBannerPosition < (cnb_totalPermaBanners - 1)) {
            cnb_nextPermaBanner = $(cnb_activePermaBanner).next('.cnb-slideContent');
        } else {
            cnb_nextPermaBanner = $('#cnb-permaBanner .cnb-slideContent').first();
        }
        $(cnb_nextPermaBanner).addClass('cnb-next');
    }

    setUpPermaBanner();
    var cnb_permaBannerTimeInterval = 6000;
    setInterval(permaBannerSwap, cnb_permaBannerTimeInterval);
    /* ###  END Perma-Banner Hide/Show Rotation  ### */
    /* ############################################# */

    /* ########################### */
    /* ### BEGIN Header Search ### */
    $('#cnb-headerSearchInputField').focusin(function () {
        var cnb_currentPlaceholder = $(this).attr('placeholder');
        var cnb_currentValue = $(this).val();
        $(this).removeClass('cnb-uppercase').addClass('cnb-normalcase');
        if (cnb_currentValue === '') {
            if ((cnb_currentPlaceholder === '') || (cnb_currentPlaceholder === 'Search')) {
                $(this).attr('placeholder', cnb_currentValue);
            } else {
                $(this).attr('placeholder', '');
            }
        } else {
            $(this).attr('placeholder', cnb_currentValue);
        }
    }).keyup(function () {
        var cnb_currentPlaceholder = $(this).attr('placeholder');
        var cnb_currentValue = $(this).val();
        $(this).attr('placeholder', cnb_currentValue);
    }).focusout(function () {
        var cnb_currentPlaceholder = $(this).attr('placeholder');
        var cnb_currentValue = $(this).val();

        if (cnb_currentValue === '') {
            $(this).attr('placeholder', 'Search').removeClass('cnb-normalcase').addClass('cnb-uppercase');
        } else {
            if ((cnb_currentPlaceholder === '') || (cnb_currentPlaceholder === 'Search')) {
                $(this).attr('placeholder', cnb_currentValue).removeClass('cnb-uppercase').addClass('cnb-normalcase');
            } else {
                $(this).attr('placeholder', cnb_currentValue).removeClass('cnb-uppercase').addClass('cnb-normalcase');
            }
        }
    });
    /* ### BEGIN Header Search ### */
    /* ########################### */

    /* ############################# */
    /* ### BEGIN Button Dropdown ### */
    function showHideDropdownButton(clickedButton) {
        $(clickedButton).find('i.fa').toggleClass('fa-plus').toggleClass('fa-minus').parent().next('.cnb-navLinks').slideToggle('slow, swing', function () {
            // swing is complete.
            $(this).parents('.cnb-button').toggleClass('cnb-open');
        });
    }
    $('.cnb-button.cnb-button-dropdown .cnb-CTA').click(function () {
        showHideDropdownButton($(this));
    });
    $('html').click(function (event) {
        var $target = $(event.target);
        if (!$target.closest('.cnb-button.cnb-button-dropdown.cnb-open').length) {
            $('.cnb-open .cnb-CTA').click();
        }
    });
    let cnb_totalButtonsInMain = $('#cnb-mainPageContent .cnb-button').length;
    $('#cnb-mainPageContent .cnb-button').each(function (index) {
        let cnb_thisZIndex = 30 + cnb_totalButtonsInMain + index;
        $(this).css('z-index', cnb_thisZIndex);
        cnb_totalButtonsInMain = cnb_totalButtonsInMain - 2;
    });
    /* ###  END Button Dropdown  ### */
    /* ############################# */

    /* ################################################### */
    /* ### BEGIN Slot Disclaimer Population and Pop-Up ### */
    $('.cnb-showDisclaimer .cnb-legalDisclaimer a').click(function (event) {
        let cnb_disclaimerHTML = $(this).parents('.cnb-legalDisclaimer').find('.cnb-promotionalDisclaimerContainer').html();

        $('#cnb-mainPageContent').prepend('<div class="cnb-slideDownWindow cnb-disclaimerPopup"><a class="cnb-popupCloseLink fa fa-window-close" href="#" title="Close Window"></a>' + cnb_disclaimerHTML + '</div>');
        let cnb_openOrClose_popUpWindow = '';
        $('.cnb-popupCloseLink').click(function (event) {
            cnb_openOrClose_popUpWindow = 'close';
            $('.cnb-windowBlocker').click();
            event.preventDefault();
        });
        if ($('#cnb-mainPageContent .cnb-disclaimerPopup').first().is(':visible')) {
            cnb_openOrClose_popUpWindow = 'close';
        } else {
            cnb_openOrClose_popUpWindow = 'open';
            $('.cnb-disclaimerPopup').first().slideDown(400);
            $('.cnb-windowBlocker').show();
        }
        /* adjustSlideDownWindowAndBlocker(cnb_openOrClose_popUpWindow, $('.cnb-disclaimerPopup')); */
        event.preventDefault();
    });
    /* ###  END Slot Disclaimer Population and Pop-Up  ### */
    /* ################################################### */

    /* ################################################################## */
    /* ### BEGIN Set Responsive Image Max-Width by XHTML Width on Img ### */
    $('.cnb-responsiveImg.cnb-staticPageIconImg').each(function () {
        var cnb_thisWidth = $(this).attr('width');
        $(this).css('max-width', cnb_thisWidth + 'px');
    });
    /* ###  END Set Responsive Image Max-Width by XHTML Width on Img  ### */
    /* ################################################################## */

    document.querySelector('.scroll-top-wrapper').addEventListener('click', (e) => {
        e.preventDefault();
        document.body.scrollTop = 0;
        document.documentElement.scrollTop = 0;
    });

    window.addEventListener("scroll", function () {
        if (this.window.pageYOffset < 565) {
            document.querySelector('.scroll-top-wrapper').classList.add('hidden')
        } else {
            document.querySelector('.scroll-top-wrapper').classList.remove('hidden')
        }
    });

    let dropbtn = document.querySelector('.dropdown .dropbtn');
    let dropdownContent = document.querySelector('.dropdown .dropdown-content');

    if (dropbtn) {
        dropbtn.href = "javascript:;";
        dropbtn.addEventListener("click", (e) => {
            if (dropdownContent.classList.contains("visible")) {
                dropdownContent.classList.remove("visible");
            } else {
                dropdownContent.classList.add("visible");
            }
        });
    }

    if (dropdownContent) {
        dropdownContent.addEventListener("click", (e) => {
            e.stopPropagation();
            dropdownContent.classList.remove("visible");
        });
    }
});
;
!function (e, t) { if ("object" == typeof exports && "object" == typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else { var i = t(); for (var n in i) ("object" == typeof exports ? exports : e)[n] = i[n] } }(this, (function () {
    return function (e) { var t = {}; function i(n) { if (t[n]) return t[n].exports; var r = t[n] = { i: n, l: !1, exports: {} }; return e[n].call(r.exports, r, r.exports, i), r.l = !0, r.exports } return i.m = e, i.c = t, i.d = function (e, t, n) { i.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: n }) }, i.r = function (e) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }) }, i.t = function (e, t) { if (1 & t && (e = i(e)), 8 & t) return e; if (4 & t && "object" == typeof e && e && e.__esModule) return e; var n = Object.create(null); if (i.r(n), Object.defineProperty(n, "default", { enumerable: !0, value: e }), 2 & t && "string" != typeof e) for (var r in e) i.d(n, r, function (t) { return e[t] }.bind(null, r)); return n }, i.n = function (e) { var t = e && e.__esModule ? function () { return e["default"] } : function () { return e }; return i.d(t, "a", t), t }, i.o = function (e, t) { return Object.prototype.hasOwnProperty.call(e, t) }, i.p = "", i(i.s = 12) }([function (e, t, i) { "use strict"; var n, r, a = i(1)(), o = i(3), s = i(4), l = i(6), u = function () { var e = new s; return n = e.getResult(), r = new l, this }; u.prototype = { getSoftwareVersion: function () { return "0.1.11" }, getBrowserData: function () { return n }, getFingerprint: function () { var e = "|", t = n.ua, i = this.getScreenPrint(), r = this.getPlugins(), a = this.getFonts(), s = this.isLocalStorage(), l = this.isSessionStorage(), u = this.getTimeZone(), c = this.getLanguage(), d = this.getSystemLanguage(), p = this.isCookie(), f = this.getCanvasPrint(); return o(t + e + i + e + r + e + a + e + s + e + l + e + u + e + c + e + d + e + p + e + f, 256) }, getCustomFingerprint: function () { for (var e = "|", t = "", i = 0; i < arguments.length; i++)t += arguments[i] + e; return o(t, 256) }, getUserAgent: function () { return n.ua }, getUserAgentLowerCase: function () { return n.ua.toLowerCase() }, getBrowser: function () { return n.browser.name }, getBrowserVersion: function () { return n.browser.version }, getBrowserMajorVersion: function () { return n.browser.major }, isIE: function () { return /IE/i.test(n.browser.name) }, isChrome: function () { return /Chrome/i.test(n.browser.name) }, isFirefox: function () { return /Firefox/i.test(n.browser.name) }, isSafari: function () { return /Safari/i.test(n.browser.name) }, isMobileSafari: function () { return /Mobile\sSafari/i.test(n.browser.name) }, isOpera: function () { return /Opera/i.test(n.browser.name) }, getEngine: function () { return n.engine.name }, getEngineVersion: function () { return n.engine.version }, getOS: function () { return n.os.name }, getOSVersion: function () { return n.os.version }, isWindows: function () { return /Windows/i.test(n.os.name) }, isMac: function () { return /Mac/i.test(n.os.name) }, isLinux: function () { return /Linux/i.test(n.os.name) }, isUbuntu: function () { return /Ubuntu/i.test(n.os.name) }, isSolaris: function () { return /Solaris/i.test(n.os.name) }, getDevice: function () { return n.device.model }, getDeviceType: function () { return n.device.type }, getDeviceVendor: function () { return n.device.vendor }, getCPU: function () { return n.cpu.architecture }, isMobile: function () { var e = n.ua || navigator.vendor || window.opera; return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(e) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0, 4)) }, isMobileMajor: function () { return this.isMobileAndroid() || this.isMobileBlackBerry() || this.isMobileIOS() || this.isMobileOpera() || this.isMobileWindows() }, isMobileAndroid: function () { return !!n.ua.match(/Android/i) }, isMobileOpera: function () { return !!n.ua.match(/Opera Mini/i) }, isMobileWindows: function () { return !!n.ua.match(/IEMobile/i) }, isMobileBlackBerry: function () { return !!n.ua.match(/BlackBerry/i) }, isMobileIOS: function () { return !!n.ua.match(/iPhone|iPad|iPod/i) }, isIphone: function () { return !!n.ua.match(/iPhone/i) }, isIpad: function () { return !!n.ua.match(/iPad/i) }, isIpod: function () { return !!n.ua.match(/iPod/i) }, getScreenPrint: function () { return "Current Resolution: " + this.getCurrentResolution() + ", Available Resolution: " + this.getAvailableResolution() + ", Color Depth: " + this.getColorDepth() + ", Device XDPI: " + this.getDeviceXDPI() + ", Device YDPI: " + this.getDeviceYDPI() }, getColorDepth: function () { return screen.colorDepth }, getCurrentResolution: function () { return screen.width + "x" + screen.height }, getAvailableResolution: function () { return screen.availWidth + "x" + screen.availHeight }, getDeviceXDPI: function () { return screen.deviceXDPI }, getDeviceYDPI: function () { return screen.deviceYDPI }, getPlugins: function () { for (var e = "", t = 0; t < navigator.plugins.length; t++)t == navigator.plugins.length - 1 ? e += navigator.plugins[t].name : e += navigator.plugins[t].name + ", "; return e }, isJava: function () { return navigator.javaEnabled() }, getJavaVersion: function () { throw new Error("Please use client.java.js or client.js if you need this functionality!") }, isFlash: function () { return !!navigator.plugins["Shockwave Flash"] }, getFlashVersion: function () { throw new Error("Please use client.flash.js or client.js if you need this functionality!") }, isSilverlight: function () { return !!navigator.plugins["Silverlight Plug-In"] }, getSilverlightVersion: function () { return this.isSilverlight() ? navigator.plugins["Silverlight Plug-In"].description : "" }, isMimeTypes: function () { return !(!navigator.mimeTypes || !navigator.mimeTypes.length) }, getMimeTypes: function () { var e = ""; if (navigator.mimeTypes) for (var t = 0; t < navigator.mimeTypes.length; t++)t == navigator.mimeTypes.length - 1 ? e += navigator.mimeTypes[t].description : e += navigator.mimeTypes[t].description + ", "; return e }, isFont: function (e) { return r.detect(e) }, getFonts: function () { for (var e = ["Abadi MT Condensed Light", "Adobe Fangsong Std", "Adobe Hebrew", "Adobe Ming Std", "Agency FB", "Aharoni", "Andalus", "Angsana New", "AngsanaUPC", "Aparajita", "Arab", "Arabic Transparent", "Arabic Typesetting", "Arial Baltic", "Arial Black", "Arial CE", "Arial CYR", "Arial Greek", "Arial TUR", "Arial", "Batang", "BatangChe", "Bauhaus 93", "Bell MT", "Bitstream Vera Serif", "Bodoni MT", "Bookman Old Style", "Braggadocio", "Broadway", "Browallia New", "BrowalliaUPC", "Calibri Light", "Calibri", "Californian FB", "Cambria Math", "Cambria", "Candara", "Castellar", "Casual", "Centaur", "Century Gothic", "Chalkduster", "Colonna MT", "Comic Sans MS", "Consolas", "Constantia", "Copperplate Gothic Light", "Corbel", "Cordia New", "CordiaUPC", "Courier New Baltic", "Courier New CE", "Courier New CYR", "Courier New Greek", "Courier New TUR", "Courier New", "DFKai-SB", "DaunPenh", "David", "DejaVu LGC Sans Mono", "Desdemona", "DilleniaUPC", "DokChampa", "Dotum", "DotumChe", "Ebrima", "Engravers MT", "Eras Bold ITC", "Estrangelo Edessa", "EucrosiaUPC", "Euphemia", "Eurostile", "FangSong", "Forte", "FrankRuehl", "Franklin Gothic Heavy", "Franklin Gothic Medium", "FreesiaUPC", "French Script MT", "Gabriola", "Gautami", "Georgia", "Gigi", "Gisha", "Goudy Old Style", "Gulim", "GulimChe", "GungSeo", "Gungsuh", "GungsuhChe", "Haettenschweiler", "Harrington", "Hei S", "HeiT", "Heisei Kaku Gothic", "Hiragino Sans GB", "Impact", "Informal Roman", "IrisUPC", "Iskoola Pota", "JasmineUPC", "KacstOne", "KaiTi", "Kalinga", "Kartika", "Khmer UI", "Kino MT", "KodchiangUPC", "Kokila", "Kozuka Gothic Pr6N", "Lao UI", "Latha", "Leelawadee", "Levenim MT", "LilyUPC", "Lohit Gujarati", "Loma", "Lucida Bright", "Lucida Console", "Lucida Fax", "Lucida Sans Unicode", "MS Gothic", "MS Mincho", "MS PGothic", "MS PMincho", "MS Reference Sans Serif", "MS UI Gothic", "MV Boli", "Magneto", "Malgun Gothic", "Mangal", "Marlett", "Matura MT Script Capitals", "Meiryo UI", "Meiryo", "Menlo", "Microsoft Himalaya", "Microsoft JhengHei", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Sans Serif", "Microsoft Tai Le", "Microsoft Uighur", "Microsoft YaHei", "Microsoft Yi Baiti", "MingLiU", "MingLiU-ExtB", "MingLiU_HKSCS", "MingLiU_HKSCS-ExtB", "Miriam Fixed", "Miriam", "Mongolian Baiti", "MoolBoran", "NSimSun", "Narkisim", "News Gothic MT", "Niagara Solid", "Nyala", "PMingLiU", "PMingLiU-ExtB", "Palace Script MT", "Palatino Linotype", "Papyrus", "Perpetua", "Plantagenet Cherokee", "Playbill", "Prelude Bold", "Prelude Condensed Bold", "Prelude Condensed Medium", "Prelude Medium", "PreludeCompressedWGL Black", "PreludeCompressedWGL Bold", "PreludeCompressedWGL Light", "PreludeCompressedWGL Medium", "PreludeCondensedWGL Black", "PreludeCondensedWGL Bold", "PreludeCondensedWGL Light", "PreludeCondensedWGL Medium", "PreludeWGL Black", "PreludeWGL Bold", "PreludeWGL Light", "PreludeWGL Medium", "Raavi", "Rachana", "Rockwell", "Rod", "Sakkal Majalla", "Sawasdee", "Script MT Bold", "Segoe Print", "Segoe Script", "Segoe UI Light", "Segoe UI Semibold", "Segoe UI Symbol", "Segoe UI", "Shonar Bangla", "Showcard Gothic", "Shruti", "SimHei", "SimSun", "SimSun-ExtB", "Simplified Arabic Fixed", "Simplified Arabic", "Snap ITC", "Sylfaen", "Symbol", "Tahoma", "Times New Roman Baltic", "Times New Roman CE", "Times New Roman CYR", "Times New Roman Greek", "Times New Roman TUR", "Times New Roman", "TlwgMono", "Traditional Arabic", "Trebuchet MS", "Tunga", "Tw Cen MT Condensed Extra Bold", "Ubuntu", "Umpush", "Univers", "Utopia", "Utsaah", "Vani", "Verdana", "Vijaya", "Vladimir Script", "Vrinda", "Webdings", "Wide Latin", "Wingdings"], t = "", i = 0; i < e.length; i++)r.detect(e[i]) && (t += i == e.length - 1 ? e[i] : e[i] + ", "); return t }, isLocalStorage: function () { try { return !!a.localStorage } catch (e) { return !0 } }, isSessionStorage: function () { try { return !!a.sessionStorage } catch (e) { return !0 } }, isCookie: function () { return navigator.cookieEnabled }, getTimeZone: function () { var e, t; return e = new Date, (t = String(-e.getTimezoneOffset() / 60)) < 0 ? "-" + ("0" + (t *= -1)).slice(-2) : "+" + ("0" + t).slice(-2) }, getLanguage: function () { return navigator.language }, getSystemLanguage: function () { return navigator.systemLanguage || window.navigator.language }, isCanvas: function () { var e = document.createElement("canvas"); try { return !(!e.getContext || !e.getContext("2d")) } catch (t) { return !1 } }, getCanvasPrint: function () { var e, t = document.createElement("canvas"); try { e = t.getContext("2d") } catch (n) { return "" } var i = "ClientJS,org <canvas> 1.0"; return e.textBaseline = "top", e.font = "14px 'Arial'", e.textBaseline = "alphabetic", e.fillStyle = "#f60", e.fillRect(125, 1, 62, 20), e.fillStyle = "#069", e.fillText(i, 2, 15), e.fillStyle = "rgba(102, 204, 0, 0.7)", e.fillText(i, 4, 17), t.toDataURL() } }, t.ClientJS = u }, function (e, t, i) { "use strict"; var n = i(2); e.exports = function () { return "object" == typeof global && global && global.Math === Math && global.Array === Array ? global : n } }, function (e, t, i) { "use strict"; "undefined" != typeof self ? e.exports = self : "undefined" != typeof window ? e.exports = window : e.exports = Function("return this")() }, function (e, t, i) { e.exports = function (e, t) { var i, n, r, a, o, s, l, u; for (i = 3 & e.length, n = e.length - i, r = t, o = 3432918353, s = 461845907, u = 0; u < n;)l = 255 & e.charCodeAt(u) | (255 & e.charCodeAt(++u)) << 8 | (255 & e.charCodeAt(++u)) << 16 | (255 & e.charCodeAt(++u)) << 24, ++u, r = 27492 + (65535 & (a = 5 * (65535 & (r = (r ^= l = (65535 & (l = (l = (65535 & l) * o + (((l >>> 16) * o & 65535) << 16) & 4294967295) << 15 | l >>> 17)) * s + (((l >>> 16) * s & 65535) << 16) & 4294967295) << 13 | r >>> 19)) + ((5 * (r >>> 16) & 65535) << 16) & 4294967295)) + ((58964 + (a >>> 16) & 65535) << 16); switch (l = 0, i) { case 3: l ^= (255 & e.charCodeAt(u + 2)) << 16; case 2: l ^= (255 & e.charCodeAt(u + 1)) << 8; case 1: r ^= l = (65535 & (l = (l = (65535 & (l ^= 255 & e.charCodeAt(u))) * o + (((l >>> 16) * o & 65535) << 16) & 4294967295) << 15 | l >>> 17)) * s + (((l >>> 16) * s & 65535) << 16) & 4294967295 }return r ^= e.length, r = 2246822507 * (65535 & (r ^= r >>> 16)) + ((2246822507 * (r >>> 16) & 65535) << 16) & 4294967295, r = 3266489909 * (65535 & (r ^= r >>> 13)) + ((3266489909 * (r >>> 16) & 65535) << 16) & 4294967295, (r ^= r >>> 16) >>> 0 } }, function (e, t, i) { var n; !function (r, a) { "use strict"; var o = "function", s = "undefined", l = "object", u = "string", c = "model", d = "name", p = "type", f = "vendor", h = "version", m = "architecture", g = "console", b = "mobile", v = "tablet", w = "smarttv", y = "wearable", x = "embedded", C = "Amazon", S = "Apple", k = "ASUS", T = "BlackBerry", M = "Firefox", A = "Google", E = "Huawei", P = "LG", N = "Microsoft", I = "Motorola", B = "Opera", j = "Samsung", L = "Sony", U = "Xiaomi", O = "Zebra", R = "Facebook", F = function (e) { var t = {}; for (var i in e) t[e[i].toUpperCase()] = e[i]; return t }, V = function (e, t) { return typeof e === u && -1 !== D(t).indexOf(D(e)) }, D = function (e) { return e.toLowerCase() }, J = function (e, t) { if (typeof e === u) return e = e.replace(/^\s\s*/, "").replace(/\s\s*$/, ""), typeof t === s ? e : e.substring(0, 255) }, _ = function (e, t) { for (var i, n, r, s, u, c, d = 0; d < t.length && !u;) { var p = t[d], f = t[d + 1]; for (i = n = 0; i < p.length && !u;)if (u = p[i++].exec(e)) for (r = 0; r < f.length; r++)c = u[++n], typeof (s = f[r]) === l && s.length > 0 ? 2 == s.length ? typeof s[1] == o ? this[s[0]] = s[1].call(this, c) : this[s[0]] = s[1] : 3 == s.length ? typeof s[1] !== o || s[1].exec && s[1].test ? this[s[0]] = c ? c.replace(s[1], s[2]) : a : this[s[0]] = c ? s[1].call(this, c, s[2]) : a : 4 == s.length && (this[s[0]] = c ? s[3].call(this, c.replace(s[1], s[2])) : a) : this[s] = c || a; d += 2 } }, G = function (e, t) { for (var i in t) if (typeof t[i] === l && t[i].length > 0) { for (var n = 0; n < t[i].length; n++)if (V(t[i][n], e)) return "?" === i ? a : i } else if (V(t[i], e)) return "?" === i ? a : i; return e }, W = { ME: "4.90", "NT 3.11": "NT3.51", "NT 4.0": "NT4.0", 2e3: "NT 5.0", XP: ["NT 5.1", "NT 5.2"], Vista: "NT 6.0", 7: "NT 6.1", 8: "NT 6.2", 8.1: "NT 6.3", 10: ["NT 6.4", "NT 10.0"], RT: "ARM" }, z = { browser: [[/\b(?:crmo|crios)\/([\w\.]+)/i], [h, [d, "Chrome"]], [/edg(?:e|ios|a)?\/([\w\.]+)/i], [h, [d, "Edge"]], [/(opera mini)\/([-\w\.]+)/i, /(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i, /(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i], [d, h], [/opios[\/ ]+([\w\.]+)/i], [h, [d, "Opera Mini"]], [/\bopr\/([\w\.]+)/i], [h, [d, B]], [/(kindle)\/([\w\.]+)/i, /(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i, /(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i, /(ba?idubrowser)[\/ ]?([\w\.]+)/i, /(?:ms|\()(ie) ([\w\.]+)/i, /(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale|qqbrowserlite|qq)\/([-\w\.]+)/i, /(weibo)__([\d\.]+)/i], [d, h], [/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i], [h, [d, "UCBrowser"]], [/\bqbcore\/([\w\.]+)/i], [h, [d, "WeChat(Win) Desktop"]], [/micromessenger\/([\w\.]+)/i], [h, [d, "WeChat"]], [/konqueror\/([\w\.]+)/i], [h, [d, "Konqueror"]], [/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i], [h, [d, "IE"]], [/yabrowser\/([\w\.]+)/i], [h, [d, "Yandex"]], [/(avast|avg)\/([\w\.]+)/i], [[d, /(.+)/, "$1 Secure Browser"], h], [/\bfocus\/([\w\.]+)/i], [h, [d, "Firefox Focus"]], [/\bopt\/([\w\.]+)/i], [h, [d, "Opera Touch"]], [/coc_coc\w+\/([\w\.]+)/i], [h, [d, "Coc Coc"]], [/dolfin\/([\w\.]+)/i], [h, [d, "Dolphin"]], [/coast\/([\w\.]+)/i], [h, [d, "Opera Coast"]], [/miuibrowser\/([\w\.]+)/i], [h, [d, "MIUI Browser"]], [/fxios\/([-\w\.]+)/i], [h, [d, M]], [/\bqihu|(qi?ho?o?|360)browser/i], [[d, "360 Browser"]], [/(oculus|samsung|sailfish)browser\/([\w\.]+)/i], [[d, /(.+)/, "$1 Browser"], h], [/(comodo_dragon)\/([\w\.]+)/i], [[d, /_/g, " "], h], [/(electron)\/([\w\.]+) safari/i, /(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i, /m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i], [d, h], [/(metasr)[\/ ]?([\w\.]+)/i, /(lbbrowser)/i], [d], [/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i], [[d, R], h], [/safari (line)\/([\w\.]+)/i, /\b(line)\/([\w\.]+)\/iab/i, /(chromium|instagram)[\/ ]([-\w\.]+)/i], [d, h], [/\bgsa\/([\w\.]+) .*safari\//i], [h, [d, "GSA"]], [/headlesschrome(?:\/([\w\.]+)| )/i], [h, [d, "Chrome Headless"]], [/ wv\).+(chrome)\/([\w\.]+)/i], [[d, "Chrome WebView"], h], [/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i], [h, [d, "Android Browser"]], [/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i], [d, h], [/version\/([\w\.]+) .*mobile\/\w+ (safari)/i], [h, [d, "Mobile Safari"]], [/version\/([\w\.]+) .*(mobile ?safari|safari)/i], [h, d], [/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i], [d, [h, G, { "1.0": "/8", 1.2: "/1", 1.3: "/3", "2.0": "/412", "2.0.2": "/416", "2.0.3": "/417", "2.0.4": "/419", "?": "/" }]], [/(webkit|khtml)\/([\w\.]+)/i], [d, h], [/(navigator|netscape\d?)\/([-\w\.]+)/i], [[d, "Netscape"], h], [/mobile vr; rv:([\w\.]+)\).+firefox/i], [h, [d, "Firefox Reality"]], [/ekiohf.+(flow)\/([\w\.]+)/i, /(swiftfox)/i, /(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i, /(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i, /(firefox)\/([\w\.]+)/i, /(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i, /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i, /(links) \(([\w\.]+)/i], [d, h]], cpu: [[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i], [[m, "amd64"]], [/(ia32(?=;))/i], [[m, D]], [/((?:i[346]|x)86)[;\)]/i], [[m, "ia32"]], [/\b(aarch64|arm(v?8e?l?|_?64))\b/i], [[m, "arm64"]], [/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i], [[m, "armhf"]], [/windows (ce|mobile); ppc;/i], [[m, "arm"]], [/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i], [[m, /ower/, "", D]], [/(sun4\w)[;\)]/i], [[m, "sparc"]], [/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i], [[m, D]]], device: [[/\b(sch-i[89]0\d|shw-m380s|sm-[pt]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i], [c, [f, j], [p, v]], [/\b((?:s[cgp]h|gt|sm)-\w+|galaxy nexus)/i, /samsung[- ]([-\w]+)/i, /sec-(sgh\w+)/i], [c, [f, j], [p, b]], [/\((ip(?:hone|od)[\w ]*);/i], [c, [f, S], [p, b]], [/\((ipad);[-\w\),; ]+apple/i, /applecoremedia\/[\w\.]+ \((ipad)/i, /\b(ipad)\d\d?,\d\d?[;\]].+ios/i], [c, [f, S], [p, v]], [/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i], [c, [f, E], [p, v]], [/(?:huawei|honor)([-\w ]+)[;\)]/i, /\b(nexus 6p|\w{2,4}-[atu]?[ln][01259x][012359][an]?)\b(?!.+d\/s)/i], [c, [f, E], [p, b]], [/\b(poco[\w ]+)(?: bui|\))/i, /\b; (\w+) build\/hm\1/i, /\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i, /\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i, /\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i], [[c, /_/g, " "], [f, U], [p, b]], [/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i], [[c, /_/g, " "], [f, U], [p, v]], [/; (\w+) bui.+ oppo/i, /\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007)\b/i], [c, [f, "OPPO"], [p, b]], [/vivo (\w+)(?: bui|\))/i, /\b(v[12]\d{3}\w?[at])(?: bui|;)/i], [c, [f, "Vivo"], [p, b]], [/\b(rmx[12]\d{3})(?: bui|;|\))/i], [c, [f, "Realme"], [p, b]], [/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i, /\bmot(?:orola)?[- ](\w*)/i, /((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i], [c, [f, I], [p, b]], [/\b(mz60\d|xoom[2 ]{0,2}) build\//i], [c, [f, I], [p, v]], [/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i], [c, [f, P], [p, v]], [/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i, /\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i, /\blg-?([\d\w]+) bui/i], [c, [f, P], [p, b]], [/(ideatab[-\w ]+)/i, /lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i], [c, [f, "Lenovo"], [p, v]], [/(?:maemo|nokia).*(n900|lumia \d+)/i, /nokia[-_ ]?([-\w\.]*)/i], [[c, /_/g, " "], [f, "Nokia"], [p, b]], [/(pixel c)\b/i], [c, [f, A], [p, v]], [/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i], [c, [f, A], [p, b]], [/droid.+ ([c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i], [c, [f, L], [p, b]], [/sony tablet [ps]/i, /\b(?:sony)?sgp\w+(?: bui|\))/i], [[c, "Xperia Tablet"], [f, L], [p, v]], [/ (kb2005|in20[12]5|be20[12][59])\b/i, /(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i], [c, [f, "OnePlus"], [p, b]], [/(alexa)webm/i, /(kf[a-z]{2}wi)( bui|\))/i, /(kf[a-z]+)( bui|\)).+silk\//i], [c, [f, C], [p, v]], [/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i], [[c, /(.+)/g, "Fire Phone $1"], [f, C], [p, b]], [/(playbook);[-\w\),; ]+(rim)/i], [c, f, [p, v]], [/\b((?:bb[a-f]|st[hv])100-\d)/i, /\(bb10; (\w+)/i], [c, [f, T], [p, b]], [/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i], [c, [f, k], [p, v]], [/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i], [c, [f, k], [p, b]], [/(nexus 9)/i], [c, [f, "HTC"], [p, v]], [/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i, /(zte)[- ]([\w ]+?)(?: bui|\/|\))/i, /(alcatel|geeksphone|nexian|panasonic|sony)[-_ ]?([-\w]*)/i], [f, [c, /_/g, " "], [p, b]], [/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i], [c, [f, "Acer"], [p, v]], [/droid.+; (m[1-5] note) bui/i, /\bmz-([-\w]{2,})/i], [c, [f, "Meizu"], [p, b]], [/\b(sh-?[altvz]?\d\d[a-ekm]?)/i], [c, [f, "Sharp"], [p, b]], [/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i, /(hp) ([\w ]+\w)/i, /(asus)-?(\w+)/i, /(microsoft); (lumia[\w ]+)/i, /(lenovo)[-_ ]?([-\w]+)/i, /(jolla)/i, /(oppo) ?([\w ]+) bui/i], [f, c, [p, b]], [/(archos) (gamepad2?)/i, /(hp).+(touchpad(?!.+tablet)|tablet)/i, /(kindle)\/([\w\.]+)/i, /(nook)[\w ]+build\/(\w+)/i, /(dell) (strea[kpr\d ]*[\dko])/i, /(le[- ]+pan)[- ]+(\w{1,9}) bui/i, /(trinity)[- ]*(t\d{3}) bui/i, /(gigaset)[- ]+(q\w{1,9}) bui/i, /(vodafone) ([\w ]+)(?:\)| bui)/i], [f, c, [p, v]], [/(surface duo)/i], [c, [f, N], [p, v]], [/droid [\d\.]+; (fp\du?)(?: b|\))/i], [c, [f, "Fairphone"], [p, b]], [/(u304aa)/i], [c, [f, "AT&T"], [p, b]], [/\bsie-(\w*)/i], [c, [f, "Siemens"], [p, b]], [/\b(rct\w+) b/i], [c, [f, "RCA"], [p, v]], [/\b(venue[\d ]{2,7}) b/i], [c, [f, "Dell"], [p, v]], [/\b(q(?:mv|ta)\w+) b/i], [c, [f, "Verizon"], [p, v]], [/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i], [c, [f, "Barnes & Noble"], [p, v]], [/\b(tm\d{3}\w+) b/i], [c, [f, "NuVision"], [p, v]], [/\b(k88) b/i], [c, [f, "ZTE"], [p, v]], [/\b(nx\d{3}j) b/i], [c, [f, "ZTE"], [p, b]], [/\b(gen\d{3}) b.+49h/i], [c, [f, "Swiss"], [p, b]], [/\b(zur\d{3}) b/i], [c, [f, "Swiss"], [p, v]], [/\b((zeki)?tb.*\b) b/i], [c, [f, "Zeki"], [p, v]], [/\b([yr]\d{2}) b/i, /\b(dragon[- ]+touch |dt)(\w{5}) b/i], [[f, "Dragon Touch"], c, [p, v]], [/\b(ns-?\w{0,9}) b/i], [c, [f, "Insignia"], [p, v]], [/\b((nxa|next)-?\w{0,9}) b/i], [c, [f, "NextBook"], [p, v]], [/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i], [[f, "Voice"], c, [p, b]], [/\b(lvtel\-)?(v1[12]) b/i], [[f, "LvTel"], c, [p, b]], [/\b(ph-1) /i], [c, [f, "Essential"], [p, b]], [/\b(v(100md|700na|7011|917g).*\b) b/i], [c, [f, "Envizen"], [p, v]], [/\b(trio[-\w\. ]+) b/i], [c, [f, "MachSpeed"], [p, v]], [/\btu_(1491) b/i], [c, [f, "Rotor"], [p, v]], [/(shield[\w ]+) b/i], [c, [f, "Nvidia"], [p, v]], [/(sprint) (\w+)/i], [f, c, [p, b]], [/(kin\.[onetw]{3})/i], [[c, /\./g, " "], [f, N], [p, b]], [/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i], [c, [f, O], [p, v]], [/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i], [c, [f, O], [p, b]], [/(ouya)/i, /(nintendo) ([wids3utch]+)/i], [f, c, [p, g]], [/droid.+; (shield) bui/i], [c, [f, "Nvidia"], [p, g]], [/(playstation [345portablevi]+)/i], [c, [f, L], [p, g]], [/\b(xbox(?: one)?(?!; xbox))[\); ]/i], [c, [f, N], [p, g]], [/smart-tv.+(samsung)/i], [f, [p, w]], [/hbbtv.+maple;(\d+)/i], [[c, /^/, "SmartTV"], [f, j], [p, w]], [/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i], [[f, P], [p, w]], [/(apple) ?tv/i], [f, [c, "Apple TV"], [p, w]], [/crkey/i], [[c, "Chromecast"], [f, A], [p, w]], [/droid.+aft(\w)( bui|\))/i], [c, [f, C], [p, w]], [/\(dtv[\);].+(aquos)/i], [c, [f, "Sharp"], [p, w]], [/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, /hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i], [[f, J], [c, J], [p, w]], [/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i], [[p, w]], [/((pebble))app/i], [f, c, [p, y]], [/droid.+; (glass) \d/i], [c, [f, A], [p, y]], [/droid.+; (wt63?0{2,3})\)/i], [c, [f, O], [p, y]], [/(quest( 2)?)/i], [c, [f, R], [p, y]], [/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i], [f, [p, x]], [/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i], [c, [p, b]], [/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i], [c, [p, v]], [/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i], [[p, v]], [/(phone|mobile(?:[;\/]| safari)|pda(?=.+windows ce))/i], [[p, b]], [/(android[-\w\. ]{0,9});.+buil/i], [c, [f, "Generic"]]], engine: [[/windows.+ edge\/([\w\.]+)/i], [h, [d, "EdgeHTML"]], [/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i], [h, [d, "Blink"]], [/(presto)\/([\w\.]+)/i, /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i, /ekioh(flow)\/([\w\.]+)/i, /(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i, /(icab)[\/ ]([23]\.[\d\.]+)/i], [d, h], [/rv\:([\w\.]{1,9})\b.+(gecko)/i], [h, d]], os: [[/microsoft (windows) (vista|xp)/i], [d, h], [/(windows) nt 6\.2; (arm)/i, /(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i, /(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i], [d, [h, G, W]], [/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i], [[d, "Windows"], [h, G, W]], [/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, /cfnetwork\/.+darwin/i], [[h, /_/g, "."], [d, "iOS"]], [/(mac os x) ?([\w\. ]*)/i, /(macintosh|mac_powerpc\b)(?!.+haiku)/i], [[d, "Mac OS"], [h, /_/g, "."]], [/droid ([\w\.]+)\b.+(android[- ]x86)/i], [h, d], [/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i, /(blackberry)\w*\/([\w\.]*)/i, /(tizen|kaios)[\/ ]([\w\.]+)/i, /\((series40);/i], [d, h], [/\(bb(10);/i], [h, [d, T]], [/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i], [h, [d, "Symbian"]], [/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i], [h, [d, "Firefox OS"]], [/web0s;.+rt(tv)/i, /\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i], [h, [d, "webOS"]], [/crkey\/([\d\.]+)/i], [h, [d, "Chromecast"]], [/(cros) [\w]+ ([\w\.]+\w)/i], [[d, "Chromium OS"], h], [/(nintendo|playstation) ([wids345portablevuch]+)/i, /(xbox); +xbox ([^\);]+)/i, /\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i, /(mint)[\/\(\) ]?(\w*)/i, /(mageia|vectorlinux)[; ]/i, /([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i, /(hurd|linux) ?([\w\.]*)/i, /(gnu) ?([\w\.]*)/i, /\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i, /(haiku) (\w+)/i], [d, h], [/(sunos) ?([\w\.\d]*)/i], [[d, "Solaris"], h], [/((?:open)?solaris)[-\/ ]?([\w\.]*)/i, /(aix) ((\d)(?=\.|\)| )[\w\.])*/i, /\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux)/i, /(unix) ?([\w\.]*)/i], [d, h]] }, q = function (e, t) { if (typeof e === l && (t = e, e = a), !(this instanceof q)) return new q(e, t).getResult(); var i = e || (typeof r !== s && r.navigator && r.navigator.userAgent ? r.navigator.userAgent : ""), n = t ? function (e, t) { var i = {}; for (var n in e) t[n] && t[n].length % 2 == 0 ? i[n] = t[n].concat(e[n]) : i[n] = e[n]; return i }(z, t) : z; return this.getBrowser = function () { var e, t = {}; return t.name = a, t.version = a, _.call(t, i, n.browser), t.major = typeof (e = t.version) === u ? e.replace(/[^\d\.]/g, "").split(".")[0] : a, t }, this.getCPU = function () { var e = {}; return e.architecture = a, _.call(e, i, n.cpu), e }, this.getDevice = function () { var e = {}; return e.vendor = a, e.model = a, e.type = a, _.call(e, i, n.device), e }, this.getEngine = function () { var e = {}; return e.name = a, e.version = a, _.call(e, i, n.engine), e }, this.getOS = function () { var e = {}; return e.name = a, e.version = a, _.call(e, i, n.os), e }, this.getResult = function () { return { ua: this.getUA(), browser: this.getBrowser(), engine: this.getEngine(), os: this.getOS(), device: this.getDevice(), cpu: this.getCPU() } }, this.getUA = function () { return i }, this.setUA = function (e) { return i = typeof e === u && e.length > 255 ? J(e, 255) : e, this }, this.setUA(i), this }; q.VERSION = "0.7.30", q.BROWSER = F([d, h, "major"]), q.CPU = F([m]), q.DEVICE = F([c, f, p, g, b, w, v, y, x]), q.ENGINE = q.OS = F([d, h]), typeof t !== s ? (typeof e !== s && e.exports && (t = e.exports = q), t.UAParser = q) : i(5) ? (n = function () { return q }.call(t, i, t, e)) === a || (e.exports = n) : typeof r !== s && (r.UAParser = q); var H = typeof r !== s && (r.jQuery || r.Zepto); if (H && !H.ua) { var X = new q; H.ua = X.getResult(), H.ua.get = function () { return X.getUA() }, H.ua.set = function (e) { X.setUA(e); var t = X.getResult(); for (var i in t) H.ua[i] = t[i] } } }("object" == typeof window ? window : this) }, function (e, t) { (function (t) { e.exports = t }).call(this, {}) }, function (e, t) { e.exports = function () { var e = ["monospace", "sans-serif", "serif"], t = document.getElementsByTagName("body")[0], i = document.createElement("span"); i.style.fontSize = "72px", i.innerHTML = "mmmmmmmmmmlli"; var n = {}, r = {}; for (var a in e) i.style.fontFamily = e[a], t.appendChild(i), n[e[a]] = i.offsetWidth, r[e[a]] = i.offsetHeight, t.removeChild(i); this.detect = function (a) { var o = !1; for (var s in e) { i.style.fontFamily = a + "," + e[s], t.appendChild(i); var l = i.offsetWidth != n[e[s]] || i.offsetHeight != r[e[s]]; t.removeChild(i), o = o || l } return o } } }, function (e, t) { "function" == typeof Object.create ? e.exports = function (e, t) { t && (e.super_ = t, e.prototype = Object.create(t.prototype, { constructor: { value: e, enumerable: !1, writable: !0, configurable: !0 } })) } : e.exports = function (e, t) { if (t) { e.super_ = t; var i = function () { }; i.prototype = t.prototype, e.prototype = new i, e.prototype.constructor = e } } }, function (e, t, i) { "use strict"; var n = i(9); e.exports = function () { return n.getJREs().toString() } }, function (e, t, i) { "use strict"; var n = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:[_\\.](\\d+))?)?)?", r = n + "$", a = n + "(\\*|\\+)?$", o = { core: ["id", "class", "title", "style"], applet: ["codebase", "code", "name", "archive", "object", "width", "height", "alt", "align", "hspace", "vspace"] }, s = o.applet.concat(o.core); function l(e) { f.debug && (console.log ? console.log(e) : alert(e)) } function u(e, t) { var i = 0, n = e.match(a); if (null != n) { if (t) return !0; for (var r = !1, o = !1, s = new Array, u = 1; u < n.length; ++u)"string" == typeof n[u] && "" != n[u] && (s[i] = n[u], i++); "+" == s[s.length - 1] ? (o = !0, r = !1, s.length--) : "*" == s[s.length - 1] ? (o = !1, r = !0, s.length--) : s.length < 4 && (o = !1, r = !0); for (var c = f.getJREs(), d = 0; d < c.length; ++d)if (f.compareVersionToPattern(c[d], s, r, o)) return !0; return !1 } var p = "Invalid versionPattern passed to versionCheck: " + e; return l("[versionCheck()] " + p), alert(p), !1 } function c(e) { document.location = "jnlp:" + function (e) { var t; if (function (e) { for (var t = ["http://", "https://", "file://"], i = 0; i < t.length; i++)if (e.toLowerCase().startsWith(t[i])) return !0; return !1 }(e)) t = e; else { var i = window.location.href, n = i.lastIndexOf("/"); t = (n > -1 ? i.substring(0, n + 1) : i + "/") + e } return t }(e) } function d() { return "Edge" == f.getBrowser() || "Chrome" == f.browserName2 || "FirefoxNoPlugin" == f.browserName2 && !u("1.8*", !1) || "NoActiveX" == f.browserName2 } function p(e) { var t = "https://java.com/dt-redirect"; return null == e || 0 == e.length ? t : ("&" == e.charAt(0) && (e = e.substring(1, e.length)), t + "?" + e) } "function" != typeof String.prototype.startsWith && (String.prototype.startsWith = function (e, t) { return t = t || 0, this.indexOf(e, t) === t }); var f = { debug: null, version: "20120801", firefoxJavaVersion: null, useStaticMimeType: !1, myInterval: null, preInstallJREList: null, brand: null, locale: null, installType: null, EAInstallEnabled: !1, EarlyAccessURL: null, oldMimeType: "application/npruntime-scriptable-plugin;DeploymentToolkit", mimeType: "application/java-deployment-toolkit", launchButtonPNG: function () { var e = "//java.com/js/webstart.png"; try { return -1 != document.location.protocol.indexOf("http") ? e : "https:" + e } catch (t) { return "https:" + e } }(), browserName: null, browserName2: null, getJREs: function () { var e = new Array; if (this.isPluginInstalled()) for (var t = this.getPlugin().jvms, i = 0; i < t.getLength(); i++)e[i] = t.get(i).version; else { var n = this.getBrowser(); "MSIE" == n ? this.testUsingActiveX("9") ? e[0] = "9" : this.testUsingActiveX("1.8.0") ? e[0] = "1.8.0" : this.testUsingActiveX("1.7.0") ? e[0] = "1.7.0" : this.testUsingActiveX("1.6.0") ? e[0] = "1.6.0" : this.testUsingActiveX("1.5.0") ? e[0] = "1.5.0" : this.testUsingActiveX("1.4.2") ? e[0] = "1.4.2" : this.testForMSVM() && (e[0] = "1.1") : "Netscape Family" == n && (this.getJPIVersionUsingMimeType(), null != this.firefoxJavaVersion ? e[0] = this.firefoxJavaVersion : this.testUsingMimeTypes("9") ? e[0] = "9" : this.testUsingMimeTypes("1.8") ? e[0] = "1.8.0" : this.testUsingMimeTypes("1.7") ? e[0] = "1.7.0" : this.testUsingMimeTypes("1.6") ? e[0] = "1.6.0" : this.testUsingMimeTypes("1.5") ? e[0] = "1.5.0" : this.testUsingMimeTypes("1.4.2") ? e[0] = "1.4.2" : "Safari" == this.browserName2 && (this.testUsingPluginsArray("9") ? e[0] = "9" : this.testUsingPluginsArray("1.8") ? e[0] = "1.8.0" : this.testUsingPluginsArray("1.7") ? e[0] = "1.7.0" : this.testUsingPluginsArray("1.6") ? e[0] = "1.6.0" : this.testUsingPluginsArray("1.5") ? e[0] = "1.5.0" : this.testUsingPluginsArray("1.4.2") && (e[0] = "1.4.2"))) } if (this.debug) for (var r = 0; r < e.length; ++r)l("[getJREs()] We claim to have detected Java SE " + e[r]); return e }, installJRE: function (e) { return l("The Deployment Toolkit installJRE()  method no longer installs JRE. It just checks if the requested version of JRE is installed and calls installLatestJRE() otherwise. More Information on usage of the Deployment Toolkit can be found in the Deployment Guide at https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/"), "undefined" != e && null != e || (e = "1.1"), null == e.match(a) && (l("Invalid requestVersion argument to installJRE(): " + e), e = "1.6"), !!this.versionCheck(e) || this.installLatestJRE() }, isAutoInstallEnabled: function (e) { return !!this.isPluginInstalled() && (void 0 === e && (e = null), function (e) { return "MSIE" != f.browserName || !!f.compareVersionToPattern(f.getPlugin().version, ["10", "0", "0"], !1, !0) || null != e && !function (e, t) { if (null == e || 0 == e.length) return !0; var i = e.charAt(e.length - 1); if ("+" != i && "*" != i && -1 != e.indexOf("_") && "_" != i && (e += "*", i = "*"), (e = e.substring(0, e.length - 1)).length > 0) { var n = e.charAt(e.length - 1); "." != n && "_" != n || (e = e.substring(0, e.length - 1)) } return "*" == i ? 0 == t.indexOf(e) : "+" == i && e <= t }("1.6.0_33+", e) }(e)) }, isCallbackSupported: function () { return this.isPluginInstalled() && this.compareVersionToPattern(this.getPlugin().version, ["10", "2", "0"], !1, !0) }, installLatestJRE: function () { if (l("The Deployment Toolkit installLatestJRE() method no longer installs JRE. If user's version of Java is below the security baseline it redirects user to java.com to get an updated JRE. More Information on usage of the Deployment Toolkit can be found in the Deployment Guide at ://docs.oracle.com/javase/8/docs/technotes/guides/deploy/"), !this.isPluginInstalled() || !this.getPlugin().installLatestJRE()) { var e = this.getBrowser(), t = navigator.platform.toLowerCase(); return "MSIE" == e ? this.IEInstall() : "Netscape Family" == e && -1 != t.indexOf("win32") ? this.FFInstall() : (location.href = p((null != this.locale ? "&locale=" + this.locale : "") + (null != this.brand ? "&brand=" + this.brand : "")), !1) } return !0 }, runApplet: function (e, t, i) { if ("undefined" != i && null != i || (i = "1.1"), null != i.match(r)) if ("?" != this.getBrowser()) { if (d()) { var n = setInterval((function () { var e; "complete" == document.readyState && (clearInterval(n), (e = document.createElement("div")).id = "messagebox", e.setAttribute("style", "background-color: #ffffce;text-align: left;border: solid 1px #f0c000; padding: 1.65em 1.65em .75em 0.5em; font-family: Helvetica, Arial, sans-serif; font-size: 75%; bottom:0; left:0; right:0; position:fixed; margin:auto; opacity:0.9; width:400px;"), e.innerHTML = '<span style="margin-left:10px;font-weight:bold;float:right;font-size:22px;line-height:20px;cursor:pointer;color:red;" onclick="this.parentElement.style.display=\'none\';">&times;</span><img src="https://java.com/js/alert_16.png"><div style="border: .85px; margin:-2.2em 0 0.55em 2.5em;"><p>Java Plug-in is not supported by this browser. <a href="https://java.com/dt-redirect">More info</a></p>', document.body.appendChild(e)) }), 15); return void l("[runApplet()] Java Plug-in is not supported by this browser") } (this.versionCheck(i + "+") || this.installJRE(i + "+")) && this.writeAppletTag(e, t) } else this.writeAppletTag(e, t); else l("[runApplet()] Invalid minimumVersion argument to runApplet():" + i) }, writeAppletTag: function (e, t) { var i = "<applet ", n = "", r = !0; for (var a in null != t && "object" == typeof t || (t = new Object), e) (function (e, t) { for (var i = e.length, n = 0; n < i; n++)if (e[n] === t) return !0; return !1 })(s, a.toLowerCase()) ? (i += " " + a + '="' + e[a] + '"', "code" == a && (r = !1)) : t[a] = e[a]; var o = !1; for (var l in t) "codebase_lookup" == l && (o = !0), "object" != l && "java_object" != l && "java_code" != l || (r = !1), n += '<param name="' + l + '" value="' + t[l] + '"/>'; o || (n += '<param name="codebase_lookup" value="false"/>'), r && (i += ' code="dummy"'), i += ">", document.write(i + "\n" + n + "\n</applet>") }, versionCheck: function (e) { return u(e, d()) }, isWebStartInstalled: function (e) { if (d()) return !0; if ("?" == this.getBrowser()) return !0; "undefined" != e && null != e || (e = "1.4.2"); var t = !1; return null != e.match(r) ? t = this.versionCheck(e + "+") : (l("[isWebStartInstaller()] Invalid minimumVersion argument to isWebStartInstalled(): " + e), t = this.versionCheck("1.4.2+")), t }, getJPIVersionUsingMimeType: function () { var e, t; for (e = 0; e < navigator.mimeTypes.length; ++e)if (null != (t = navigator.mimeTypes[e].type.match(/^application\/x-java-applet;jpi-version=(.*)$/))) return this.firefoxJavaVersion = t[1], void (this.useStaticMimeType = !0); for (e = 0; e < navigator.mimeTypes.length; ++e)null != (t = navigator.mimeTypes[e].type.match(/^application\/x-java-applet;version=(.*)$/)) && (null == this.firefoxJavaVersion || this.compareVersions(t[1], this.firefoxJavaVersion)) && (this.firefoxJavaVersion = t[1]) }, launchWebStartApplication: function (e) { if (this.getJPIVersionUsingMimeType(), 0 == u("1.7.0+", !1)) if (d()) c(e); else if (0 == this.installJRE("1.7.0+") || 0 == this.isWebStartInstalled("1.7.0")) return !1; var t = null; document.documentURI && (t = document.documentURI), null == t && (t = document.URL); var i, n = this.getBrowser(); if ("MSIE" == n ? i = '<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="0" height="0"><PARAM name="launchjnlp" value="' + e + '"><PARAM name="docbase" value="' + encodeURIComponent(t) + '"></object>' : "Netscape Family" == n && (i = '<embed type="' + (this.useStaticMimeType ? "application/x-java-applet;jpi-version=" : "application/x-java-applet;version=") + this.firefoxJavaVersion + '" width="0" height="0" launchjnlp="' + e + '"docbase="' + encodeURIComponent(t) + '" />'), "undefined" == document.body || null == document.body) document.write(i), document.location = t; else { var r = document.createElement("div"); r.id = "div1", r.style.position = "relative", r.style.left = "-10000px", r.style.margin = "0px auto", r.className = "dynamicDiv", r.innerHTML = i, document.body.appendChild(r) } }, createWebStartLaunchButtonEx: function (e) { var t = "javascript:deployJava.launchWebStartApplication('" + e + "');"; document.write('<a href="' + t + '" onMouseOver="window.status=\'\'; return true;"><img src="' + this.launchButtonPNG + '" border="0" /></a>') }, createWebStartLaunchButton: function (e, t) { var i = "javascript:if (!deployJava.isWebStartInstalled(&quot;" + t + "&quot;)) {if (deployJava.installLatestJRE()) {if (deployJava.launch(&quot;" + e + "&quot;)) {}}} else {if (deployJava.launch(&quot;" + e + "&quot;)) {}}"; document.write('<a href="' + i + '" onMouseOver="window.status=\'\'; return true;"><img src="' + this.launchButtonPNG + '" border="0" /></a>') }, launch: function (e) { return document.location = e, !0 }, launchEx: function (e) { return c(e), !0 }, isPluginInstalled: function () { var e = this.getPlugin(); return !(!e || !e.jvms) }, isAutoUpdateEnabled: function () { return !!this.isPluginInstalled() && this.getPlugin().isAutoUpdateEnabled() }, setAutoUpdateEnabled: function () { return !!this.isPluginInstalled() && this.getPlugin().setAutoUpdateEnabled() }, setInstallerType: function (e) { return l("The Deployment Toolkit no longer installs JRE. Method setInstallerType() is no-op. More Information on usage of the Deployment Toolkit can be found in the Deployment Guide at ://docs.oracle.com/javase/8/docs/technotes/guides/deploy/"), !1 }, setAdditionalPackages: function (e) { return l("The Deployment Toolkit no longer installs JRE. Method setAdditionalPackages() is no-op. More Information on usage of the Deployment Toolkit can be found in the Deployment Guide at ://docs.oracle.com/javase/8/docs/technotes/guides/deploy/"), !1 }, setEarlyAccess: function (e) { this.EAInstallEnabled = e }, isPlugin2: function () { if (this.isPluginInstalled() && this.versionCheck("1.6.0_10+")) try { return this.getPlugin().isPlugin2() } catch (e) { } return !1 }, allowPlugin: function () { return this.getBrowser(), "Safari" != this.browserName2 && "Opera" != this.browserName2 }, getPlugin: function () { this.refresh(); var e = null; return this.allowPlugin() && (e = document.getElementById("deployJavaPlugin")), e }, compareVersionToPattern: function (e, t, i, n) { if (e == undefined || t == undefined) return !1; var a = e.match(r); if (null != a) { for (var o = 0, s = new Array, l = 1; l < a.length; ++l)"string" == typeof a[l] && "" != a[l] && (s[o] = a[l], o++); var u = Math.min(s.length, t.length); if (n) { for (var c = 0; c < u; ++c) { var d = parseInt(s[c]), p = parseInt(t[c]); if (d < p) return !1; if (d > p) return !0 } return !0 } for (var f = 0; f < u; ++f)if (s[f] != t[f]) return !1; return !!i || s.length == t.length } return !1 }, getBrowser: function () { if (null == this.browserName) { var e = navigator.userAgent.toLowerCase(); if (l("[getBrowser()] navigator.userAgent.toLowerCase() -> " + e), -1 != e.indexOf("edge")) this.browserName = "Edge", this.browserName2 = "Edge"; else if (-1 != e.indexOf("msie") && -1 == e.indexOf("opera")) this.browserName = "MSIE", this.browserName2 = "MSIE"; else if (-1 != e.indexOf("trident") || -1 != e.indexOf("Trident")) { if (this.browserName = "MSIE", this.browserName2 = "MSIE", -1 != e.indexOf("windows nt 6.3") || -1 != e.indexOf("windows nt 6.2")) try { new ActiveXObject("htmlfile") } catch (t) { this.browserName2 = "NoActiveX" } } else -1 != e.indexOf("iphone") ? (this.browserName = "Netscape Family", this.browserName2 = "iPhone") : -1 != e.indexOf("firefox") && -1 == e.indexOf("opera") ? (this.browserName = "Netscape Family", this.isPluginInstalled() ? this.browserName2 = "Firefox" : this.browserName2 = "FirefoxNoPlugin") : -1 != e.indexOf("chrome") ? (this.browserName = "Netscape Family", this.browserName2 = "Chrome") : -1 != e.indexOf("safari") ? (this.browserName = "Netscape Family", this.browserName2 = "Safari") : -1 != e.indexOf("mozilla") && -1 == e.indexOf("opera") ? (this.browserName = "Netscape Family", this.browserName2 = "Other") : -1 != e.indexOf("opera") ? (this.browserName = "Netscape Family", this.browserName2 = "Opera") : (this.browserName = "?", this.browserName2 = "unknown"); l("[getBrowser()] Detected browser name:" + this.browserName + ", " + this.browserName2) } return this.browserName }, testUsingActiveX: function (e) { var t = "JavaWebStart.isInstalled." + e + ".0"; if ("undefined" == typeof ActiveXObject || !ActiveXObject) return l("[testUsingActiveX()] Browser claims to be IE, but no ActiveXObject object?"), !1; try { return null != new ActiveXObject(t) } catch (i) { return !1 } }, testForMSVM: function () { if ("undefined" != typeof oClientCaps) { var e = oClientCaps.getComponentVersion("{08B0E5C0-4FCB-11CF-AAA5-00401C608500}", "ComponentID"); return "" != e && "5,0,5000,0" != e } return !1 }, testUsingMimeTypes: function (e) { if (!navigator.mimeTypes) return l("[testUsingMimeTypes()] Browser claims to be Netscape family, but no mimeTypes[] array?"), !1; for (var t = 0; t < navigator.mimeTypes.length; ++t) { var i = navigator.mimeTypes[t].type.match(/^application\/x-java-applet\x3Bversion=(1\.8|1\.7|1\.6|1\.5|1\.4\.2)$/); if (null != i && this.compareVersions(i[1], e)) return !0 } return !1 }, testUsingPluginsArray: function (e) { if (!navigator.plugins || !navigator.plugins.length) return !1; for (var t = navigator.platform.toLowerCase(), i = 0; i < navigator.plugins.length; ++i) { var n = navigator.plugins[i].description; if (-1 != n.search(/^Java Switchable Plug-in (Cocoa)/)) { if (this.compareVersions("1.5.0", e)) return !0 } else if (-1 != n.search(/^Java/) && -1 != t.indexOf("win") && (this.compareVersions("1.5.0", e) || this.compareVersions("1.6.0", e))) return !0 } return !!this.compareVersions("1.5.0", e) }, IEInstall: function () { return location.href = p((null != this.locale ? "&locale=" + this.locale : "") + (null != this.brand ? "&brand=" + this.brand : "")), !1 }, done: function (e, t) { }, FFInstall: function () { return location.href = p((null != this.locale ? "&locale=" + this.locale : "") + (null != this.brand ? "&brand=" + this.brand : "") + (null != this.installType ? "&type=" + this.installType : "")), !1 }, compareVersions: function (e, t) { for (var i = e.split("."), n = t.split("."), r = 0; r < i.length; ++r)i[r] = Number(i[r]); for (var a = 0; a < n.length; ++a)n[a] = Number(n[a]); return 2 == i.length && (i[2] = 0), i[0] > n[0] || !(i[0] < n[0]) && (i[1] > n[1] || !(i[1] < n[1]) && (i[2] > n[2] || !(i[2] < n[2]))) }, enableAlerts: function () { this.browserName = null, this.debug = !0 }, poll: function () { this.refresh(); var e = this.getJREs(); 0 == this.preInstallJREList.length && 0 != e.length && clearInterval(this.myInterval), 0 != this.preInstallJREList.length && 0 != e.length && this.preInstallJREList[0] != e[0] && clearInterval(this.myInterval) }, writePluginTag: function () { var e = this.getBrowser(); "MSIE" == e ? document.write('<object classid="clsid:CAFEEFAC-DEC7-0000-0001-ABCDEFFEDCBA" id="deployJavaPlugin" width="0" height="0"></object>') : "Netscape Family" == e && this.allowPlugin() && this.writeEmbedTag() }, refresh: function () { (navigator.plugins.refresh(!1), "Netscape Family" == this.getBrowser() && this.allowPlugin()) && (null == document.getElementById("deployJavaPlugin") && this.writeEmbedTag()) }, writeEmbedTag: function () { var e = !1; if (null != navigator.mimeTypes) { for (var t = 0; t < navigator.mimeTypes.length; t++)navigator.mimeTypes[t].type == this.mimeType && navigator.mimeTypes[t].enabledPlugin && (document.write('<embed id="deployJavaPlugin" type="' + this.mimeType + '" hidden="true" />'), e = !0); if (!e) for (var i = 0; i < navigator.mimeTypes.length; i++)navigator.mimeTypes[i].type == this.oldMimeType && navigator.mimeTypes[i].enabledPlugin && document.write('<embed id="deployJavaPlugin" type="' + this.oldMimeType + '" hidden="true" />') } } }; if (f.writePluginTag(), null == f.locale) { var h = null; if (null == h) try { h = navigator.userLanguage } catch (m) { } if (null == h) try { h = navigator.systemLanguage } catch (m) { } if (null == h) try { h = navigator.language } catch (m) { } null != h && (h.replace("-", "_"), f.locale = h) } e.exports = f }, function (e, t, i) { "use strict"; var n = i(11); e.exports = function () { if (this.isFlash()) { var e = n.getFlashPlayerVersion(); return e.major + "." + e.minor + "." + e.release } return "" } }, function (e, t) {
        /*!    SWFObject v2.3.20130521 <http://github.com/swfobject/swfobject>
            is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
        */
        var i, n, r, a, o, s, l = "undefined", u = "object", c = "Shockwave Flash", d = "application/x-shockwave-flash", p = "SWFObjectExprInst", f = "onreadystatechange", h = window, m = document, g = navigator, b = !1, v = [], w = [], y = [], x = [], C = !1, S = !1, k = !0, T = !1, M = function () { var e = typeof m.getElementById !== l && typeof m.getElementsByTagName !== l && typeof m.createElement !== l, t = g.userAgent.toLowerCase(), i = g.platform.toLowerCase(), n = /win/.test(i || t), r = /mac/.test(i || t), a = !!/webkit/.test(t) && parseFloat(t.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")), o = "Microsoft Internet Explorer" === g.appName, s = [0, 0, 0], p = null; if (typeof g.plugins !== l && typeof g.plugins[c] === u) (p = g.plugins[c].description) && typeof g.mimeTypes !== l && g.mimeTypes[d] && g.mimeTypes[d].enabledPlugin && (b = !0, o = !1, p = p.replace(/^.*\s+(\S+\s+\S+$)/, "$1"), s[0] = _(p.replace(/^(.*)\..*$/, "$1")), s[1] = _(p.replace(/^.*\.(.*)\s.*$/, "$1")), s[2] = /[a-zA-Z]/.test(p) ? _(p.replace(/^.*[a-zA-Z]+(.*)$/, "$1")) : 0); else if (typeof h.ActiveXObject !== l) try { var f = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); f && (p = f.GetVariable("$version")) && (o = !0, s = [_((p = p.split(" ")[1].split(","))[0]), _(p[1]), _(p[2])]) } catch (v) { } return { w3: e, pv: s, wk: a, ie: o, win: n, mac: r } }(); function A() { if (!C && document.getElementsByTagName("body")[0]) { try { var e, t = J("span"); t.style.display = "none", (e = m.getElementsByTagName("body")[0].appendChild(t)).parentNode.removeChild(e), e = null, t = null } catch (r) { return } C = !0; for (var i = v.length, n = 0; n < i; n++)v[n]() } } function E(e) { C ? e() : v[v.length] = e } function P() { var e = w.length; if (e > 0) for (var t = 0; t < e; t++) { var i = w[t].id, n = w[t].callbackFn, r = { success: !1, id: i }; if (M.pv[0] > 0) { var a = D(i); if (a) if (!G(w[t].swfVersion) || M.wk && M.wk < 312) if (w[t].expressInstall && I()) { var o = {}; o.data = w[t].expressInstall, o.width = a.getAttribute("width") || "0", o.height = a.getAttribute("height") || "0", a.getAttribute("class") && (o.styleclass = a.getAttribute("class")), a.getAttribute("align") && (o.align = a.getAttribute("align")); for (var s = {}, u = a.getElementsByTagName("param"), c = u.length, d = 0; d < c; d++)"movie" !== u[d].getAttribute("name").toLowerCase() && (s[u[d].getAttribute("name")] = u[d].getAttribute("value")); B(o, s, i, n) } else j(a), n && n(r); else z(i, !0), n && (r.success = !0, r.ref = N(i), r.id = i, n(r)) } else if (z(i, !0), n) { var p = N(i); p && typeof p.SetVariable !== l && (r.success = !0, r.ref = p, r.id = p.id), n(r) } } } function N(e) { var t = null, i = D(e); return i && "OBJECT" === i.nodeName.toUpperCase() && (t = typeof i.SetVariable !== l ? i : i.getElementsByTagName(u)[0] || i), t } function I() { return !S && G("6.0.65") && (M.win || M.mac) && !(M.wk && M.wk < 312) } function B(e, t, o, s) { var u = D(o); if (o = V(o), S = !0, r = s || null, a = { success: !1, id: o }, u) { "OBJECT" === u.nodeName.toUpperCase() ? (i = L(u), n = null) : (i = u, n = o), e.id = p, (typeof e.width === l || !/%$/.test(e.width) && _(e.width) < 310) && (e.width = "310"), (typeof e.height === l || !/%$/.test(e.height) && _(e.height) < 137) && (e.height = "137"); var c = M.ie ? "ActiveX" : "PlugIn", d = "MMredirectURL=" + encodeURIComponent(h.location.toString().replace(/&/g, "%26")) + "&MMplayerType=" + c + "&MMdoctitle=" + encodeURIComponent(m.title.slice(0, 47) + " - Flash Player Installation"); if (typeof t.flashvars !== l ? t.flashvars += "&" + d : t.flashvars = d, M.ie && 4 != u.readyState) { var f = J("div"); o += "SWFObjectNew", f.setAttribute("id", o), u.parentNode.insertBefore(f, u), u.style.display = "none", R(u) } U(e, t, o) } } function j(e) { if (M.ie && 4 != e.readyState) { e.style.display = "none"; var t = J("div"); e.parentNode.insertBefore(t, e), t.parentNode.replaceChild(L(e), t), R(e) } else e.parentNode.replaceChild(L(e), e) } function L(e) { var t = J("div"); if (M.win && M.ie) t.innerHTML = e.innerHTML; else { var i = e.getElementsByTagName(u)[0]; if (i) { var n = i.childNodes; if (n) for (var r = n.length, a = 0; a < r; a++)1 == n[a].nodeType && "PARAM" === n[a].nodeName || 8 == n[a].nodeType || t.appendChild(n[a].cloneNode(!0)) } } return t } function U(e, t, i) { var n, r, a, o, s = D(i); if (i = V(i), M.wk && M.wk < 312) return n; if (s) { var c, p, f, h = M.ie ? J("div") : J(u); for (f in typeof e.id === l && (e.id = i), t) Object.prototype.hasOwnProperty.call(t, f) && "movie" !== f.toLowerCase() && O(h, f, t[f]); for (c in M.ie && (r = e.data, a = h.innerHTML, (o = J("div")).innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'><param name='movie' value='" + r + "'>" + a + "</object>", h = o.firstChild), e) Object.prototype.hasOwnProperty.call(e, c) && ("styleclass" === (p = c.toLowerCase()) ? h.setAttribute("class", e[c]) : "classid" !== p && "data" !== p && h.setAttribute(c, e[c])); M.ie ? y[y.length] = e.id : (h.setAttribute("type", d), h.setAttribute("data", e.data)), s.parentNode.replaceChild(h, s), n = h } return n } function O(e, t, i) { var n = J("param"); n.setAttribute("name", t), n.setAttribute("value", i), e.appendChild(n) } function R(e) { var t = D(e); t && "OBJECT" === t.nodeName.toUpperCase() && (M.ie ? (t.style.display = "none", function i() { if (4 == t.readyState) { for (var e in t) "function" == typeof t[e] && (t[e] = null); t.parentNode.removeChild(t) } else setTimeout(i, 10) }()) : t.parentNode.removeChild(t)) } function F(e) { return e && e.nodeType && 1 === e.nodeType } function V(e) { return F(e) ? e.id : e } function D(e) { if (F(e)) return e; var t = null; try { t = m.getElementById(e) } catch (i) { } return t } function J(e) { return m.createElement(e) } function _(e) { return parseInt(e, 10) } function G(e) { e += ""; var t = M.pv, i = e.split("."); return i[0] = _(i[0]), i[1] = _(i[1]) || 0, i[2] = _(i[2]) || 0, t[0] > i[0] || t[0] == i[0] && t[1] > i[1] || t[0] == i[0] && t[1] == i[1] && t[2] >= i[2] } function W(e, t, i, n) { var r = m.getElementsByTagName("head")[0]; if (r) { var a = "string" == typeof i ? i : "screen"; if (n && (o = null, s = null), !o || s != a) { var u = J("style"); u.setAttribute("type", "text/css"), u.setAttribute("media", a), o = r.appendChild(u), M.ie && typeof m.styleSheets !== l && m.styleSheets.length > 0 && (o = m.styleSheets[m.styleSheets.length - 1]), s = a } o && (typeof o.addRule !== l ? o.addRule(e, t) : typeof m.createTextNode !== l && o.appendChild(m.createTextNode(e + " {" + t + "}"))) } } function z(e, t) { if (k) { var i = t ? "visible" : "hidden", n = D(e); C && n ? n.style.visibility = i : "string" == typeof e && W("#" + e, "visibility:" + i) } } function q(e) { return null !== /[\\"<>.;]/.exec(e) && typeof encodeURIComponent !== l ? encodeURIComponent(e) : e } M.w3 && ((typeof m.readyState !== l && ("complete" === m.readyState || "interactive" === m.readyState) || typeof m.readyState === l && (m.getElementsByTagName("body")[0] || m.body)) && A(), C || (typeof m.addEventListener !== l && m.addEventListener("DOMContentLoaded", A, !1), M.ie && (m.attachEvent(f, (function X() { "complete" === m.readyState && (m.detachEvent(f, X), A()) })), h == top && function $() { if (!C) { try { m.documentElement.doScroll("left") } catch (e) { return void setTimeout($, 0) } A() } }()), M.wk && function K() { C || (/loaded|complete/.test(m.readyState) ? A() : setTimeout(K, 0)) }())), v[0] = function () { b ? function () { var e = m.getElementsByTagName("body")[0], t = J(u); t.setAttribute("style", "visibility: hidden;"), t.setAttribute("type", d); var i = e.appendChild(t); if (i) { var n = 0; !function r() { if (typeof i.GetVariable !== l) try { var a = i.GetVariable("$version"); a && (a = a.split(" ")[1].split(","), M.pv = [_(a[0]), _(a[1]), _(a[2])]) } catch (o) { M.pv = [8, 0, 0] } else if (n < 10) return n++, void setTimeout(r, 10); e.removeChild(t), i = null, P() }() } else P() }() : P() }, M.ie && window.attachEvent("onunload", (function () { for (var e = x.length, t = 0; t < e; t++)x[t][0].detachEvent(x[t][1], x[t][2]); for (var i = y.length, n = 0; n < i; n++)R(y[n]); for (var r in M) M[r] = null; for (var a in M = null, H) H[a] = null; H = null })); var H = { registerObject: function (e, t, i, n) { if (M.w3 && e && t) { var r = {}; r.id = e, r.swfVersion = t, r.expressInstall = i, r.callbackFn = n, w[w.length] = r, z(e, !1) } else n && n({ success: !1, id: e }) }, getObjectById: function (e) { if (M.w3) return N(e) }, embedSWF: function (e, t, i, n, r, a, o, s, c, d) { var p = V(t), f = { success: !1, id: p }; M.w3 && !(M.wk && M.wk < 312) && e && t && i && n && r ? (z(p, !1), E((function () { i += "", n += ""; var h = {}; if (c && typeof c === u) for (var m in c) h[m] = c[m]; h.data = e, h.width = i, h.height = n; var g = {}; if (s && typeof s === u) for (var b in s) g[b] = s[b]; if (o && typeof o === u) for (var v in o) if (Object.prototype.hasOwnProperty.call(o, v)) { var w = T ? encodeURIComponent(v) : v, y = T ? encodeURIComponent(o[v]) : o[v]; typeof g.flashvars !== l ? g.flashvars += "&" + w + "=" + y : g.flashvars = w + "=" + y } if (G(r)) { var x = U(h, g, t); h.id == p && z(p, !0), f.success = !0, f.ref = x, f.id = x.id } else { if (a && I()) return h.data = a, void B(h, g, t, d); z(p, !0) } d && d(f) }))) : d && d(f) }, switchOffAutoHideShow: function () { k = !1 }, enableUriEncoding: function (e) { T = typeof e === l || e }, ua: M, getFlashPlayerVersion: function () { return { major: M.pv[0], minor: M.pv[1], release: M.pv[2] } }, hasFlashPlayerVersion: G, createSWF: function (e, t, i) { return M.w3 ? U(e, t, i) : undefined }, showExpressInstall: function (e, t, i, n) { M.w3 && I() && B(e, t, i, n) }, removeSWF: function (e) { M.w3 && R(e) }, createCSS: function (e, t, i, n) { M.w3 && W(e, t, i, n) }, addDomLoadEvent: E, addLoadEvent: function (e) { if (typeof h.addEventListener !== l) h.addEventListener("load", e, !1); else if (typeof m.addEventListener !== l) m.addEventListener("load", e, !1); else if (typeof h.attachEvent !== l) !function (e, t, i) { e.attachEvent(t, i), x[x.length] = [e, t, i] }(h, "onload", e); else if ("function" == typeof h.onload) { var t = h.onload; h.onload = function () { t(), e() } } else h.onload = e }, getQueryParamValue: function (e) { var t = m.location.search || m.location.hash; if (t) { if (/\?/.test(t) && (t = t.split("?")[1]), !e) return q(t); for (var i = t.split("&"), n = 0; n < i.length; n++)if (i[n].substring(0, i[n].indexOf("=")) == e) return q(i[n].substring(i[n].indexOf("=") + 1)) } return "" }, expressInstallCallback: function () { if (S) { var e = D(p); e && i && (e.parentNode.replaceChild(i, e), n && (z(n, !0), M.ie && (i.style.display = "block")), r && r(a)), S = !1 } }, version: "2.3" }; e.exports = H
    }, function (e, t, i) { "use strict"; var n = i(7), r = i(0).ClientJS, a = i(8), o = i(10); function s() { r.apply(this, arguments) } n(s, r), s.prototype.getJavaVersion = a, s.prototype.getFlashVersion = o, t.ClientJS = s }])
}));
//# sourceMappingURL=client.min.js.map;
(function (fingerprint, $) {

    fingerprint.get = function () {
        const ClientJS = window.ClientJS;
        // Create a new ClientJS object
        const client = new ClientJS();

        // Get the client's fingerprint id
        return client.getFingerprint();
    }

    fingerprint.save = function () {
        const key = fingerprint.get();
        $.ajax({
            url: '/Checkout/SetBrowserKey',
            type: 'POST',
            data: { 'key': key }
        }).fail(function (jqXHR, textStatus, errorThrown) {
            console.log('error: the fingerprint failed on ajax')
        });

    }

    return fingerprint;

})(shopHq.fingerprint = shopHq.fingerprint || {}, jQuery);

$(document).ready(function () {
    shopHq.fingerprint.save();
})

;
(function (overlays, $) {
	let $modal;
	let $hiddenField;
	let $errorSpan;
	let $emailField;
	let $submitButton;

	overlays.submitEmailOverlayForm = function () {
		$errorSpan = $('.js-email-overlay-modal .js-email-overlay-email__error')

		if ($emailField.val()) {
			let regex = /^(?![0-9]+@)([a-z0-9а-я_.-]{3,20})@([a-zа-я_]{3,20})\.([a-zа-я]{2,5})(\.[a-zа-я]{2,5})?$/gm;

			if (regex.test($emailField.val())) {
				let url = `https://cloud.em.christopherandbanks.com/EmailNotification?email=${$emailField.val()}&frequency=Daily`;
				$emailField.removeAttr('aria-describedBy');
				$errorSpan.removeClass('c-email-overlay-email__error_active');
				window.open(url, '_blank');
				$modal.modal('hide');

				return true;
			}
		}

		$emailField.attr('aria-describedBy', 'emailOverlayModalEmailError');
		$errorSpan.addClass('c-email-overlay-email__error_active');

		return false;
	}

	// on ready
	$(function () {

		// Set up the email overlay
		$modal = $('.js-email-overlay-modal');
		$hiddenField = $('.js-email-overlay-enabled-hidden');
		$emailField = $('.js-email-overlay-modal .js-email-overlay-email');
		$submitButton = $('.js-email-overlay-modal .js-email-overlay-submit');

		if ($modal.length > 0 && $hiddenField.length > 0 && $hiddenField.val() === 'True') {
			window.onscroll = function () {
				var scrollLimit = 200;

				if (window.scrollY >= scrollLimit && $hiddenField.val() === 'True') {
					$hiddenField.val('False');
					$modal.modal('show');
				}
			};
		}
	});

	return overlays;

})(shopHq.overlays = shopHq.overlays || {}, jQuery);;
