/*!
 * Bootstrap v3.3.6 (http://getbootstrap.com)
 * Copyright 2011-2015 Twitter, Inc.
 * Licensed under the MIT license
 */
if("undefined"==typeof cbsjq)throw new Error("Bootstrap's JavaScript requires cbsjq");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1||b[0]>2)throw new Error("Bootstrap's JavaScript requires cbsjq version 1.9.1 or higher, but lower than version 3")}(cbsjq),+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}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",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(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(cbsjq),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.6",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a(f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(cbsjq),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.6",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),a(c.target).is('input[type="radio"]')||a(c.target).is('input[type="checkbox"]')||c.preventDefault()}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(cbsjq),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.6",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));return a>this.$items.length-1||0>a?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){return this.sliding?void 0:this.slide("next")},c.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(cbsjq),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.6",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[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 e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(cbsjq),+function(a){"use strict";function b(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function c(c){c&&3===c.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=b(d),f={relatedTarget:this};e.hasClass("open")&&(c&&"click"==c.type&&/input|textarea/i.test(c.target.tagName)&&a.contains(e[0],c.target)||(e.trigger(c=a.Event("hide.bs.dropdown",f)),c.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",f)))))}))}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.6",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=b(e),g=f.hasClass("open");if(c(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",c);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),f.toggleClass("open").trigger(a.Event("shown.bs.dropdown",h))}return!1}},g.prototype.keydown=function(c){if(/(38|40|27|32)/.test(c.which)&&!/input|textarea/i.test(c.target.tagName)){var d=a(this);if(c.preventDefault(),c.stopPropagation(),!d.is(".disabled, :disabled")){var e=b(d),g=e.hasClass("open");if(!g&&27!=c.which||g&&27==c.which)return 27==c.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.disabled):visible a",i=e.find(".dropdown-menu"+h);if(i.length){var j=i.index(c.target);38==c.which&&j>0&&j--,40==c.which&&j<i.length-1&&j++,~j||(j=0),i.eq(j).trigger("focus")}}}};var h=a.fn.dropdown;a.fn.dropdown=d,a.fn.dropdown.Constructor=g,a.fn.dropdown.noConflict=function(){return a.fn.dropdown=h,this},a(document).on("click.bs.dropdown.data-api",c).on("click.bs.dropdown.data-api",".dropdown form",function(a){a.stopPropagation()}).on("click.bs.dropdown.data-api",f,g.prototype.toggle).on("keydown.bs.dropdown.data-api",f,g.prototype.keydown).on("keydown.bs.dropdown.data-api",".dropdown-menu",g.prototype.keydown)}(cbsjq),+function(a){"use strict";function b(b,d){return this.each(function(){var e=a(this),f=e.data("bs.modal"),g=a.extend({},c.DEFAULTS,e.data(),"object"==typeof b&&b);f||e.data("bs.modal",f=new c(this,g)),"string"==typeof b?f[b](d):g.show&&f.show(d)})}var c=function(b,c){this.options=c,this.$body=a(document.body),this.$element=a(b),this.$dialog=this.$element.find(".modal-dialog"),this.$backdrop=null,this.isShown=null,this.originalBodyPad=null,this.scrollbarWidth=0,this.ignoreBackdropClick=!1,this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,a.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))};c.VERSION="3.3.6",c.TRANSITION_DURATION=300,c.BACKDROP_TRANSITION_DURATION=150,c.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},c.prototype.toggle=function(a){return this.isShown?this.hide():this.show(a)},c.prototype.show=function(b){var d=this,e=a.Event("show.bs.modal",{relatedTarget:b});this.$element.trigger(e),this.isShown||e.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(){d.$element.one("mouseup.dismiss.bs.modal",function(b){a(b.target).is(d.$element)&&(d.ignoreBackdropClick=!0)})}),this.backdrop(function(){var e=a.support.transition&&d.$element.hasClass("fade");d.$element.parent().length||d.$element.appendTo(d.$body),d.$element.show().scrollTop(0),d.adjustDialog(),e&&d.$element[0].offsetWidth,d.$element.addClass("in"),d.enforceFocus();var f=a.Event("shown.bs.modal",{relatedTarget:b});e?d.$dialog.one("bsTransitionEnd",function(){d.$element.trigger("focus").trigger(f)}).emulateTransitionEnd(c.TRANSITION_DURATION):d.$element.trigger("focus").trigger(f)}))},c.prototype.hide=function(b){b&&b.preventDefault(),b=a.Event("hide.bs.modal"),this.$element.trigger(b),this.isShown&&!b.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(c.TRANSITION_DURATION):this.hideModal())},c.prototype.enforceFocus=function(){a(document).off("focusin.bs.modal").on("focusin.bs.modal",a.proxy(function(a){this.$element[0]===a.target||this.$element.has(a.target).length||this.$element.trigger("focus")},this))},c.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keydown.dismiss.bs.modal",a.proxy(function(a){27==a.which&&this.hide()},this)):this.isShown||this.$element.off("keydown.dismiss.bs.modal")},c.prototype.resize=function(){this.isShown?a(window).on("resize.bs.modal",a.proxy(this.handleUpdate,this)):a(window).off("resize.bs.modal")},c.prototype.hideModal=function(){var a=this;this.$element.hide(),this.backdrop(function(){a.$body.removeClass("modal-open"),a.resetAdjustments(),a.resetScrollbar(),a.$element.trigger("hidden.bs.modal")})},c.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},c.prototype.backdrop=function(b){var d=this,e=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var f=a.support.transition&&e;if(this.$backdrop=a(document.createElement("div")).addClass("modal-backdrop "+e).appendTo(this.$body),this.$element.on("click.dismiss.bs.modal",a.proxy(function(a){return this.ignoreBackdropClick?void(this.ignoreBackdropClick=!1):void(a.target===a.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus():this.hide()))},this)),f&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!b)return;f?this.$backdrop.one("bsTransitionEnd",b).emulateTransitionEnd(c.BACKDROP_TRANSITION_DURATION):b()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var g=function(){d.removeBackdrop(),b&&b()};a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",g).emulateTransitionEnd(c.BACKDROP_TRANSITION_DURATION):g()}else b&&b()},c.prototype.handleUpdate=function(){this.adjustDialog()},c.prototype.adjustDialog=function(){var a=this.$element[0].scrollHeight>document.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&a?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!a?this.scrollbarWidth:""})},c.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},c.prototype.checkScrollbar=function(){var a=window.innerWidth;if(!a){var b=document.documentElement.getBoundingClientRect();a=b.right-Math.abs(b.left)}this.bodyIsOverflowing=document.body.clientWidth<a,this.scrollbarWidth=this.measureScrollbar()},c.prototype.setScrollbar=function(){var a=parseInt(this.$body.css("padding-right")||0,10);this.originalBodyPad=document.body.style.paddingRight||"",this.bodyIsOverflowing&&this.$body.css("padding-right",a+this.scrollbarWidth)},c.prototype.resetScrollbar=function(){this.$body.css("padding-right",this.originalBodyPad)},c.prototype.measureScrollbar=function(){var a=document.createElement("div");a.className="modal-scrollbar-measure",this.$body.append(a);var b=a.offsetWidth-a.clientWidth;return this.$body[0].removeChild(a),b};var d=a.fn.modal;a.fn.modal=b,a.fn.modal.Constructor=c,a.fn.modal.noConflict=function(){return a.fn.modal=d,this},a(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(c){var d=a(this),e=d.attr("href"),f=a(d.attr("data-target")||e&&e.replace(/.*(?=#[^\s]+$)/,"")),g=f.data("bs.modal")?"toggle":a.extend({remote:!/#/.test(e)&&e},f.data(),d.data());d.is("a")&&c.preventDefault(),f.one("show.bs.modal",function(a){a.isDefaultPrevented()||f.one("hidden.bs.modal",function(){d.is(":visible")&&d.trigger("focus")})}),b.call(f,g,this)})}(cbsjq),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.tooltip"),f="object"==typeof b&&b;(e||!/destroy|hide/.test(b))&&(e||d.data("bs.tooltip",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.type=null,this.options=null,this.enabled=null,this.timeout=null,this.hoverState=null,this.$element=null,this.inState=null,this.init("tooltip",a,b)};c.VERSION="3.3.6",c.TRANSITION_DURATION=150,c.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}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(a.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 e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusin"==b.type?"focus":"hover"]=!0),c.tip().hasClass("in")||"in"==c.hoverState?void(c.hoverState="in"):(clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.isInStateTrue=function(){for(var a in this.inState)if(this.inState[a])return!0;return!1},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusout"==b.type?"focus":"hover"]=!1),c.isInStateTrue()?void 0:(clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide())},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.getPosition(this.$viewport);h="bottom"==h&&k.bottom+m>o.bottom?"top":"top"==h&&k.top-m<o.top?"bottom":"right"==h&&k.right+l>o.width?"left":"left"==h&&k.left-l<o.left?"right":h,f.removeClass(n).addClass(h)}var p=this.getCalculatedOffset(h,k,l,m);this.applyPlacement(p,h);var q=function(){var a=e.hoverState;e.$element.trigger("shown.bs."+e.type),e.hoverState=null,"out"==a&&e.leave(e)};a.support.transition&&this.$tip.hasClass("fade")?f.one("bsTransitionEnd",q).emulateTransitionEnd(c.TRANSITION_DURATION):q()}},c.prototype.applyPlacement=function(b,c){var d=this.tip(),e=d[0].offsetWidth,f=d[0].offsetHeight,g=parseInt(d.css("margin-top"),10),h=parseInt(d.css("margin-left"),10);isNaN(g)&&(g=0),isNaN(h)&&(h=0),b.top+=g,b.left+=h,a.offset.setOffset(d[0],a.extend({using:function(a){d.css({top:Math.round(a.top),left:Math.round(a.left)})}},b),0),d.addClass("in");var i=d[0].offsetWidth,j=d[0].offsetHeight;"top"==c&&j!=f&&(b.top=b.top+f-j);var k=this.getViewportAdjustedDelta(c,b,i,j);k.left?b.left+=k.left:b.top+=k.top;var l=/top|bottom/.test(c),m=l?2*k.left-e+i:2*k.top-f+j,n=l?"offsetWidth":"offsetHeight";d.offset(b),this.replaceArrow(m,d[0][n],l)},c.prototype.replaceArrow=function(a,b,c){this.arrow().css(c?"left":"top",50*(1-a/b)+"%").css(c?"top":"left","")},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.options.html?"html":"text"](b),a.removeClass("fade in top bottom left right")},c.prototype.hide=function(b){function d(){"in"!=e.hoverState&&f.detach(),e.$element.removeAttr("aria-describedby").trigger("hidden.bs."+e.type),b&&b()}var e=this,f=a(this.$tip),g=a.Event("hide.bs."+this.type);return this.$element.trigger(g),g.isDefaultPrevented()?void 0:(f.removeClass("in"),a.support.transition&&f.hasClass("fade")?f.one("bsTransitionEnd",d).emulateTransitionEnd(c.TRANSITION_DURATION):d(),this.hoverState=null,this)},c.prototype.fixTitle=function(){var a=this.$element;(a.attr("title")||"string"!=typeof a.attr("data-original-title"))&&a.attr("data-original-title",a.attr("title")||"").attr("title","")},c.prototype.hasContent=function(){return this.getTitle()},c.prototype.getPosition=function(b){b=b||this.$element;var c=b[0],d="BODY"==c.tagName,e=c.getBoundingClientRect();null==e.width&&(e=a.extend({},e,{width:e.right-e.left,height:e.bottom-e.top}));var f=d?{top:0,left:0}:b.offset(),g={scroll:d?document.documentElement.scrollTop||document.body.scrollTop:b.scrollTop()},h=d?{width:a(window).width(),height:a(window).height()}:null;return a.extend({},e,g,h,f)},c.prototype.getCalculatedOffset=function(a,b,c,d){return"bottom"==a?{top:b.top+b.height,left:b.left+b.width/2-c/2}:"top"==a?{top:b.top-d,left:b.left+b.width/2-c/2}:"left"==a?{top:b.top+b.height/2-d/2,left:b.left-c}:{top:b.top+b.height/2-d/2,left:b.left+b.width}},c.prototype.getViewportAdjustedDelta=function(a,b,c,d){var e={top:0,left:0};if(!this.$viewport)return e;var f=this.options.viewport&&this.options.viewport.padding||0,g=this.getPosition(this.$viewport);if(/right|left/.test(a)){var h=b.top-f-g.scroll,i=b.top+f-g.scroll+d;h<g.top?e.top=g.top-h:i>g.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;j<g.left?e.left=g.left-j:k>g.right&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){if(!this.$tip&&(this.$tip=a(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},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),b?(c.inState.click=!c.inState.click,c.isInStateTrue()?c.enter(c):c.leave(c)):c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type),a.$tip&&a.$tip.detach(),a.$tip=null,a.$arrow=null,a.$viewport=null})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(cbsjq),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;(e||!/destroy|hide/.test(b))&&(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.6",c.DEFAULTS=a.extend({},a.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>'}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(cbsjq),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.6",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b<e[0])return this.activeTarget=null,this.clear();for(a=e.length;a--;)g!=f[a]&&b>=e[a]&&(void 0===e[a+1]||b<e[a+1])&&this.activate(f[a])},b.prototype.activate=function(b){this.activeTarget=b,this.clear();var c=this.selector+'[data-target="'+b+'"],'+this.selector+'[href="'+b+'"]',d=a(c).parents("li").addClass("active");
d.parent(".dropdown-menu").length&&(d=d.closest("li.dropdown").addClass("active")),d.trigger("activate.bs.scrollspy")},b.prototype.clear=function(){a(this.selector).parentsUntil(this.options.target,".active").removeClass("active")};var d=a.fn.scrollspy;a.fn.scrollspy=c,a.fn.scrollspy.Constructor=b,a.fn.scrollspy.noConflict=function(){return a.fn.scrollspy=d,this},a(window).on("load.bs.scrollspy.data-api",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);c.call(b,b.data())})})}(cbsjq),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.tab");e||d.data("bs.tab",e=new c(this)),"string"==typeof b&&e[b]()})}var c=function(b){this.element=a(b)};c.VERSION="3.3.6",c.TRANSITION_DURATION=150,c.prototype.show=function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.data("target");if(d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),!b.parent("li").hasClass("active")){var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a.Event("show.bs.tab",{relatedTarget:e[0]});if(e.trigger(f),b.trigger(g),!g.isDefaultPrevented()&&!f.isDefaultPrevented()){var h=a(d);this.activate(b.closest("li"),c),this.activate(h,h.parent(),function(){e.trigger({type:"hidden.bs.tab",relatedTarget:b[0]}),b.trigger({type:"shown.bs.tab",relatedTarget:e[0]})})}}},c.prototype.activate=function(b,d,e){function f(){g.removeClass("active").find("> .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(cbsjq),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.6",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=e?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(cbsjq);
/**
 * jQuery number plug-in 2.1.3
 * Copyright 2012, Digital Fusion
 * Licensed under the MIT license.
 * http://opensource.teamdf.com/license/
 *
 * A jQuery plugin which implements a permutation of phpjs.org's number_format to provide
 * simple number formatting, insertion, and as-you-type masking of a number.
 * 
 * @author	Sam Sehnert
 * @docs	http://www.teamdf.com/web/jquery-number-format-redux/196/
 */
(function($){
	
	"use strict";
	
	/**
	 * Method for selecting a range of characters in an input/textarea.
	 *
	 * @param int rangeStart			: Where we want the selection to start.
	 * @param int rangeEnd				: Where we want the selection to end.
	 *
	 * @return void;
	 */
	function setSelectionRange( rangeStart, rangeEnd )
	{
		// Check which way we need to define the text range.
		if( this.createTextRange )
		{
			var range = this.createTextRange();
				range.collapse( true );
				range.moveStart( 'character',	rangeStart );
				range.moveEnd( 'character',		rangeEnd-rangeStart );
				range.select();
		}
		
		// Alternate setSelectionRange method for supporting browsers.
		else if( this.setSelectionRange )
		{
			this.focus();
			this.setSelectionRange( rangeStart, rangeEnd );
		}
	}
	
	/**
	 * Get the selection position for the given part.
	 * 
	 * @param string part			: Options, 'Start' or 'End'. The selection position to get.
	 *
	 * @return int : The index position of the selection part.
	 */
	function getSelection( part )
	{
		var pos	= this.value.length;
		
		// Work out the selection part.
		part = ( part.toLowerCase() == 'start' ? 'Start' : 'End' );
		
		if( document.selection ){
			// The current selection
			var range = document.selection.createRange(), stored_range, selectionStart, selectionEnd;
			// We'll use this as a 'dummy'
			stored_range = range.duplicate();
			// Select all text
			//stored_range.moveToElementText( this );
			stored_range.expand('textedit');
			// Now move 'dummy' end point to end point of original range
			stored_range.setEndPoint( 'EndToEnd', range );
			// Now we can calculate start and end points
			selectionStart = stored_range.text.length - range.text.length;
			selectionEnd = selectionStart + range.text.length;
			return part == 'Start' ? selectionStart : selectionEnd;
		}
		
		else if(typeof(this['selection'+part])!="undefined")
		{
		 	pos = this['selection'+part];
		}
		return pos;
	}
	
	/**
	 * Substitutions for keydown keycodes.
	 * Allows conversion from e.which to ascii characters.
	 */
	var _keydown = {
		codes : {
			188 : 44,
			109 : 45,
			190 : 46,
			191 : 47,
			192 : 96,
			220 : 92,
			222 : 39,
			221 : 93,
			219 : 91,
			173 : 45,
			187 : 61, //IE Key codes
			186 : 59, //IE Key codes
			189 : 45, //IE Key codes
			110 : 46  //IE Key codes
        },
        shifts : {
			96 : "~",
			49 : "!",
			50 : "@",
			51 : "#",
			52 : "$",
			53 : "%",
			54 : "^",
			55 : "&",
			56 : "*",
			57 : "(",
			48 : ")",
			45 : "_",
			61 : "+",
			91 : "{",
			93 : "}",
			92 : "|",
			59 : ":",
			39 : "\"",
			44 : "<",
			46 : ">",
			47 : "?"
        }
    };
	
	/**
	 * jQuery number formatter plugin. This will allow you to format numbers on an element.
	 *
	 * @params proxied for format_number method.
	 *
	 * @return : The jQuery collection the method was called with.
	 */
	$.fn.number = function( number, decimals, dec_point, thousands_sep ){
	    
	    // Enter the default thousands separator, and the decimal placeholder.
	    thousands_sep	= (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
	    dec_point		= (typeof dec_point === 'undefined') ? '.' : dec_point;
	    decimals		= (typeof decimals === 'undefined' ) ? 0 : decimals;
	    	    
	    // Work out the unicode character for the decimal placeholder.
	    var u_dec			= ('\\u'+('0000'+(dec_point.charCodeAt(0).toString(16))).slice(-4)),
	    	regex_dec_num	= new RegExp('[^'+u_dec+'0-9]','g'),
	    	regex_dec		= new RegExp(u_dec,'g');
	    
	    // If we've specified to take the number from the target element,
	    // we loop over the collection, and get the number.
	    if( number === true )
	    {
	    	// If this element is a number, then we add a keyup
	    	if( this.is('input:text') )
	    	{
	    		// Return the jquery collection.
	    		return this.on({
	    			
	    			/**
	    			 * Handles keyup events, re-formatting numbers.
	    			 *
	    			 * @param object e			: the keyup event object.s
	    			 *
	    			 * @return void;
	    			 */
	    			'keydown.format' : function(e){
	    				
	    				// Define variables used in the code below.
	    				var $this	= $(this),
	    					data	= $this.data('numFormat'),
	    					code	= (e.keyCode ? e.keyCode : e.which),
							chara	= '', //unescape(e.originalEvent.keyIdentifier.replace('U+','%u')),
	    					start	= getSelection.apply(this,['start']),
	    					end		= getSelection.apply(this,['end']),
	    					val		= '',
	    					setPos	= false;
	    				
	    				// Webkit (Chrome & Safari) on windows screws up the keyIdentifier detection
	    				// for numpad characters. I've disabled this for now, because while keyCode munging
	    				// below is hackish and ugly, it actually works cross browser & platform.
	    				
//	    				if( typeof e.originalEvent.keyIdentifier !== 'undefined' )
//	    				{
//	    					chara = unescape(e.originalEvent.keyIdentifier.replace('U+','%u'));
//	    				}
//	    				else
//	    				{
	    					if (_keydown.codes.hasOwnProperty(code)) {
					            code = _keydown.codes[code];
					        }
					        if (!e.shiftKey && (code >= 65 && code <= 90)){
					        	code += 32;
					        } else if (!e.shiftKey && (code >= 69 && code <= 105)){
					        	code -= 48;
					        } else if (e.shiftKey && _keydown.shifts.hasOwnProperty(code)){
					            //get shifted keyCode value
					            chara = _keydown.shifts[code];
					        }
					        
					        if( chara == '' ) chara = String.fromCharCode(code);
//	    				}
						

			
	    				
	    				// Stop executing if the user didn't type a number key, a decimal character, or backspace.
	    				if( code !== 8 && chara != dec_point && !chara.match(/[0-9]/) )
	    				{
	    					// We need the original keycode now...
	    					var key = (e.keyCode ? e.keyCode : e.which);
	    					if( // Allow control keys to go through... (delete, etc)
	    						key == 46 || key == 8 || key == 9 || key == 27 || key == 13 || 
	    						// Allow: Ctrl+A, Ctrl+R
	    						( (key == 65 || key == 82 ) && ( e.ctrlKey || e.metaKey ) === true ) || 
	    						// Allow: Ctrl+V, Ctrl+C
	    						( (key == 86 || key == 67 ) && ( e.ctrlKey || e.metaKey ) === true ) || 
	    						// Allow: home, end, left, right
	    						( (key >= 35 && key <= 39) )
							){
								return;
							}
							// But prevent all other keys.
							e.preventDefault();
							return false;
	    				}
	    				
	    				// The whole lot has been selected, or if the field is empty...
	    				if( start == 0 && end == this.value.length || $this.val() == 0 )
	    				{
	    					if( code === 8 )
	    					{
		    					// Blank out the field, but only if the data object has already been instanciated.
	    						start = end = 1;
	    						this.value = '';
	    						
	    						// Reset the cursor position.
		    					data.init = (decimals>0?-1:0);
		    					data.c = (decimals>0?-(decimals+1):0);
		    					setSelectionRange.apply(this, [0,0]);
		    				}
		    				else if( chara === dec_point )
		    				{
		    					start = end = 1;
		    					this.value = '0'+ dec_point + (new Array(decimals+1).join('0'));
		    					
		    					// Reset the cursor position.
		    					data.init = (decimals>0?1:0);
		    					data.c = (decimals>0?-(decimals+1):0);
		    				}
		    				else if( this.value.length === 0 )
		    				{
		    					// Reset the cursor position.
		    					data.init = (decimals>0?-1:0);
		    					data.c = (decimals>0?-(decimals):0);
		    				}
	    				}
	    				
	    				// Otherwise, we need to reset the caret position
	    				// based on the users selection.
	    				else
	    				{
	    					data.c = end-this.value.length;
	    				}
	    				
	    				// If the start position is before the decimal point,
	    				// and the user has typed a decimal point, we need to move the caret
	    				// past the decimal place.
	    				if( decimals > 0 && chara == dec_point && start == this.value.length-decimals-1 )
	    				{
	    					data.c++;
	    					data.init = Math.max(0,data.init);
	    					e.preventDefault();
	    					
	    					// Set the selection position.
	    					setPos = this.value.length+data.c;
	    				}
	    				
	    				// If the user is just typing the decimal place,
	    				// we simply ignore it.
	    				else if( chara == dec_point )
	    				{
	    					data.init = Math.max(0,data.init);
	    					e.preventDefault();
	    				}
	    				
	    				// If hitting the delete key, and the cursor is behind a decimal place,
	    				// we simply move the cursor to the other side of the decimal place.
	    				else if( decimals > 0 && code == 8 && start == this.value.length-decimals )
	    				{
	    					e.preventDefault();
	    					data.c--;
	    					
	    					// Set the selection position.
	    					setPos = this.value.length+data.c;
	    				}
	    				
	    				// If hitting the delete key, and the cursor is to the right of the decimal
	    				// (but not directly to the right) we replace the character preceeding the
	    				// caret with a 0.
	    				else if( decimals > 0 && code == 8 && start > this.value.length-decimals )
	    				{
	    					if( this.value === '' ) return;
	    					
	    					// If the character preceeding is not already a 0,
	    					// replace it with one.
	    					if( this.value.slice(start-1, start) != '0' )
	    					{
	    						val = this.value.slice(0, start-1) + '0' + this.value.slice(start);
	    						$this.val(val.replace(regex_dec_num,'').replace(regex_dec,dec_point));
	    					}
	    					
	    					e.preventDefault();
	    					data.c--;
	    					
	    					// Set the selection position.
	    					setPos = this.value.length+data.c;
	    				}
	    				
	    				// If the delete key was pressed, and the character immediately
	    				// before the caret is a thousands_separator character, simply
	    				// step over it.
	    				else if( code == 8 && this.value.slice(start-1, start) == thousands_sep )
	    				{
	    					e.preventDefault();
	    					data.c--;
	    					
	    					// Set the selection position.
	    					setPos = this.value.length+data.c;
	    				}
	    				
	    				// If the caret is to the right of the decimal place, and the user is entering a
	    				// number, remove the following character before putting in the new one. 
	    				else if(
	    					decimals > 0 &&
	    					start == end &&
	    					this.value.length > decimals+1 &&
	    					start > this.value.length-decimals-1 && isFinite(+chara) &&
		    				!e.metaKey && !e.ctrlKey && !e.altKey && chara.length === 1
	    				)
	    				{
	    					// If the character preceeding is not already a 0,
	    					// replace it with one.
	    					if( end === this.value.length )
	    					{
	    						val = this.value.slice(0, start-1);
	    					}
	    					else
	    					{
	    						val = this.value.slice(0, start)+this.value.slice(start+1);
	    					}
	    					
	    					// Reset the position.
	    					this.value = val;
	    					setPos = start;
	    				}
	    				
	    				// If we need to re-position the characters.
	    				if( setPos !== false )
	    				{
	    					//console.log('Setpos keydown: ', setPos );
	    					setSelectionRange.apply(this, [setPos, setPos]);
	    				}
	    				
	    				// Store the data on the element.
	    				$this.data('numFormat', data);
	    				
	    			},
	    			
	    			/**
	    			 * Handles keyup events, re-formatting numbers.
	    			 *
	    			 * @param object e			: the keyup event object.s
	    			 *
	    			 * @return void;
	    			 */
	    			'keyup.format' : function(e){
	    				
	    				// Store these variables for use below.
	    				var $this	= $(this),
	    					data	= $this.data('numFormat'),
	    					code	= (e.keyCode ? e.keyCode : e.which),
	    					start	= getSelection.apply(this,['start']),
	    					setPos;
	    				    				    			
	    				// Stop executing if the user didn't type a number key, a decimal, or a comma.
	    				if( this.value === '' || (code < 48 || code > 57) && (code < 96 || code > 105 ) && code !== 8 ) return;
	    				
	    				// Re-format the textarea.
	    				$this.val($this.val());

	    				if( decimals > 0 )
	    				{
		    				// If we haven't marked this item as 'initialised'
		    				// then do so now. It means we should place the caret just 
		    				// before the decimal. This will never be un-initialised before
		    				// the decimal character itself is entered.
		    				if( data.init < 1 )
		    				{
		    					start		= this.value.length-decimals-( data.init < 0 ? 1 : 0 );
		    					data.c		= start-this.value.length;
		    					data.init	= 1;
		    					
		    					$this.data('numFormat', data);
		    				}
		    				
		    				// Increase the cursor position if the caret is to the right
		    				// of the decimal place, and the character pressed isn't the delete key.
		    				else if( start > this.value.length-decimals && code != 8 )
		    				{
		    					data.c++;
		    					
		    					// Store the data, now that it's changed.
		    					$this.data('numFormat', data);
		    				}
	    				}
	    				
	    				//console.log( 'Setting pos: ', start, decimals, this.value.length + data.c, this.value.length, data.c );
	    				
	    				// Set the selection position.
	    				setPos = this.value.length+data.c;
	    				setSelectionRange.apply(this, [setPos, setPos]);
	    			},
	    			
	    			/**
	    			 * Reformat when pasting into the field.
	    			 *
	    			 * @param object e 		: jQuery event object.
	    			 *
	    			 * @return false : prevent default action.
	    			 */
	    			'paste.format' : function(e){
	    				
	    				// Defint $this. It's used twice!.
	    				var $this		= $(this),
	    					original	= e.originalEvent,
	    					val		= null;
						
						// Get the text content stream.
						if (window.clipboardData && window.clipboardData.getData) { // IE
							val = window.clipboardData.getData('Text');
						} else if (original.clipboardData && original.clipboardData.getData) {
							val = original.clipboardData.getData('text/plain');
						}
						
	    				// Do the reformat operation.
	    				$this.val(val);
	    				
	    				// Stop the actual content from being pasted.
	    				e.preventDefault();
	    				return false;
	    			}
	    		
	    		})
	    		
	    		// Loop each element (which isn't blank) and do the format.
    			.each(function(){
    			
    				var $this = $(this).data('numFormat',{
    					c				: -(decimals+1),
    					decimals		: decimals,
    					thousands_sep	: thousands_sep,
    					dec_point		: dec_point,
    					regex_dec_num	: regex_dec_num,
    					regex_dec		: regex_dec,
    					init			: false
    				});
    				
    				// Return if the element is empty.
    				if( this.value === '' ) return;
    				
    				// Otherwise... format!!
    				$this.val($this.val());
    			});
	    	}
	    	else
	    	{
		    	// return the collection.
		    	return this.each(function(){
		    		var $this = $(this), num = +$this.text().replace(regex_dec_num,'').replace(regex_dec,'.');
		    		$this.number( !isFinite(num) ? 0 : +num, decimals, dec_point, thousands_sep );
		    	});
	    	}
	    }
	    
	    // Add this number to the element as text.
	    return this.text( $.number.apply(window,arguments) );
	};
	
	//
	// Create .val() hooks to get and set formatted numbers in inputs.
	//
	
	// We check if any hooks already exist, and cache
	// them in case we need to re-use them later on.
	var origHookGet = null, origHookSet = null;
	 
	// Check if a text valHook already exists.
	if( $.isPlainObject( $.valHooks.text ) )
	{
	    // Preserve the original valhook function
	    // we'll call this for values we're not 
	    // explicitly handling.
	    if( $.isFunction( $.valHooks.text.get ) ) origHookGet = $.valHooks.text.get;
	    if( $.isFunction( $.valHooks.text.set ) ) origHookSet = $.valHooks.text.set;
	}
	else
	{
	    // Define an object for the new valhook.
	    $.valHooks.text = {};
	} 
	
	/**
	 * Define the valHook to return normalised field data against an input
	 * which has been tagged by the number formatter.
	 *
	 * @param object el			: The raw DOM element that we're getting the value from.
	 *
	 * @return mixed : Returns the value that was written to the element as a
	 *				   javascript number, or undefined to let jQuery handle it normally.
	 */
	$.valHooks.text.get = function( el ){
		
		// Get the element, and its data.
		var $this	= $(el), num,
			data	= $this.data('numFormat');
		
        // Does this element have our data field?
        if( !data )
        {
            // Check if the valhook function already existed
            if( $.isFunction( origHookGet ) )
            {
                // There was, so go ahead and call it
                return origHookGet(el);
            }
            else
            {
                // No previous function, return undefined to have jQuery
                // take care of retrieving the value
                return undefined;
			}
		}
		else
		{			
			// Remove formatting, and return as number.
			if( el.value === '' ) return '';
			
			// Convert to a number.
			num = +(el.value
				.replace( data.regex_dec_num, '' )
				.replace( data.regex_dec, '.' ));
		
			// If we've got a finite number, return it.
			// Otherwise, simply return 0.
			// Return as a string... thats what we're
			// used to with .val()
			return ''+( isFinite( num ) ? num : 0 );
		}
	};
	
	/**
	 * A valhook which formats a number when run against an input
	 * which has been tagged by the number formatter.
	 *
	 * @param object el		: The raw DOM element (input element).
	 * @param float			: The number to set into the value field.
	 *
	 * @return mixed : Returns the value that was written to the element,
	 *				   or undefined to let jQuery handle it normally. 
	 */
	$.valHooks.text.set = function( el, val )
	{
		// Get the element, and its data.
		var $this	= $(el),
			data	= $this.data('numFormat');
		
		// Does this element have our data field?
		if( !data )
		{
		    
		    // Check if the valhook function already exists
		    if( $.isFunction( origHookSet ) )
		    {
		        // There was, so go ahead and call it
		        return origHookSet(el,val);
		    }
		    else
		    {
		        // No previous function, return undefined to have jQuery
		        // take care of retrieving the value
		        return undefined;
			}
		}
		else
		{
			// Otherwise, don't worry about other valhooks, just run ours.
			return el.value = $.number( val, data.decimals, data.dec_point, data.thousands_sep );
		}
	};
	
	/**
	 * The (modified) excellent number formatting method from PHPJS.org.
	 * http://phpjs.org/functions/number_format/
	 *
	 * @modified by Sam Sehnert (teamdf.com)
	 *	- don't redefine dec_point, thousands_sep... just overwrite with defaults.
	 *	- don't redefine decimals, just overwrite as numeric.
	 *	- Generate regex for normalizing pre-formatted numbers.
	 *
	 * @param float number			: The number you wish to format, or TRUE to use the text contents
	 *								  of the element as the number. Please note that this won't work for
	 *								  elements which have child nodes with text content.
	 * @param int decimals			: The number of decimal places that should be displayed. Defaults to 0.
	 * @param string dec_point		: The character to use as a decimal point. Defaults to '.'.
	 * @param string thousands_sep	: The character to use as a thousands separator. Defaults to ','.
	 *
	 * @return string : The formatted number as a string.
	 */
	$.number = function( number, decimals, dec_point, thousands_sep ){
		// Set the default values here, instead so we can use them in the replace below.
		thousands_sep	= (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
		dec_point		= (typeof dec_point === 'undefined') ? '.' : dec_point;
		decimals		= !isFinite(+decimals) ? 0 : Math.abs(decimals);
		
		// Work out the unicode representation for the decimal place and thousand sep.	
		var u_dec = ('\\u'+('0000'+(dec_point.charCodeAt(0).toString(16))).slice(-4));
		var u_sep = ('\\u'+('0000'+(thousands_sep.charCodeAt(0).toString(16))).slice(-4));
		
		// Fix the number, so that it's an actual number.
		number = (number + '')
			.replace('\.', dec_point) // because the number if passed in as a float (having . as decimal point per definition) we need to replace this with the passed in decimal point character
			.replace(new RegExp(u_sep,'g'),'')
			.replace(new RegExp(u_dec,'g'),'.')
			.replace(new RegExp('[^0-9+\-Ee.]','g'),'');
		
		var n = !isFinite(+number) ? 0 : +number,
		    s = '',
		    toFixedFix = function (n, decimals) {
		        var k = Math.pow(10, decimals);
		        return '' + Math.round(n * k) / k;
		    };
		
		// Fix for IE parseFloat(0.55).toFixed(0) = 0;
		s = (decimals ? toFixedFix(n, decimals) : '' + Math.round(n)).split('.');
		if (s[0].length > 3) {
		    s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, thousands_sep);
		}
		if ((s[1] || '').length < decimals) {
		    s[1] = s[1] || '';
		    s[1] += new Array(decimals - s[1].length + 1).join('0');
		}
		return s.join(dec_point);
	}
	
})(cbsjq);
(function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
var Application = (function (app, document) {

    this.scope = this;

    /*
     *  An easy-to-use library for eliminating the 300ms delay between a physical 
     *  tap and the firing of a click event on mobile browsers.
    */
    FastClick.attach(document.body);


    /**
     *  Initializes application
     *  @private
     */
    app.applicationInit = function () {
        try {
            app.initializeMobileMenu();
            app.initializeDesktopMenu();
        }
        catch (err) {
            //alert(err.message);
        }
    }

    /**
     *  Initializes Mobile and Tablet nevigation
     *  @private
     */
    app.initializeDesktopMenu = function () {
        cbsjq(".nav-items .item >a").click(function (e) {
            if (e.target.tagName == "A") {
                return;
            }
            if (!cbsjq(this).parent().find('ul').length) return;

            cbsjq(".nav-items .item").find('ul').removeClass("active");

            if (cbsjq(this).parent().hasClass("selected")) {
                cbsjq(this).parent().toggleClass("selected");
                cbsjq(this).children('span').removeClass("downcarat");
                cbsjq(this).parent().children('ul').toggleClass("");
                cbsjq(this).parent().children('a').attr('aria-expanded', 'false');
            } else {
                cbsjq(this).parent().siblings().removeClass("selected");
                cbsjq(this).children('span').addClass("downcarat");
                cbsjq(this).parent().toggleClass("selected");
                cbsjq(this).parent().children('ul').toggleClass("active");
                cbsjq(this).parent().children('a').attr('aria-expanded', 'true');
            }
        });

        cbsjq(".nav-items .item").each(function () {
            if (cbsjq(this).hasClass("selected")) {
                cbsjq(this).children('ul').toggleClass("active");
            }
        });

        // Left navigation functionality        
        cbsjq('.desktop-menu .desktop-navigation .nav-items >li a').each(function () {
            if (!(cbsjq(this).parent().has("ul").length)) {
                cbsjq(this).addClass('no-caret');
            }
        });
    }

    /**
     *  Initializes Mobile and Tablet nevigation
     *  @private
     */
    app.initializeMobileMenu = function () {

        var slideout = new Slideout({
            'panel': document.getElementById('main'),
            'menu': document.getElementById('menu'),
            'padding': 268,
            'tolerance': 70,
            'side': 'right'
        });

        //ssb
        cbsjq(document).ready(function () {


            cbsjq(document).click(function (o) {
                try {
                    var queryparams = window.location.href.substring(window.location.href.lastIndexOf('/') + 1).split("?")[1];
                    if (queryparams && queryparams.indexOf("speedbump") >= 0) {
                        window.history.pushState("object or string", "Title", "/" + window.location.href.substring(window.location.href.lastIndexOf('/') + 1).split("?")[0]);
                    }
                } catch (err) { }
                if (cbsjq('.mobile-headercontainer').is(':visible')) {
                    var btn = cbsjq(this).find('.js-slideout-toggle');
                    var iconbar = cbsjq(this).find('.icon-bar');
                    var menu = cbsjq(this).find('.slideout-menu');
                    var iconcross = cbsjq(this).find('.icon-cross');
                    var slidetog = cbsjq('.js-slideout-toggle')[0];
                    if (o.target == slidetog || o.target == iconbar[0] || o.target == iconbar[1] || o.target == iconbar[2] || o.target == iconcross[0]) {

                        cbsjq('.js-slideout-toggle').toggleClass('active');
                        if (cbsjq('.js-slideout-toggle').hasClass('active')) {
                            cbsjq('.js-slideout-toggle').attr('aria-expanded', 'true');
                            //cbsjq('#menu.slideout-menu .menu-section ul > li:first a').focus().blur();
                            cbsjq('#menu.slideout-menu .menu-section ul > li:first a').focus();
                        } else {
                            cbsjq('.js-slideout-toggle').attr('aria-expanded', 'false');
                        }

                        var jQmenu = cbsjq('#menu');
                        if (cbsjq('.js-slideout-toggle').hasClass('open')) {
                            cbsjq('.js-slideout-toggle').removeClass('open');
                            cbsjq('.slideout-menu').hide();
                            //cbsjq('#main').attr('aria-hidden', 'false');

                            cbsjq('.hero-outer-container').attr('aria-hidden', 'false');
                            cbsjq('.container').attr('aria-hidden', 'false');
                            cbsjq('.userdetail').attr('aria-hidden', 'true');
                            cbsjq('footer').attr('aria-hidden', 'false');
                            cbsjq('.mobile-logo-container').attr('aria-hidden', 'false');
                            cbsjq('.nav-sign-on-button').attr('aria-hidden', 'false');
                            cbsjq('.skip-main').attr('aria-hidden', 'false');
                            //cbsjq('.desktop-headercontainer').attr('aria-hidden', 'false');

                            jQmenu.attr('aria-expanded', 'false');

                            jQmenu.animate({ left: -320 }, 'slow', function () {
                                //cbsjq('.js-slideout-toggle').removeClass('open');
                                //cbsjq('.slideout-menu').hide();
                                cbsjq('.js-slideout-toggle').html('<span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>');
                                cbsjq('.js-slideout-toggle').attr('aria-label', 'menu');
                            });
                        }
                        else {
                            cbsjq('.slideout-menu').show();
                            //cbsjq('#main').attr('aria-hidden', 'true');

                            //COMMENTED OUT FOR HAMBURGER FIX ( and moved inside animation)
                            //cbsjq('.hero-outer-container').attr('aria-hidden', 'true');
                            //cbsjq('.container').attr('aria-hidden', 'true');
                            //cbsjq('.userdetail').attr('aria-hidden', 'true');
                            //cbsjq('footer').attr('aria-hidden', 'true');
                            //cbsjq('.mobile-logo-container').attr('aria-hidden', 'true');
                            //cbsjq('.nav-sign-on-button').attr('aria-hidden', 'true');

                            cbsjq('#menu').attr('aria-expanded', 'true');
                            //cbsjq('#menu.slideout-menu .menu-section ul > li:first a').focus().blur();
                            cbsjq('#menu.slideout-menu .menu-section ul > li:first a').focus();

                            cbsjq('#menu').animate({ left: 0 }, 'slow', function () {
                                cbsjq('.js-slideout-toggle').addClass('open');
                                cbsjq('.js-slideout-toggle').html('<span class="icon-cross"></span>');
                                cbsjq('.js-slideout-toggle').attr('aria-label', 'close menu');
                                //MOVED HERE FROM ABOVE
                                cbsjq('.hero-outer-container').attr('aria-hidden', 'true');
                                cbsjq('.container').attr('aria-hidden', 'true');
                                cbsjq('.userdetail').attr('aria-hidden', 'true');
                                cbsjq('footer').attr('aria-hidden', 'true');
                                cbsjq('.mobile-logo-container').attr('aria-hidden', 'true');
                                cbsjq('.nav-sign-on-button').attr('aria-hidden', 'true');
                                cbsjq('.skip-main').attr('aria-hidden', 'true');
                                //cbsjq('.desktop-headercontainer').attr('aria-hidden', 'true');

                                //cbsjq('#menu.slideout-menu .menu-section ul > li:first a').focus().blur();
                                cbsjq('#menu.slideout-menu .menu-section ul > li:first a').focus();
                            });
                        }
                    } else if (o.target !== btn[0] && o.target !== menu[0] && (o.target !== iconbar[0] || o.target !== iconbar[1] || o.target !== iconbar[2])) {
                        var jQmenu = cbsjq('#menu');

                        cbsjq('.js-slideout-toggle').toggleClass('active');
                        if (cbsjq('.js-slideout-toggle').hasClass('active')) {
                            cbsjq('.js-slideout-toggle').attr('aria-expanded', 'true');
                        } else {
                            cbsjq('.js-slideout-toggle').attr('aria-expanded', 'false');
                        }

                        /*
                        cbsjq(this).toggleClass('active');
                        if (cbsjq(this).hasClass('active')) {
                            cbsjq(this).attr('aria-expanded', 'true');
                        } else {
                            cbsjq(this).attr('aria-expanded', 'false');
                        }*/

                        cbsjq('.js-slideout-toggle').removeClass('open');
                        cbsjq('.slideout-menu').hide();
                        cbsjq('#menu').attr('aria-expanded', 'false');
                        //cbsjq('#main').attr('aria-hidden', 'false');

                        //TO FIX HAMBURGER ADA ISSUE MOVED INSIDE ANIMATION
                        cbsjq('.hero-outer-container').attr('aria-hidden', 'false');
                        cbsjq('.container').attr('aria-hidden', 'false');
                        cbsjq('.userdetail').attr('aria-hidden', 'true');
                        cbsjq('footer').attr('aria-hidden', 'false');
                        cbsjq('.mobile-logo-container').attr('aria-hidden', 'false');
                        cbsjq('.nav-sign-on-button').attr('aria-hidden', 'false');
                        cbsjq('.skip-main').attr('aria-hidden', 'false');
                        //cbsjq('.desktop-headercontainer').attr('aria-hidden', 'false');

                        jQmenu.animate({ left: -320 }, 'slow', function () {
                            //cbsjq('.js-slideout-toggle').removeClass('open');
                            //cbsjq('.slideout-menu').hide();

                            //MOVED HERE
                            //cbsjq('.hero-outer-container').attr('aria-hidden', 'false');
                            //cbsjq('.container').attr('aria-hidden', 'false');
                            //cbsjq('.userdetail').attr('aria-hidden', 'false');
                            //cbsjq('footer').attr('aria-hidden', 'false');
                            //cbsjq('.mobile-logo-container').attr('aria-hidden', 'false');
                            //cbsjq('.nav-sign-on-button').attr('aria-hidden', 'false');
                            //cbsjq('.skip-main').attr('aria-hidden', 'false');


                            cbsjq('.js-slideout-toggle').html('<span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>');
                        });


                    }
                }//check for mobile header visibility

            })
        });


        document.querySelector('.menu').addEventListener('click', function (eve) {
            if (eve.target.nodeName === 'A') { slideout.close(); }
        });

        slideout.disableTouch();
        var menuResizeStatus = app.utils.debounce(function () {
            if (window.innerWidth > 979) {
                if (cbsjq('.slideout-menu').css('display') === "block") {
                    slideout.close();
                }
            }
        }, 250);

        window.addEventListener('resize', menuResizeStatus);
    }


    /**
     * Utilities
     */
    app.utils = {

        // Primitives check
        /* -------------------------------------------------------------------------- */

        isObj: function (obj) {
            return obj === Object(obj);
        },

        isNumber: function (num) {
            return !isNaN(parseFloat(num)) && isFinite(num);
        },

        // Key and touch event checks
        /* -------------------------------------------------------------------------- */
        hasTouch: function () {
            return 'ontouchstart' in document;
        },

        hasTouchWin: function () {
            return navigator.msMaxTouchPoints && navigator.msMaxTouchPoints > 1;
        },

        hasPointer: function () {
            return !!window.navigator.msPointerEnabled;
        },

        hasKeyDown: function () {
            return 'onkeydown' in document;
        },

        hasMouseDown: function () {
            return 'onclick' in document;
        },

        // Arithmetic checks
        /* -------------------------------------------------------------------------- */
        random: function () {
            return Math.random();
        },

        // Array utils
        /* -------------------------------------------------------------------------- */
        is_arr: function (arr) {
            return typeof (arr) == 'object' && (arr instanceof Array);
        },

        emptyArray: function (arr) {
            for (var i = arr.length; i > 0; i--) {
                arr.pop();
            }

            arr.length = 0;
        },

        shuffle: function (array) {
            var arrLength = array.length;

            for (var i = 0; i < arrLength; i++) {
                var random = arrLength * this.random() | 0;

                if (random == i) { continue; }

                var newArrElement = array[random];
                array[random] = array[i];
                array[i] = newArrElement;
            }

            return array;
        },

        // String utils
        /* -------------------------------------------------------------------------- */
        capitaliseFirst: function (string) {
            return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
        },

        // Timer utils
        /* -------------------------------------------------------------------------- */

        debounce: function (func, wait, immediate) {
            var timeout;

            return function () {
                var context = this, args = arguments;

                var later = function () {
                    timeout = null;
                    if (!immediate) func.apply(context, args);
                };

                var callNow = immediate && !timeout;
                clearTimeout(timeout);
                timeout = setTimeout(later, wait);

                if (callNow) func.apply(context, args);
            };
        }
    }
    /**
     * Public API
     */

    // functions for setting arrow positions
    cbsjq(function () {
        cbsjq('.accordion-group .accordion-body').on('show.bs.collapse', function () {
            cbsjq(this).parent().find('.accordion-heading').css('background-position', 'right -155px, 0px 0px');
        });
        cbsjq('.accordion-group .accordion-body').on('hidden.bs.collapse', function () {
            cbsjq(this).parent().find('.accordion-heading').css('background-position', 'right -3px, 0px 0px');
        });

        cbsjq('.benefits-details-content .accordion-group  .accordion-body').on('show.bs.collapse', function () {
            cbsjq(this).parent().find('.menu-carret-icon').css('background-position', '0 4px ');
            cbsjq(this).parents('.benefits-details-content').css('background-color', '#f7f7f7');
        });
        cbsjq('.benefits-details-content .accordion-group .accordion-body').on('hidden.bs.collapse', function () {
            cbsjq(this).parent().find('.menu-carret-icon').css('background-position', '0 -30px ');
            cbsjq(this).parents('.benefits-details-content').css('background-color', '#fff');
        });
        cbsjq('.score-lenders-container .accordion-group  .accordion-body').on('show.bs.collapse', function () {
            cbsjq(this).parent().find('.accordion-heading').css('background-position', 'right -155px, 0px 0px');

        });
        cbsjq('.score-lenders-container .accordion-group .accordion-body').on('hidden.bs.collapse', function () {
            cbsjq(this).parent().find('.accordion-heading').css('background-position', 'right -3px, 0px 0px');
        });
        cbsjq('.gray-accordion-heading .accordion-group  .accordion-body').on('show.bs.collapse', function () {
            cbsjq(this).parent().find('.accordion-heading').css('background-position', 'right 12px top -100px ');

        });
        cbsjq('.gray-accordion-heading .accordion-group .accordion-body').on('hidden.bs.collapse', function () {
            cbsjq(this).parent().find('.accordion-heading').css('background-position', 'right 12px top 20px ');
        });

        cbsjq('.prestige .collapse.in').prev('.panel-heading').addClass('active');
        cbsjq('.prestige #accordion, #bs-collapse')
        .on('show.bs.collapse', function (a) {
            cbsjq(a.target).prev('.panel-heading').addClass('active');
        })
        .on('hide.bs.collapse', function (a) {
            cbsjq(a.target).prev('.panel-heading').removeClass('active');
        });
        cbsjq(".prestige .toggle-arrow").click(function (e) {
            e.preventDefault();
            cbsjq(".toggle-arrow").not(cbsjq(this)).removeClass("active");
            cbsjq(this).toggleClass("active");
        });

    });

    cbsjq(function () {
        // Add class js-load-more-items to card val prop section if body has citi brand class
        if ((document.body).className.match('citi')) {
            if (cbsjq('.val-prop-bottom-more-section').length > 0) {
                cbsjq('.val-prop-bottom-more-section').addClass('js-load-more-items').removeClass('js-set-columns-equal');
            }
            else if (cbsjq('.card-val-prop-section').length > 0) {
                cbsjq('.card-val-prop-section').addClass('js-load-more-items').removeClass('js-set-columns-equal');
            }
        }

        // Open CVP load more if anchor exists
        cbsjq('.val-prop-bottom-description a').click(function (e) {
            var href = cbsjq(this).attr('href');
            var firstChar = href.substring(0, 1);

            if (firstChar == '#' && (href.length)) {
                var jqElements = cbsjq('.js-load-more-items .val-prop-bottom-section .js-load-more,.js-load-more-items .val-prop-bottom-section .load-more,.js-load-more-items.val-prop-bottom-more-section .load-more');
                cbsjq('.js-load-more-items .val-prop-bottom ul li').show();
                cbsjq('.js-load-more-items .val-prop-bottom-more-items>li').show();
                jqElements.addClass('active');
                jqElements.find('.show-all').css('background-position', '0px -53px ');
                jqElements.find('.show-all').attr('title', 'Opened');
                jqElements.find('.show-all-anchor').text('Show less card benefits');
                if ((document.body).className.match('diamond')) {
                    jqElements.find('.show-all-anchor').text("Show Fewer of Your Card's Key Features");
                    cbsjq(this).attr('aria-label', "Show Fewer of Your Card's Key Features");
                    cbsjq(this).attr('aria-expanded', 'true');
                }
            }

        });

        cbsjq('#closesf').click(function (e) {
            cbsjq('.stickyfooter').css({ "position": "relative" });
            cbsjq('.stickyfooter').addClass('sticky100');
            cbsjq('#closesf').css("display", "none");
            //ensighten
            window.citiData.custLink = "closeStickyFooter|" + cbsjq(this).attr('data-campaign');
            Bootstrapper.ensEvent.trigger("CardBenefitsCustomLink");
        }); 
        cbsjq('.stickyfooter a.sf-button').click(function (e) {
            trackOfferCatalogClick(cbsjq(this).prop('href'), "SF", cbsjq(this).attr('data-uuid'), "1");
            //ensighten
            window.citiData.custLink = cbsjq(this).attr('href');
            Bootstrapper.ensEvent.trigger("CardBenefitsCustomLink");
        });


        // CVP Load first three li on page load
        if (cbsjq('.js-load-more-items .load-more').length != 0) {
            cbsjq('.js-load-more-items .val-prop-bottom ul li').hide();
            cbsjq('.js-load-more-items .val-prop-bottom-more-items>li').hide();
            cbsjq('.js-load-more-items .val-prop-bottom ul li:lt(3)').show();
            cbsjq('.js-load-more-items .val-prop-bottom-more-items>li:lt(1)').show();
            var licount = cbsjq('.js-load-more-items .val-prop-bottom ul li').size();
            var morelicount = cbsjq('.js-load-more-items .val-prop-bottom-more-items>li').size();
            cbsjq('.js-load-more-items .val-prop-bottom-section .js-load-more,.js-load-more-items .val-prop-bottom-section .load-more,.js-load-more-items.val-prop-bottom-more-section .load-more').click(function (e) {
                if (!cbsjq(this).hasClass('active')) {
                    cbsjq(this).addClass('active');
                    cbsjq('.js-load-more-items .val-prop-bottom ul li:lt(' + licount + ')').slideDown("slow");
                    cbsjq('.js-load-more-items .val-prop-bottom-more-items>li:lt(' + morelicount + ')').slideDown("slow");
                    cbsjq(this).find('.show-all').css('background-position', '0px -53px ');
                    cbsjq(this).find('.show-all').attr('title', 'Opened');
                    cbsjq(this).find('.show-all-anchor').text('Show less card benefits');
                    if ((document.body).className.match('diamond')) {
                        cbsjq(this).find('.show-all-anchor').text("Show Fewer of Your Card's Key Features");
                        cbsjq(this).attr('aria-label', "Show Fewer of Your Card's Key Features");
                        cbsjq(this).attr('aria-expanded', 'true');
                    }
                }
                else {
                    cbsjq(this).removeClass('active');
                    cbsjq('.js-load-more-items .val-prop-bottom ul li').not(':lt(3)').slideUp();
                    cbsjq('.js-load-more-items .val-prop-bottom-more-items>li').not(':lt(1)').slideUp();
                    cbsjq(this).find('.show-all').css('background-position', '0px 0px ');
                    cbsjq(this).find('.show-all').attr('title', 'Closed');
                    cbsjq(this).find('.show-all-anchor').text('Show All card benefits');
                    if ((document.body).className.match('diamond')) {
                        cbsjq(this).find('.show-all-anchor').text("Show More of Your Card's Key Features");
                        cbsjq(this).attr('aria-label', "Show More of Your Card's Key Features");
                        cbsjq(this).attr('aria-expanded', 'false');
                    }
                }
                e.preventDefault();
            });
        }

        // FAQ Accordion - show all questions if less than 10
        if (cbsjq('.accordion-inner .faq-inner-container .faq-inner-accordion').size() > 10) {
            // Load more faq question
            cbsjq('.accordion-inner .faq-inner-container .faq-inner-accordion').hide();
            cbsjq('.accordion-inner .faq-inner-container .faq-inner-accordion:lt(5)').show();
            var faqcount = cbsjq('.accordion-inner .faq-inner-container .faq-inner-accordion').size();;
            cbsjq('.view-all-faq a').click(function (e) {
                if (!cbsjq(this).hasClass('active')) {
                    cbsjq(this).addClass('active');
                    cbsjq(this).attr('aria-expanded', 'true');
                    if (!cbsjq(this).hasClass('text-capitalize'))
                        cbsjq(this).addClass('text-capitalize');
                    cbsjq('.accordion-inner .faq-inner-container .faq-inner-accordion:lt(' + faqcount + ')').slideDown("slow");
                    cbsjq(this).parent().find('.view-all-faq-icon').css('background-position', '0px -50px ');
                    cbsjq(this).parent().parent().find('.view-all-faq a b').text('Close additional FAQs');
                    //cbsjq(this).parent().find('.view-all-faq-icon').attr('aria-expanded', 'true');
                    cbsjq(this).parent().parent().find('.view-all-faq a').attr('aria-label', 'Close additional FAQs');
                    cbsjq(this).parent().find('.view-all-faq-icon').attr('aria-label', 'Close additional FAQs');

                }
                else {
                    cbsjq(this).removeClass('active');
                    cbsjq(this).attr('aria-expanded', 'false');
                    if (!cbsjq(this).hasClass('text-capitalize'))
                        cbsjq(this).addClass('text-capitalize');
                    cbsjq('.accordion-inner .faq-inner-container .faq-inner-accordion').not(':lt(5)').slideUp();
                    cbsjq(this).parent().find('.view-all-faq-icon').css('background-position', '0px 0px ');
                    cbsjq(this).parent().find('.view-all-faq-icon').attr('aria-label', 'View All Frequently Asked Questions above');
                    cbsjq(this).parent().parent().find('.view-all-faq a b').text('View All Frequently Asked Questions');
                    cbsjq(this).parent().parent().find('.view-all-faq a').attr('aria-label', 'View All Frequently Asked Questions above');
                    //cbsjq(this).parent().find('.view-all-faq-icon').attr('aria-expanded', 'false');
                }
                e.preventDefault();
            });
            cbsjq('.view-all-faq-icon').click(function (e) {
                if (!cbsjq(this).hasClass('active')) {
                    cbsjq(this).addClass('active');
                    cbsjq(this).attr('aria-expanded', 'true');
                    if (!cbsjq(this).hasClass('text-capitalize'))
                        cbsjq(this).addClass('text-capitalize');
                    cbsjq('.accordion-inner .faq-inner-container .faq-inner-accordion:lt(' + faqcount + ')').slideDown("slow");
                    cbsjq(this).parent().find('.view-all-faq-icon').css('background-position', '0px -50px ');
                    cbsjq(this).parent().parent().find('.view-all-faq a b').text('Close additional FAQs');
                    cbsjq(this).parent().parent().find('.view-all-faq a').attr('aria-expanded', 'true');
                }
                else {
                    cbsjq(this).removeClass('active');
                    cbsjq(this).attr('aria-expanded', 'false');
                    if (!cbsjq(this).hasClass('text-capitalize'))
                        cbsjq(this).addClass('text-capitalize');
                    cbsjq('.accordion-inner .faq-inner-container .faq-inner-accordion').not(':lt(5)').slideUp();
                    cbsjq(this).parent().find('.view-all-faq-icon').css('background-position', '0px 0px ');
                    cbsjq(this).parent().parent().find('.view-all-faq a b').text('View All Frequently Asked Questions');
                    cbsjq(this).parent().parent().find('.view-all-faq a').attr('aria-label', 'View All Frequently Asked Questions above');
                    cbsjq(this).parent().find('.view-all-faq-icon a').attr('aria-label', 'View All Frequently Asked Questions above');
                    cbsjq(this).parent().parent().find('.view-all-faq a').attr('aria-expanded', 'false');
                }
                e.preventDefault();
            });
        } else {
            cbsjq('.view-all-faq').hide();
        }

        var innerAccordionFunctionality = function (selector) {
            cbsjq(selector).click(function (e) {
                e.preventDefault();
                if (!cbsjq(this).hasClass('active')) {
                    cbsjq(this).addClass('active');
                    cbsjq(this).parent().parent().addClass('active');
                    cbsjq(this).next('.accordion-content').stop().slideDown();
                    cbsjq(this).attr('aria-expanded', 'true');
                    cbsjq(this).parent().find('.menu-carret-icon').css('background-position', '0px 4px ');
                }
                else {
                    cbsjq(this).removeClass('active');
                    cbsjq(this).parent().parent().removeClass('active');
                    cbsjq(this).next('.accordion-content').stop().slideUp();
                    cbsjq(this).attr('aria-expanded', 'false');
                    cbsjq(this).parent().find('.menu-carret-icon').css('background-position', '0px -30px ');
                }
            });
        }

        // Inner accordion functionality for FicoFAQs and Benefits and Features inner accordions
        innerAccordionFunctionality('.faq-inner-accordion .faq-accordion-container a.toggle');
        innerAccordionFunctionality('.faq-inner-accordion .faq-accordion-container a.toggle1');
        innerAccordionFunctionality('.benefits-and-features-inner-accordion .benefits-and-features-accordion-container a.toggle');

        // Calculator show hide functionality
        cbsjq('.show-hide-calculator .show-hide-button').click(function (e) {
            if (!cbsjq(this).hasClass('active')) {
                cbsjq(this).addClass('active');

                cbsjq(this).parent().parent().find('.show-hide-sliders').stop().slideUp();
                if (cbsjq(this).parent().parent().hasClass('aaplatinum-calculator') || cbsjq(this).parent().parent().hasClass('aaexecutive-calculator'))
                    cbsjq(this).find('.button-content').text('Show Miles Calculator');
                else
                    cbsjq(this).find('.button-content').text('Show Points Calculator');
                if ((document.body).className.match('costco-consumer') || (document.body).className.match('costco-business')) {
                    cbsjq(this).find('.button-content').text('Open Costco Cash Rewards Calculator');
                };
                cbsjq(this).find('.arrow-image').css('background-position', '0px -30px ');
                cbsjq(this).attr('title', 'Closed');
                cbsjq(this).attr('aria-expanded', 'false');
                cbsjq(this).children('.arrow-image').attr('aria-label', 'Closed');
            }
            else {
                cbsjq(this).removeClass('active');
                cbsjq(this).parent().parent().find('.show-hide-sliders').stop().slideDown();
                if (cbsjq(this).parent().parent().hasClass('aaplatinum-calculator') || cbsjq(this).parent().parent().hasClass('aaexecutive-calculator'))
                    cbsjq(this).find('.button-content').text('Hide Miles Calculator');
                else
                    cbsjq(this).find('.button-content').text('Hide Points Calculator');
                if ((document.body).className.match('costco-consumer') || (document.body).className.match('costco-business')) {
                    cbsjq(this).find('.button-content').text('Hide Costco Cash Rewards Calculator');
                };
                cbsjq(this).find('.arrow-image').css('background-position', '0px 8px ');
                cbsjq(this).attr('title', 'Opened');
                cbsjq(this).attr('aria-expanded', 'true');
                cbsjq(this).children('.arrow-image').attr('aria-label', 'Opened');
            }
            e.preventDefault();
        });

        cbsjq('.view-all-btn').click(function (e) {
            cbsjq(this).siblings('.val-prop-bottom-more-container').slideToggle();
            if (!cbsjq(this).hasClass('active')) {
                cbsjq(this).addClass('active');
                cbsjq(this).find('.show-all').css('background-position', '0px -53px ');
                cbsjq(this).find('.show-all').attr('title', 'Opened');
                cbsjq(this).find('.show-all-anchor').text("Show Fewer of Your Card's Key Features");
                cbsjq(this).attr('aria-expanded', 'true');
            }
            else {
                cbsjq(this).removeClass('active');
                cbsjq(this).find('.show-all').css('background-position', '0px 0px ');
                cbsjq(this).find('.show-all').attr('title', 'Closed');
                cbsjq(this).find('.show-all-anchor').text("Show More of Your Card's Key Features");
                cbsjq(this).attr('aria-expanded', 'false');
            }
        });

        cbsjq('.nav-tabs .scorehistory h2').click(function () {
            if (cbsjq(this).parent().hasClass('non-active')) {
                cbsjq(this).parent().removeClass('non-active').addClass('active');
            }
            cbsjq('.nav-tabs .keyfactors').removeClass('active').addClass('non-active');
        });
        cbsjq('.nav-tabs .keyfactors h2').click(function () {
            if (cbsjq(this).parent().hasClass('non-active')) {
                cbsjq(this).parent().removeClass('non-active').addClass('active');
            }
            cbsjq('.nav-tabs .scorehistory').removeClass('active').addClass('non-active');
        });

        if (window.innerWidth < 620) {
            cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container a.toggle').click(function (e) {
                //cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container div.toggle').click(function (e) {
                e.preventDefault();
                if (!cbsjq(this).hasClass('active')) {
                    cbsjq(this).addClass('active');
                    cbsjq(this).attr('aria-expanded', 'true');
                    cbsjq(this).parent().find('.accordion-content').stop().slideDown();
                    cbsjq(this).parent().find('.score-lenders-menu-carret-icon').css('background-position', '0px -72px ');
                }
                else {
                    cbsjq(this).removeClass('active');
                    cbsjq(this).attr('aria-expanded', 'false');
                    cbsjq(this).parent().find('.accordion-content').stop().slideUp();
                    cbsjq(this).parent().find('.score-lenders-menu-carret-icon').css('background-position', '0px 0px ');
                }
            });
        }
        else {
            cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container a.toggle').click(function (e) {
                //cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container div.toggle').click(function (e) {
                e.preventDefault();
            });
        }
        if (window.innerWidth < 768) {
            cbsjq('#tabs-1').append(cbsjq('#tabs-2'));
            cbsjq('#tabs-2, #tabs-1').addClass('active in');
            setFicoGraphLines(6);
            cbsjq('.fico-line').show();
        }
        if (window.innerWidth > 619) {
            cbsjq('.key-factors-content .key-factors-container').append(cbsjq('.score-history-container'));
            cbsjq('#ScoreHistory').append(cbsjq('.key-factors-content .key-factors-container .key-factors-inner-container'));

            cbsjq('.Key-factors-main-container .scorehistory').click(function () {

                cbsjq('.key-factors-content > #ScoreHistory').removeClass('hidden-sm hidden-md hidden-lg');

                cbsjq('#ScoreHistory').addClass('active in');
                var height = cbsjq("#KeyFactors").height() + 19;
                cbsjq('.fico-line').remove();
                cbsjq('.lines-active').removeClass('lines-active');
                cbsjq('.fico-line').show();
                setFicoGraphLines(height);
            });

            cbsjq('.Key-factors-main-container .keyfactors').click(function () {

                cbsjq('.fico-line').hide();
            });
        }

    });

    // Back to top functionality
    cbsjq(function () {
        try {

            var $rightSection = cbsjq('.card-benefits');
            var endingRight = (cbsjq(window).width() - ($rightSection.offset().left + $rightSection.outerWidth()));
            cbsjq('.back-to-top').css('right', endingRight - 82);

            // Move Back to top button to left side if right margin too small
            if (endingRight < 100) {
                var endingLeft = (cbsjq(window).width() - $rightSection.offset().left);
                cbsjq('.back-to-top').hide();
                cbsjq(window).unbind('scroll');
            } else {
                var rightSectionPosition = $rightSection.position();

                cbsjq(window).scroll(function () {
                    var topPosition = 1000;
                    if (rightSectionPosition.top > 0) {
                        topPosition = rightSectionPosition.top;
                    }
                    if (cbsjq(this).scrollTop() > topPosition) {
                        cbsjq('.back-to-top').fadeIn();
                    } else {
                        cbsjq('.back-to-top').fadeOut();
                    }
                });
                cbsjq('.back-to-top a').click(function () {
                    cbsjq("html, body").animate({ scrollTop: 0 }, 600, function (e) { cbsjq('body').focus(); });
                    return false;
                });
                // set top for back to top based on footer
                var $footer = cbsjq('footer');
                var footerHeight = $footer.height() + parseInt($footer.css('padding-top')) + parseInt($footer.css('padding-bottom'));
                cbsjq('.back-to-top').css('bottom', footerHeight);

            }
        }
        catch (err) {

        }
    });

    // Card selector functionality
    cbsjq(function () {
        // For mobile
        cbsjq('.card-benefits .utility-preferred-card-cta').click(function (e) {
            e.preventDefault();
            if (cbsjq(this).parents('.utility-bar').find('.card-selector-container').length > 0) {

                if (cbsjq(this).hasClass('active')) {
                    cbsjq(this).removeClass('active');
                    cbsjq(this).parents('.utility-bar').find('.cross-icon-container').hide();
                    cbsjq(this).parents('.utility-bar').find('.card-selector-container').stop().slideUp();
                } else {
                    cbsjq(this).addClass('active');
                    cbsjq(this).parents('.utility-bar').find('.cross-icon-container').css('display', 'inline-block');
                    cbsjq(this).parents('.utility-bar').find('.card-selector-container').stop().slideDown();
                }
            }
        });

        cbsjq('.cross-icon-container.hidden-sm').click(function (e) {
            e.preventDefault();
            if (cbsjq(this).parent().find('.utility-preferred-card-header .utility-preferred-card-cta').hasClass('active')) {
                cbsjq(this).parent().find('.utility-preferred-card-header .utility-preferred-card-cta').removeClass('active');
            }
            cbsjq(this).parents('.utility-bar').find('.card-selector-container').slideUp();
            cbsjq(this).hide();
            cbsjq(this).parents('.utility-bar').find('.utility-preferred-card-header').css('border-right', 'none');
        });

        // For mobile
        cbsjq('.card-benefits .preferred-card-cta').click(function (e) {
            e.preventDefault();
            if (cbsjq(this).parents('.utility-menu-container').find('.card-selector-container').length > 0) {

                if (cbsjq(this).hasClass('active')) {
                    cbsjq(this).removeClass('active');
                    cbsjq(this).parents('.utility-menu-container').find('.cross-icon-container').hide();
                    cbsjq(this).parent().css('border-right', 'none');
                    cbsjq(this).parents('.utility-menu').removeClass('border');
                    cbsjq(this).parents('.utility-menu-container').find('.card-selector-container').stop().slideUp();
                } else {
                    cbsjq(this).addClass('active');
                    cbsjq(this).parents('.utility-menu-container').find('.cross-icon-container').css('display', 'inline-block');
                    cbsjq(this).parent().css('border-right', '1px solid #d8d8d8');
                    cbsjq(this).parents('.utility-menu').addClass('border');
                    cbsjq(this).parents('.utility-menu-container').find('.card-selector-container').stop().slideDown();
                }
            }
        });

        cbsjq('.cross-icon-container.hidden-sm').click(function (e) {
            e.preventDefault();
            if (cbsjq(this).parent().find('.preferred-card-header .preferred-card-cta').hasClass('active')) {
                cbsjq(this).parent().find('.preferred-card-header .preferred-card-cta').removeClass('active');
            }
            cbsjq(this).parents('.utility-menu-container').find('.card-selector-container').slideUp();
            cbsjq(this).hide();
            cbsjq(this).parents('.utility-menu-container').find('.preferred-card-header').css('border-right', 'none');
            cbsjq(this).parents('.utility-menu').removeClass('border');
        });

        // For desktop
        cbsjq('.card-benefits .view-card-container').click(function (e) {
            e.preventDefault();
            if (cbsjq(this).parent().parent().find('.card-selector-container').length > 0) {
                if (cbsjq(this).hasClass('active')) {
                    cbsjq(this).removeClass('active');
                    cbsjq(this).find('.cross-icon-container').hide();
                    cbsjq(this).find('.view-cards').show();
                    cbsjq(this).find('.view-cards a').focus();
                    cbsjq(this).parents('.utility-menu').removeClass('border');
                    cbsjq(this).parent().parent().find('.card-selector-container').stop().slideUp();
                } else {
                    cbsjq(this).addClass('active');
                    cbsjq(this).find('.view-cards').hide();
                    cbsjq(this).find('.cross-icon-container').show();
                    cbsjq(this).find('a.cross-icon').focus();
                    cbsjq(this).parents('.utility-menu').addClass('border');
                    cbsjq(this).parent().parent().find('.card-selector-container').stop().slideDown();
                }
            }
        });
    });


    // Benefit category functionality
    cbsjq(function () {
        if (cbsjq('.accordion-benefits-category').length > 0) {
            cbsjq('.accordion-benefits-category .accordion-group .card-feature-listing li').each(function () {
                if (cbsjq(this).find('.accordion-anchor').is(':visible')) {
                    cbsjq(this).find('.accordion-anchor').click(function () {
                        if (cbsjq(this).next('.secondary-val-prop-section').length > 0) {
                            cbsjq(this).next('.secondary-val-prop-section')
                              .removeAttr('aria-hidden')
                              .css('display', 'block');
                            var nextfocus = cbsjq(this).next('.secondary-val-prop-section').find('.secondary-val-prop-title');
                            //console.log("cbsjq(this)");
                            //console.log(cbsjq(this));
                            //console.log("*******************");

                            //console.log("cbsjq(this).next('.secondary-val-prop-section')");
                            //console.log(cbsjq(this).next('.secondary-val-prop-section'));
                            //console.log("*******************");

                            //console.log("nextfocus");
                            //console.log(nextfocus);
                            //console.log("*******************");
                            nextfocus.attr("tabindex", -1);
                            nextfocus.focus();
                            //if (/AppleWebKit\/([\d.]+)/.exec(navigator.userAgent)) {
                            //    setTimeout(function () {
                            //        nextfocus.focus();
                            //    }, 500);
                            //};
                            cbsjq(this).hide();
                        }
                    });
                }
            });
        }

    });

    cbsjq(function () {
        // WebKit contentEditable focus bug workaround: 
        if (/AppleWebKit\/([\d.]+)/.exec(navigator.userAgent)) {
            cbsjq('.accordion-anchor').on('blur', function () {
                try {
                    cbsjq('.accordion-anchor').off('blur');
                    var editableFix = jQuery('<input style="width:1px;height:1px;border:none;margin:0;padding:0;" tabIndex="-1">').appendTo(element);
                    editableFix.focus();
                    editableFix[0].setSelectionRange(0, 0);
                    editableFix.blur();
                    editableFix.remove();
                } catch (e) { }
            });
        };
    });

    // Card selector functionality
    cbsjq(function () {
        if (cbsjq('.utility-bar').length > 0) {
            if (cbsjq('.utility-bar').find('.view-card-container').length <= 0) {
                cbsjq('.utility-bar').addClass('full-width');
            }
        }
    });

    // Adding hero class
    cbsjq(function () {
        if ((document.body).className.match('cash')) {
            if (cbsjq('.hero-outer-container .hero-container').length > 0) {
                if (cbsjq('.hero-outer-container .hero-container').find('.hero-anchor-container').length > 0) {
                    cbsjq('.hero-outer-container .hero-container').addClass('hero-top');
                }
            }
        }
    });

    // Tooltip
    if (cbsjq('.val-prop-top a.tooltip-anchor img').attr('src', '/dist/imgs/tooltip.png')) {
        cbsjq('.val-prop-top a.tooltip-anchor').attr('href', 'javascript:;');
        cbsjq('.val-prop-top a.tooltip-anchor').hover(function () {
            cbsjq(this).find('img').attr('src', '/dist/imgs/tooltip_hover.png');
        }, function () {
            cbsjq(this).find('img').attr('src', '/dist/imgs/tooltip.png');
        });
    }
    cbsjq(function () {
        cbsjq('[data-toggle="popover"]').popover({
            html: true,
            trigger: 'manual'
        }).click(function (e) {
            cbsjq(this).popover('toggle');
            e.preventDefault();
        });

        cbsjq('body').on('click', function (e) {
            cbsjq('[data-toggle=popover]').each(function () {
                // hide any open popovers when the anywhere else in the body is clicked
                if (!cbsjq(this).is(e.target) && cbsjq(this).has(e.target).length === 0 && cbsjq('.popover').has(e.target).length === 0) {
                    cbsjq(this).popover('hide');

                }
            });
        });
    });

    // Speedbumps
    //cbsjq(function () {
    //    cbsjq('.speedbump').attr('data-toggle', 'modal');
    //    cbsjq('.modal-content .cancel').attr('data-dismiss', 'modal');
    //    cbsjq('.btnSecondPartyContinue').click(function () {
    //        cbsjq(this).parents('.modal').modal('hide');
    //    });
    //});







    // Hide promo carousel if there is only 1 item
    cbsjq(function () {
        cbsjq('.carousel').each(function () {
            cbsjq(this).carousel();
        });
    });

    // Level 1 Lookup functionality
    cbsjq(function () {
        function HideOnBlur(tbClearSelector, tbHideSelector) {
            var tbClear = cbsjq(tbClearSelector);
            cbsjq(tbClearSelector).blur(function () {
                cbsjq(tbHideSelector).val(tbClear.val()).show();
                tbClear.hide();
            });
            cbsjq(tbHideSelector).focus(function () {
                cbsjq(this).hide();
                tbClear.show().focus();
            });

            if (tbClear.length > 0) {
                cbsjq(tbHideSelector).val(tbClear.val()).show();
                tbClear.hide();
            }
        }

        HideOnBlur(".txtAccountNumber", ".txtAccountNumber_Pass");
        HideOnBlur(".txtZipCode", ".txtZipCode_Pass");
        HideOnBlur(".txtExpDate", ".txtExpDate_Pass");

        if (cbsjq('#Level1Lookup').length != 0) {
            cbsjq('#Level1Lookup').modal();
        }
    });

    cbsjq(function () {
        cbsjq('.protection-listing').each(function () {
            if (cbsjq(this).find('.listing-summary').length > 0) {
                if (cbsjq(this).find('.listing-summary:hidden')) {
                    cbsjq(this).css('border', 'none');
                }
            }
        });
    });

    // Service Panel : Hide border if listing-summary is hidden
    cbsjq(function () {
        cbsjq('.protection-listing').each(function () {
            if (cbsjq(this).find('.listing-summary').length > 0) {
                if (cbsjq(this).find('.listing-summary:hidden')) {
                    cbsjq(this).addClass('no-border');
                } else {
                    cbsjq(this).addClass('with-border');
                }
            }
        });
    });

    // Footer legal disclosure accordion
    //cbsjq(function () {
    //    cbsjq('.footer-legal-disclosure').on("click", function (e) {
    //        e.preventDefault();
    //        cbsjq(this).next('.footer-content').slideToggle();
    //        if (cbsjq(this).attr('aria-expanded') == 'false') {
    //            cbsjq(this).attr('aria-expanded', 'true');
    //            cbsjq(this).find('.white-caret').css({ 'background-position': '-9px 0px' });
    //        } else {
    //            cbsjq(this).attr('aria-expanded', 'false');
    //            cbsjq(this).find('.white-caret').css({ 'background-position': '5px 0px' });
    //        }
    //    });
    //});

    // fico graph line functionality based on graph tab container and offsets
    function setFicoGraphLines(height) {

        var $dataPtsContainer = cbsjq('.fico-graph-panel');
        var first = true;
        // if 'lines-active' flag not set
        if (!$dataPtsContainer.hasClass('lines-active')) {
            var xOffset;
            var yOffset;
            var colOffset;

            // lines: go through each [data-point, data-point+1] and draw connecting lines where applicable
            var $dataPtsColumns = $dataPtsContainer.find('.graph-col');
            for (var i = 0; i < $dataPtsColumns.length - 1; i++) {

                // if current index is last index, return (no more lines to connect)
                if (i === $dataPtsColumns.length - 1) {
                    return;
                }
                // if column has no data-point, continue without drawing line
                var $dataPt = cbsjq($dataPtsColumns[i]).find('.data-point');
                if ($dataPt.length < 1) {
                    continue;
                }

                // if next column has no data-point, continue without drawing line
                var $dataPtNxt = cbsjq($dataPtsColumns[i + 1]).find('.data-point');
                if ($dataPtNxt.length < 1) {
                    continue;
                }

                // get graph point [x,y] offset so that the line starts in the middle of the graph point
                var dataPtWidthOffset = $dataPt.width() / 2;
                var dataPtNxtWidthOffset = $dataPtNxt.width() / 2;
                var dataPtHeightOffset = $dataPt.height() / 2;
                var dataPtNxtHeightOffset = $dataPtNxt.height() / 2;

                // keep other lines relative to the starting point
                //if (i == 0) {
                //    xOffset = $dataPt.offset().left;
                //    yOffset = cbsjq('.fico-graph-inner').offset().top;
                //    colOffset = $dataPtsContainer.find('.graph-col').first().css('margin-left');
                //}
                if (first) {
                    xOffset = $dataPt.offset().left;
                    yOffset = cbsjq('.fico-graph-inner').offset().top;
                    var colOffset = $dataPtsContainer.find('.graph-col').first().css('margin-left');
                    if (i > 0) {
                        var marginLeftSize = parseInt(colOffset, 10);
                        secondcolOffset = cbsjq($dataPtsContainer.find('.graph-col')[1]).css('margin-left');
                        var marginBetweenSize = parseInt(secondcolOffset, 10);
                        for (var a = 0; a < i; a++) {
                            marginLeftSize += marginBetweenSize;
                        }
                        colOffset = marginLeftSize + 'px';
                    }
                    first = false;
                }

                // get current and next data pts x and y coordinates, relative to the container
                var x1 = ($dataPt.offset().left - xOffset + 3); // - $dataPtsContainer.offset().left;
                var x2 = ($dataPtNxt.offset().left - xOffset + 3); // - $dataPtsContainer.offset().left;
                var y1 = ($dataPt.offset().top - yOffset + dataPtHeightOffset); //- $dataPtsContainer.offset().top;
                var y2 = ($dataPtNxt.offset().top - yOffset + dataPtNxtHeightOffset); // - $dataPtsContainer.offset().top;                
                // draw connecting line
                $dataPtsContainer.find('.fico-graph-inner').append(cbsjq.line({ x: x1, y: y1 }, { x: x2, y: y2 }, { className: 'fico-line' }).css('margin-left', colOffset));
            }
            // set flag
            $dataPtsContainer.addClass('lines-active');
        }
    }

    // equal height for three column
    function setHeight(column) {
        var maxHeight = 0;
        //Get all the element 
        var $column = cbsjq(column);
        //Loop all the column
        for (var i = 0; i < $column.length; i++) {
            var $elem = $column.eq(i);
            if ($elem.height() > maxHeight) {
                maxHeight = $elem.height();
            }
        }
        //Set the height
        $column.height(maxHeight);
    }

    function setEqualHeightWithAbsoluteButton(column, anchorClass) {
        var maxHeight = 0;
        //Get all the element 
        var $column = cbsjq(column);
        //Loop all the column
        for (var i = 0; i < $column.length; i++) {
            var $elem = $column.eq(i);
            var $elemHeight = $elem.height() + $elem.find(anchorClass).height();
            if ($elemHeight > maxHeight) {
                maxHeight = $elemHeight;
            }
        }
        //Set the height
        $column.height(maxHeight);
    };

    cbsjq('.save-preferences').click(function (e) {
        e.preventDefault();
        switch (cbsjq(this).val()) {
            case 'Save Preferences':
                cbsjq(this).siblings('.email-options').find('input').prop('disabled', true);
                cbsjq(this).val('Update My Preferences');
                break;
            case 'Update My Preferences':
                cbsjq(this).siblings('.email-options').find('input').prop('disabled', false);
                cbsjq(this).val('Save Preferences');
                break;
        }
    });

    function resizeFicoVideos() {
        try {
            var vidWidth = document.getElementById('featured-video-carousel').offsetWidth;
            var height = vidWidth * .562;
            cbsjq(".ficoVideoIframe").css({ width: vidWidth, height: height });
            if (!vidWidth || vidWidth == 0) {
                var iframes = document.getElementsByTagName("iframe");
                for (i = 0; i < iframes.length; i++) {
                    iframe = iframes[i].contentWindow;
                    iframe.postMessage('{"event":"command","func":"' + 'stopVideo' + '","args":""}', '*');
                }
            }

        } catch (e) { }
    }

    cbsjq(window).resize(function () {
        // Js for site terms of use
        if (cbsjq('.hero-outer-container').length <= 0) {
            if (window.innerWidth < 979) {
                cbsjq('.container > .row').css("margin-top", "0px");
            }
            if (window.innerWidth > 979) {
                cbsjq('.container > .row').css("margin-top", "30px");
            }
        }

        //if (window.innerWidth > 979) {
        //    cbsjq('.footer-content').show();
        //} else {
        //    cbsjq('.footer-content').hide();
        //}
        cbsjq('.footer-content').show();

        if (window.innerWidth > 619) {
            // Set equal height to card-feature-listing section
            cbsjq('.card-feature-listing > li').css('height', 'auto');
            cbsjq('.card-feature-listing > li >a').css('height', 'auto');
            setEqualHeightWithAbsoluteButton(cbsjq('.card-feature-listing > li'), '.view-more');
            cbsjq('.card-feature-listing > li >a').css('height', cbsjq('.card-feature-listing > li').height());

            // Set equal height to valprop section
            cbsjq('.js-set-columns-equal .val-prop-bottom-section .val-prop-bottom > ul > li').css('height', 'auto');
            setHeight(cbsjq('.js-set-columns-equal .val-prop-bottom-section .val-prop-bottom > ul > li'));

            // Set equal height to calculator option-image-container
            cbsjq('.thank-you-sliders .points-slider-wrapper .points-slider-options .option .option-image-container').css('height', 'auto');
            setHeight(cbsjq('.thank-you-sliders .points-slider-wrapper .points-slider-options .option .option-image-container'));
        }

        // Append the content for score history in desktop
        if (window.innerWidth > 619) {
            cbsjq('.key-factors-content .key-factors-container').append(cbsjq('.score-history-container'));
            cbsjq('#ScoreHistory').append(cbsjq('.key-factors-content .key-factors-container .key-factors-inner-container'));

            cbsjq('.Key-factors-main-container .scorehistory').click(function () {
                cbsjq('.key-factors-content > #ScoreHistory').removeClass('hidden-sm hidden-md hidden-lg');
            });
        }

        if (window.innerWidth > 619) {
            cbsjq('#tabs-2').removeClass('active');
            cbsjq('.tab-content').append(cbsjq('#tabs-2'));
            //cbsjq('#tabs-1').remove(cbsjq('#tabs-2'));
        }

        if (window.innerWidth < 620) {
            cbsjq('.card-feature-listing > li').css('height', 'auto');
            cbsjq('.card-feature-listing > li >a').css('height', 'auto');
            cbsjq('.card-feature-listing > li >a').css('height', 'auto');
            cbsjq('#collapseKeyFactors .accordion-inner').append(cbsjq('.key-factors-inner-container'));
            cbsjq('#tabs-1').append(cbsjq('#tabs-2'));
            cbsjq('#tabs-2, #tabs-1').addClass('active in');

            // Set auto height to valprop section for mobile
            cbsjq('.js-set-columns-equal .val-prop-bottom-section .val-prop-bottom > ul > li').css('height', 'auto');

            // Set auto height to calculator option-image-container
            cbsjq('.thank-you-sliders .points-slider-wrapper .points-slider-options .option .option-image-container').css('height', 'auto');
        }

        if (window.innerWidth < 620) {
            cbsjq('#tabs-1').append(cbsjq('#tabs-2'));
            cbsjq('#KeyFactors, .keyfactors').removeClass('non-active').addClass('active in');
            cbsjq('.scorehistory').removeClass('active in').addClass('non-active');

            cbsjq('#collapseKeyFactors .accordion-inner').append(cbsjq('.key-factors-inner-container'));
            cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container a.toggle').unbind('click');
            //cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container div.toggle').unbind('click');
            cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container a.toggle').click(function (e) {
                //cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container div.toggle').click(function (e) {
                e.preventDefault();
                if (!cbsjq(this).hasClass('active')) {
                    cbsjq(this).addClass('active');
                    cbsjq(this).attr('aria-expanded', 'true');
                    cbsjq(this).parent().find('.accordion-content').stop().slideDown();
                    cbsjq(this).parent().find('.score-lenders-menu-carret-icon').css('background-position', '0px -72px ');
                }
                else {
                    cbsjq(this).removeClass('active');
                    cbsjq(this).attr('aria-expanded', 'false');
                    cbsjq(this).parent().find('.accordion-content').stop().slideUp();
                    cbsjq(this).parent().find('.score-lenders-menu-carret-icon').css('background-position', '0px 0px ');
                }
            });

            cbsjq('.key-factors-container.accordion  .accordion-toggle').unbind('click');
            cbsjq('.key-factors-container.accordion  .accordion-toggle').click(function (e) {
                cbsjq('.key-factors-container.accordion .accordion-group  .accordion-body').on('shown.bs.collapse', function () {
                    cbsjq('.fico-line').remove();
                    cbsjq('.lines-active').removeClass('lines-active');
                    setFicoGraphLines(6);
                    cbsjq('.fico-line').show();
                });
            });
        }
        else {
            cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container a.toggle').click(function (e) {
                //cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container div.toggle').click(function (e) {
                e.preventDefault();
            });
            cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container a.toggle').parent().find('.accordion-content').removeAttr('style');
            //cbsjq('.score-lenders-inner-accordion .score-lenders-accordion-container div.toggle').parent().find('.accordion-content').removeAttr('style');
        }

        if (window.innerWidth < 768) {
            cbsjq('.fico-line').remove();
            cbsjq('.lines-active').removeClass('lines-active');
            setFicoGraphLines(6);
            cbsjq('.fico-line').show();
        }

        if (window.innerWidth > 619) {
            if (cbsjq('#KeyFactors').hasClass('active in')) {
                cbsjq('#ScoreHistory').removeClass('active in');
            }

            if (cbsjq('.fico-graph-panel').hasClass('lines-active')) {
                cbsjq('.fico-line').remove();
                cbsjq('.lines-active').removeClass('lines-active');
                if (cbsjq('.fico-graph-panel').is(':visible')) {
                    var height = cbsjq("#KeyFactors").height() + 19;
                    setFicoGraphLines(height);
                    cbsjq('.fico-line').show();
                }
            }
            cbsjq('.key-factors-content .key-factors-container').append(cbsjq('.score-history-container'));
            cbsjq('#ScoreHistory').append(cbsjq('.key-factors-content .key-factors-container .key-factors-inner-container'));

            cbsjq('.Key-factors-main-container .scorehistory a').unbind('click');
            cbsjq('.Key-factors-main-container .scorehistory').click(function (e) {
                cbsjq('.key-factors-content > #ScoreHistory').removeClass('hidden-sm hidden-md hidden-lg');


                cbsjq('#ScoreHistory').addClass('active in');
                var height = cbsjq("#KeyFactors").height() + 19;
                cbsjq('.fico-line').remove();
                cbsjq('.lines-active').removeClass('lines-active');
                setFicoGraphLines(height);
                cbsjq('.fico-line').show();
            });

            cbsjq('.Key-factors-main-container .keyfactors').click(function () {
                cbsjq('.fico-line').hide();
            });
        }

        // Back to top functionality
        cbsjq(function () {
            try {
                var $rightSection = cbsjq('.card-benefits');
                var endingRight = (cbsjq(window).width() - ($rightSection.offset().left + $rightSection.outerWidth()));
                cbsjq('.back-to-top').css('right', endingRight - 82);

                // Move Back to top button to left side if right margin too small
                if (endingRight < 100) {
                    var endingLeft = (cbsjq(window).width() - $rightSection.offset().left);
                    cbsjq('.back-to-top').hide();
                    cbsjq(window).unbind('scroll');
                }
                else {
                    var rightSectionPosition = $rightSection.position();

                    cbsjq(window).scroll(function () {
                        var topPosition = 1000;
                        if (rightSectionPosition.top > 0) {
                            topPosition = rightSectionPosition.top;
                        }
                        if (cbsjq(this).scrollTop() > topPosition) {
                            cbsjq('.back-to-top').fadeIn();
                        } else {
                            cbsjq('.back-to-top').fadeOut();
                        }
                    });
                    cbsjq('.back-to-top a').click(function () {
                        cbsjq("html, body").animate({ scrollTop: 0 }, 600);
                        return false;

                    });
                    // set top for back to top based on footer
                    var $footer = cbsjq('footer');
                    var footerHeight = $footer.height() + parseInt($footer.css('padding-top')) + parseInt($footer.css('padding-bottom'));
                    cbsjq('.back-to-top').css('bottom', footerHeight);
                }
            }
            catch (err) {

            }
        });

        resizeFicoVideos();
    });

    cbsjq(window).load(function () {


        cbsjq('.wrapper #e .footer-container').css("margin-left", "0px !important");


        //var hl1 = cbsjq('.headerl1'); //#nav_utility
        //var hl2 = cbsjq('.headerl2'); //#citilmHeader
        //var hl3 = cbsjq('.headerl3'); //#nav_main
        //cbsjq('.headercontainer .left').css('height', cbsjq('#citilmHeader').height());
        //cbsjq('.headercontainer .right').css('height', cbsjq('#citilmHeader').height());

        //cbsjq('.headercontainer .left').css('background-color', cbsjq('#citilmHeader').css('background-color'));
        //cbsjq('.headercontainer .right').css('background-color', cbsjq('#citilmHeader').css('background-color'));
        //cbsjq('.headercontainer .middle').css('background-color', cbsjq('#citilmHeader').css('background-color'));

        //hl1.css("background-image", cbsjq('#nav_utility').css('background-image'));
        //hl1.css("background-position", cbsjq('#nav_utility').css('background-position'));
        //hl1.css("height", cbsjq('#nav_utility').css('height'));

        //hl1.css("border-bottom-color", cbsjq('#nav_utility').css('border-bottom-color'));
        //hl1.css("border-bottom-style", cbsjq('#nav_utility').css('border-bottom-style'));
        //hl1.css("border-bottom-width", cbsjq('#nav_utility').css('border-bottom-width'));



        //hl2.css("background-image", cbsjq('#citilmHeader').css('background-image'));
        //hl2.css("background-color", cbsjq('#citilmHeader').css('background-color'));
        //hl2.css("height", '86px');


        //hl3.css("background-image", cbsjq('#nav_main').css('background-image'));
        //hl3.css("background-position-y", cbsjq('#nav_main').css('background-position-y'));
        //hl3.css("background-position", cbsjq('#nav_main').css('background-position'));

        //hl3.css("background-color", cbsjq('#nav_main').css('background-color'));
        //hl3.css("border-bottom-color", cbsjq('#nav_main').css('border-bottom-color'));
        //hl3.css("border-bottom-style", cbsjq('#nav_main').css('border-bottom-style'));
        //hl3.css("border-bottom-width", cbsjq('#nav_main').css('border-bottom-width'));

        //hl3.css("border-top-color", cbsjq('#nav_main').css('border-top-color'));
        //hl3.css("border-top-style", cbsjq('#nav_main').css('border-top-style'));
        //hl3.css("border-top-width", cbsjq('#nav_main').css('border-top-width'));

        //hl3.css("height", cbsjq('#nav_main').css('height'));

        //cbsjq('.headercontainer').css('margin-bottom', -4);

        //if ($login_level && $login_level == "3") {
        //    cbsjq('.breadcrumb').css('padding-top', '0px');//changed from 10px to 5px on 21st Sept 2017
        //    cbsjq('.hero-outer-container').css('margin-top', '12px');
        //    cbsjq('.breadcrumb').css('height', '29.4px'); //fico score wheel issue
        //}
        //if (cbsjq('.level3').length > 0 && cbsjq('#nav_welcome').length == 0) {
        //    cbsjq('#citi-topNav-container').after('<div id="nav_welcome" class="citiBrandingNav" tabindex="-1"></div>');
        //}



        if (cbsjq('.mobile-headercontainer').is(':visible')) {
            cbsjq('.mobile-headercontainer').attr('aria-hidden', false)
            cbsjq('#menu.mobile-navigation').attr('aria-hidden', false)
        } else {
            cbsjq('.mobile-headercontainer').attr('aria-hidden', true)
            cbsjq('#menu.mobile-navigation').attr('aria-hidden', true)
        }

        //Fix for hamburger menu
        if (cbsjq('.desktop-headercontainer').is(':visible')) {
            cbsjq('.desktop-headercontainer').attr('aria-hidden', false)

        } else {
            cbsjq('.desktop-headercontainer').attr('aria-hidden', true)

        }

        cbsjq('.score-lenders-container .accordion-heading .accordion-toggle').click(function (e) {
            e.preventDefault();
        });

        if (cbsjq('.utility-bar').length) {
            cbsjq(document).on("keyup", function (e) {
                var code = e.keyCode;
                if (code == '9') {
                    if (!cbsjq(document.activeElement).parents('.utility-bar').length && cbsjq('.utility-bar .view-card-container').hasClass('active')) {
                        cbsjq('.utility-bar').find('.cross-icon-container a').focus();
                    }
                }
            });
        }

        if (window.innerWidth <= 979) {
            cbsjq(document).on("keyup", function (e) {
                var code = e.keyCode;
                if (code == '9') {
                    if (!cbsjq(document.activeElement).parents('.slideout-menu').length &&
                        cbsjq('html').hasClass('slideout-open') &&
                        !cbsjq(document.activeElement).hasClass('js-slideout-toggle')) {
                        cbsjq('.gsc-input').focus();
                    }
                }
            });
        }


        cbsjq('.gsc-search-button').attr('role', 'presentation');

        // Initialize tooltips
        //cbsjq('.dpc-tooltip').tooltip();

        // Append modal to end of body
        cbsjq('.modal').appendTo("body");

        if (cbsjq('.desktop-hero-contents .hero-contents').height() > (cbsjq('.hero-container').height() - 30)) {
            if (!cbsjq('.prestige')) {
                cbsjq('.hero-container .img-responsive.hidden-xs').css('min-height', '320px');
                cbsjq('.container .card-benefits').css('margin-top', '60px');
            }
        }

        // Js for site terms of use        
        if (cbsjq('.hero-outer-container').length <= 0) {
            cbsjq('.main-content .container').css("padding-top", "0px");
            cbsjq('.main-content .desktop-menu').css("margin-top", "0px");
            cbsjq('.container .row >.card-benefits').css("margin-top", "0px");
            if (window.innerWidth > 979) {
                cbsjq('.container > .row').css("margin-top", "30px");
            }
        }

        //FAQ page scrolling to correct place.
        try {
            if (window.location.href.indexOf("faq") > -1) {
                var fragment = location.hash;
                if (fragment != '') {
                    var id = fragment.substr(1);
                    var anchor = document.getElementById(id);
                    if (anchor != null) {
                        cbsjq(fragment).trigger("click");
                        cbsjq(fragment).next('.accordion-body').stop().slideDown();
                        //cbsjq(fragment).addClass('active');
                        //cbsjq(fragment).parent().parent().addClass('active');
                        //cbsjq(fragment).next('.accordion-content').stop().slideDown();
                        //cbsjq(fragment).attr('aria-expanded', 'true');
                        anchor.scrollIntoView(false);
                        document.body.scrollTop -= 20;
                        anchor.focus();
                        cbsjq(document).scrollTop(cbsjq(fragment).offset().top - 20);

                        //IE scroll issue
                        setTimeout(function () {
                            cbsjq(document).scrollTop(cbsjq(fragment).offset().top - 20);
                        }, 300);

                    }
                } else {
                    //open up the first faq
                    //FAQ page anchor
                    if (window.location.href.indexOf("faq") > -1) {
                        cbsjq('.toggle1:first').addClass('active');
                        cbsjq('.toggle1:first').parent().parent().addClass('active');
                        cbsjq('.toggle1:first').next('.accordion-content').stop().slideDown();
                        cbsjq('.toggle1:first').attr('aria-expanded', 'true');
                    }
                }
            }
        } catch (err) { }



        cbsjq('.main-content .container').css("text-indent", "0");
        cbsjq('.hero-outer-container').css("text-indent", "0");

        if (window.innerWidth > 619) {
            // Set equal height to card-feature-listing section            
            setEqualHeightWithAbsoluteButton(cbsjq('.card-feature-listing > li'), '.view-more');
            cbsjq('.card-feature-listing > li >a').css('height', cbsjq('.card-feature-listing > li').height());

            // Set equal height to valprop section
            setHeight(cbsjq('.js-set-columns-equal .val-prop-bottom-section .val-prop-bottom > ul > li:not(.plus-lockup-li)'));

            // Set equal height to calculator option-image-container
            setHeight(cbsjq('.thank-you-sliders .points-slider-wrapper .points-slider-options .option .option-image-container'));

            // Set equal height to utility-menu-container
            //setHeight(cbsjq('.utility-menu-container .utility-menu > div'));
        }

    });

    return {
        init: app.applicationInit
    }

})(Application || {}, document, window);


try {
    module.exports = Application.init();
}
catch (err) {
}

cbsjq.fn.exists = function () { return this.length > 0; }

//manage tab within panel
var $accordionGroup;
var gtarget;

window.HandlePanelKeyPress = function (e) {
    try {

        if (gtarget == null || document.activeElement.className == "modal-title")
            return;
        var code = e.keyCode;
        var containingDiv = $accordionGroup.find(gtarget);

        var inputs = cbsjq(containingDiv).find(":tabbable");
        var selectedelem = document.activeElement;
        var currElement = inputs.index(document.activeElement);
        var firstInput = inputs[0];
        var lastInput = inputs[inputs.length - 1];
        if (firstInput === undefined && lastInput === undefined)
            return;


        if ((code == '38' || code == '37') && document.activeElement != firstInput) {
            // up arrow
            e.preventDefault();
            if (currElement < 0) {
                console.log("a:" + code);
                cbsjq(lastInput).focus();
            } else {
                console.log("b:" + code);
                cbsjq(inputs[currElement - 1]).focus();
            }
        }

        else if ((code == '40' || code == '39') && document.activeElement != lastInput) {
            // down arrow
            e.preventDefault();
            if (currElement < 0) {
                console.log("c:" + code);
                cbsjq(firstInput).focus();
            } else {
                console.log("d:" + code);
                cbsjq(inputs[currElement + 1]).focus();
            }
        }

        // Tab + Shift key
        if (code == '9' && e.shiftKey) {
            if (currElement < 0) {
                e.preventDefault();
                cbsjq(lastInput).focus();
            } else if (document.activeElement == firstInput) {
                e.preventDefault();
                cbsjq(lastInput).focus();
            }

        }
            // Tab only
        else if (code == '9' && !e.shiftKey) {
            if (currElement < 0) {
                e.preventDefault();
                cbsjq(firstInput).focus();
            } else if (document.activeElement == lastInput) {
                e.preventDefault();
                cbsjq(firstInput).focus();
            }

        }
    } catch (err) { }
}


cbsjq(document).ready(function () {

    //cbsjq('.speedbump').on("click", (function () { getSpeedbump(cbsjq(this).attr('href')); return false; }));

    cbsjq('#skipToMainMobile').on('click', function () {
        cbsjq('#maincontentMobile')
         .attr('tabindex', -1)
         .focus();
    });

    cbsjq("a[class^='ensightendown_']").on('click', function () {
            var mar = cbsjq(this).attr('class').split("_");
            var type = mar[1];
            var ftype = mar[2];
            var today = new Date();
            var dd = today.getDate();

            var mm = today.getMonth() + 1;
            var yy = today.getFullYear().toString().substr(2, 2);
            if (dd < 10) {
                dd = '0' + dd;
            }
            if (mm < 10) {
                mm = '0' + mm;
            }
        window.citiData.downloadName = "download|" + type + "|" + yy + mm + dd + "|" + ftype;
        //var thisFileName = cbsjq(this).attr('href').replace(/~|_|-|\./g, " ");
        Bootstrapper.ensEvent.trigger("CardBenefitsDownload");
    });


    // Open Tile Click Event
    var triggerCard;
    cbsjq(window).resize(function () {
        if (cbsjq('.mobile-headercontainer').is(':visible')) {
            cbsjq('.mobile-headercontainer').attr('aria-hidden', false)
            cbsjq('#menu.mobile-navigation').attr('aria-hidden', false)
        } else {
            cbsjq('.mobile-headercontainer').attr('aria-hidden', true)
            cbsjq('#menu.mobile-navigation').attr('aria-hidden', true)
        }

        //Fix for hamburger menu
        if (cbsjq('.desktop-headercontainer').is(':visible')) {
            cbsjq('.desktop-headercontainer').attr('aria-hidden', false)

        } else {
            cbsjq('.desktop-headercontainer').attr('aria-hidden', true)

        }
    });

    //cbsjq('.card-feature-listing > li > a').click(function (e) {
    //cbsjq('.card-feature-listing > li > a').on('click tap touchstart touchend', function (e) {
    cbsjq('.card-feature-listing > li > a').on('click tap', function (e) {
        try {

            if (cbsjq(this).next('.secondary-val-prop-section').length > 0) {
                return true;
            }

            cbsjq('.accordion-group').attr('aria-hidden', 'true');
            cbsjq('.accordion-heading').attr('aria-hidden', 'true');
            cbsjq('.card-val-prop-section').attr('aria-hidden', 'true');
            cbsjq('header').attr('aria-hidden', 'true');
            cbsjq('footer').attr('aria-hidden', 'true');
            cbsjq('.disclosures-content').attr('aria-hidden', 'true');
            cbsjq('.disclosure-holder').attr('aria-hidden', 'true');
            cbsjq('.headline-container').attr('aria-hidden', 'true');
            cbsjq('.featured-benefit-container').attr('aria-hidden', 'true');
            cbsjq('.card-benefits .secondary-val-prop-section').attr('aria-hidden', 'true');//added extra class to avoid conflict with another acccordion
            cbsjq('.promo-carousel').attr('aria-hidden', 'true');
            cbsjq('.hero-outer-container').attr('aria-hidden', 'true');
            cbsjq('.menu').attr('aria-hidden', 'true');
            cbsjq('.card-benefits-left').attr('aria-hidden', 'true');
            cbsjq('.utility-bar').attr('aria-hidden', 'true');
            cbsjq('.card-value-prop-section').attr('aria-hidden', 'true');
            cbsjq('.calculator-module').attr('aria-hidden', 'true');
            cbsjq('.skip-main').attr('aria-hidden', 'true');
            cbsjq('.back-to-top.hidden-xs.hidden-sm').attr('aria-hidden', 'true');
            if (cbsjq('#kampyleButtonContainer').exists()) { cbsjq('#kampyleButtonContainer').attr('aria-hidden', 'true'); }
            if (cbsjq('.LPMcontainer.LPMoverlay').exists()) { cbsjq('.LPMcontainer.LPMoverlay').attr('aria-hidden', 'true'); }


            triggerCard = e.currentTarget;
            cbsjq(this).closest('.accordion-group').find('.protection-listing').removeClass('hidden');
            gtarget = cbsjq(this).attr('href');

            // Get all of the expanded tiles
            var $listingSummary = cbsjq(this).closest('.accordion-group').find('.protection-listing > .listing-summary');

            $listingSummary.find('.cross-icon').focus(); //ssb new
            $accordionGroup = cbsjq(this).closest('.accordion-group');
            $accordionGroup.attr('aria-hidden', 'false');


            // Stop any running animations
            cbsjq(this).closest('.card-feature-listing').stop();
            $listingSummary.stop();
            $accordionGroup.find(gtarget).stop();

            //PID 520 - Costco - Consumer Immersive Page 
            cbsjq(this).closest('.card-feature-listing').find('li').attr('aria-hidden', 'true');
            cbsjq(this).parent().attr('aria-hidden', 'false');
            cbsjq('.large-promo-banner').attr('aria-hidden', 'true');
            if (cbsjq('.calculator-content-top').length) {
                cbsjq('.calculator-content-top').attr('aria-hidden', 'true');
            }

            if ($listingSummary.exists() && $accordionGroup.find(gtarget).exists()) {
                $listingSummary.fadeOut(500);
                cbsjq(this).closest('.card-feature-listing').fadeOut(500, function () {
                    $accordionGroup.find(gtarget).fadeIn(100, function () {
                        $listingSummary.find('.cross-icon').focus();
                        cbsjq('.accordion-group').attr('aria-hidden', 'true');
                        cbsjq('.card-val-prop-section').attr('aria-hidden', 'true');
                        cbsjq('.accordion-heading').attr('aria-hidden', 'true');
                        $accordionGroup.attr('aria-hidden', 'false');
                        cbsjq('.hero-outer-container').attr('aria-hidden', 'true');
                        cbsjq('.menu').attr('aria-hidden', 'true');
                        cbsjq('.card-benefits-left').attr('aria-hidden', 'true');
                        cbsjq('.utility-bar').attr('aria-hidden', 'true');
                        cbsjq('.card-value-prop-section').attr('aria-hidden', 'true');
                        cbsjq('.calculator-module').attr('aria-hidden', 'true');
                        cbsjq('header').attr('aria-hidden', 'true');
                        cbsjq('footer').attr('aria-hidden', 'true');

                        cbsjq('.disclosures-content').attr('aria-hidden', 'true');
                        cbsjq('.disclosure-holder').attr('aria-hidden', 'true');
                        cbsjq('.headline-container').attr('aria-hidden', 'true');
                        cbsjq('.featured-benefit-container').attr('aria-hidden', 'true');
                        cbsjq('.card-benefits  .secondary-val-prop-section').attr('aria-hidden', 'true');
                        cbsjq('.promo-carousel').attr('aria-hidden', 'true');
                        cbsjq('.skip-main').attr('aria-hidden', 'true');
                    });

                    cbsjq(document).on('keydown.panelkeypress', HandlePanelKeyPress);


                });




            }
        } catch (err) { }


    });

    // Close Tile Click Event
    cbsjq('.servicing-panel-top .cross-icon').click(function () {
        //console.log('close tile click event triggered.');
        gtarget = null;

        //console.log('cbsjq(this)');
        //console.log(cbsjq(this));
        //console.log('-------------------');

        cbsjq(document).off(".panelkeypress");
        var $listingSummary = cbsjq(this).closest('.accordion-group').find('.protection-listing > .listing-summary');
        //console.log('$listingSummary');
        //console.log($listingSummary);
        //console.log('-------------------');

        //remove the footer back link
        cbsjq(".disclosure-back").remove();
        $listingSummary.fadeOut(300, function () {
            cbsjq(this).closest('.accordion-group').find('.card-feature-listing').fadeIn(1, function () {
                //setTimeout(function () { triggerCard.focus(); }, 200);
                triggerCard.focus();
                //cbsjq($triggerCard).focus();
                cbsjq(this).closest('.accordion-group').find('.protection-listing').addClass('hidden');
                //cbsjq($triggerCard).attr('aria-expanded', 'false');
                cbsjq('.accordion-group').attr('aria-hidden', 'false');
                cbsjq('.accordion-heading').attr('aria-hidden', 'false');
                cbsjq('.hero-outer-container').attr('aria-hidden', 'false');
                cbsjq('.card-val-prop-section').attr('aria-hidden', 'false');
                cbsjq('.menu').attr('aria-hidden', 'false');
                cbsjq('.card-benefits-left').attr('aria-hidden', 'false');
                cbsjq('.utility-bar').attr('aria-hidden', 'false');
                cbsjq('.card-value-prop-section').attr('aria-hidden', 'false');
                cbsjq('.calculator-module').attr('aria-hidden', 'false');
                cbsjq('header').attr('aria-hidden', 'false');
                cbsjq('footer').attr('aria-hidden', 'false');
                cbsjq('.disclosures-content').attr('aria-hidden', 'false');
                cbsjq('.featured-benefit-container').attr('aria-hidden', 'false');
                cbsjq('.card-benefits .secondary-val-prop-section').attr('aria-hidden', 'false');
                cbsjq('.promo-carousel').attr('aria-hidden', 'false');
                cbsjq('.disclosure-holder').attr('aria-hidden', 'false');
                cbsjq('.headline-container').attr('aria-hidden', 'false');
                cbsjq('.skip-main').attr('aria-hidden', 'false');
                //PID 520 - Costco - Consumer Immersive Page 
                cbsjq('.card-feature-listing').find('li').attr('aria-hidden', 'false');
                cbsjq('.large-promo-banner').attr('aria-hidden', 'false');
                cbsjq('.back-to-top.hidden-xs.hidden-sm').attr('aria-hidden', 'false');
                if (cbsjq('#kampyleButtonContainer').exists()) { cbsjq('#kampyleButtonContainer').attr('aria-hidden', 'false'); }
                if (cbsjq('.LPMcontainer.LPMoverlay').exists()) { cbsjq('.LPMcontainer.LPMoverlay').attr('aria-hidden', 'false'); }
                if (cbsjq('.calculator-content-top').length) {
                    cbsjq('.calculator-content-top').attr('aria-hidden', 'false');
                }
            });
        });
    });

    function updateBarCoordinate(obj) {
        var currElement = obj;
        var min = currElement.getAttribute("min");
        var max = currElement.getAttribute("max");
        var curVal = currElement.getAttribute("aria-valuenow");
        var percentLoc = ((curVal - min) / (max - min)) * 94.5;
        var bar = currElement.parentNode.getElementsByClassName("bar-follower");
        bar[0].style.left = percentLoc + '%';
    }
    function updateHtml5BTotal() {
        var total = 0;
        cbsjq('.prestige-rewards-projector .section-3x').each(function () {
            var points = Math.floor(cbsjq(this).find('.Xpoints').val());
            total += points;
        });
        total = total * 12;
        var giftCardPoints = total * .01;
        var giftCardPoints = Math.floor(giftCardPoints / 25) * 25;
        var redeemAirline = Math.floor((total * .0125) / 1) * 1;

        cbsjq('.prestige-rewards-projector').find('.redeem-airline').html("$" + redeemAirline.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
        cbsjq('.prestige-rewards-projector').find('.redeem-giftcard').html("$" + giftCardPoints.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
        cbsjq('.prestige-rewards-projector').find('.totalPoints').html(total.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));

    }
    window.keepCBSSessionAlive = keepCBSSessionAlive;
    function keepCBSSessionAlive() {
        cbsjq.ajax({
            type: "POST",
            context: this,
            data: { scController: "Login", scAction: "KeepSessionAlive" },
            success: function (data) {
            //    alert("Updated Session");
            //},
            //error: function (data) {
            //    alert("Didn't Updated Session");
            }
        });
    }
    //Html5 calculator
    cbsjq('.html5calculatorB').on("input change", function (e) {
        cbsjq(this).parent().find('.bar-follower .price').html("$" + this.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
        //var multi = Math.floor(cbsjq(this).parent().find('.multiplier').val());
        var multi = cbsjq(this).parent().find('.multiplier').val();
        var val = multi * this.value;
        cbsjq(this).parent().find('.Xpoints').val(val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ""));
        cbsjq(this).parent().find('.bar-follower .saved').html("$" + val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
        cbsjq(this).parent().parent().find('.points-row').find('.value').text(val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
        cbsjq(this).parent().find('.value').text("$" + val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
        cbsjq(this).attr('aria-valuenow', this.value);
        cbsjq(this).attr('aria-valuetext', this.value);
        cbsjq(this).attr('title', this.value);
        //cbsjq(this).attr('aria-valuetext', val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " ");
        //cbsjq(this).attr('title', val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " ");
        updateBarCoordinate(this);
        updateHtml5BTotal();
    });

    //doneal - Added to see voiceover clicks.  Leaving it here in case we need it later.
    //var anchors = Array.prototype.slice.call(document.getElementsByTagName("a"));

    //['touchstart', 'touchend', 'mouseup', 'mousedown', 'click'].forEach(
    //    function (eventName) {
    //        anchors.forEach(function (tag) {
    //            tag.addEventListener(eventName, function () {
    //                console.log('a#' + tag.id + ': ' + tag.className + ':' + eventName);
    //            });

    //        });

    //    }
    //);
    //doneal PID 408
    cbsjq('#PointsBack').on('show.bs.collapse', function () {
        cbsjq('#Supermarkets').collapse('hide');
        cbsjq('#RoundUp').collapse('hide');
    });
    cbsjq('#Supermarkets').on('show.bs.collapse', function () {
        cbsjq('#PointsBack').collapse('hide');
        cbsjq('#RoundUp').collapse('hide');
    });
    cbsjq('#RoundUp').on('show.bs.collapse', function () {
        cbsjq('#PointsBack').collapse('hide');
        cbsjq('#Supermarkets').collapse('hide');
    });
});
},{}]},{},[1]);

//$(document).ready(function () {
//    // Open Tile Click Event
//    var $triggerCard;
//    $('.card-feature-listing > li > a').click(function (e) {
//        var $this = $(this);
//        $triggerCard = e.currentTarget;
//        $this.closest('.accordion-group').find('.protection-listing').removeClass('hidden');
//        var target = $this.attr('href');

//        // Get all of the expanded tiles
//        var $listingSummary = $this.closest('.accordion-group').find('.protection-listing > .listing-summary');
//        var $accordionGroup = $this.closest('.accordion-group');

//        // Stop any running animations
//        $this.closest('.card-feature-listing').stop();
//        $listingSummary.stop();
//        $accordionGroup.find(target).stop();

//        if ($listingSummary.exists() && $accordionGroup.find(target).exists()) {
//            $listingSummary.fadeOut(500);
//            $this.closest('.card-feature-listing').fadeOut(300, function () {
//                $accordionGroup.find(target).fadeIn(1000, function () {
//                    $listingSummary.find('.cross-icon').focus();
//                });
//            });
//        }


//    });

//    // Close Tile Click Event
//    $('.servicing-panel-top .cross-icon').click(function () {
//        var $this = $(this);
//        var $listingSummary = $this.closest('.accordion-group').find('.protection-listing > .listing-summary');
//        $listingSummary.fadeOut(1000, function () {
//            $this.closest('.accordion-group').find('.card-feature-listing').fadeIn(1000, function () {
//                $($triggerCard).focus();
//                $this.closest('.accordion-group').find('.protection-listing').addClass('hidden');
//            });
//        });
//    });
//});
// JavaScript Document

//"use strict";
var ATTApp = null;


(function ($) {

    ATTApp = {
        init: function () {
            $(ATTApp.selectors.ATTProductsPoints).val(0);
            $(ATTApp.selectors.ExpTravelPoints).val(0);
            $(ATTApp.selectors.onlinePurchasesPoints).val(0);
            $(ATTApp.selectors.otherPurchasesPoints).val(0);
            if (!$.find('.exp').length) {
                $(ATTApp.selectors.monthsDivs).text("0");
            }
        },

        initExp: function () {
            $(ATTApp.selectors.ATTProductsPoints).val('0');
            $(ATTApp.selectors.ExpTravelPoints).val('0');
            $(ATTApp.selectors.onlinePurchasesPoints).val('0');
            $(ATTApp.selectors.otherPurchasesPoints).val('0');
            $('.exp #ATT-products').val('000');
            $('.exp #Exp-travel').val('000');
            $('.exp #online-purchases').val('000');
            $('.exp #other-purchases-products').val('000');
            $(ATTApp.selectors.monthsDivs).text('$000');
            $('.exp #additional-points-value').text('0');
        },
        selectors: {
            //Mobile menu Selectors
            'monthsDivs': '#months',
            'eliteNightsValue': '#additional-points-value',
            'ATTProductsPoints': '#ATT-products-points',
            'ExpTravelPoints': '#Exp-travel-points',
            'onlinePurchasesPoints': '#online-purchases-points',
            'otherPurchasesPoints': '#other-purchases-points'
        },
        months: {
            config: {
                'maxPoints': 25000,
                'monthsText': 'You are eligible',
                'xPoints': 2
            },
        },
        slider: {
            config: {
                'range': "min",
                'value': 0,
                'minVal': 0,
                'maxVal': 12500,
                'maxValOther': 25000,
                'step': 10
            }
        },
        TotalPoints: function () {
            if ($('#slider-Exp-travel').length > 0) {
                return parseFloat($(ATTApp.selectors.ExpTravelPoints).val()) +
                              parseFloat($(ATTApp.selectors.onlinePurchasesPoints).val().replace('$', '')) +
                              parseFloat($(ATTApp.selectors.otherPurchasesPoints).val().replace('$', ''));
            } else {
                return parseFloat($(ATTApp.selectors.ATTProductsPoints).val()) +
                              parseFloat($(ATTApp.selectors.onlinePurchasesPoints).val().replace('$', '')) +
                              parseFloat($(ATTApp.selectors.otherPurchasesPoints).val().replace('$', ''));
            }
        },
        TotalEliteNights: function () {
            //return (ATTApp.TotalPoints() * 12) / 2500;
            if ($('#slider-Exp-travel').length > 0) {
                //var attPointValue = $('#Exp-travel-points').val().replace('$', '');
                //var otherPointValue = $('#other-purchases-points').val().replace('$', '');
                var attPointValue = $('#Exp-travel').val().replace('$', '');
                var otherPointValue = $('#other-purchases').val().replace('$', '');
                attPointValue = attPointValue.replace(/\,/g, "");
                otherPointValue = otherPointValue.replace(/\,/g, "");
                return ((parseFloat(attPointValue) + parseFloat(otherPointValue)) / 2500) * 12;
            } else {
                //var attPointValue = $('#ATT-products-points').val().replace('$', '');
                //var otherPointValue = $('#other-purchases-points').val().replace('$', '');
                var attPointValue = $('#ATT-products').val().replace('$', '');
                var otherPointValue = $('#other-purchases').val().replace('$', '');
                attPointValue = attPointValue.replace(/\,/g, "");
                otherPointValue = otherPointValue.replace(/\,/g, "");
                return ((parseFloat(attPointValue) + parseFloat(otherPointValue)) / 2500) * 12;
            }
        },


        DisplayCash: function () {
            var totalPoints = ATTApp.TotalPoints();
            var totalEliteNights = ATTApp.TotalEliteNights();

            var hotelCash = 0;
            var hotelCoupons = 0;
            var eliteNights = 0;

            if (isNaN(totalPoints)) {
                totalPoints = 1;
            } else {
                totalPoints *= 12;
            }

            hotelCoupons = parseInt(totalPoints / 3500);

            if (hotelCoupons >= 1) {
                if ($('.expedia-calculator').length > 0) {
                    $(ATTApp.selectors.monthsDivs).text("$" + ATTApp.NumberWithCommas(Math.floor((totalPoints) * 0.007143)));
                } else {
                    $(ATTApp.selectors.monthsDivs).text("$" + hotelCoupons * 25);
                }
                $(".months-text").css("display", "block");
            } else {
                $(ATTApp.selectors.monthsDivs).text("$000");
            }

            var goldStatus = $('.gold-status');
            if (totalEliteNights < 15) {
                $(ATTApp.selectors.eliteNightsValue).text(Math.floor(totalEliteNights));
                $(ATTApp.selectors.eliteNightsValue).append(goldStatus.addClass('hidden').attr('aria-hidden', 'true'));
            } else {
                $(ATTApp.selectors.eliteNightsValue).html(goldStatus.removeClass('hidden').attr('aria-hidden', 'false'));
            }
        },
        DisplayCashATT: function () {
            totalPoints = ATTApp.TotalPoints();

            if (totalPoints === 0) {
                $(ATTApp.selectors.monthsDivs).text("0");
            } else {
                $(ATTApp.selectors.monthsDivs).text(ATTApp.NumberWithCommas(totalPoints));
                //$(".months").css("display", "block");
            }
        },
        NumberWithCommas: function (n) {
            return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
        }
    };




    $(document).ready(function () {



        var ATTproducts,
            onlinePurchases,
            otherPurchases,
            totalPoints = 0;

        if ($.find('.exp').length > 0) { /* Exp branding*/
            ATTApp.initExp();
        } else {
            ATTApp.init();
        }
        //bindPointsSlider(obj, dollars, points, alt, stepValue, maxValue)



        function bindATTSlider(obj, dollars, points, maxValue, xPoints) {

            //Html5 calculator
            $(obj).on("input change", function (event) {
                var range = ATTApp.slider.config.range;
                var value = ATTApp.slider.config.value;
                var min = ATTApp.slider.config.minVal;
                var max = maxValue;
                var step = ATTApp.slider.config.step;

                if ($('.exp').length > 0) { /* Exp branding*/
                    $(dollars).val('$' + ATTApp.NumberWithCommas(this.value));
                }
                else { /* ATT Branding */
                    $(dollars).val(this.value);
                }
                ATTproducts = (this.value);
                if ($.isNumeric(ATTApp.months.config.xPoints) && $.isNumeric(ATTproducts)) {

                    var multiplier = $(event.target).parent().find('.multiplier');
                    if (multiplier.length > 0 && multiplier.val() > 1) {
                        $(points).val(ATTproducts * multiplier.val());
                        updateSliderAriaLabel(obj, ATTproducts, ATTproducts * multiplier.val(), 'earns', 'points monthly');
                        $(this).attr('aria-valuenow', ATTproducts);
                        $(this).attr('aria-valuetext', ATTproducts);
                        trackSliderInteraction($(this).attr('id'));
                    } else {
                        $(points).val(ATTproducts * xPoints);
                        updateSliderAriaLabel(this, ATTproducts, ATTproducts * multiplier.val(), 'earns', 'points monthly');
                        $(this).attr('aria-valuenow', ATTproducts);
                        $(this).attr('aria-valuetext', ATTproducts);
                        trackSliderInteraction($(this).attr('id'));
                    }
                }
                if ($.find('.exp').length > 0) { /* Exp branding*/
                    ATTApp.DisplayCash();
                }
                else { /* ATT Branding */
                    ATTApp.DisplayCashATT();
                }
                updateSliderColors(obj);

            });


            if ($('.exp').length > 0) { /* Exp branding*/
                if ($(obj).val())
                    $(dollars).val("$" + $(obj).val());
                else
                    $(dollars).val("$" + 0);
            }
            else { /* ATT Branding */
                if ($(obj).val())
                    $(dollars).val($(obj).val());
                else
                    $(dollars).val("0");
            }
            // Set up the number formatting.		
            $(points).number(true, 0);
        }

        bindATTSlider("#slider-ATT-products", "#ATT-products", "#ATT-products-points", ATTApp.slider.config.maxVal, ATTApp.months.config.xPoints);
        bindATTSlider("#slider-Exp-travel", "#Exp-travel", "#Exp-travel-points", ATTApp.slider.config.maxVal, ATTApp.months.config.xPoints);
        bindATTSlider("#slider-online-purchases", "#online-purchases", "#online-purchases-points", ATTApp.slider.config.maxVal, ATTApp.months.config.xPoints);
        bindATTSlider("#slider-other-purchases", "#other-purchases", "#other-purchases-points", ATTApp.slider.config.maxValOther, 1);

        /* Sliders Function */
        function bindPointsSlider(obj, dollars, points, alt, stepValue, maxValue) {
            //HTML5 calculator code
            $(obj).on("input change", function (event) {
                var range = 5;
                var value = 10;
                var min = 0;
                var max = stepValue;
                var step = maxValue;

                $(obj).parent().find('.Xpoints').val(this.value);
                $(obj).parent().find('.value').text(this.value);

                uiValue = (this.value);
                var valuewithComma = uiValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                $(dollars).val(valuewithComma);
                $(dollars).attr('value', valuewithComma);
                var multiplierAriaLabel = $(event.target).parent().find('.multiplier');
                updateSliderAriaLabel(obj, uiValue, uiValue * multiplierAriaLabel.val(), 'earns', 'miles');
                $(this).attr('aria-valuenow', uiValue);
                $(this).attr('aria-valuetext', uiValue);
                $(this).attr('title', uiValue);

                if ($.isNumeric(uiValue)) {
                    var multiplier = $(event.target).parent().find('.multiplier');
                    if (multiplier.length > 0) {
                        $(dollars).val(valuewithComma);
                        $(points).val((uiValue * multiplier.val()).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
                        $(this).attr('aria-label', uiValue * multiplier.val() + ' Miles');
                        trackSliderInteraction($(obj).attr('id'));
                    } else {
                        $(dollars).val(uiValue);
                        $(points).val(uiValue);
                        $(this).attr('aria-label', uiValue * multiplier.val() + ' Miles');
                        trackSliderInteraction($(obj).attr('id'));
                    }
                }
                updateSliderColors(obj);

            });

 
        }

        /* AAdvantage Sliders */
        if ($("#slider-aa").length > 0) {
            var slideAaAnchor = $('#slider-aa').find('.ui-slider-handle');
            bindPointsSlider("#slider-aa", "#aa-purchases", "#aa-purchases-points", slideAaAnchor, 50, 10000);
        }
        if ($("#slider-aa-other").length > 0) {
            var slideAaOtherAnchor = $('#slider-aa-other').find('.ui-slider-handle');
            bindPointsSlider("#slider-aa-other", "#aa-other-purchases", "#aa-other-purchases-points", slideAaOtherAnchor, 50, 10000);
        }
        if ($("#slider-aa-car-rental").length > 0) {
            var slideAaAnchor = $('#slider-aa-car-rental').find('.ui-slider-handle');
            bindPointsSlider("#slider-aa-car-rental", "#aa-car-rental", "#aa-car-rental-points", slideAaAnchor, 50, 10000);
        }
        if ($("#slider-aa-telecom").length > 0) {
            var slideAaAnchor = $('#slider-aa-telecom').find('.ui-slider-handle');
            bindPointsSlider("#slider-aa-telecom", "#aa-telecom", "#aa-telecom-points", slideAaAnchor, 50, 10000);
        }
        if ($("#slider-aa-gasstation").length > 0) {
            var slideAaAnchor = $('#slider-aa').find('.ui-slider-handle');
            bindPointsSlider("#slider-aa-gasstation", "#aa-gasstation", "#aa-gasstation-points", slideAaAnchor, 50, 10000);
        }

        //if ($("#costco-slider-gas").length > 0) {
        //    var slideCostAnchor = $('#costco-slider-gas').find('.ui-slider-handle');
        //    bindPointsSlider("#costco-slider-gas", "#aa-purchases", "#aa-purchases-points", slideCostAnchor, 50, 10000);
        //}


    });


})(cbsjq);




(function ($) {
    $.fn.tyclouds = function () {
        var tcEl = this;

        if (!$('#tooltip-thankyou').length) {
            $('body').append('<div id="tooltip-thankyou"/>');
        }
        $(document).mousemove(function (mTC) {
            $("#tooltip-thankyou").css({ top: (mTC.pageY - 55) + "px", left: (mTC.pageX - 47) + "px" });
        });
        $(document).on('keydown', function (e) {
            var code = e.keyCode;
            var currElement = document.activeElement;
            try {
                if (code == '38' || code == '37' || code == '40' || code == '39') {
                    updateToolTipCloudCoordinate();
                } else if ((code == '9' && e.shiftKey) || (code == '9' && !e.shiftKey)) {
                    //tab out
                    $('#tooltip-thankyou').hide();
                }
            } catch (err) { }


        });
        tcEl.each(function () {
            var el = $(this);
            var ti = el.attr('title');
            el.hover(function () {
                //var val = $(this).parent().attr('value');
                var val = this.value;
                if (typeof val !== typeof undefined && val !== false) {
                    $('#tooltip-thankyou').text("$" + val);
                } else {
                    $('#tooltip-thankyou').text("$0");
                }

                $('#tooltip-thankyou').fadeTo(300, 1);
                el.attr('title', '');
            }, function () {
                $('#tooltip-thankyou').hide();
                el.attr('title', ti);
            });
            el.on("focus", function () {
                //var val = $(this).parent().attr('value');
                updateToolTipCloudCoordinate();
                var val = this.value;
                if (typeof val !== typeof undefined && val !== false) {
                    $('#tooltip-thankyou').text("$" + val);
                } else {
                    $('#tooltip-thankyou').text("$0");
                }

                $('#tooltip-thankyou').fadeTo(300, 1);
                el.attr('title', '');
            });
            el.on("blur", function () {
                $('#tooltip-thankyou').hide();
            });

        });
    };
})(cbsjq);

cbsjq(window).load(function () {

    /* Thank You Sliders */

    function convertIntToCurrencyFormat(num) {
        num = num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
        var patt = /\.\d{1}/g;
        var patt2 = /\.\d{2}/g;
        if (patt.test(num)) {
            num += '0';
        } else if (patt.test(num) == false) {
            num += '.00';
        }
        return num;
    }

    //Html5 calculator
    cbsjq('.html5calculator').on("input change", function (e) {
        cbsjq('#tooltip-thankyou').html("$" + this.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
        var multi = Math.floor(cbsjq(this).parent().find('.multiplier').val());
        var val = multi * this.value;
        cbsjq(this).parent().find('.Xpoints').val(val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ""));
        cbsjq(this).parent().find('.value').text(val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " ");
        //cbsjq(this).attr('aria-valuenow', val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "") + " ");
        cbsjq(this).attr('aria-valuenow', this.value);
        cbsjq(this).attr('aria-valuetext', this.value);
        //cbsjq(this).attr('aria-valuetext', val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " ");
        //cbsjq(this).attr('title', val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " ");
        cbsjq(this).attr('title', this.value);
        updateAnnualPoints(val);
        updateForeignAnnually();
        updateSliderColors(this);

    });

    function bindThankYouPointsSlider(obj) {

        var max = cbsjq(obj).attr('max');
        var increment = cbsjq(obj).attr('increment');
        cbsjq('.member-status-section input[type=radio]').click(function (e) {
            updateAnnualPoints();
        });
        cbsjq(obj).removeClass('ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all');
    }

    //Ensighten tracking for calculator usage 
    function trackSliderInteraction(name) {
        try {
            var pid = $prodId; //'<%= CPPSession.PID.ToString() %>';
            var s = s_gi('citibbprod');
            s.linkTrackVars = 'prop40,eVar12,events';
            s.linkTrackEvent = 'event20';
            s.prop40 = name;
            s.evar12 = pid;
            s.events = "event20";
            s.tl(true, 'o', 'calculator usage');
        } catch (err) { }
    }
    function bindCostcoPointsSlider(obj) {
        var max = cbsjq(obj).attr('max');
        var increment = cbsjq(obj).attr('increment');

        //HTML5 calculator code
        cbsjq(obj).on("input change", function (event) {
            var range = 5;
            var value = 10;
            var min = 0;
            var max = Math.floor(increment);
            var step = Math.floor(max);

            cbsjq('#tooltip-thankyou').html("$" + this.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
            cbsjq(this).parent().find('.dollars-text .dollars').html(this.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
            var multi = Math.floor(cbsjq(this).parent().find('.multiplier').val());
            var val = Math.floor(multi * this.value / 100);
            var nonroundedval = multi * this.value / 100;
            var valcents = parseFloat(multi * this.value / 100).toFixed(2);
            //cbsjq(this).parent().find('.Xpoints').val(nonroundedval.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ""));
            cbsjq(this).parent().find('.Xpoints').val(nonroundedval);
            cbsjq(this).parent().find('.value').text(val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " ");
            cbsjq(this).parent().find('.valuecents').text(valcents.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " ");
            //cbsjq(this).attr('aria-valuenow', val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "") + " ");
            cbsjq(this).attr('aria-valuenow', this.value);
            //cbsjq(this).attr('aria-valuetext', val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " ");
            cbsjq(this).attr('aria-valuetext', this.value);
            cbsjq(this).attr('title', this.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " ");
            updateAnnualPointsCostco(nonroundedval);
            updateForeignAnnually();

            cbsjq(obj).attr('value', val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
            updateSliderAriaLabel(obj, val, val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), 'earns', 'dollars per month');
            trackSliderInteraction(cbsjq(obj).attr('id'));
            updateSliderColors(obj);

        });
        //REMOVED BELOW FOR HTML5 calculator functionality

    }

    function updateSliderColors(obj) {
        try {
            if (cbsjq(obj).hasClass("slider-gradient")) {
                var val = (cbsjq(obj).val() - cbsjq(obj).attr('min')) / (cbsjq(obj).attr('max') - cbsjq(obj).attr('min'));
                var x = cbsjq(obj).css('background-image');
                var css = cbsjq(obj).css('background-image');
                var end = 'rgb' + css.split('rgb')[2].split(')')[0] + ')';
                var begin = 'rgb' + css.split('rgb')[1].split(')')[0] + ')';
                cbsjq(obj).css('background',
                            '-webkit-gradient(linear, left top, right top, '
                            + 'color-stop(' + val + ',' + begin + '),'
                            + 'color-stop(' + val + ',' + end + ')'
                            + ')'
                            );
            }
        } catch (e) { }

    }

    function updateAnnualPointsCostco(sliderval) {
        var total = 0.0;
        cbsjq('.points-slider-options .option').each(function () {
            var points = parseFloat(cbsjq(this).find('.Xpoints').val()).toFixed(2);
            total += eval(points);
        });
        total = total * 12;
        cbsjq('.points-total .total').text('[' + Math.ceil(total).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ']');

        if (cbsjq('.points-total > span').length > 0 && cbsjq('.points-total > span').find('.total-points').length > 0) {
            cbsjq('.points-total > span').find('.total-points').text(cbsjq('.points-total .total').text());
        }

        if ((document.body).className.match('costco-business') || (document.body).className.match('costco-consumer')) {
            cbsjq('.points-total .total').text(total.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ".00");
        }

        // If Hilton
        if (cbsjq('.member-status-section').length > 0) {
            var basePoints = 0;

            var travelSpent = cbsjq('#slider-travel').val();

            //basePoints += travelSpent ? travelSpent.replace(",", '') * cbsjq('.member-status-section').find(':checked ~ .multiplier').val() : 0;
            basePoints += travelSpent ? travelSpent * cbsjq('.member-status-section').find(':checked ~ .multiplier').val() : 0;
            var totalPoints = 0;
            totalPoints += basePoints;

            cbsjq('.points-slider-options .option').each(function () {
                var points = Math.floor(cbsjq(this).find('.Xpoints').val());
                totalPoints += points;
            });

            // anualize
            totalPoints *= 12;

            cbsjq('.member-status-section').find('.base-points .total').text(Math.ceil(basePoints).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
            cbsjq('.points-slider-wrapper').find('.total-annual-points-number .total').text(Math.ceil(totalPoints).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
        }
    }
    function updateAnnualPoints(sliderval) {
        var total = 0;
        cbsjq('.points-slider-options .option').each(function () {
            var points = Math.floor(cbsjq(this).find('.Xpoints').val());
            total += points;
        });
        total = total * 12;
        cbsjq('.points-total .total').text('[' + Math.ceil(total).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ']');

        if (cbsjq('.points-total > span').length > 0 && cbsjq('.points-total > span').find('.total-points').length > 0) {
            cbsjq('.points-total > span').find('.total-points').text(cbsjq('.points-total .total').text());
        }

        if ((document.body).className.match('costco-business') || (document.body).className.match('costco-consumer')) {
            cbsjq('.points-total .total').text(total.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ".00");
        }

        // If Hilton
        if (cbsjq('.member-status-section').length > 0) {
            var basePoints = 0;

            var travelSpent = cbsjq('#slider-travel').val();

            //basePoints += travelSpent ? travelSpent.replace(",", '') * cbsjq('.member-status-section').find(':checked ~ .multiplier').val() : 0;
            basePoints += travelSpent ? travelSpent * cbsjq('.member-status-section').find(':checked ~ .multiplier').val() : 0;
            var totalPoints = 0;
            totalPoints += basePoints;

            cbsjq('.points-slider-options .option').each(function () {
                var points = Math.floor(cbsjq(this).find('.Xpoints').val());
                totalPoints += points;
            });

            // anualize
            totalPoints *= 12;

            cbsjq('.member-status-section').find('.base-points .total').text(Math.ceil(basePoints).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
            cbsjq('.points-slider-wrapper').find('.total-annual-points-number .total').text(Math.ceil(totalPoints).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
        }

        // If ThankYou Preferred
        var redeemPoints = 0;
        if (cbsjq('.thankyou.preferred').length == 1) {
            redeemPoints = total * .01;
        }
        else if (cbsjq('body.prestige').length == 1) {
            redeemPoints = Math.floor((total * .0133) / 1) * 1;
        }
        else {
            redeemPoints = total * .0125;
            redeemPoints = Math.floor(redeemPoints);
        }

        if (cbsjq('.aa-points-redeemable .total').length == 1) {
            var aaRedeemPoints = Math.floor((total * .016) / 1) * 1;
            cbsjq('.aa-points-redeemable .total').text(aaRedeemPoints.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
        }

        cbsjq('.points-redeemable .total').text(redeemPoints.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));

        var giftCardPoints = total * .01;
        var giftCardPoints = Math.floor(giftCardPoints / 25) * 25;
        cbsjq('.points-gift-cards-value .total').text(giftCardPoints.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
    }

    function updateSliderAriaLabel(obj, sliderValue, mulValue, verb, unit) {
        try {
            if (cbsjq(obj).length > 0) {
                var ariaLabel = cbsjq(obj).find('.ui-slider-handle').attr('aria-label');
                if (ariaLabel.indexOf(':') != -1) {
                    ariaLabel = ariaLabel.substring(0, ariaLabel.indexOf(':'));
                }
                var newAriaLabel = ariaLabel + ': ' + sliderValue + ' dollars ' + verb + ' ' + mulValue + ' ' + unit;
                cbsjq(obj).parent().find('.ui-slider-handle').attr('aria-label', newAriaLabel);
            }
        } catch (e) { }
    }

    function updateForeignAnnually() {
        var points = Math.floor(cbsjq('.foreign-slider').find('.Xpoints').val()) * .03;
        cbsjq('.foreign-total .total').text(Math.ceil(points));
        updateSliderAriaLabel('.foreign-slider', Math.floor(cbsjq('.foreign-slider').find('.Xpoints').val()), Math.ceil(points), 'saves', 'dollars');
    }

    function updateToolTipCloudCoordinate() {
        var currElement = document.activeElement;
        var x = cbsjq(currElement).offset().left;
        var y = cbsjq(currElement).offset().top;
        var el, newPoint, newPlace, offset, siblings, k;
        width = currElement.offsetWidth;
        newPoint = (currElement.value - currElement.getAttribute("min")) / (currElement.getAttribute("max") - currElement.getAttribute("min"));
        offset = -1.3;
        if (newPoint < 0) { newPlace = 0; }
        else if (newPoint > 1) { newPlace = width; }
        else { newPlace = width * newPoint + offset; offset -= newPoint; }
        x = x + newPlace;
        y = y;
        cbsjq("#tooltip-thankyou").css({ top: (y - 55) + "px", left: (x - 47) + "px" });
    }

    bindThankYouPointsSlider("#slider-gas");
    bindThankYouPointsSlider("#slider-travel");
    bindThankYouPointsSlider("#slider-dining");
    bindThankYouPointsSlider("#slider-entertainment");
    bindThankYouPointsSlider("#slider-other");
    bindThankYouPointsSlider("#slider-foreign");

    // Slider for costco page
    bindCostcoPointsSlider("#costco-slider-gas");
    bindCostcoPointsSlider("#costco-slider-travel");
    bindCostcoPointsSlider("#costco-slider-dining");
    bindCostcoPointsSlider("#costco-slider-other");

    if (cbsjq(".html5calculator").length) {
        cbsjq('.option a.ui-slider-handle').tyclouds();
        cbsjq('.html5calculator').tyclouds();
    };
});



var ToolTip = (function(){
	var target = "";
	var origin = "";
	var left = 0;
	var top = 0;
	var width = 0;
	var height = 0;
	var orientation = "vertical";
	var tooltipHovered = false;
	var pageX = 0;
	var pageY = 0;
	var originPosition = '';
	var fixedPosition = '';

	var addListeners = function(){
        cbsjq('.tipOrigin').each(function() {
            if (!cbsjq(this).data('tooltip-bound')) {
                cbsjq(this).data('tooltip-bound',true);
                cbsjq(this).hover(
                    function(e){
                        origin = cbsjq(this);
                        pageX = e.pageX;
                        pageY = e.pageY;
                        cbsjq('.tooltip').hide();
                        cbsjq('.tooltip').stop(true, true);
                        try{
                            target = cbsjq(this).attr('class').split('tip_')[1].split(' ')[0];
                            try {
                                torientation = cbsjq(this).attr('class').split('dir_')[1].split(' ')[0];
                                if (torientation)
                                    orientation = torientation;
                            } catch (e) { orientation = "horizontal"; }
                            
                            try {
                                originPosition = cbsjq(this).attr('class').split('origin_')[1].split(' ')[0];
                                if (!originPosition) {
                                    originPosition = '';
                                } else { //Determine if the menu should be fixed at top, bottom or default
                                    try {
                                        fixedPosition = cbsjq(this).attr('class').split('fixed_')[1].split(' ')[0];
                                    }
                                    catch (e) {
                                        fixedPosition = '';
                                    }
                                }
                            } catch (e) { originPosition = ''; }

                            try {
                                fwidth = cbsjq(this).attr('class').split('dir_')[1].split(' ')[0];
                                if (fwidth)
                                    width = fwidth;
                            } catch (e) { orientation = "horizontal"; }

                            getDimensions();				
                            showTip();
                            if (orientation == 'horizontal') {
                                cbsjq('.'+target).hover(function(){
                                    tooltipHovered = true;
                                }, function(){
                                    origin = cbsjq('.tip_'+target);
                                    hideTip();
                                    tooltipHovered = false;
                                });
                            }
                        }
                        catch(e){}				
                    },
                    function(e){
                        if (orientation == 'horizontal') {
                            setTimeout(function(){
                                if (!tooltipHovered) {
                                    origin = cbsjq(this);
                                    hideTip();
                                }
                            }, 50);
                        }
                        else {
                            origin = cbsjq(this);
                            hideTip();
                        }
                    }
                );
            }
        });
	};
	var getDimensions = function(){
		width = cbsjq('.'+target).data('width') ? cbsjq('.'+target).data('width') : cbsjq('.'+target).width();
        // Cache width
        cbsjq('.'+target).data('width', width);
		height = cbsjq('.'+target).data('height') ? cbsjq('.'+target).data('height') : cbsjq('.'+target).height();
        // Cache height
        cbsjq('.'+target).data('height', height);
	};
	var showTip = function(){
		origin.addClass('toolTipHover');	
		left = origin.position().left;
		top = origin.position().top;
		positionToolTip();
		cbsjq('.'+target).addClass('tooltipContent');
		cbsjq('.'+target).show();//fadeIn(200);		
	};
	var hideTip = function(){
        spike = cbsjq('.spike',cbsjq('.'+target)).get(0);
        if (fixedPosition == '') {
            cbsjq('.' + target).hide();
            try {
                if (spike.parentNode !== null) {
                    var removed = spike.parentNode.removeChild(spike);
                    removed = null;
                }
            } catch (e) { }
            origin.removeClass('toolTipHover');
        } else {
            cbsjq('.' + target).delay(500).fadeOut(500);
        }
	};
	var positionToolTip = function(){
		orientation == 'vertical' ? orientateVertically() : orientateHorizontally();
	};
	var orientateVertically = function(){
		getOffset();
		//cbsjq('.'+target).css('left',origin.offset().left + (origin.width()/2) - cbsjq('#page').offset().left - 25);
		cbsjq('.' + target).css('left', origin.position().left);
		cbsjq('.'+target).css('top', top+60);
	};
	var orientateHorizontally = function(){
		getOffset();
		cbsjq('.'+target).css('left',origin.position().left+50);
		cbsjq('.'+target).css('top',origin.offset().top-48);
	};

	var getOffset = function(){
		if (originPosition == 'fixed') {
			return getOffsetFixed();
		}
		var val = 40;
		var valLeft = 65;
		//left += cbsjq('#page').offset().left + 25;
		
		if(orientation == 'horizontal'){
            outer =cbsjq('.outer', cbsjq('.'+target)).get(0); 
            //if (!cbsjq('.'+target+' .spike').length) {
                spike = document.createElement('div');
                spike.className = 'spike spikeOnLeft';
                spacer = document.createTextNode(String.fromCharCode(160));
                spike.appendChild(spacer);
                outer.appendChild(spike);
            //}
			return;
		}
		else if( Number(origin.offset().top ) - cbsjq(window).scrollTop() < height ){
			left = pageX - cbsjq('#page').offset().left - 25;
			top = pageY;
			top += val;

			if (Number(origin.offset().left ) + cbsjq('#page').offset().left + width > (cbsjq(window).scrollLeft() + cbsjq(window).width())) {
				left -= width;
				left += valLeft;
                outer = cbsjq('.outer', cbsjq('.'+target)).get(0);
                inner = cbsjq('.inner', cbsjq('.'+target)).get(0);
                //if (!cbsjq('.'+target+' .spike').length) {
                    spike = document.createElement('div');
                    spike.className = 'spike spikeAtTopRight';
                    spacer = document.createTextNode(String.fromCharCode(160));
                    spike.appendChild(spacer);
                    outer.insertBefore(spike,inner);
                //}
			}
			else {
                targetEl = cbsjq('.'+target).get(0);
                outer = cbsjq('.'+target+' .outer').get(0);
                //if (!cbsjq('.'+target+' .spike').length) {
                    spike = document.createElement('div');
                    spike.className = 'spike spikeAtTop';
                    spacer = document.createTextNode(String.fromCharCode(160));
                    spike.appendChild(spacer);
                    targetEl.insertBefore(spike,outer);
                //}
				top -= 40;
			}
		}
		else {
			left = pageX - cbsjq('#page').offset().left - 25;
			top = pageY - 45;
			top -= height;
			if (Number(origin.offset().left ) + cbsjq('#page').offset().left + width > (cbsjq(window).scrollLeft() + cbsjq(window).width())) {
				left -= width;
				left += valLeft;
			}
			else {
                outer =cbsjq('.outer', cbsjq('.'+target)).get(0); 
                //if (!cbsjq('.'+target+' .spike').length) {
                    spike = document.createElement('div');
                    spike.className = 'spike spikeAtBottom';
                    spacer = document.createTextNode(String.fromCharCode(160));
                    spike.appendChild(spacer);
                    outer.appendChild(spike);
                //}
			}
		}	
	};
	
	var getOffsetFixed = function() {
		if(orientation == 'horizontal'){
			//setSpike('bottom');
		} 
		/*else if( Number(origin.offset().top ) - cbsjq(window).scrollTop() < height ){
			top += height;
			
			if (Number(origin.offset().left ) + cbsjq('#page').offset().left + width > (cbsjq(window).scrollLeft() + cbsjq(window).width())) {
				left -= width;
				left += 68;
				top += 70;
				setSpike('top-right');
			}
			else {
				setSpike('top');
				top += 50;
				left -= 23;
			}
		} */
		else{
			//	top += 30;
			
		    if (fixedPosition == '') {

		        top = Number(origin.offset().top) - height - 30;

		        if (Number(origin.offset().left) + cbsjq('#page').offset().left + width > (cbsjq(window).scrollLeft() + cbsjq(window).width())) {

		            left -= width;
		            left += 67;
		        }
		        else {
		            outer = cbsjq('.' + target).get(0);
		            //if (!cbsjq('.'+target+' .spike').length) {
		            spike = document.createElement('div');
		            spike.className = 'spike spikeBottom';
		            spacer = document.createTextNode(String.fromCharCode(160));
		            spike.appendChild(spacer);
		            outer.appendChild(spike);
		            //}
		            return;
		            //left -= 4;
		            //setSpike('bottom');
		        }
		    }
		    else {
		            spike = document.createElement('div');
		            spike.className = 'spike spikeAtBottom';
		            outer = cbsjq('.outer', cbsjq('.' + target)).get(0);
		        if (fixedPosition == 'top') {
		            top = Number(origin.offset().top) - (height);
		            //if (!cbsjq('.'+target+' .spike').length) {
		            spacer = document.createTextNode(String.fromCharCode(160));
		            if (cbsjq('.' + target).has(".spike").length == 0) {
		                spike.appendChild(spacer);
		                outer.appendChild(spike);
		            }
		        }
		        else if (fixedPosition == 'bottom') {
		            targetEl = cbsjq('.' + target).get(0);
		            top = Number(origin.offset().top) + cbsjq(origin).height();
		            spike.className = 'spike spikeAtTop';
		            spacer = document.createTextNode(String.fromCharCode(160));
		            if (cbsjq('.' + target).has(".spike").length == 0) {
		                spike.appendChild(spacer);
		                targetEl.insertBefore(spike, outer);
		            }
		        }
		    }

		}	
	};

return{
	init:function(o){
		if(o){orientation = o.orientation;}
		addListeners();
	}	
};
})();

(function($){
    cbsjq.fn.idle = function (time) {
		var i = $(this);
		i.queue(function(){
			setTimeout(function(){
				i.dequeue();
			}, time);
		});
	};
})(cbsjq);


cbsjq(document).ready(function () {
    var flag = false;
    cbsjq('.speedbump').on("click", (function () {
        if (!flag) {
            flag = true;
            setTimeout(function () { flag = false; }, 100);
            setupEnsightenSpeedbumpOpen(cbsjq(this).attr('href'));
            getSpeedbump(cbsjq(this).attr('href'));
        }
        return false;
    }));

});
//to support thank you video

function loadScript(url, callback) {

    var script = document.createElement("script");
    script.type = "text/javascript";

    if (script.readyState) {  //IE
        script.onreadystatechange = function () {
            if (script.readyState == "loaded" ||
                script.readyState == "complete") {
                script.onreadystatechange = null;
                callback();
            }
        };
    } else {  //Others
        script.onload = function () {
            callback();
        };
    }

    script.src = url;
    document.getElementsByTagName("head")[0].appendChild(script);
}

var whoClickedSpeedBump = "";
var openSpeedbumpEnsightenName = "";
function setupEnsightenSpeedbumpOpen(triggerClass) {
    openSpeedbumpEnsightenName = citiData.pageName;
    if (typeof s != "undefined" && typeof s.pagename != "undefined") {
        openSpeedbumpEnsightenName = s.pageName;
    }
    var localPage = window.location.pathname.replace(/\//g, ":");
    citiData.pageName = "BenefitBuilder" + localPage + "-Overlay";
    citiData.localpageName = citiData.pageName;
    if (typeof s != "undefined" && typeof s.pagename != "undefined") {
        s.pageName = citiData.pageName;
    }
    Bootstrapper.ensEvent.trigger('naAnalyticsCardBenefitsPageView');
}
function setupEnsightenSpeedbumpSelect(hrefLocation) {
    window.citiData.custLink = hrefLocation;
    //Bootstrapper.ensEvent.trigger("CardBenefitsCustomLink");
    citiData.pageName = openSpeedbumpEnsightenName;
    citiData.localpageName = openSpeedbumpEnsightenName;
    if (typeof s != "undefined" && typeof s.pagename != "undefined") {
        s.pageName = citiData.pageName;
    }
}
function ensightenSpeedbumpClose() {
    citiData.pageName = openSpeedbumpEnsightenName;
    citiData.localpageName = openSpeedbumpEnsightenName;
    if (typeof s != "undefined" && typeof s.pagename != "undefined") {
        s.pageName = citiData.pageName;
    }
    Bootstrapper.ensEvent.trigger('naAnalyticsCardBenefitsPageView');
}
function getSpeedbump(triggerClass) {
    getSpeedbump(triggerClass, null);
}

function getFocusable(triggerClass) {
    if (cbsjq(document.activeElement).hasClass("speedbump")) {
        return cbsjq(document.activeElement);
    }
    return cbsjq("[href='" + triggerClass + "']");
}
function getSpeedbump(triggerClass, offerCatalogUid) {
    // Element that triggered modal
    //var $triggerElement = cbsjq(Event.currentTarget);
    if (triggerClass) {

        cbsjq(document).off(".panelkeypress");
        whoClickedSpeedBump = getFocusable(triggerClass);
        if (!cbsjq(triggerClass).length) {
            //var jsonData = {
            //    triggerClass: triggerClass
            //};
            //routes.MapRoute("SpeedBump", "speedbumps/getspeedbump.aspx", new { controller = "SpeedBump", action = "GetSpeedbump" });
            //$.ajax({
            //    type: "POST",
            //    contentType: "application/json; charset=utf-8",
            //    url: "/speedbumps/getspeedbump.aspx?url=" + window.location,
            //    data: JSON.stringify(jsonData),
            cbsjq.ajax({
                type: "POST",
                context: this,
                data: { scController: "SpeedBump", scAction: "GetSpeedbump", triggerClass: triggerClass },
                success: function (data) {
                    try {
                        cbsjq('body').append(data.message);
                        if (cbsjq(".O1")[0]) {
                            if (offerCatalogUid) {
                                cbsjq('a.O1').on("click", (function () {
                                    trackOfferCatalogClick(cbsjq(this).prop('href'), "O1", offerCatalogUid + "d", "1");
                                }));
                            }
                        }
                        //if (cbsjq('.btnSecondPartyContinue')[0]) {
                        //    cbsjq('a.btnSecondPartyContinue').on("click", (function () {
                        //        trackOfferCatalogClick(cbsjq(this).prop('href'), "O1", offerCatalogUid + "d", "1");
                        //    }));
                        //}
                    } catch (err) { }

                    /*
                    try{
                    
                        cbsjq('#modal-bodyid').find("script").each(function (i) {
                            eval(cbsjq(this).text());
                        });
                    } catch (err) { }*/

                    cbsjq(triggerClass).modal('show');
                    cbsjq(triggerClass).attr('tabindex', '-1');
                    //doneal remove aria-live polite based on ada defect from ficoscorecorona 202004
                    //cbsjq(triggerClass).attr('aria-live', 'polite');
                    cbsjq(triggerClass).on('shown.bs.modal', function (e) {

                        setTimeout(function () {
                            // ADA - Put focus on dialog and read content
                            var title = cbsjq(triggerClass).find('.modal-title');
                            if (title.length > 0)
                                cbsjq(triggerClass).find('.modal-title').focus();
                            else {
                                var body = cbsjq(triggerClass).find('#modal-bodyid');
                                if (body.length > 0)
                                    cbsjq(triggerClass).find('#modal-bodyid').focus();
                                else
                                    cbsjq('#closebutton').focus();
                            }

                            // ADA - When open, keep tab focus within modal
                            var inputs = cbsjq(triggerClass).find('select, input, textarea, button, a').filter(':visible');
                            var firstInput = inputs[0];
                            var lastInput = inputs[inputs.length - 1];
                            //var modalDoc = document.getElementById(triggerClass);
                            //var arrowDoc = modalDoc.getElementsByClassName("modal-content");

                            cbsjq(document).on('keydown', function (e) {
                                var code = e.keyCode;
                                var currElement = inputs.index(document.activeElement);

                                if ((code == '38' || code == '37') && document.activeElement != firstInput) {
                                    // up arrow
                                    e.preventDefault();
                                    if (currElement < 0) {
                                        cbsjq(lastInput).focus();
                                    } else {
                                        cbsjq(inputs[currElement - 1]).focus();
                                        if (currElement == 1) {
                                            cbsjq('#modal-bodyid').scrollTop(0);
                                        }
                                    }
                                }

                                else if ((code == '40' || code == '39') && document.activeElement != lastInput) {
                                    // down arrow
                                    e.preventDefault();
                                    if (currElement < 0) {
                                        cbsjq(firstInput).focus();
                                        cbsjq('#modal-bodyid').scrollTop(0);
                                    } else {
                                        cbsjq(inputs[currElement + 1]).focus();
                                    }
                                }

                                // Tab + Shift key
                                if (code == '9' && e.shiftKey) {
                                    if (currElement < 0) {
                                        cbsjq(lastInput).focus();
                                    }
                                    if (document.activeElement == firstInput &&
                                        cbsjq('body').hasClass('modal-open')) {
                                        e.preventDefault();
                                        cbsjq(lastInput).focus();
                                    }
                                }
                                // Tab only
                                else if (code == '9' && !e.shiftKey) {
                                    if (currElement < 0) {
                                        cbsjq(firstInput).focus();
                                        cbsjq('#modal-bodyid').scrollTop(0);
                                    }
                                    if (document.activeElement == lastInput &&
                                        cbsjq('body').hasClass('modal-open')) {
                                        e.preventDefault();
                                        cbsjq(firstInput).focus();
                                        cbsjq('#modal-bodyid').scrollTop(0);

                                    }
                                }
                                if (code == '27') {
                                    // escape
                                    e.preventDefault();
                                    setTimeout(function () { whoClickedSpeedBump.focus(); }, 100);
                                    ensightenSpeedbumpClose();
                                }
                            });
                        }, 300);//end
                    });
                    hideModal();
                }
            });
        } else {
            cbsjq(triggerClass).modal('show');
            //hideModal();
        }


        // Hide modal after opening tab to external site
        function hideModal() {
            var hideModalflag = false;
            var ipad = false;
            cbsjq('.btnSecondPartyContinue, .cancel, .close').on("touchend", function (e) {
                ipad = true;
                cbsjq(this).trigger("click");
                setTimeout(function () { whoClickedSpeedBump.focus(); }, 100);
            });


            cbsjq('.btnSecondPartyContinue, .cancel, .close').on("click", function (e) {
                e.preventDefault();
                if (!hideModalflag) {
                    hideModalflag = true;
                    setTimeout(function () { hideModalflag = false; }, 100);
                    // if (!cbsjq(this).hasClass('btnSecondPartyContinue')) {
                    // }
                    cbsjq(this).parents('.modal').modal('hide');
                    cbsjq(document).on('keydown.panelkeypress', HandlePanelKeyPress);
                    // ADA - Return focus back to triggering element on close
                    if (!ipad) {
                        whoClickedSpeedBump.focus();
                    }
                    //window.history.pushState("object or string", "Title", "/" + window.location.href.substring(window.location.href.lastIndexOf('/') + 1).split("?")[0]);
                    if (cbsjq(this).hasClass('btnSecondPartyContinue')) {
                        setupEnsightenSpeedbumpSelect(cbsjq(this).attr('href'));
                        window.open(cbsjq(this).attr('href'), cbsjq(this).attr('target'));
                    } else {
                        ensightenSpeedbumpClose();
                    }
                }
                return false;
            });
            //cbsjq('.btnSecondPartyContinue, .cancel, .close').click(function (e) {
            //    if (!cbsjq(this).hasClass('btnSecondPartyContinue')) {
            //        e.preventDefault();
            //    }
            //    cbsjq(this).parents('.modal').modal('hide');
            //    cbsjq(document).on('keydown.panelkeypress', HandlePanelKeyPress);
            //    // ADA - Return focus back to triggering element on close
            //    whoClickedSpeedBump.focus();
            //    window.history.pushState("object or string", "Title", "/" + window.location.href.substring(window.location.href.lastIndexOf('/') + 1).split("?")[0]);
            //    //cbsjq($triggerElement).focus();
            //});
        }
    }
}
// pop bootstrap speedbump when ?speedbump=id is passed.
function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)", "i"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}
if (/[?&]speedbump=/.test(location.search)) {
    var popsb = getParameterByName('speedbump');
    getSpeedbump('#' + popsb);
    //cbsjq('#' + popsb).modal('show');
}




(function () {
    var animationSupport = false,
        animationString = 'animation',
        vendorPrefix = prefix = '',
        domPrefixes = ['Webkit', 'Moz', 'O', 'ms', 'Khtml'];

    cbsjq(document).ready(function () {
        var style = document.body.style;
        if (style.animationName !== undefined) { animationSupport = true; }

        if (animationSupport === false) {
            for (var i = 0; i < domPrefixes.length; i++) {
                if (style[domPrefixes[i] + 'AnimationName'] !== undefined) {
                    prefix = domPrefixes[i];
                    animationString = prefix + 'Animation';
                    vendorPrefix = '-' + prefix.toLowerCase() + '-';
                    animationSupport = true;
                    break;
                }
            }
        }
    });


    var $createKeyframeStyleTag = function (id, css) {
        if (cbsjq.keyframe.debug) { console.log(id + " " + css); }
        return cbsjq("<style>" + css + "</style>").attr({
            "class": "keyframe-style",
            id: id,
            type: "text/css"
        }).appendTo("head");
    };

    cbsjq.keyframe = {
        debug: false,
        getVendorPrefix: function () {
            return vendorPrefix;
        },
        isSupported: function () {
            return animationSupport;
        },
        generate: function (frameData) {
            var frameName = frameData.name || "";
            var css = "@" + vendorPrefix + "keyframes " + frameName + " {";

            for (var key in frameData) {
                if (key !== "name" && key !== "media" && key !== "complete") {
                    css += key + " {";

                    for (var property in frameData[key]) {
                        css += property + ":" + frameData[key][property] + ";";
                    }

                    css += "}";
                }
            }
            if (window.PrefixFree)
                css = PrefixFree.prefixCSS(css + "}");
            else
                css += "}";
            if (frameData.media) {
                css = "@media " + frameData.media + "{" + css + "}";
            }

            var $frameStyle = cbsjq("style#" + frameData.name);

            if ($frameStyle.length > 0) {
                $frameStyle.html(css);

                var $elems = cbsjq("*").filter(function () {
                    return this.style && this.style[animationString + 'Name'] && this.style[animationString + "Name"] === frameName;
                });

                $elems.each(function () {
                    var $el = cbsjq(this);
                    var options = $el.data("keyframeOptions");
                    $el.resetKeyframe(function () {
                        $el.playKeyframe(options);
                    });
                });
            } else {
                $createKeyframeStyleTag(frameName, css);
            }
        },
        define: function (frameData) {
            if (frameData.length) {
                for (var i = 0; i < frameData.length; i++) {
                    var frame = frameData[i];
                    this.generate(frame);
                }
            } else {
                this.generate(frameData);
            }
        }
    };

    var animationPlayState = "animation-play-state";
    var playStateRunning = "running";

    cbsjq.fn.resetKeyframe = function (callback) {
        var $el = cbsjq(this).css(vendorPrefix + animationPlayState, playStateRunning).css(vendorPrefix + "animation", "none");

        if (callback) {
            setTimeout(callback, 1);
        }
    };

    cbsjq.fn.pauseKeyframe = function () {
        cbsjq(this).css(vendorPrefix + animationPlayState, "paused");
    };

    cbsjq.fn.resumeKeyframe = function () {
        cbsjq(this).css(vendorPrefix + animationPlayState, playStateRunning);
    };

    cbsjq.fn.playKeyframe = function (frameOptions, callback) {

        var animObjToStr = function (obj) {
            obj = cbsjq.extend({
                duration: '0s',
                timingFunction: "ease",
                delay: '0s',
                iterationCount: 1,
                direction: "normal",
                fillMode: "forwards"
            }, obj);
            return [obj.name, obj.duration, obj.timingFunction, obj.delay, obj.iterationCount, obj.direction, obj.fillMode].join(" ");
        };

        var animationcss = "";

        if (cbsjq.isArray(frameOptions)) {
            var frameOptionsStrings = [];
            for (var i = 0; i < frameOptions.length; i++) {
                if (typeof frameOptions[i] === 'string') {
                    frameOptionsStrings.push(frameOptions[i]);
                } else {
                    frameOptionsStrings.push(animObjToStr(frameOptions[i]));
                }
            }
            animationcss = frameOptionsStrings.join(", ");
        } else if (typeof frameOptions === 'string') {
            animationcss = frameOptions;
        } else {
            animationcss = animObjToStr(frameOptions);
        }

        var animationkey = vendorPrefix + "animation";
        var pfx = ["webkit", "moz", "MS", "o", ""];

        if (!callback && frameOptions.complete) {
            callback = frameOptions.complete;
        }

        var _prefixEvent = function (element, type, callback) {
            for (var i = 0; i < pfx.length; i++) {
                if (!pfx[i]) {
                    type = type.toLowerCase();
                }
                var evt = pfx[i] + type;
                element.off(evt).on(evt, callback);
            }
        };

        this.each(function () {
            var $el = cbsjq(this).addClass("boostKeyframe").css(vendorPrefix + animationPlayState, playStateRunning).css(animationkey, animationcss).data("keyframeOptions", frameOptions);
            if (cbsjq.keyframe.debug) {
                console.group();
                if (vendorPrefix) { console.log("Vendor Prefix: " + vendorPrefix); }
                console.log("Style Applied: " + animationcss);
                var testCss = $el.css(animationkey);
                console.log("Rendered Style: " + (testCss ? testCss : $el[0].style.animation));
                console.groupEnd();
            }
            if (callback) {
                _prefixEvent($el, 'AnimationIteration', callback);
                _prefixEvent($el, 'AnimationEnd', callback);
            }
        });
        return this;
    };

    $createKeyframeStyleTag("boost-keyframe", " .boostKeyframe{" + vendorPrefix + "transform:scale3d(1,1,1);}");

}).call(this);
/*!
 * jQuery DOM Line plugin v0.1.3
 * Copyright (c) 2011 Gilmore Davidson
 * https://gilmoreorless.github.com/jquery-dom-line/
 *
 * @license Open source under the MIT licence: http://gilmoreorless.mit-license.org/2011/
 */
!function(t,e){function r(t){return t.x===e&&t.y===e?!1:(t.x=parseFloat(t.x)||0,t.y=parseFloat(t.y)||0,t)}function a(e,r,a){var n=[e.x,e.y,r.x,r.y,a.w,a.h].join(",");if(o[n])return t.extend({},o[n]);var i,s=Math.abs(r.x-e.x),l=Math.abs(r.y-e.y),h=s&&l?Math.sqrt(s*s+l*l):s||l,d=Math.min(e.x,r.x),u=Math.min(e.y,r.y),x=d+s/2,c=u+l/2,p=x-h/2,y=c,b=o[n]={width:h};return a.w>1&&(b.width-=a.w-1),a.h>1&&(y-=a.h/2),a.bw&&(p+=a.bw/2),a.bh&&(y+=a.bh/2),t.support.matrixFilter||(p-=a.l,y-=a.t),p=Math.round(p),y=Math.round(y),b.width=Math.round(b.width),i=s?l?(180+180*Math.atan2(e.y-r.y,e.x-r.x)/Math.PI+360)%360:e.x<r.x?0:180:e.y<r.y?90:270,b.transform="rotate("+i+"deg)",b.left=p,b.top=y,b.extra={center:{x:x,y:c},rotation:{deg:i,rad:i%360*Math.PI/180}},t.extend({},b)}var o={};t.line=function(e,o,n){if(e=r(e),o=r(o),!e||!o)return!1;var i,s,l,h=t.extend({},t.line.defaults,n||{}),d=h.elem?t(h.elem):t("<div/>",{"class":h.className}),u={position:"absolute",backgroundColor:h.lineColor,width:1,height:h.lineWidth},x=d;return d.css(u),d.length&&!d[0].parentNode&&d.appendTo("body"),s={w:d.outerWidth(),h:d.outerHeight(),l:parseFloat(d.css("marginLeft"))||0,t:parseFloat(d.css("marginTop"))||0},t.support.matrixFilter&&(s.bw=(parseFloat(d.css("borderLeftWidth"))||0)+(parseFloat(d.css("borderRightWidth"))||0),s.bh=(parseFloat(d.css("borderTopWidth"))||0)+(parseFloat(d.css("borderBottomWidth"))||0)),i=a(e,o,s),l=i.extra,delete i.extra,d.css(i),h.returnValues&&(x={from:e,to:o,center:l.center,rotation:l.rotation}),x},t.line.defaults={elem:"",className:"jquery-line",lineWidth:1,lineColor:"#000",returnValues:!1}}(cbsjq);
/*
 * transform: A jQuery cssHooks adding cross-browser 2d transform capabilities to $.fn.css() and $.fn.animate()
 *
 * limitations:
 * - requires jQuery 1.4.3+
 * - Should you use the *translate* property, then your elements need to be absolutely positionned in a relatively positionned wrapper **or it will fail in IE678**.
 * - transformOrigin is not accessible
 *
 * latest version and complete README available on Github:
 * https://github.com/louisremi/jquery.transform.js
 *
 * Copyright 2011 @louis_remi
 * Licensed under the MIT license.
 *
 * This saved you an hour of work?
 * Send me music http://www.amazon.co.uk/wishlist/HNTU0468LQON
 *
 */
if(!cbsjq.cssHooks.transform)!function(t,e,r,s,n){function a(e){e=e.split(")");var r,n,a,i=t.trim,o=-1,c=e.length-1,p=O?new Float32Array(6):[],l=O?new Float32Array(6):[],f=O?new Float32Array(6):[1,0,0,1,0,0];for(p[0]=p[3]=f[0]=f[3]=1,p[1]=p[2]=p[4]=p[5]=0;++o<c;){switch(r=e[o].split("("),n=i(r[0]),a=r[1],l[0]=l[3]=1,l[1]=l[2]=l[4]=l[5]=0,n){case Y+"X":l[4]=parseInt(a,10);break;case Y+"Y":l[5]=parseInt(a,10);break;case Y:a=a.split(","),l[4]=parseInt(a[0],10),l[5]=parseInt(a[1]||0,10);break;case j:a=u(a),l[0]=s.cos(a),l[1]=s.sin(a),l[2]=-s.sin(a),l[3]=s.cos(a);break;case H+"X":l[0]=+a;break;case H+"Y":l[3]=a;break;case H:a=a.split(","),l[0]=a[0],l[3]=a.length>1?a[1]:a[0];break;case $+"X":l[2]=s.tan(u(a));break;case $+"Y":l[1]=s.tan(u(a));break;case z:a=a.split(","),l[0]=a[0],l[1]=a[1],l[2]=a[2],l[3]=a[3],l[4]=parseInt(a[4],10),l[5]=parseInt(a[5],10)}f[0]=p[0]*l[0]+p[2]*l[1],f[1]=p[1]*l[0]+p[3]*l[1],f[2]=p[0]*l[2]+p[2]*l[3],f[3]=p[1]*l[2]+p[3]*l[3],f[4]=p[0]*l[4]+p[2]*l[5]+p[4],f[5]=p[1]*l[4]+p[3]*l[5]+p[5],p=[f[0],f[1],f[2],f[3],f[4],f[5]]}return f}function i(t){var e,r,n,a=t[0],i=t[1],o=t[2],c=t[3];return a*c-i*o?(e=s.sqrt(a*a+i*i),a/=e,i/=e,n=a*o+i*c,o-=a*n,c-=i*n,r=s.sqrt(o*o+c*c),o/=r,c/=r,n/=r,i*o>a*c&&(a=-a,i=-i,n=-n,e=-e)):e=r=n=0,[[Y,[+t[4],+t[5]]],[j,s.atan2(i,a)],[$+"X",s.atan(n)],[H,[e,r]]]}function o(e,r){var s,n,o,u,m={start:[],end:[]},x=-1;if(("none"==e||p(e))&&(e=""),("none"==r||p(r))&&(r=""),e&&r&&!r.indexOf("matrix")&&g(e).join()==g(r.split(")")[0]).join()&&(m.origin=e,e="",r=r.slice(r.indexOf(")")+1)),e||r){if(e&&r&&l(e)!=l(r))m.start=i(a(e)),m.end=i(a(r));else for(e&&(e=e.split(")"))&&(s=e.length),r&&(r=r.split(")"))&&(s=r.length);++x<s-1;)e[x]&&(n=e[x].split("(")),r[x]&&(o=r[x].split("(")),u=t.trim((n||o)[0]),f(m.start,c(u,n?n[1]:0)),f(m.end,c(u,o?o[1]:0));return m}}function c(t,e){var r,s=+!t.indexOf(H),n=t.replace(/e[XY]/,"e");switch(t){case Y+"Y":case H+"Y":e=[s,e?parseFloat(e):s];break;case Y+"X":case Y:case H+"X":r=1;case H:e=e?(e=e.split(","))&&[parseFloat(e[0]),parseFloat(e.length>1?e[1]:t==H?r||e[0]:s+"")]:[s,s];break;case $+"X":case $+"Y":case j:e=e?u(e):0;break;case z:return i(e?g(e):[1,0,0,1,0,0])}return[[n,e]]}function p(t){return v.test(t)}function l(t){return t.replace(/(?:\([^)]*\))|\s/g,"")}function f(t,e,r){for(;r=e.shift();)t.push(r)}function u(t){return~t.indexOf("deg")?parseInt(t,10)*(2*s.PI/360):~t.indexOf("grad")?parseInt(t,10)*(s.PI/200):parseFloat(t)}function g(t){return t=/([^,]*),([^,]*),([^,]*),([^,]*),([^,p]*)(?:px)?,([^)p]*)(?:px)?/.exec(t),[t[1],t[2],t[3],t[4],t[5],t[6]]}for(var m,x,d,k,h=r.createElement("div"),y=h.style,b="Transform",I=["O"+b,"ms"+b,"Webkit"+b,"Moz"+b],M=I.length,O=("Float32Array"in e),X=/Matrix([^)]*)/,v=/^\s*matrix\(\s*1\s*,\s*0\s*,\s*0\s*,\s*1\s*(?:,\s*0(?:px)?\s*){2}\)\s*$/,w="transform",F="transformOrigin",Y="translate",j="rotate",H="scale",$="skew",z="matrix";M--;)I[M]in y&&(t.support[w]=m=I[M],t.support[F]=m+"Origin");m||(t.support.matrixFilter=x=""===y.filter),t.cssNumber[w]=t.cssNumber[F]=!0,m&&m!=w?(t.cssProps[w]=m,t.cssProps[F]=m+"Origin",m=="Moz"+b?d={get:function(e,r){return r?t.css(e,m).split("px").join(""):e.style[m]},set:function(t,e){t.style[m]=/matrix\([^)p]*\)/.test(e)?e.replace(/matrix((?:[^,]*,){4})([^,]*),([^)]*)/,z+"$1$2px,$3px"):e}}:/^1\.[0-5](?:\.|$)/.test(t.fn.jquery)&&(d={get:function(e,r){return r?t.css(e,m.replace(/^ms/,"Ms")):e.style[m]}})):x&&(d={get:function(e,r,s){var a,i,o=r&&e.currentStyle?e.currentStyle:e.style;return o&&X.test(o.filter)?(a=RegExp.$1.split(","),a=[a[0].split("=")[1],a[2].split("=")[1],a[1].split("=")[1],a[3].split("=")[1]]):a=[1,0,0,1],t.cssHooks[F]?(i=t._data(e,"transformTranslate",n),a[4]=i?i[0]:0,a[5]=i?i[1]:0):(a[4]=o?parseInt(o.left,10)||0:0,a[5]=o?parseInt(o.top,10)||0:0),s?a:z+"("+a+")"},set:function(e,r,s){var n,i,o,c,p=e.style;s||(p.zoom=1),r=a(r),i=["Matrix(M11="+r[0],"M12="+r[2],"M21="+r[1],"M22="+r[3],"SizingMethod='auto expand'"].join(),o=(n=e.currentStyle)&&n.filter||p.filter||"",p.filter=X.test(o)?o.replace(X,i):o+" progid:DXImageTransform.Microsoft."+i+")",t.cssHooks[F]?t.cssHooks[F].set(e,r):((c=t.transform.centerOrigin)&&(p["margin"==c?"marginLeft":"left"]=-(e.offsetWidth/2)+e.clientWidth/2+"px",p["margin"==c?"marginTop":"top"]=-(e.offsetHeight/2)+e.clientHeight/2+"px"),p.left=r[4]+"px",p.top=r[5]+"px")}}),d&&(t.cssHooks[w]=d),k=d&&d.get||t.css,t.fx.step.transform=function(e){var r,n,a,i,c=e.elem,p=e.start,l=e.end,f=e.pos,u="",g=1e5;for(p&&"string"!=typeof p||(p||(p=k(c,m)),x&&(c.style.zoom=1),l=l.split("+=").join(p),t.extend(e,o(p,l)),p=e.start,l=e.end),r=p.length;r--;)switch(n=p[r],a=l[r],i=0,n[0]){case Y:i="px";case H:i||(i=""),u=n[0]+"("+s.round((n[1][0]+(a[1][0]-n[1][0])*f)*g)/g+i+","+s.round((n[1][1]+(a[1][1]-n[1][1])*f)*g)/g+i+")"+u;break;case $+"X":case $+"Y":case j:u=n[0]+"("+s.round((n[1]+(a[1]-n[1])*f)*g)/g+"rad)"+u}e.origin&&(u=e.origin+u),d&&d.set?d.set(c,u,1):c.style[m]=u},t.transform={centerOrigin:"margin"}}(cbsjq,window,document,Math);
/*
	countUp.js
	by @inorganik
*/

// target = id of html element or var of previously selected html element where counting occurs
// startVal = the value you want to begin at
// endVal = the value you want to arrive at
// decimals = number of decimal places, default 0
// duration = duration of animation in seconds, default 2
// options = optional object of options (see below)

var CountUp = function (target, startVal, endVal, decimals, duration, options) {

    var self = this;
    self.version = function () { return '1.9.3'; };

    // default options
    self.options = {
        useEasing: true, // toggle easing
        useGrouping: true, // 1,000,000 vs 1000000
        separator: ',', // character to use as a separator
        decimal: '.', // character to use as a decimal
        easingFn: easeOutExpo, // optional custom easing function, default is Robert Penner's easeOutExpo
        formattingFn: formatNumber, // optional custom formatting function, default is formatNumber above
        prefix: '', // optional text before the result
        suffix: '', // optional text after the result
        numerals: [] // optionally pass an array of custom numerals for 0-9
    };

    // extend default options with passed options object
    if (options && typeof options === 'object') {
        for (var key in self.options) {
            if (options.hasOwnProperty(key) && options[key] !== null) {
                self.options[key] = options[key];
            }
        }
    }

    if (self.options.separator === '') {
        self.options.useGrouping = false;
    }
    else {
        // ensure the separator is a string (formatNumber assumes this)
        self.options.separator = '' + self.options.separator;
    }

    // make sure requestAnimationFrame and cancelAnimationFrame are defined
    // polyfill for browsers without native support
    // by Opera engineer Erik Möller
    var lastTime = 0;
    var vendors = ['webkit', 'moz', 'ms', 'o'];
    for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
        window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
        window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
    }
    if (!window.requestAnimationFrame) {
        window.requestAnimationFrame = function (callback, element) {
            var currTime = new Date().getTime();
            var timeToCall = Math.max(0, 16 - (currTime - lastTime));
            var id = window.setTimeout(function () { callback(currTime + timeToCall); }, timeToCall);
            lastTime = currTime + timeToCall;
            return id;
        };
    }
    if (!window.cancelAnimationFrame) {
        window.cancelAnimationFrame = function (id) {
            clearTimeout(id);
        };
    }

    function formatNumber(num) {
        var neg = (num < 0),
        	x, x1, x2, x3, i, len;
        num = Math.abs(num).toFixed(self.decimals);
        num += '';
        x = num.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? self.options.decimal + x[1] : '';
        if (self.options.useGrouping) {
            x3 = '';
            for (i = 0, len = x1.length; i < len; ++i) {
                if (i !== 0 && ((i % 3) === 0)) {
                    x3 = self.options.separator + x3;
                }
                x3 = x1[len - i - 1] + x3;
            }
            x1 = x3;
        }
        // optional numeral substitution
        if (self.options.numerals.length) {
            x1 = x1.replace(/[0-9]/g, function (w) {
                return self.options.numerals[+w];
            })
            x2 = x2.replace(/[0-9]/g, function (w) {
                return self.options.numerals[+w];
            })
        }
        return (neg ? '-' : '') + self.options.prefix + x1 + x2 + self.options.suffix;
    }
    // Robert Penner's easeOutExpo
    function easeOutExpo(t, b, c, d) {
        return c * (-Math.pow(2, -10 * t / d) + 1) * 1024 / 1023 + b;
    }
    function ensureNumber(n) {
        return (typeof n === 'number' && !isNaN(n));
    }

    self.initialize = function () {
        if (self.initialized) return true;

        self.error = '';
        self.d = (typeof target === 'string') ? document.getElementById(target) : target;
        if (!self.d) {
            self.error = '[CountUp] target is null or undefined'
            return false;
        }
        self.startVal = Number(startVal);
        self.endVal = Number(endVal);
        // error checks
        if (ensureNumber(self.startVal) && ensureNumber(self.endVal)) {
            self.decimals = Math.max(0, decimals || 0);
            self.dec = Math.pow(10, self.decimals);
            self.duration = Number(duration) * 1000 || 2000;
            self.countDown = (self.startVal > self.endVal);
            self.frameVal = self.startVal;
            self.initialized = true;
            return true;
        }
        else {
            self.error = '[CountUp] startVal (' + startVal + ') or endVal (' + endVal + ') is not a number';
            return false;
        }
    };

    // Print value to target
    self.printValue = function (value) {
        var result = self.options.formattingFn(value);

        if (self.d.tagName === 'INPUT') {
            this.d.value = result;
        }
        else if (self.d.tagName === 'text' || self.d.tagName === 'tspan') {
            this.d.textContent = result;
        }
        else {
            this.d.innerHTML = result;
        }
    };

    self.count = function (timestamp) {

        if (!self.startTime) { self.startTime = timestamp; }

        self.timestamp = timestamp;
        var progress = timestamp - self.startTime;
        self.remaining = self.duration - progress;

        // to ease or not to ease
        if (self.options.useEasing) {
            if (self.countDown) {
                self.frameVal = self.startVal - self.options.easingFn(progress, 0, self.startVal - self.endVal, self.duration);
            } else {
                self.frameVal = self.options.easingFn(progress, self.startVal, self.endVal - self.startVal, self.duration);
            }
        } else {
            if (self.countDown) {
                self.frameVal = self.startVal - ((self.startVal - self.endVal) * (progress / self.duration));
            } else {
                self.frameVal = self.startVal + (self.endVal - self.startVal) * (progress / self.duration);
            }
        }

        // don't go past endVal since progress can exceed duration in the last frame
        if (self.countDown) {
            self.frameVal = (self.frameVal < self.endVal) ? self.endVal : self.frameVal;
        } else {
            self.frameVal = (self.frameVal > self.endVal) ? self.endVal : self.frameVal;
        }

        // decimal
        self.frameVal = Math.round(self.frameVal * self.dec) / self.dec;

        // format and print value
        self.printValue(self.frameVal);

        // whether to continue
        if (progress < self.duration) {
            self.rAF = requestAnimationFrame(self.count);
        } else {
            if (self.callback) self.callback();
        }
    };
    // start your animation
    self.start = function (callback) {
        if (!self.initialize()) return;
        self.callback = callback;
        self.rAF = requestAnimationFrame(self.count);
    };
    // toggles pause/resume animation
    self.pauseResume = function () {
        if (!self.paused) {
            self.paused = true;
            cancelAnimationFrame(self.rAF);
        } else {
            self.paused = false;
            delete self.startTime;
            self.duration = self.remaining;
            self.startVal = self.frameVal;
            requestAnimationFrame(self.count);
        }
    };
    // reset to startVal so animation can be run again
    self.reset = function () {
        self.paused = false;
        delete self.startTime;
        self.initialized = false;
        if (self.initialize()) {
            cancelAnimationFrame(self.rAF);
            self.printValue(self.startVal);
        }
    };
    // pass a new endVal and start animation
    self.update = function (newEndVal) {
        if (!self.initialize()) return;
        newEndVal = Number(newEndVal);
        if (!ensureNumber(newEndVal)) {
            self.error = '[CountUp] update() - new endVal is not a number: ' + newEndVal;
            return;
        }
        self.error = '';
        if (newEndVal === self.frameVal) return;
        cancelAnimationFrame(self.rAF);
        self.paused = false;
        delete self.startTime;
        self.startVal = self.frameVal;
        self.endVal = newEndVal;
        self.countDown = (self.startVal > self.endVal);
        self.rAF = requestAnimationFrame(self.count);
    };

    // format startVal on initialization
    if (self.initialize()) self.printValue(self.startVal);
};
cbsjq(function ($) {
    if ($("#myCarousel.P1")[0]) {
        setCatalogOffer("first", "fast");
        $('.carousel-control').on("click", (function () { setCatalogOffer($(this).prop('class'), "slow");}));
    }
    if ($(".large-promo-banner")[0]) {
        $('.large-promo-banner a').on("click", (function () { trackOfferCatalogClick($(this).prop('href'),"P2",null,null); }));
    }
    if ($(".featured-benefits-pod")[0]) {
        $('.featured-benefits-pod a').on("click", (function () { trackOfferCatalogClick($(this).prop('href'), "P3",$(this).prop('id'),$(this).prop('class')); }));
    }
    if ($(".featured-benefits-mob")[0]) {
        $('.featured-benefits-mob a').on("click", (function () { trackOfferCatalogClick($(this).prop('href'), "P3", $(this).prop('id'), $(this).prop('class')); }));
    }
});

function setCatalogOffer(myclass, speed) {

    cbsjq.ajax({
        type: "POST",
        context: this,
        data: { scController: "Ads", scAction: "GetP1Offer", classname: myclass },
        success: function (data) {

            if (speed === "fast") {
                cbsjq('.carousel-content').html(data.offerText);
            } else {
                cbsjq('.carousel-content').hide().html(data.offerText).fadeIn('slow');
            }

            if (data.count < 1) {
                cbsjq('.promo-carousel').hide();
            }
            else if (data.count == 1) {
                cbsjq('.promo-carousel').find('.carousel-control').hide();
            }

            cbsjq('.carousel-content a').on('click', function () { trackP1OfferCatalogClick("P1"); });
        },
        error: function (data) {
            cbsjq('.promo-carousel.row').hide();
        }
    });
}

function trackP1OfferCatalogClick(location) {
    cbsjq.ajax({
        type: "POST",
        context: this,
        data: { scController: "Ads", scAction: "TrackP1OfferClick" },
        success: function (data) {
        }
    });
}

function trackOfferCatalogClick(href, loc, uid, pos) {    
    if (href != null && uid != null && pos != null) {
        uid = uid.substring(0, uid.length - 1);
        if (href.indexOf("?") !== -1) {
            href += "&OCUID=" + uid + "&OCPOS=" + pos;
        } else {
            href += "?OCUID=" + uid + "&OCPOS=" + pos;
        }
    }
    cbsjq.ajax({
        type: "POST",
        context: this,
        data: { scController: "Ads", scAction: "TrackOfferClick", href:href, location: loc},
        success: function (data) {
        }
    });
}


cbsjq(document).ready(function () {
    //$('#fico-score-svg .fico-score-meter').css('stroke-dashoffset', 1474);
    //if ($login_level && $login_level == "3") {
    //    cbsjq('.breadcrumb').css('height', '65.2px'); //fico score wheel issue (29.4 + 35.8(hieight of citi header botton extension)
    //}


    if (cbsjq('#fico-score-svg')) {
        setTimeout(function () {
            cbsjq('#dot').css('visibility', 'visible');
            cbsjq('#fico-score-svg .fico-score-meter').css('stroke-dashoffset', 1474);
            cbsjq('#fico-score-svg').css('visibility', 'visible');
            cbsjq('.fico-score-wheel').css('display', 'block');
            animateFicoScore(cbsjq('#fico-score-value').attr('value'));
        }, 1800);
        //setFicoGraphLines(6);

    }

});

// check on window load for the meter svg
cbsjq(window).load(function () {
    //cbsjq('#fico-score-svg').css('visibility', 'visible');
    //cbsjq('.fico-score-number').css('visibility', 'visible');
    // cbsjq('#dot').css('visibility', 'visible');
    //  cbsjq('#fico-score-svg .fico-score-meter').css('stroke-dashoffset', 1474);

    if (cbsjq('#fico-score-svg')) {
        //animateFicoScore(cbsjq('#fico-score-value').attr('value'));
        //setTimeout(function(){animateFicoScore(cbsjq('#fico-score-value').attr('value'));},2000);
        setFicoGraphLines(6);
    }
});

function calcStrokeOffsetRange(score, minScoreInRange, startOffset, lengthFactor) {
    return startOffset - ((score - minScoreInRange) * lengthFactor);
}

// Calculate stroke offset by score
function calcStrokeOffset(score) {
    score = parseInt(score);

    if (250 <= score && score < 580) {
        return calcStrokeOffsetRange(score, 250, 1474, 1.04);
    }
    else if (score < 670) {
        return calcStrokeOffsetRange(score, 580, 1133, 2.7);
    }
    else if (score < 740) {
        return calcStrokeOffsetRange(score, 670, 893, 3.97);
    }
    else if (score < 800) {
        return calcStrokeOffsetRange(score, 740, 619, 4.2);
    }
    else if (score <= 900) {
        return calcStrokeOffsetRange(score, 800, 371, 3.31);
    }
    else {
        alert("Invalid score- score must be between 250 and 900");
        return;
    }
}

// FICO score meter animation
function animateFicoScore(score, timeInMs) {
    cbsjq('.fico-score-number').css('visibility', 'visible');

    if (!timeInMs) { timeInMs = 700; }

    var timeInSec = (timeInMs / 1000).toFixed(1);

    if (!score && score !== 0) { return; }

    var totalLength = 1474;

    var strokeOffset = calcStrokeOffset(score);

    // 294 = range of degrees (-148 -> +146), 1474 = total stroke
    var angle = Math.floor(((1474 - strokeOffset) * (294 / 1474)) - 148) + 'deg';

    var options2 = {
        useEasing: false,
        useGrouping: true,
        separator: ',',
        decimal: '.',
        prefix: '',
        suffix: ''
    };

    var scoreCount = new CountUp("fico-score-number-countup", 250, score, 0, .7, options2);

    if (detectIEAndEdge()) {

        cbsjq('#dot').css('transform', 'rotate(-148deg)');

        // start animations at same time
        (function () {

            scoreCount.start();

            cbsjq('#fico-score-svg .fico-score-meter').animate({
                'stroke-dashoffset': strokeOffset
            }, { duration: timeInMs, queue: false });

            cbsjq('#dot').animate({
                'transform': 'rotate(' + angle + ')'
            }, { duration: timeInMs, queue: false });


        })();

    } else {

        cbsjq.keyframe.define({
            name: 'fico-score',
            from: {
                'stroke-dashoffset': totalLength
            },
            to: {
                'stroke-dashoffset': strokeOffset
            }
        });

        cbsjq.keyframe.define({
            name: 'fico-dot',
            from: {
                'transform': 'rotate(-148deg)'
            },
            to: {
                'transform': 'rotate(' + angle + ')'
            }
        });

        scoreCount.start();

        cbsjq('.fico-score-meter').playKeyframe({
            name: 'fico-score',
            duration: timeInSec + 's',
            timingFunction: 'linear',
            delay: '0s',
            direction: 'normal'
        });

        cbsjq('#dot').playKeyframe({
            name: 'fico-dot',
            duration: timeInSec + 's',
            timingFunction: 'linear',
            delay: '0s',
            direction: 'normal'
        });
    }


}

// fico graph line functionality based on graph tab container and offsets
function setFicoGraphLines(height) {

    var $dataPtsContainer = cbsjq('.fico-graph-panel');
    var first = true;
    // if 'lines-active' flag not set
    if (!$dataPtsContainer.hasClass('lines-active')) {
        var xOffset;
        var yOffset;
        var colOffset;

        // lines: go through each [data-point, data-point+1] and draw connecting lines where applicable
        var $dataPtsColumns = $dataPtsContainer.find('.graph-col');
        for (var i = 0; i < $dataPtsColumns.length - 1; i++) {

            // if current index is last index, return (no more lines to connect)
            if (i === $dataPtsColumns.length - 1) {
                return;
            }
            // if column has no data-point, continue without drawing line
            var $dataPt = cbsjq($dataPtsColumns[i]).find('.data-point');
            if ($dataPt.length < 1) {
                continue;
            }

            // if next column has no data-point, continue without drawing line
            var $dataPtNxt = cbsjq($dataPtsColumns[i + 1]).find('.data-point');
            if ($dataPtNxt.length < 1) {
                continue;
            }

            // get graph point [x,y] offset so that the line starts in the middle of the graph point
            var dataPtWidthOffset = $dataPt.width() / 2;
            var dataPtNxtWidthOffset = $dataPtNxt.width() / 2;
            var dataPtHeightOffset = $dataPt.height() / 2;
            var dataPtNxtHeightOffset = $dataPtNxt.height() / 2;

            // keep other lines relative to the starting point
            //if (i == 0) {
            if (first) {
                xOffset = $dataPt.offset().left;
                yOffset = cbsjq('.fico-graph-inner').offset().top;
                var colOffset = $dataPtsContainer.find('.graph-col').first().css('margin-left');
                if (i > 0) {
                    var marginLeftSize = parseInt(colOffset, 10);
                    secondcolOffset = cbsjq($dataPtsContainer.find('.graph-col')[1]).css('margin-left');
                    var marginBetweenSize = parseInt(secondcolOffset, 10);
                    for (var a = 0; a < i; a++) {
                        marginLeftSize += marginBetweenSize;
                    }
                    colOffset = marginLeftSize + 'px';
                }
                first = false;
            }

            // get current and next data pts x and y coordinates, relative to the container
            var x1 = ($dataPt.offset().left - xOffset + 3); // - $dataPtsContainer.offset().left;
            var x2 = ($dataPtNxt.offset().left - xOffset + 3); // - $dataPtsContainer.offset().left;
            var y1 = ($dataPt.offset().top - yOffset + dataPtHeightOffset); //- $dataPtsContainer.offset().top;
            var y2 = ($dataPtNxt.offset().top - yOffset + dataPtNxtHeightOffset); // - $dataPtsContainer.offset().top;                
            // draw connecting line
            $dataPtsContainer.find('.fico-graph-inner').append(cbsjq.line({ x: x1, y: y1 }, { x: x2, y: y2 }, { className: 'fico-line' }).css('margin-left', colOffset));
        }
        // set flag
        $dataPtsContainer.addClass('lines-active');
    }
}

// detect IE11 & Edge for Jquery animation vs css animation
// https://codepen.io/gapcode/pen/vEJNZN?editors=0010
function detectIEAndEdge() {
    var ua = window.navigator.userAgent;
    var msie = ua.indexOf('MSIE ');
    var trident = ua.indexOf('Trident/');
    var edge = ua.indexOf('Edge/');

    return msie > 0 || trident > 0 || edge > 0;
}



