/*! jQuery v3.2.1 | (c) JS Foundation and other contributors | jquery.org/license */
!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.2.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c<b?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:h,sort:c.sort,splice:c.splice},r.extend=r.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||r.isFunction(g)||(g={}),h===i&&(g=this,h--);h<i;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(r.isPlainObject(d)||(e=Array.isArray(d)))?(e?(e=!1,f=c&&Array.isArray(c)?c:[]):f=c&&r.isPlainObject(c)?c:{},g[b]=r.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},r.extend({expando:"jQuery"+(q+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===r.type(a)},isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){var b=r.type(a);return("number"===b||"string"===b)&&!isNaN(a-parseFloat(a))},isPlainObject:function(a){var b,c;return!(!a||"[object Object]"!==k.call(a))&&(!(b=e(a))||(c=l.call(b,"constructor")&&b.constructor,"function"==typeof c&&m.call(c)===n))},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?j[k.call(a)]||"object":typeof a},globalEval:function(a){p(a)},camelCase:function(a){return a.replace(t,"ms-").replace(u,v)},each:function(a,b){var c,d=0;if(w(a)){for(c=a.length;d<c;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(s,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(w(Object(a))?r.merge(c,"string"==typeof a?[a]:a):h.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:i.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;d<c;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;f<g;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,f=0,h=[];if(w(a))for(d=a.length;f<d;f++)e=b(a[f],f,c),null!=e&&h.push(e);else for(f in a)e=b(a[f],f,c),null!=e&&h.push(e);return g.apply([],h)},guid:1,proxy:function(a,b){var c,d,e;if("string"==typeof b&&(c=a[b],b=a,a=c),r.isFunction(a))return d=f.call(arguments,2),e=function(){return a.apply(b||this,d.concat(f.call(arguments)))},e.guid=a.guid=a.guid||r.guid++,e},now:Date.now,support:o}),"function"==typeof Symbol&&(r.fn[Symbol.iterator]=c[Symbol.iterator]),r.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){j["[object "+b+"]"]=b.toLowerCase()});function w(a){var b=!!a&&"length"in a&&a.length,c=r.type(a);return"function"!==c&&!r.isWindow(a)&&("array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a)}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",M="\\["+K+"*("+L+")(?:"+K+"*([*^$|!~]?=)"+K+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+L+"))|)"+K+"*\\]",N=":("+L+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+M+")*)|.*)\\)|)",O=new RegExp(K+"+","g"),P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+N),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),aa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ba=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ca=function(a,b){return b?"\0"===a?"\ufffd":a.slice(0,-1)+"\\"+a.charCodeAt(a.length-1).toString(16)+" ":"\\"+a},da=function(){m()},ea=ta(function(a){return a.disabled===!0&&("form"in a||"label"in a)},{dir:"parentNode",next:"legend"});try{G.apply(D=H.call(v.childNodes),v.childNodes),D[v.childNodes.length].nodeType}catch(fa){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s=b&&b.ownerDocument,w=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==w&&9!==w&&11!==w)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==w&&(l=Z.exec(a)))if(f=l[1]){if(9===w){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(s&&(j=s.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(l[2])return G.apply(d,b.getElementsByTagName(a)),d;if((f=l[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==w)s=b,r=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(ba,ca):b.setAttribute("id",k=u),o=g(a),h=o.length;while(h--)o[h]="#"+k+" "+sa(o[h]);r=o.join(","),s=$.test(a)&&qa(b.parentNode)||b}if(r)try{return G.apply(d,s.querySelectorAll(r)),d}catch(x){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(P,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("fieldset");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&a.sourceIndex-b.sourceIndex;if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return function(b){return"form"in b?b.parentNode&&b.disabled===!1?"label"in b?"label"in b.parentNode?b.parentNode.disabled===a:b.disabled===a:b.isDisabled===a||b.isDisabled!==!a&&ea(b)===a:b.disabled===a:"label"in b&&b.disabled===a}}function pa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function qa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),v!==n&&(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(n.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){return a.getAttribute("id")===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}}):(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c,d,e,f=b.getElementById(a);if(f){if(c=f.getAttributeNode("id"),c&&c.value===a)return[f];e=b.getElementsByName(a),d=0;while(f=e[d++])if(c=f.getAttributeNode("id"),c&&c.value===a)return[f]}return[]}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){if("undefined"!=typeof b.getElementsByClassName&&p)return b.getElementsByClassName(a)},r=[],q=[],(c.qsa=Y.test(n.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="<a id='"+u+"'></a><select id='"+u+"-\r\\' msallowcapture=''><option selected=''></option></select>",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){a.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+K+"*[*^$|!~]?="),2!==a.querySelectorAll(":enabled").length&&q.push(":enabled",":disabled"),o.appendChild(a).disabled=!0,2!==a.querySelectorAll(":disabled").length&&q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Y.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"*"),s.call(a,"[s!='']:x"),r.push("!=",N)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Y.test(o.compareDocumentPosition),t=b||Y.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?I(k,a)-I(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?I(k,a)-I(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?la(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(S,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.escape=function(a){return(a+"").replace(ba,ca)},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(_,aa),a[3]=(a[3]||a[4]||a[5]||"").replace(_,aa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return V.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&T.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(_,aa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(O," ")+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(P,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(_,aa),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return U.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(_,aa).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:oa(!1),disabled:oa(!0),checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:pa(function(){return[0]}),last:pa(function(a,b){return[b-1]}),eq:pa(function(a,b,c){return[c<0?c+b:c]}),even:pa(function(a,b){for(var c=0;c<b;c+=2)a.push(c);return a}),odd:pa(function(a,b){for(var c=1;c<b;c+=2)a.push(c);return a}),lt:pa(function(a,b,c){for(var d=c<0?c+b:c;--d>=0;)a.push(d);return a}),gt:pa(function(a,b,c){for(var d=c<0?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=ma(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=na(b);function ra(){}ra.prototype=d.filters=d.pseudos,d.setFilters=new ra,g=ga.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){c&&!(e=Q.exec(h))||(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=R.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(P," ")}),h=h.slice(c.length));for(g in d.filter)!(e=V[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?ga.error(a):z(a,i).slice(0)};function sa(a){for(var b=0,c=a.length,d="";b<c;b++)d+=a[b].value;return d}function ta(a,b,c){var d=b.dir,e=b.next,f=e||d,g=c&&"parentNode"===f,h=x++;return b.first?function(b,c,e){while(b=b[d])if(1===b.nodeType||g)return a(b,c,e);return!1}:function(b,c,i){var j,k,l,m=[w,h];if(i){while(b=b[d])if((1===b.nodeType||g)&&a(b,c,i))return!0}else while(b=b[d])if(1===b.nodeType||g)if(l=b[u]||(b[u]={}),k=l[b.uniqueID]||(l[b.uniqueID]={}),e&&e===b.nodeName.toLowerCase())b=b[d]||b;else{if((j=k[f])&&j[0]===w&&j[1]===h)return m[2]=j[2];if(k[f]=m,m[2]=a(b,c,i))return!0}return!1}}function ua(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function va(a,b,c){for(var d=0,e=b.length;d<e;d++)ga(a,b[d],c);return c}function wa(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;h<i;h++)(f=a[h])&&(c&&!c(f,d,e)||(g.push(f),j&&b.push(h)));return g}function xa(a,b,c,d,e,f){return d&&!d[u]&&(d=xa(d)),e&&!e[u]&&(e=xa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||va(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:wa(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=wa(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=wa(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ya(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ta(function(a){return a===b},h,!0),l=ta(function(a){return I(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];i<f;i++)if(c=d.relative[a[i].type])m=[ta(ua(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;e<f;e++)if(d.relative[a[e].type])break;return xa(i>1&&ua(m),i>1&&sa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(P,"$1"),c,i<e&&ya(a.slice(i,e)),e<f&&ya(a=a.slice(e)),e<f&&sa(a))}m.push(c)}return ua(m)}function za(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=E.call(i));u=wa(u)}G.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&ga.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=ya(b[c]),f[u]?d.push(f):e.push(f);f=A(a,za(e,d)),f.selector=a}return f},i=ga.select=function(a,b,c,e){var f,i,j,k,l,m="function"==typeof a&&a,n=!e&&g(a=m.selector||a);if(c=c||[],1===n.length){if(i=n[0]=n[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&9===b.nodeType&&p&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(_,aa),b)||[])[0],!b)return c;m&&(b=b.parentNode),a=a.slice(i.shift().value.length)}f=V.needsContext.test(a)?0:i.length;while(f--){if(j=i[f],d.relative[k=j.type])break;if((l=d.find[k])&&(e=l(j.matches[0].replace(_,aa),$.test(i[0].type)&&qa(b.parentNode)||b))){if(i.splice(f,1),a=e.length&&sa(i),!a)return G.apply(c,e),c;break}}}return(m||h(a,n))(e,b,!p,c,!b||$.test(a)&&qa(b.parentNode)||b),c},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("fieldset"))}),ja(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){if(!c)return a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){if(!c&&"input"===a.nodeName.toLowerCase())return a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(J,function(a,b,c){var d;if(!c)return a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);r.find=x,r.expr=x.selectors,r.expr[":"]=r.expr.pseudos,r.uniqueSort=r.unique=x.uniqueSort,r.text=x.getText,r.isXMLDoc=x.isXML,r.contains=x.contains,r.escapeSelector=x.escape;var y=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&r(a).is(c))break;d.push(a)}return d},z=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},A=r.expr.match.needsContext;function B(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()}var C=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,D=/^.[^:#\[\.,]*$/;function E(a,b,c){return r.isFunction(b)?r.grep(a,function(a,d){return!!b.call(a,d,a)!==c}):b.nodeType?r.grep(a,function(a){return a===b!==c}):"string"!=typeof b?r.grep(a,function(a){return i.call(b,a)>-1!==c}):D.test(b)?r.filter(b,a,c):(b=r.filter(b,a),r.grep(a,function(a){return i.call(b,a)>-1!==c&&1===a.nodeType}))}r.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?r.find.matchesSelector(d,a)?[d]:[]:r.find.matches(a,r.grep(b,function(a){return 1===a.nodeType}))},r.fn.extend({find:function(a){var b,c,d=this.length,e=this;if("string"!=typeof a)return this.pushStack(r(a).filter(function(){for(b=0;b<d;b++)if(r.contains(e[b],this))return!0}));for(c=this.pushStack([]),b=0;b<d;b++)r.find(a,e[b],c);return d>1?r.uniqueSort(c):c},filter:function(a){return this.pushStack(E(this,a||[],!1))},not:function(a){return this.pushStack(E(this,a||[],!0))},is:function(a){return!!E(this,"string"==typeof a&&A.test(a)?r(a):a||[],!1).length}});var F,G=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,H=r.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||F,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:G.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof r?b[0]:b,r.merge(this,r.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),C.test(e[1])&&r.isPlainObject(b))for(e in b)r.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&(this[0]=f,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):r.isFunction(a)?void 0!==c.ready?c.ready(a):a(r):r.makeArray(a,this)};H.prototype=r.fn,F=r(d);var I=/^(?:parents|prev(?:Until|All))/,J={children:!0,contents:!0,next:!0,prev:!0};r.fn.extend({has:function(a){var b=r(a,this),c=b.length;return this.filter(function(){for(var a=0;a<c;a++)if(r.contains(this,b[a]))return!0})},closest:function(a,b){var c,d=0,e=this.length,f=[],g="string"!=typeof a&&r(a);if(!A.test(a))for(;d<e;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&r.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?r.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?i.call(r(a),this[0]):i.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(r.uniqueSort(r.merge(this.get(),r(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function K(a,b){while((a=a[b])&&1!==a.nodeType);return a}r.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return y(a,"parentNode")},parentsUntil:function(a,b,c){return y(a,"parentNode",c)},next:function(a){return K(a,"nextSibling")},prev:function(a){return K(a,"previousSibling")},nextAll:function(a){return y(a,"nextSibling")},prevAll:function(a){return y(a,"previousSibling")},nextUntil:function(a,b,c){return y(a,"nextSibling",c)},prevUntil:function(a,b,c){return y(a,"previousSibling",c)},siblings:function(a){return z((a.parentNode||{}).firstChild,a)},children:function(a){return z(a.firstChild)},contents:function(a){return B(a,"iframe")?a.contentDocument:(B(a,"template")&&(a=a.content||a),r.merge([],a.childNodes))}},function(a,b){r.fn[a]=function(c,d){var e=r.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=r.filter(d,e)),this.length>1&&(J[a]||r.uniqueSort(e),I.test(a)&&e.reverse()),this.pushStack(e)}});var L=/[^\x20\t\r\n\f]+/g;function M(a){var b={};return r.each(a.match(L)||[],function(a,c){b[c]=!0}),b}r.Callbacks=function(a){a="string"==typeof a?M(a):r.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=e||a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h<f.length)f[h].apply(c[0],c[1])===!1&&a.stopOnFalse&&(h=f.length,c=!1)}a.memory||(c=!1),b=!1,e&&(f=c?[]:"")},j={add:function(){return f&&(c&&!b&&(h=f.length-1,g.push(c)),function d(b){r.each(b,function(b,c){r.isFunction(c)?a.unique&&j.has(c)||f.push(c):c&&c.length&&"string"!==r.type(c)&&d(c)})}(arguments),c&&!b&&i()),this},remove:function(){return r.each(arguments,function(a,b){var c;while((c=r.inArray(b,f,c))>-1)f.splice(c,1),c<=h&&h--}),this},has:function(a){return a?r.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||b||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j};function N(a){return a}function O(a){throw a}function P(a,b,c,d){var e;try{a&&r.isFunction(e=a.promise)?e.call(a).done(b).fail(c):a&&r.isFunction(e=a.then)?e.call(a,b,c):b.apply(void 0,[a].slice(d))}catch(a){c.apply(void 0,[a])}}r.extend({Deferred:function(b){var c=[["notify","progress",r.Callbacks("memory"),r.Callbacks("memory"),2],["resolve","done",r.Callbacks("once memory"),r.Callbacks("once memory"),0,"resolved"],["reject","fail",r.Callbacks("once memory"),r.Callbacks("once memory"),1,"rejected"]],d="pending",e={state:function(){return d},always:function(){return f.done(arguments).fail(arguments),this},"catch":function(a){return e.then(null,a)},pipe:function(){var a=arguments;return r.Deferred(function(b){r.each(c,function(c,d){var e=r.isFunction(a[d[4]])&&a[d[4]];f[d[1]](function(){var a=e&&e.apply(this,arguments);a&&r.isFunction(a.promise)?a.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[d[0]+"With"](this,e?[a]:arguments)})}),a=null}).promise()},then:function(b,d,e){var f=0;function g(b,c,d,e){return function(){var h=this,i=arguments,j=function(){var a,j;if(!(b<f)){if(a=d.apply(h,i),a===c.promise())throw new TypeError("Thenable self-resolution");j=a&&("object"==typeof a||"function"==typeof a)&&a.then,r.isFunction(j)?e?j.call(a,g(f,c,N,e),g(f,c,O,e)):(f++,j.call(a,g(f,c,N,e),g(f,c,O,e),g(f,c,N,c.notifyWith))):(d!==N&&(h=void 0,i=[a]),(e||c.resolveWith)(h,i))}},k=e?j:function(){try{j()}catch(a){r.Deferred.exceptionHook&&r.Deferred.exceptionHook(a,k.stackTrace),b+1>=f&&(d!==O&&(h=void 0,i=[a]),c.rejectWith(h,i))}};b?k():(r.Deferred.getStackHook&&(k.stackTrace=r.Deferred.getStackHook()),a.setTimeout(k))}}return r.Deferred(function(a){c[0][3].add(g(0,a,r.isFunction(e)?e:N,a.notifyWith)),c[1][3].add(g(0,a,r.isFunction(b)?b:N)),c[2][3].add(g(0,a,r.isFunction(d)?d:O))}).promise()},promise:function(a){return null!=a?r.extend(a,e):e}},f={};return r.each(c,function(a,b){var g=b[2],h=b[5];e[b[1]]=g.add,h&&g.add(function(){d=h},c[3-a][2].disable,c[0][2].lock),g.add(b[3].fire),f[b[0]]=function(){return f[b[0]+"With"](this===f?void 0:this,arguments),this},f[b[0]+"With"]=g.fireWith}),e.promise(f),b&&b.call(f,f),f},when:function(a){var b=arguments.length,c=b,d=Array(c),e=f.call(arguments),g=r.Deferred(),h=function(a){return function(c){d[a]=this,e[a]=arguments.length>1?f.call(arguments):c,--b||g.resolveWith(d,e)}};if(b<=1&&(P(a,g.done(h(c)).resolve,g.reject,!b),"pending"===g.state()||r.isFunction(e[c]&&e[c].then)))return g.then();while(c--)P(e[c],h(c),g.reject);return g.promise()}});var Q=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;r.Deferred.exceptionHook=function(b,c){a.console&&a.console.warn&&b&&Q.test(b.name)&&a.console.warn("jQuery.Deferred exception: "+b.message,b.stack,c)},r.readyException=function(b){a.setTimeout(function(){throw b})};var R=r.Deferred();r.fn.ready=function(a){return R.then(a)["catch"](function(a){r.readyException(a)}),this},r.extend({isReady:!1,readyWait:1,ready:function(a){(a===!0?--r.readyWait:r.isReady)||(r.isReady=!0,a!==!0&&--r.readyWait>0||R.resolveWith(d,[r]))}}),r.ready.then=R.then;function S(){d.removeEventListener("DOMContentLoaded",S),
a.removeEventListener("load",S),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",S),a.addEventListener("load",S));var T=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)T(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h<i;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},U=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function V(){this.expando=r.expando+V.uid++}V.uid=1,V.prototype={cache:function(a){var b=a[this.expando];return b||(b={},U(a)&&(a.nodeType?a[this.expando]=b:Object.defineProperty(a,this.expando,{value:b,configurable:!0}))),b},set:function(a,b,c){var d,e=this.cache(a);if("string"==typeof b)e[r.camelCase(b)]=c;else for(d in b)e[r.camelCase(d)]=b[d];return e},get:function(a,b){return void 0===b?this.cache(a):a[this.expando]&&a[this.expando][r.camelCase(b)]},access:function(a,b,c){return void 0===b||b&&"string"==typeof b&&void 0===c?this.get(a,b):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d=a[this.expando];if(void 0!==d){if(void 0!==b){Array.isArray(b)?b=b.map(r.camelCase):(b=r.camelCase(b),b=b in d?[b]:b.match(L)||[]),c=b.length;while(c--)delete d[b[c]]}(void 0===b||r.isEmptyObject(d))&&(a.nodeType?a[this.expando]=void 0:delete a[this.expando])}},hasData:function(a){var b=a[this.expando];return void 0!==b&&!r.isEmptyObject(b)}};var W=new V,X=new V,Y=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Z=/[A-Z]/g;function $(a){return"true"===a||"false"!==a&&("null"===a?null:a===+a+""?+a:Y.test(a)?JSON.parse(a):a)}function _(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(Z,"-$&").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c=$(c)}catch(e){}X.set(a,b,c)}else c=void 0;return c}r.extend({hasData:function(a){return X.hasData(a)||W.hasData(a)},data:function(a,b,c){return X.access(a,b,c)},removeData:function(a,b){X.remove(a,b)},_data:function(a,b,c){return W.access(a,b,c)},_removeData:function(a,b){W.remove(a,b)}}),r.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=X.get(f),1===f.nodeType&&!W.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=r.camelCase(d.slice(5)),_(f,d,e[d])));W.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){X.set(this,a)}):T(this,function(b){var c;if(f&&void 0===b){if(c=X.get(f,a),void 0!==c)return c;if(c=_(f,a),void 0!==c)return c}else this.each(function(){X.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){X.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=W.get(a,b),c&&(!d||Array.isArray(c)?d=W.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return W.get(a,c)||W.access(a,c,{empty:r.Callbacks("once memory").add(function(){W.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?r.queue(this[0],a):void 0===b?this:this.each(function(){var c=r.queue(this,a,b);r._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&r.dequeue(this,a)})},dequeue:function(a){return this.each(function(){r.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=r.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=W.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var aa=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ba=new RegExp("^(?:([+-])=|)("+aa+")([a-z%]*)$","i"),ca=["Top","Right","Bottom","Left"],da=function(a,b){return a=b||a,"none"===a.style.display||""===a.style.display&&r.contains(a.ownerDocument,a)&&"none"===r.css(a,"display")},ea=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};function fa(a,b,c,d){var e,f=1,g=20,h=d?function(){return d.cur()}:function(){return r.css(a,b,"")},i=h(),j=c&&c[3]||(r.cssNumber[b]?"":"px"),k=(r.cssNumber[b]||"px"!==j&&+i)&&ba.exec(r.css(a,b));if(k&&k[3]!==j){j=j||k[3],c=c||[],k=+i||1;do f=f||".5",k/=f,r.style(a,b,k+j);while(f!==(f=h()/i)&&1!==f&&--g)}return c&&(k=+k||+i||0,e=c[1]?k+(c[1]+1)*c[2]:+c[2],d&&(d.unit=j,d.start=k,d.end=e)),e}var ga={};function ha(a){var b,c=a.ownerDocument,d=a.nodeName,e=ga[d];return e?e:(b=c.body.appendChild(c.createElement(d)),e=r.css(b,"display"),b.parentNode.removeChild(b),"none"===e&&(e="block"),ga[d]=e,e)}function ia(a,b){for(var c,d,e=[],f=0,g=a.length;f<g;f++)d=a[f],d.style&&(c=d.style.display,b?("none"===c&&(e[f]=W.get(d,"display")||null,e[f]||(d.style.display="")),""===d.style.display&&da(d)&&(e[f]=ha(d))):"none"!==c&&(e[f]="none",W.set(d,"display",c)));for(f=0;f<g;f++)null!=e[f]&&(a[f].style.display=e[f]);return a}r.fn.extend({show:function(){return ia(this,!0)},hide:function(){return ia(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){da(this)?r(this).show():r(this).hide()})}});var ja=/^(?:checkbox|radio)$/i,ka=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,la=/^$|\/(?:java|ecma)script/i,ma={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ma.optgroup=ma.option,ma.tbody=ma.tfoot=ma.colgroup=ma.caption=ma.thead,ma.th=ma.td;function na(a,b){var c;return c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[],void 0===b||b&&B(a,b)?r.merge([a],c):c}function oa(a,b){for(var c=0,d=a.length;c<d;c++)W.set(a[c],"globalEval",!b||W.get(b[c],"globalEval"))}var pa=/<|&#?\w+;/;function qa(a,b,c,d,e){for(var f,g,h,i,j,k,l=b.createDocumentFragment(),m=[],n=0,o=a.length;n<o;n++)if(f=a[n],f||0===f)if("object"===r.type(f))r.merge(m,f.nodeType?[f]:f);else if(pa.test(f)){g=g||l.appendChild(b.createElement("div")),h=(ka.exec(f)||["",""])[1].toLowerCase(),i=ma[h]||ma._default,g.innerHTML=i[1]+r.htmlPrefilter(f)+i[2],k=i[0];while(k--)g=g.lastChild;r.merge(m,g.childNodes),g=l.firstChild,g.textContent=""}else m.push(b.createTextNode(f));l.textContent="",n=0;while(f=m[n++])if(d&&r.inArray(f,d)>-1)e&&e.push(f);else if(j=r.contains(f.ownerDocument,f),g=na(l.appendChild(f),"script"),j&&oa(g),c){k=0;while(f=g[k++])la.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),o.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var ra=d.documentElement,sa=/^key/,ta=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ua=/^([^.]*)(?:\.(.+)|)/;function va(){return!0}function wa(){return!1}function xa(){try{return d.activeElement}catch(a){}}function ya(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)ya(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=wa;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=W.get(a);if(q){c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(ra,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(L)||[""],j=b.length;while(j--)h=ua.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=W.hasData(a)&&W.get(a);if(q&&(i=q.events)){b=(b||"").match(L)||[""],j=b.length;while(j--)if(h=ua.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&W.remove(a,"handle events")}},dispatch:function(a){var b=r.event.fix(a),c,d,e,f,g,h,i=new Array(arguments.length),j=(W.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;c<arguments.length;c++)i[c]=arguments[c];if(b.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,b)!==!1){h=r.event.handlers.call(this,b,j),c=0;while((f=h[c++])&&!b.isPropagationStopped()){b.currentTarget=f.elem,d=0;while((g=f.handlers[d++])&&!b.isImmediatePropagationStopped())b.rnamespace&&!b.rnamespace.test(g.namespace)||(b.handleObj=g,b.data=g.data,e=((r.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(b.result=e)===!1&&(b.preventDefault(),b.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,b),b.result}},handlers:function(a,b){var c,d,e,f,g,h=[],i=b.delegateCount,j=a.target;if(i&&j.nodeType&&!("click"===a.type&&a.button>=1))for(;j!==this;j=j.parentNode||this)if(1===j.nodeType&&("click"!==a.type||j.disabled!==!0)){for(f=[],g={},c=0;c<i;c++)d=b[c],e=d.selector+" ",void 0===g[e]&&(g[e]=d.needsContext?r(e,this).index(j)>-1:r.find(e,this,null,[j]).length),g[e]&&f.push(d);f.length&&h.push({elem:j,handlers:f})}return j=this,i<b.length&&h.push({elem:j,handlers:b.slice(i)}),h},addProp:function(a,b){Object.defineProperty(r.Event.prototype,a,{enumerable:!0,configurable:!0,get:r.isFunction(b)?function(){if(this.originalEvent)return b(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[a]},set:function(b){Object.defineProperty(this,a,{enumerable:!0,configurable:!0,writable:!0,value:b})}})},fix:function(a){return a[r.expando]?a:new r.Event(a)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==xa()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===xa()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&B(this,"input"))return this.click(),!1},_default:function(a){return B(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}}},r.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c)},r.Event=function(a,b){return this instanceof r.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?va:wa,this.target=a.target&&3===a.target.nodeType?a.target.parentNode:a.target,this.currentTarget=a.currentTarget,this.relatedTarget=a.relatedTarget):this.type=a,b&&r.extend(this,b),this.timeStamp=a&&a.timeStamp||r.now(),void(this[r.expando]=!0)):new r.Event(a,b)},r.Event.prototype={constructor:r.Event,isDefaultPrevented:wa,isPropagationStopped:wa,isImmediatePropagationStopped:wa,isSimulated:!1,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=va,a&&!this.isSimulated&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=va,a&&!this.isSimulated&&a.stopPropagation()},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=va,a&&!this.isSimulated&&a.stopImmediatePropagation(),this.stopPropagation()}},r.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,"char":!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(a){var b=a.button;return null==a.which&&sa.test(a.type)?null!=a.charCode?a.charCode:a.keyCode:!a.which&&void 0!==b&&ta.test(a.type)?1&b?1:2&b?3:4&b?2:0:a.which}},r.event.addProp),r.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){r.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return e&&(e===d||r.contains(d,e))||(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),r.fn.extend({on:function(a,b,c,d){return ya(this,a,b,c,d)},one:function(a,b,c,d){return ya(this,a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,r(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return b!==!1&&"function"!=typeof b||(c=b,b=void 0),c===!1&&(c=wa),this.each(function(){r.event.remove(this,a,c,b)})}});var za=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,Aa=/<script|<style|<link/i,Ba=/checked\s*(?:[^=]|=\s*.checked.)/i,Ca=/^true\/(.*)/,Da=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function Ea(a,b){return B(a,"table")&&B(11!==b.nodeType?b:b.firstChild,"tr")?r(">tbody",a)[0]||a:a}function Fa(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function Ga(a){var b=Ca.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ha(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(W.hasData(a)&&(f=W.access(a),g=W.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;c<d;c++)r.event.add(b,e,j[e][c])}X.hasData(a)&&(h=X.access(a),i=r.extend({},h),X.set(b,i))}}function Ia(a,b){var c=b.nodeName.toLowerCase();"input"===c&&ja.test(a.type)?b.checked=a.checked:"input"!==c&&"textarea"!==c||(b.defaultValue=a.defaultValue)}function Ja(a,b,c,d){b=g.apply([],b);var e,f,h,i,j,k,l=0,m=a.length,n=m-1,q=b[0],s=r.isFunction(q);if(s||m>1&&"string"==typeof q&&!o.checkClone&&Ba.test(q))return a.each(function(e){var f=a.eq(e);s&&(b[0]=q.call(this,e,f.html())),Ja(f,b,c,d)});if(m&&(e=qa(b,a[0].ownerDocument,!1,a,d),f=e.firstChild,1===e.childNodes.length&&(e=f),f||d)){for(h=r.map(na(e,"script"),Fa),i=h.length;l<m;l++)j=e,l!==n&&(j=r.clone(j,!0,!0),i&&r.merge(h,na(j,"script"))),c.call(a[l],j,l);if(i)for(k=h[h.length-1].ownerDocument,r.map(h,Ga),l=0;l<i;l++)j=h[l],la.test(j.type||"")&&!W.access(j,"globalEval")&&r.contains(k,j)&&(j.src?r._evalUrl&&r._evalUrl(j.src):p(j.textContent.replace(Da,""),k))}return a}function Ka(a,b,c){for(var d,e=b?r.filter(b,a):a,f=0;null!=(d=e[f]);f++)c||1!==d.nodeType||r.cleanData(na(d)),d.parentNode&&(c&&r.contains(d.ownerDocument,d)&&oa(na(d,"script")),d.parentNode.removeChild(d));return a}r.extend({htmlPrefilter:function(a){return a.replace(za,"<$1></$2>")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=r.contains(a.ownerDocument,a);if(!(o.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||r.isXMLDoc(a)))for(g=na(h),f=na(a),d=0,e=f.length;d<e;d++)Ia(f[d],g[d]);if(b)if(c)for(f=f||na(a),g=g||na(h),d=0,e=f.length;d<e;d++)Ha(f[d],g[d]);else Ha(a,h);return g=na(h,"script"),g.length>0&&oa(g,!i&&na(a,"script")),h},cleanData:function(a){for(var b,c,d,e=r.event.special,f=0;void 0!==(c=a[f]);f++)if(U(c)){if(b=c[W.expando]){if(b.events)for(d in b.events)e[d]?r.event.remove(c,d):r.removeEvent(c,d,b.handle);c[W.expando]=void 0}c[X.expando]&&(c[X.expando]=void 0)}}}),r.fn.extend({detach:function(a){return Ka(this,a,!0)},remove:function(a){return Ka(this,a)},text:function(a){return T(this,function(a){return void 0===a?r.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=a)})},null,a,arguments.length)},append:function(){return Ja(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ea(this,a);b.appendChild(a)}})},prepend:function(){return Ja(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ea(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ja(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ja(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(r.cleanData(na(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return r.clone(this,a,b)})},html:function(a){return T(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!Aa.test(a)&&!ma[(ka.exec(a)||["",""])[1].toLowerCase()]){a=r.htmlPrefilter(a);try{for(;c<d;c++)b=this[c]||{},1===b.nodeType&&(r.cleanData(na(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=[];return Ja(this,arguments,function(b){var c=this.parentNode;r.inArray(this,a)<0&&(r.cleanData(na(this)),c&&c.replaceChild(b,this))},a)}}),r.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){r.fn[a]=function(a){for(var c,d=[],e=r(a),f=e.length-1,g=0;g<=f;g++)c=g===f?this:this.clone(!0),r(e[g])[b](c),h.apply(d,c.get());return this.pushStack(d)}});var La=/^margin/,Ma=new RegExp("^("+aa+")(?!px)[a-z%]+$","i"),Na=function(b){var c=b.ownerDocument.defaultView;return c&&c.opener||(c=a),c.getComputedStyle(b)};!function(){function b(){if(i){i.style.cssText="box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%",i.innerHTML="",ra.appendChild(h);var b=a.getComputedStyle(i);c="1%"!==b.top,g="2px"===b.marginLeft,e="4px"===b.width,i.style.marginRight="50%",f="4px"===b.marginRight,ra.removeChild(h),i=null}}var c,e,f,g,h=d.createElement("div"),i=d.createElement("div");i.style&&(i.style.backgroundClip="content-box",i.cloneNode(!0).style.backgroundClip="",o.clearCloneStyle="content-box"===i.style.backgroundClip,h.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",h.appendChild(i),r.extend(o,{pixelPosition:function(){return b(),c},boxSizingReliable:function(){return b(),e},pixelMarginRight:function(){return b(),f},reliableMarginLeft:function(){return b(),g}}))}();function Oa(a,b,c){var d,e,f,g,h=a.style;return c=c||Na(a),c&&(g=c.getPropertyValue(b)||c[b],""!==g||r.contains(a.ownerDocument,a)||(g=r.style(a,b)),!o.pixelMarginRight()&&Ma.test(g)&&La.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function Pa(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}var Qa=/^(none|table(?!-c[ea]).+)/,Ra=/^--/,Sa={position:"absolute",visibility:"hidden",display:"block"},Ta={letterSpacing:"0",fontWeight:"400"},Ua=["Webkit","Moz","ms"],Va=d.createElement("div").style;function Wa(a){if(a in Va)return a;var b=a[0].toUpperCase()+a.slice(1),c=Ua.length;while(c--)if(a=Ua[c]+b,a in Va)return a}function Xa(a){var b=r.cssProps[a];return b||(b=r.cssProps[a]=Wa(a)||a),b}function Ya(a,b,c){var d=ba.exec(b);return d?Math.max(0,d[2]-(c||0))+(d[3]||"px"):b}function Za(a,b,c,d,e){var f,g=0;for(f=c===(d?"border":"content")?4:"width"===b?1:0;f<4;f+=2)"margin"===c&&(g+=r.css(a,c+ca[f],!0,e)),d?("content"===c&&(g-=r.css(a,"padding"+ca[f],!0,e)),"margin"!==c&&(g-=r.css(a,"border"+ca[f]+"Width",!0,e))):(g+=r.css(a,"padding"+ca[f],!0,e),"padding"!==c&&(g+=r.css(a,"border"+ca[f]+"Width",!0,e)));return g}function $a(a,b,c){var d,e=Na(a),f=Oa(a,b,e),g="border-box"===r.css(a,"boxSizing",!1,e);return Ma.test(f)?f:(d=g&&(o.boxSizingReliable()||f===a.style[b]),"auto"===f&&(f=a["offset"+b[0].toUpperCase()+b.slice(1)]),f=parseFloat(f)||0,f+Za(a,b,c||(g?"border":"content"),d,e)+"px")}r.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Oa(a,"opacity");return""===c?"1":c}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=r.camelCase(b),i=Ra.test(b),j=a.style;return i||(b=Xa(h)),g=r.cssHooks[b]||r.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:j[b]:(f=typeof c,"string"===f&&(e=ba.exec(c))&&e[1]&&(c=fa(a,b,e),f="number"),null!=c&&c===c&&("number"===f&&(c+=e&&e[3]||(r.cssNumber[h]?"":"px")),o.clearCloneStyle||""!==c||0!==b.indexOf("background")||(j[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i?j.setProperty(b,c):j[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=r.camelCase(b),i=Ra.test(b);return i||(b=Xa(h)),g=r.cssHooks[b]||r.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=Oa(a,b,d)),"normal"===e&&b in Ta&&(e=Ta[b]),""===c||c?(f=parseFloat(e),c===!0||isFinite(f)?f||0:e):e}}),r.each(["height","width"],function(a,b){r.cssHooks[b]={get:function(a,c,d){if(c)return!Qa.test(r.css(a,"display"))||a.getClientRects().length&&a.getBoundingClientRect().width?$a(a,b,d):ea(a,Sa,function(){return $a(a,b,d)})},set:function(a,c,d){var e,f=d&&Na(a),g=d&&Za(a,b,d,"border-box"===r.css(a,"boxSizing",!1,f),f);return g&&(e=ba.exec(c))&&"px"!==(e[3]||"px")&&(a.style[b]=c,c=r.css(a,b)),Ya(a,c,g)}}}),r.cssHooks.marginLeft=Pa(o.reliableMarginLeft,function(a,b){if(b)return(parseFloat(Oa(a,"marginLeft"))||a.getBoundingClientRect().left-ea(a,{marginLeft:0},function(){return a.getBoundingClientRect().left}))+"px"}),r.each({margin:"",padding:"",border:"Width"},function(a,b){r.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];d<4;d++)e[a+ca[d]+b]=f[d]||f[d-2]||f[0];return e}},La.test(a)||(r.cssHooks[a+b].set=Ya)}),r.fn.extend({css:function(a,b){return T(this,function(a,b,c){var d,e,f={},g=0;if(Array.isArray(b)){for(d=Na(a),e=b.length;g<e;g++)f[b[g]]=r.css(a,b[g],!1,d);return f}return void 0!==c?r.style(a,b,c):r.css(a,b)},a,b,arguments.length>1)}});function _a(a,b,c,d,e){return new _a.prototype.init(a,b,c,d,e)}r.Tween=_a,_a.prototype={constructor:_a,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||r.easing._default,this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(r.cssNumber[c]?"":"px")},cur:function(){var a=_a.propHooks[this.prop];return a&&a.get?a.get(this):_a.propHooks._default.get(this)},run:function(a){var b,c=_a.propHooks[this.prop];return this.options.duration?this.pos=b=r.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):_a.propHooks._default.set(this),this}},_a.prototype.init.prototype=_a.prototype,_a.propHooks={_default:{get:function(a){var b;return 1!==a.elem.nodeType||null!=a.elem[a.prop]&&null==a.elem.style[a.prop]?a.elem[a.prop]:(b=r.css(a.elem,a.prop,""),b&&"auto"!==b?b:0)},set:function(a){r.fx.step[a.prop]?r.fx.step[a.prop](a):1!==a.elem.nodeType||null==a.elem.style[r.cssProps[a.prop]]&&!r.cssHooks[a.prop]?a.elem[a.prop]=a.now:r.style(a.elem,a.prop,a.now+a.unit)}}},_a.propHooks.scrollTop=_a.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},r.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2},_default:"swing"},r.fx=_a.prototype.init,r.fx.step={};var ab,bb,cb=/^(?:toggle|show|hide)$/,db=/queueHooks$/;function eb(){bb&&(d.hidden===!1&&a.requestAnimationFrame?a.requestAnimationFrame(eb):a.setTimeout(eb,r.fx.interval),r.fx.tick())}function fb(){return a.setTimeout(function(){ab=void 0}),ab=r.now()}function gb(a,b){var c,d=0,e={height:a};for(b=b?1:0;d<4;d+=2-b)c=ca[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function hb(a,b,c){for(var d,e=(kb.tweeners[b]||[]).concat(kb.tweeners["*"]),f=0,g=e.length;f<g;f++)if(d=e[f].call(c,b,a))return d}function ib(a,b,c){var d,e,f,g,h,i,j,k,l="width"in b||"height"in b,m=this,n={},o=a.style,p=a.nodeType&&da(a),q=W.get(a,"fxshow");c.queue||(g=r._queueHooks(a,"fx"),null==g.unqueued&&(g.unqueued=0,h=g.empty.fire,g.empty.fire=function(){g.unqueued||h()}),g.unqueued++,m.always(function(){m.always(function(){g.unqueued--,r.queue(a,"fx").length||g.empty.fire()})}));for(d in b)if(e=b[d],cb.test(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}n[d]=q&&q[d]||r.style(a,d)}if(i=!r.isEmptyObject(b),i||!r.isEmptyObject(n)){l&&1===a.nodeType&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=q&&q.display,null==j&&(j=W.get(a,"display")),k=r.css(a,"display"),"none"===k&&(j?k=j:(ia([a],!0),j=a.style.display||j,k=r.css(a,"display"),ia([a]))),("inline"===k||"inline-block"===k&&null!=j)&&"none"===r.css(a,"float")&&(i||(m.done(function(){o.display=j}),null==j&&(k=o.display,j="none"===k?"":k)),o.display="inline-block")),c.overflow&&(o.overflow="hidden",m.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]})),i=!1;for(d in n)i||(q?"hidden"in q&&(p=q.hidden):q=W.access(a,"fxshow",{display:j}),f&&(q.hidden=!p),p&&ia([a],!0),m.done(function(){p||ia([a]),W.remove(a,"fxshow");for(d in n)r.style(a,d,n[d])})),i=hb(p?q[d]:0,d,m),d in q||(q[d]=i.start,p&&(i.end=i.start,i.start=0))}}function jb(a,b){var c,d,e,f,g;for(c in a)if(d=r.camelCase(c),e=b[d],f=a[c],Array.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=r.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kb(a,b,c){var d,e,f=0,g=kb.prefilters.length,h=r.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=ab||fb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;g<i;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),f<1&&i?c:(i||h.notifyWith(a,[j,1,0]),h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:r.extend({},b),opts:r.extend(!0,{specialEasing:{},easing:r.easing._default},c),originalProperties:b,originalOptions:c,startTime:ab||fb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=r.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;c<d;c++)j.tweens[c].run(1);return b?(h.notifyWith(a,[j,1,0]),h.resolveWith(a,[j,b])):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jb(k,j.opts.specialEasing);f<g;f++)if(d=kb.prefilters[f].call(j,a,k,j.opts))return r.isFunction(d.stop)&&(r._queueHooks(j.elem,j.opts.queue).stop=r.proxy(d.stop,d)),d;return r.map(k,hb,j),r.isFunction(j.opts.start)&&j.opts.start.call(a,j),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always),r.fx.timer(r.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j}r.Animation=r.extend(kb,{tweeners:{"*":[function(a,b){var c=this.createTween(a,b);return fa(c.elem,a,ba.exec(b),c),c}]},tweener:function(a,b){r.isFunction(a)?(b=a,a=["*"]):a=a.match(L);for(var c,d=0,e=a.length;d<e;d++)c=a[d],kb.tweeners[c]=kb.tweeners[c]||[],kb.tweeners[c].unshift(b)},prefilters:[ib],prefilter:function(a,b){b?kb.prefilters.unshift(a):kb.prefilters.push(a)}}),r.speed=function(a,b,c){var d=a&&"object"==typeof a?r.extend({},a):{complete:c||!c&&b||r.isFunction(a)&&a,duration:a,easing:c&&b||b&&!r.isFunction(b)&&b};return r.fx.off?d.duration=0:"number"!=typeof d.duration&&(d.duration in r.fx.speeds?d.duration=r.fx.speeds[d.duration]:d.duration=r.fx.speeds._default),null!=d.queue&&d.queue!==!0||(d.queue="fx"),d.old=d.complete,d.complete=function(){r.isFunction(d.old)&&d.old.call(this),d.queue&&r.dequeue(this,d.queue)},d},r.fn.extend({fadeTo:function(a,b,c,d){return this.filter(da).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=r.isEmptyObject(a),f=r.speed(b,c,d),g=function(){var b=kb(this,r.extend({},a),f);(e||W.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=r.timers,g=W.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&db.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));!b&&c||r.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=W.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=r.timers,g=d?d.length:0;for(c.finish=!0,r.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;b<g;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),r.each(["toggle","show","hide"],function(a,b){var c=r.fn[b];r.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gb(b,!0),a,d,e)}}),r.each({slideDown:gb("show"),slideUp:gb("hide"),slideToggle:gb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){r.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),r.timers=[],r.fx.tick=function(){var a,b=0,c=r.timers;for(ab=r.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||r.fx.stop(),ab=void 0},r.fx.timer=function(a){r.timers.push(a),r.fx.start()},r.fx.interval=13,r.fx.start=function(){bb||(bb=!0,eb())},r.fx.stop=function(){bb=null},r.fx.speeds={slow:600,fast:200,_default:400},r.fn.delay=function(b,c){return b=r.fx?r.fx.speeds[b]||b:b,c=c||"fx",this.queue(c,function(c,d){var e=a.setTimeout(c,b);d.stop=function(){a.clearTimeout(e)}})},function(){var a=d.createElement("input"),b=d.createElement("select"),c=b.appendChild(d.createElement("option"));a.type="checkbox",o.checkOn=""!==a.value,o.optSelected=c.selected,a=d.createElement("input"),a.value="t",a.type="radio",o.radioValue="t"===a.value}();var lb,mb=r.expr.attrHandle;r.fn.extend({attr:function(a,b){return T(this,r.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){r.removeAttr(this,a)})}}),r.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return"undefined"==typeof a.getAttribute?r.prop(a,b,c):(1===f&&r.isXMLDoc(a)||(e=r.attrHooks[b.toLowerCase()]||(r.expr.match.bool.test(b)?lb:void 0)),void 0!==c?null===c?void r.removeAttr(a,b):e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!==(d=e.get(a,b))?d:(d=r.find.attr(a,b),
null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&B(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(L);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),lb={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=mb[b]||r.find.attr;mb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=mb[g],mb[g]=e,e=null!=c(a,b,d)?g:null,mb[g]=f),e}});var nb=/^(?:input|select|textarea|button)$/i,ob=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return T(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):nb.test(a.nodeName)||ob.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});function pb(a){var b=a.match(L)||[];return b.join(" ")}function qb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,qb(this)))});if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,qb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,qb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(L)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=qb(this),b&&W.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":W.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+pb(qb(c))+" ").indexOf(b)>-1)return!0;return!1}});var rb=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":Array.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(rb,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:pb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d<i;d++)if(c=e[d],(c.selected||d===f)&&!c.disabled&&(!c.parentNode.disabled||!B(c.parentNode,"optgroup"))){if(b=r(c).val(),g)return b;h.push(b)}return h},set:function(a,b){var c,d,e=a.options,f=r.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=r.inArray(r.valHooks.option.get(d),f)>-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(Array.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var sb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!sb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?b:new r.Event(p,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=q.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:r.makeArray(c,[b]),n=r.event.special[p]||{},f||!n.trigger||n.trigger.apply(e,c)!==!1)){if(!f&&!n.noBubble&&!r.isWindow(e)){for(j=n.delegateType||p,sb.test(j+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),i=h;i===(e.ownerDocument||d)&&o.push(i.defaultView||i.parentWindow||a)}g=0;while((h=o[g++])&&!b.isPropagationStopped())b.type=g>1?j:n.bindType||p,m=(W.get(h,"events")||{})[b.type]&&W.get(h,"handle"),m&&m.apply(h,c),m=k&&h[k],m&&m.apply&&U(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=p,f||b.isDefaultPrevented()||n._default&&n._default.apply(o.pop(),c)!==!1||!U(e)||k&&r.isFunction(e[p])&&!r.isWindow(e)&&(i=e[k],i&&(e[k]=null),r.event.triggered=p,e[p](),r.event.triggered=void 0,i&&(e[k]=i)),b.result}},simulate:function(a,b,c){var d=r.extend(new r.Event,c,{type:a,isSimulated:!0});r.event.trigger(d,null,b)}}),r.fn.extend({trigger:function(a,b){return this.each(function(){r.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];if(c)return r.event.trigger(a,b,c,!0)}}),r.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,b){r.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),r.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),o.focusin="onfocusin"in a,o.focusin||r.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){r.event.simulate(b,a.target,r.event.fix(a))};r.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=W.access(d,b);e||d.addEventListener(a,c,!0),W.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=W.access(d,b)-1;e?W.access(d,b,e):(d.removeEventListener(a,c,!0),W.remove(d,b))}}});var tb=a.location,ub=r.now(),vb=/\?/;r.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(d){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||r.error("Invalid XML: "+b),c};var wb=/\[\]$/,xb=/\r?\n/g,yb=/^(?:submit|button|image|reset|file)$/i,zb=/^(?:input|select|textarea|keygen)/i;function Ab(a,b,c,d){var e;if(Array.isArray(b))r.each(b,function(b,e){c||wb.test(a)?d(a,e):Ab(a+"["+("object"==typeof e&&null!=e?b:"")+"]",e,c,d)});else if(c||"object"!==r.type(b))d(a,b);else for(e in b)Ab(a+"["+e+"]",b[e],c,d)}r.param=function(a,b){var c,d=[],e=function(a,b){var c=r.isFunction(b)?b():b;d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==c?"":c)};if(Array.isArray(a)||a.jquery&&!r.isPlainObject(a))r.each(a,function(){e(this.name,this.value)});else for(c in a)Ab(c,a[c],b,e);return d.join("&")},r.fn.extend({serialize:function(){return r.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=r.prop(this,"elements");return a?r.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!r(this).is(":disabled")&&zb.test(this.nodeName)&&!yb.test(a)&&(this.checked||!ja.test(a))}).map(function(a,b){var c=r(this).val();return null==c?null:Array.isArray(c)?r.map(c,function(a){return{name:b.name,value:a.replace(xb,"\r\n")}}):{name:b.name,value:c.replace(xb,"\r\n")}}).get()}});var Bb=/%20/g,Cb=/#.*$/,Db=/([?&])_=[^&]*/,Eb=/^(.*?):[ \t]*([^\r\n]*)$/gm,Fb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Gb=/^(?:GET|HEAD)$/,Hb=/^\/\//,Ib={},Jb={},Kb="*/".concat("*"),Lb=d.createElement("a");Lb.href=tb.href;function Mb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(L)||[];if(r.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Nb(a,b,c,d){var e={},f=a===Jb;function g(h){var i;return e[h]=!0,r.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Ob(a,b){var c,d,e=r.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&r.extend(!0,a,d),a}function Pb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}if(f)return f!==i[0]&&i.unshift(f),c[f]}function Qb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}r.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:tb.href,type:"GET",isLocal:Fb.test(tb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Kb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":r.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Ob(Ob(a,r.ajaxSettings),b):Ob(r.ajaxSettings,a)},ajaxPrefilter:Mb(Ib),ajaxTransport:Mb(Jb),ajax:function(b,c){"object"==typeof b&&(c=b,b=void 0),c=c||{};var e,f,g,h,i,j,k,l,m,n,o=r.ajaxSetup({},c),p=o.context||o,q=o.context&&(p.nodeType||p.jquery)?r(p):r.event,s=r.Deferred(),t=r.Callbacks("once memory"),u=o.statusCode||{},v={},w={},x="canceled",y={readyState:0,getResponseHeader:function(a){var b;if(k){if(!h){h={};while(b=Eb.exec(g))h[b[1].toLowerCase()]=b[2]}b=h[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return k?g:null},setRequestHeader:function(a,b){return null==k&&(a=w[a.toLowerCase()]=w[a.toLowerCase()]||a,v[a]=b),this},overrideMimeType:function(a){return null==k&&(o.mimeType=a),this},statusCode:function(a){var b;if(a)if(k)y.always(a[y.status]);else for(b in a)u[b]=[u[b],a[b]];return this},abort:function(a){var b=a||x;return e&&e.abort(b),A(0,b),this}};if(s.promise(y),o.url=((b||o.url||tb.href)+"").replace(Hb,tb.protocol+"//"),o.type=c.method||c.type||o.method||o.type,o.dataTypes=(o.dataType||"*").toLowerCase().match(L)||[""],null==o.crossDomain){j=d.createElement("a");try{j.href=o.url,j.href=j.href,o.crossDomain=Lb.protocol+"//"+Lb.host!=j.protocol+"//"+j.host}catch(z){o.crossDomain=!0}}if(o.data&&o.processData&&"string"!=typeof o.data&&(o.data=r.param(o.data,o.traditional)),Nb(Ib,o,c,y),k)return y;l=r.event&&o.global,l&&0===r.active++&&r.event.trigger("ajaxStart"),o.type=o.type.toUpperCase(),o.hasContent=!Gb.test(o.type),f=o.url.replace(Cb,""),o.hasContent?o.data&&o.processData&&0===(o.contentType||"").indexOf("application/x-www-form-urlencoded")&&(o.data=o.data.replace(Bb,"+")):(n=o.url.slice(f.length),o.data&&(f+=(vb.test(f)?"&":"?")+o.data,delete o.data),o.cache===!1&&(f=f.replace(Db,"$1"),n=(vb.test(f)?"&":"?")+"_="+ub++ +n),o.url=f+n),o.ifModified&&(r.lastModified[f]&&y.setRequestHeader("If-Modified-Since",r.lastModified[f]),r.etag[f]&&y.setRequestHeader("If-None-Match",r.etag[f])),(o.data&&o.hasContent&&o.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",o.contentType),y.setRequestHeader("Accept",o.dataTypes[0]&&o.accepts[o.dataTypes[0]]?o.accepts[o.dataTypes[0]]+("*"!==o.dataTypes[0]?", "+Kb+"; q=0.01":""):o.accepts["*"]);for(m in o.headers)y.setRequestHeader(m,o.headers[m]);if(o.beforeSend&&(o.beforeSend.call(p,y,o)===!1||k))return y.abort();if(x="abort",t.add(o.complete),y.done(o.success),y.fail(o.error),e=Nb(Jb,o,c,y)){if(y.readyState=1,l&&q.trigger("ajaxSend",[y,o]),k)return y;o.async&&o.timeout>0&&(i=a.setTimeout(function(){y.abort("timeout")},o.timeout));try{k=!1,e.send(v,A)}catch(z){if(k)throw z;A(-1,z)}}else A(-1,"No Transport");function A(b,c,d,h){var j,m,n,v,w,x=c;k||(k=!0,i&&a.clearTimeout(i),e=void 0,g=h||"",y.readyState=b>0?4:0,j=b>=200&&b<300||304===b,d&&(v=Pb(o,y,d)),v=Qb(o,v,y,j),j?(o.ifModified&&(w=y.getResponseHeader("Last-Modified"),w&&(r.lastModified[f]=w),w=y.getResponseHeader("etag"),w&&(r.etag[f]=w)),204===b||"HEAD"===o.type?x="nocontent":304===b?x="notmodified":(x=v.state,m=v.data,n=v.error,j=!n)):(n=x,!b&&x||(x="error",b<0&&(b=0))),y.status=b,y.statusText=(c||x)+"",j?s.resolveWith(p,[m,x,y]):s.rejectWith(p,[y,x,n]),y.statusCode(u),u=void 0,l&&q.trigger(j?"ajaxSuccess":"ajaxError",[y,o,j?m:n]),t.fireWith(p,[y,x]),l&&(q.trigger("ajaxComplete",[y,o]),--r.active||r.event.trigger("ajaxStop")))}return y},getJSON:function(a,b,c){return r.get(a,b,c,"json")},getScript:function(a,b){return r.get(a,void 0,b,"script")}}),r.each(["get","post"],function(a,b){r[b]=function(a,c,d,e){return r.isFunction(c)&&(e=e||d,d=c,c=void 0),r.ajax(r.extend({url:a,type:b,dataType:e,data:c,success:d},r.isPlainObject(a)&&a))}}),r._evalUrl=function(a){return r.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},r.fn.extend({wrapAll:function(a){var b;return this[0]&&(r.isFunction(a)&&(a=a.call(this[0])),b=r(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this},wrapInner:function(a){return r.isFunction(a)?this.each(function(b){r(this).wrapInner(a.call(this,b))}):this.each(function(){var b=r(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=r.isFunction(a);return this.each(function(c){r(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){r(this).replaceWith(this.childNodes)}),this}}),r.expr.pseudos.hidden=function(a){return!r.expr.pseudos.visible(a)},r.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},r.ajaxSettings.xhr=function(){try{return new a.XMLHttpRequest}catch(b){}};var Rb={0:200,1223:204},Sb=r.ajaxSettings.xhr();o.cors=!!Sb&&"withCredentials"in Sb,o.ajax=Sb=!!Sb,r.ajaxTransport(function(b){var c,d;if(o.cors||Sb&&!b.crossDomain)return{send:function(e,f){var g,h=b.xhr();if(h.open(b.type,b.url,b.async,b.username,b.password),b.xhrFields)for(g in b.xhrFields)h[g]=b.xhrFields[g];b.mimeType&&h.overrideMimeType&&h.overrideMimeType(b.mimeType),b.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");for(g in e)h.setRequestHeader(g,e[g]);c=function(a){return function(){c&&(c=d=h.onload=h.onerror=h.onabort=h.onreadystatechange=null,"abort"===a?h.abort():"error"===a?"number"!=typeof h.status?f(0,"error"):f(h.status,h.statusText):f(Rb[h.status]||h.status,h.statusText,"text"!==(h.responseType||"text")||"string"!=typeof h.responseText?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=c(),d=h.onerror=c("error"),void 0!==h.onabort?h.onabort=d:h.onreadystatechange=function(){4===h.readyState&&a.setTimeout(function(){c&&d()})},c=c("abort");try{h.send(b.hasContent&&b.data||null)}catch(i){if(c)throw i}},abort:function(){c&&c()}}}),r.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),r.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return r.globalEval(a),a}}}),r.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),r.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(e,f){b=r("<script>").prop({charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&f("error"===a.type?404:200,a.type)}),d.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Tb=[],Ub=/(=)\?(?=&|$)|\?\?/;r.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Tb.pop()||r.expando+"_"+ub++;return this[a]=!0,a}}),r.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Ub.test(b.url)?"url":"string"==typeof b.data&&0===(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ub.test(b.data)&&"data");if(h||"jsonp"===b.dataTypes[0])return e=b.jsonpCallback=r.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Ub,"$1"+e):b.jsonp!==!1&&(b.url+=(vb.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||r.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){void 0===f?r(a).removeProp(e):a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Tb.push(e)),g&&r.isFunction(f)&&f(g[0]),g=f=void 0}),"script"}),o.createHTMLDocument=function(){var a=d.implementation.createHTMLDocument("").body;return a.innerHTML="<form></form><form></form>",2===a.childNodes.length}(),r.parseHTML=function(a,b,c){if("string"!=typeof a)return[];"boolean"==typeof b&&(c=b,b=!1);var e,f,g;return b||(o.createHTMLDocument?(b=d.implementation.createHTMLDocument(""),e=b.createElement("base"),e.href=d.location.href,b.head.appendChild(e)):b=d),f=C.exec(a),g=!c&&[],f?[b.createElement(f[1])]:(f=qa([a],b,g),g&&g.length&&r(g).remove(),r.merge([],f.childNodes))},r.fn.load=function(a,b,c){var d,e,f,g=this,h=a.indexOf(" ");return h>-1&&(d=pb(a.slice(h)),a=a.slice(0,h)),r.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&r.ajax({url:a,type:e||"GET",dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?r("<div>").append(r.parseHTML(a)).find(d):a)}).always(c&&function(a,b){g.each(function(){c.apply(this,f||[a.responseText,b,a])})}),this},r.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){r.fn[b]=function(a){return this.on(b,a)}}),r.expr.pseudos.animated=function(a){return r.grep(r.timers,function(b){return a===b.elem}).length},r.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=r.css(a,"position"),l=r(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=r.css(a,"top"),i=r.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),r.isFunction(b)&&(b=b.call(a,c,r.extend({},h))),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},r.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){r.offset.setOffset(this,a,b)});var b,c,d,e,f=this[0];if(f)return f.getClientRects().length?(d=f.getBoundingClientRect(),b=f.ownerDocument,c=b.documentElement,e=b.defaultView,{top:d.top+e.pageYOffset-c.clientTop,left:d.left+e.pageXOffset-c.clientLeft}):{top:0,left:0}},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===r.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),B(a[0],"html")||(d=a.offset()),d={top:d.top+r.css(a[0],"borderTopWidth",!0),left:d.left+r.css(a[0],"borderLeftWidth",!0)}),{top:b.top-d.top-r.css(c,"marginTop",!0),left:b.left-d.left-r.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent;while(a&&"static"===r.css(a,"position"))a=a.offsetParent;return a||ra})}}),r.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c="pageYOffset"===b;r.fn[a]=function(d){return T(this,function(a,d,e){var f;return r.isWindow(a)?f=a:9===a.nodeType&&(f=a.defaultView),void 0===e?f?f[b]:a[d]:void(f?f.scrollTo(c?f.pageXOffset:e,c?e:f.pageYOffset):a[d]=e)},a,d,arguments.length)}}),r.each(["top","left"],function(a,b){r.cssHooks[b]=Pa(o.pixelPosition,function(a,c){if(c)return c=Oa(a,b),Ma.test(c)?r(a).position()[b]+"px":c})}),r.each({Height:"height",Width:"width"},function(a,b){r.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){r.fn[d]=function(e,f){var g=arguments.length&&(c||"boolean"!=typeof e),h=c||(e===!0||f===!0?"margin":"border");return T(this,function(b,c,e){var f;return r.isWindow(b)?0===d.indexOf("outer")?b["inner"+a]:b.document.documentElement["client"+a]:9===b.nodeType?(f=b.documentElement,Math.max(b.body["scroll"+a],f["scroll"+a],b.body["offset"+a],f["offset"+a],f["client"+a])):void 0===e?r.css(b,c,h):r.style(b,c,e,h)},b,g?e:void 0,g)}})}),r.fn.extend({bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}}),r.holdReady=function(a){a?r.readyWait++:r.ready(!0)},r.isArray=Array.isArray,r.parseJSON=JSON.parse,r.nodeName=B,"function"==typeof define&&define.amd&&define("jquery",[],function(){return r});var Vb=a.jQuery,Wb=a.$;return r.noConflict=function(b){return a.$===r&&(a.$=Wb),b&&a.jQuery===r&&(a.jQuery=Vb),r},b||(a.jQuery=a.$=r),r});
;
/*
 Copyright (C) Federico Zivolo 2017
 Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT).
 */(function(e,t){'object'==typeof exports&&'undefined'!=typeof module?module.exports=t():'function'==typeof define&&define.amd?define(t):e.Popper=t()})(this,function(){'use strict';function e(e){return e&&'[object Function]'==={}.toString.call(e)}function t(e,t){if(1!==e.nodeType)return[];var o=window.getComputedStyle(e,null);return t?o[t]:o}function o(e){return'HTML'===e.nodeName?e:e.parentNode||e.host}function n(e){if(!e||-1!==['HTML','BODY','#document'].indexOf(e.nodeName))return window.document.body;var i=t(e),r=i.overflow,p=i.overflowX,s=i.overflowY;return /(auto|scroll)/.test(r+s+p)?e:n(o(e))}function r(e){var o=e&&e.offsetParent,i=o&&o.nodeName;return i&&'BODY'!==i&&'HTML'!==i?-1!==['TD','TABLE'].indexOf(o.nodeName)&&'static'===t(o,'position')?r(o):o:window.document.documentElement}function p(e){var t=e.nodeName;return'BODY'!==t&&('HTML'===t||r(e.firstElementChild)===e)}function s(e){return null===e.parentNode?e:s(e.parentNode)}function d(e,t){if(!e||!e.nodeType||!t||!t.nodeType)return window.document.documentElement;var o=e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING,i=o?e:t,n=o?t:e,a=document.createRange();a.setStart(i,0),a.setEnd(n,0);var f=a.commonAncestorContainer;if(e!==f&&t!==f||i.contains(n))return p(f)?f:r(f);var l=s(e);return l.host?d(l.host,t):d(e,s(t).host)}function a(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:'top',o='top'===t?'scrollTop':'scrollLeft',i=e.nodeName;if('BODY'===i||'HTML'===i){var n=window.document.documentElement,r=window.document.scrollingElement||n;return r[o]}return e[o]}function f(e,t){var o=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=a(t,'top'),n=a(t,'left'),r=o?-1:1;return e.top+=i*r,e.bottom+=i*r,e.left+=n*r,e.right+=n*r,e}function l(e,t){var o='x'===t?'Left':'Top',i='Left'==o?'Right':'Bottom';return+e['border'+o+'Width'].split('px')[0]+ +e['border'+i+'Width'].split('px')[0]}function m(e,t,o,i){return _(t['offset'+e],o['client'+e],o['offset'+e],ie()?o['offset'+e]+i['margin'+('Height'===e?'Top':'Left')]+i['margin'+('Height'===e?'Bottom':'Right')]:0)}function h(){var e=window.document.body,t=window.document.documentElement,o=ie()&&window.getComputedStyle(t);return{height:m('Height',e,t,o),width:m('Width',e,t,o)}}function c(e){return se({},e,{right:e.left+e.width,bottom:e.top+e.height})}function g(e){var o={};if(ie())try{o=e.getBoundingClientRect();var i=a(e,'top'),n=a(e,'left');o.top+=i,o.left+=n,o.bottom+=i,o.right+=n}catch(e){}else o=e.getBoundingClientRect();var r={left:o.left,top:o.top,width:o.right-o.left,height:o.bottom-o.top},p='HTML'===e.nodeName?h():{},s=p.width||e.clientWidth||r.right-r.left,d=p.height||e.clientHeight||r.bottom-r.top,f=e.offsetWidth-s,m=e.offsetHeight-d;if(f||m){var g=t(e);f-=l(g,'x'),m-=l(g,'y'),r.width-=f,r.height-=m}return c(r)}function u(e,o){var i=ie(),r='HTML'===o.nodeName,p=g(e),s=g(o),d=n(e),a=t(o),l=+a.borderTopWidth.split('px')[0],m=+a.borderLeftWidth.split('px')[0],h=c({top:p.top-s.top-l,left:p.left-s.left-m,width:p.width,height:p.height});if(h.marginTop=0,h.marginLeft=0,!i&&r){var u=+a.marginTop.split('px')[0],b=+a.marginLeft.split('px')[0];h.top-=l-u,h.bottom-=l-u,h.left-=m-b,h.right-=m-b,h.marginTop=u,h.marginLeft=b}return(i?o.contains(d):o===d&&'BODY'!==d.nodeName)&&(h=f(h,o)),h}function b(e){var t=window.document.documentElement,o=u(e,t),i=_(t.clientWidth,window.innerWidth||0),n=_(t.clientHeight,window.innerHeight||0),r=a(t),p=a(t,'left'),s={top:r-o.top+o.marginTop,left:p-o.left+o.marginLeft,width:i,height:n};return c(s)}function y(e){var i=e.nodeName;return'BODY'===i||'HTML'===i?!1:'fixed'===t(e,'position')||y(o(e))}function w(e,t,i,r){var p={top:0,left:0},s=d(e,t);if('viewport'===r)p=b(s);else{var a;'scrollParent'===r?(a=n(o(e)),'BODY'===a.nodeName&&(a=window.document.documentElement)):'window'===r?a=window.document.documentElement:a=r;var f=u(a,s);if('HTML'===a.nodeName&&!y(s)){var l=h(),m=l.height,c=l.width;p.top+=f.top-f.marginTop,p.bottom=m+f.top,p.left+=f.left-f.marginLeft,p.right=c+f.left}else p=f}return p.left+=i,p.top+=i,p.right-=i,p.bottom-=i,p}function v(e){var t=e.width,o=e.height;return t*o}function E(e,t,o,i,n){var r=5<arguments.length&&void 0!==arguments[5]?arguments[5]:0;if(-1===e.indexOf('auto'))return e;var p=w(o,i,r,n),s={top:{width:p.width,height:t.top-p.top},right:{width:p.right-t.right,height:p.height},bottom:{width:p.width,height:p.bottom-t.bottom},left:{width:t.left-p.left,height:p.height}},d=Object.keys(s).map(function(e){return se({key:e},s[e],{area:v(s[e])})}).sort(function(e,t){return t.area-e.area}),a=d.filter(function(e){var t=e.width,i=e.height;return t>=o.clientWidth&&i>=o.clientHeight}),f=0<a.length?a[0].key:d[0].key,l=e.split('-')[1];return f+(l?'-'+l:'')}function x(e,t,o){var i=d(t,o);return u(o,i)}function O(e){var t=window.getComputedStyle(e),o=parseFloat(t.marginTop)+parseFloat(t.marginBottom),i=parseFloat(t.marginLeft)+parseFloat(t.marginRight),n={width:e.offsetWidth+i,height:e.offsetHeight+o};return n}function L(e){var t={left:'right',right:'left',bottom:'top',top:'bottom'};return e.replace(/left|right|bottom|top/g,function(e){return t[e]})}function S(e,t,o){o=o.split('-')[0];var i=O(e),n={width:i.width,height:i.height},r=-1!==['right','left'].indexOf(o),p=r?'top':'left',s=r?'left':'top',d=r?'height':'width',a=r?'width':'height';return n[p]=t[p]+t[d]/2-i[d]/2,n[s]=o===s?t[s]-i[a]:t[L(s)],n}function T(e,t){return Array.prototype.find?e.find(t):e.filter(t)[0]}function C(e,t,o){if(Array.prototype.findIndex)return e.findIndex(function(e){return e[t]===o});var i=T(e,function(e){return e[t]===o});return e.indexOf(i)}function N(t,o,i){var n=void 0===i?t:t.slice(0,C(t,'name',i));return n.forEach(function(t){t.function&&console.warn('`modifier.function` is deprecated, use `modifier.fn`!');var i=t.function||t.fn;t.enabled&&e(i)&&(o.offsets.popper=c(o.offsets.popper),o.offsets.reference=c(o.offsets.reference),o=i(o,t))}),o}function k(){if(!this.state.isDestroyed){var e={instance:this,styles:{},attributes:{},flipped:!1,offsets:{}};e.offsets.reference=x(this.state,this.popper,this.reference),e.placement=E(this.options.placement,e.offsets.reference,this.popper,this.reference,this.options.modifiers.flip.boundariesElement,this.options.modifiers.flip.padding),e.originalPlacement=e.placement,e.offsets.popper=S(this.popper,e.offsets.reference,e.placement),e.offsets.popper.position='absolute',e=N(this.modifiers,e),this.state.isCreated?this.options.onUpdate(e):(this.state.isCreated=!0,this.options.onCreate(e))}}function W(e,t){return e.some(function(e){var o=e.name,i=e.enabled;return i&&o===t})}function B(e){for(var t=[!1,'ms','Webkit','Moz','O'],o=e.charAt(0).toUpperCase()+e.slice(1),n=0;n<t.length-1;n++){var i=t[n],r=i?''+i+o:e;if('undefined'!=typeof window.document.body.style[r])return r}return null}function D(){return this.state.isDestroyed=!0,W(this.modifiers,'applyStyle')&&(this.popper.removeAttribute('x-placement'),this.popper.style.left='',this.popper.style.position='',this.popper.style.top='',this.popper.style[B('transform')]=''),this.disableEventListeners(),this.options.removeOnDestroy&&this.popper.parentNode.removeChild(this.popper),this}function H(e,t,o,i){var r='BODY'===e.nodeName,p=r?window:e;p.addEventListener(t,o,{passive:!0}),r||H(n(p.parentNode),t,o,i),i.push(p)}function P(e,t,o,i){o.updateBound=i,window.addEventListener('resize',o.updateBound,{passive:!0});var r=n(e);return H(r,'scroll',o.updateBound,o.scrollParents),o.scrollElement=r,o.eventsEnabled=!0,o}function A(){this.state.eventsEnabled||(this.state=P(this.reference,this.options,this.state,this.scheduleUpdate))}function M(e,t){return window.removeEventListener('resize',t.updateBound),t.scrollParents.forEach(function(e){e.removeEventListener('scroll',t.updateBound)}),t.updateBound=null,t.scrollParents=[],t.scrollElement=null,t.eventsEnabled=!1,t}function I(){this.state.eventsEnabled&&(window.cancelAnimationFrame(this.scheduleUpdate),this.state=M(this.reference,this.state))}function R(e){return''!==e&&!isNaN(parseFloat(e))&&isFinite(e)}function U(e,t){Object.keys(t).forEach(function(o){var i='';-1!==['width','height','top','right','bottom','left'].indexOf(o)&&R(t[o])&&(i='px'),e.style[o]=t[o]+i})}function Y(e,t){Object.keys(t).forEach(function(o){var i=t[o];!1===i?e.removeAttribute(o):e.setAttribute(o,t[o])})}function F(e,t,o){var i=T(e,function(e){var o=e.name;return o===t}),n=!!i&&e.some(function(e){return e.name===o&&e.enabled&&e.order<i.order});if(!n){var r='`'+t+'`';console.warn('`'+o+'`'+' modifier is required by '+r+' modifier in order to work, be sure to include it before '+r+'!')}return n}function j(e){return'end'===e?'start':'start'===e?'end':e}function K(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],o=ae.indexOf(e),i=ae.slice(o+1).concat(ae.slice(0,o));return t?i.reverse():i}function q(e,t,o,i){var n=e.match(/((?:\-|\+)?\d*\.?\d*)(.*)/),r=+n[1],p=n[2];if(!r)return e;if(0===p.indexOf('%')){var s;switch(p){case'%p':s=o;break;case'%':case'%r':default:s=i;}var d=c(s);return d[t]/100*r}if('vh'===p||'vw'===p){var a;return a='vh'===p?_(document.documentElement.clientHeight,window.innerHeight||0):_(document.documentElement.clientWidth,window.innerWidth||0),a/100*r}return r}function G(e,t,o,i){var n=[0,0],r=-1!==['right','left'].indexOf(i),p=e.split(/(\+|\-)/).map(function(e){return e.trim()}),s=p.indexOf(T(p,function(e){return-1!==e.search(/,|\s/)}));p[s]&&-1===p[s].indexOf(',')&&console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');var d=/\s*,\s*|\s+/,a=-1===s?[p]:[p.slice(0,s).concat([p[s].split(d)[0]]),[p[s].split(d)[1]].concat(p.slice(s+1))];return a=a.map(function(e,i){var n=(1===i?!r:r)?'height':'width',p=!1;return e.reduce(function(e,t){return''===e[e.length-1]&&-1!==['+','-'].indexOf(t)?(e[e.length-1]=t,p=!0,e):p?(e[e.length-1]+=t,p=!1,e):e.concat(t)},[]).map(function(e){return q(e,n,t,o)})}),a.forEach(function(e,t){e.forEach(function(o,i){R(o)&&(n[t]+=o*('-'===e[i-1]?-1:1))})}),n}for(var z=Math.min,V=Math.floor,_=Math.max,X=['native code','[object MutationObserverConstructor]'],Q=function(e){return X.some(function(t){return-1<(e||'').toString().indexOf(t)})},J='undefined'!=typeof window,Z=['Edge','Trident','Firefox'],$=0,ee=0;ee<Z.length;ee+=1)if(J&&0<=navigator.userAgent.indexOf(Z[ee])){$=1;break}var i,te=J&&Q(window.MutationObserver),oe=te?function(e){var t=!1,o=0,i=document.createElement('span'),n=new MutationObserver(function(){e(),t=!1});return n.observe(i,{attributes:!0}),function(){t||(t=!0,i.setAttribute('x-index',o),++o)}}:function(e){var t=!1;return function(){t||(t=!0,setTimeout(function(){t=!1,e()},$))}},ie=function(){return void 0==i&&(i=-1!==navigator.appVersion.indexOf('MSIE 10')),i},ne=function(e,t){if(!(e instanceof t))throw new TypeError('Cannot call a class as a function')},re=function(){function e(e,t){for(var o,n=0;n<t.length;n++)o=t[n],o.enumerable=o.enumerable||!1,o.configurable=!0,'value'in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}return function(t,o,i){return o&&e(t.prototype,o),i&&e(t,i),t}}(),pe=function(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e},se=Object.assign||function(e){for(var t,o=1;o<arguments.length;o++)for(var i in t=arguments[o],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},de=['auto-start','auto','auto-end','top-start','top','top-end','right-start','right','right-end','bottom-end','bottom','bottom-start','left-end','left','left-start'],ae=de.slice(3),fe={FLIP:'flip',CLOCKWISE:'clockwise',COUNTERCLOCKWISE:'counterclockwise'},le=function(){function t(o,i){var n=this,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};ne(this,t),this.scheduleUpdate=function(){return requestAnimationFrame(n.update)},this.update=oe(this.update.bind(this)),this.options=se({},t.Defaults,r),this.state={isDestroyed:!1,isCreated:!1,scrollParents:[]},this.reference=o.jquery?o[0]:o,this.popper=i.jquery?i[0]:i,this.options.modifiers={},Object.keys(se({},t.Defaults.modifiers,r.modifiers)).forEach(function(e){n.options.modifiers[e]=se({},t.Defaults.modifiers[e]||{},r.modifiers?r.modifiers[e]:{})}),this.modifiers=Object.keys(this.options.modifiers).map(function(e){return se({name:e},n.options.modifiers[e])}).sort(function(e,t){return e.order-t.order}),this.modifiers.forEach(function(t){t.enabled&&e(t.onLoad)&&t.onLoad(n.reference,n.popper,n.options,t,n.state)}),this.update();var p=this.options.eventsEnabled;p&&this.enableEventListeners(),this.state.eventsEnabled=p}return re(t,[{key:'update',value:function(){return k.call(this)}},{key:'destroy',value:function(){return D.call(this)}},{key:'enableEventListeners',value:function(){return A.call(this)}},{key:'disableEventListeners',value:function(){return I.call(this)}}]),t}();return le.Utils=('undefined'==typeof window?global:window).PopperUtils,le.placements=de,le.Defaults={placement:'bottom',eventsEnabled:!0,removeOnDestroy:!1,onCreate:function(){},onUpdate:function(){},modifiers:{shift:{order:100,enabled:!0,fn:function(e){var t=e.placement,o=t.split('-')[0],i=t.split('-')[1];if(i){var n=e.offsets,r=n.reference,p=n.popper,s=-1!==['bottom','top'].indexOf(o),d=s?'left':'top',a=s?'width':'height',f={start:pe({},d,r[d]),end:pe({},d,r[d]+r[a]-p[a])};e.offsets.popper=se({},p,f[i])}return e}},offset:{order:200,enabled:!0,fn:function(e,t){var o,i=t.offset,n=e.placement,r=e.offsets,p=r.popper,s=r.reference,d=n.split('-')[0];return o=R(+i)?[+i,0]:G(i,p,s,d),'left'===d?(p.top+=o[0],p.left-=o[1]):'right'===d?(p.top+=o[0],p.left+=o[1]):'top'===d?(p.left+=o[0],p.top-=o[1]):'bottom'===d&&(p.left+=o[0],p.top+=o[1]),e.popper=p,e},offset:0},preventOverflow:{order:300,enabled:!0,fn:function(e,t){var o=t.boundariesElement||r(e.instance.popper);e.instance.reference===o&&(o=r(o));var i=w(e.instance.popper,e.instance.reference,t.padding,o);t.boundaries=i;var n=t.priority,p=e.offsets.popper,s={primary:function(e){var o=p[e];return p[e]<i[e]&&!t.escapeWithReference&&(o=_(p[e],i[e])),pe({},e,o)},secondary:function(e){var o='right'===e?'left':'top',n=p[o];return p[e]>i[e]&&!t.escapeWithReference&&(n=z(p[o],i[e]-('right'===e?p.width:p.height))),pe({},o,n)}};return n.forEach(function(e){var t=-1===['left','top'].indexOf(e)?'secondary':'primary';p=se({},p,s[t](e))}),e.offsets.popper=p,e},priority:['left','right','top','bottom'],padding:5,boundariesElement:'scrollParent'},keepTogether:{order:400,enabled:!0,fn:function(e){var t=e.offsets,o=t.popper,i=t.reference,n=e.placement.split('-')[0],r=V,p=-1!==['top','bottom'].indexOf(n),s=p?'right':'bottom',d=p?'left':'top',a=p?'width':'height';return o[s]<r(i[d])&&(e.offsets.popper[d]=r(i[d])-o[a]),o[d]>r(i[s])&&(e.offsets.popper[d]=r(i[s])),e}},arrow:{order:500,enabled:!0,fn:function(e,t){if(!F(e.instance.modifiers,'arrow','keepTogether'))return e;var o=t.element;if('string'==typeof o){if(o=e.instance.popper.querySelector(o),!o)return e;}else if(!e.instance.popper.contains(o))return console.warn('WARNING: `arrow.element` must be child of its popper element!'),e;var i=e.placement.split('-')[0],n=e.offsets,r=n.popper,p=n.reference,s=-1!==['left','right'].indexOf(i),d=s?'height':'width',a=s?'top':'left',f=s?'left':'top',l=s?'bottom':'right',m=O(o)[d];p[l]-m<r[a]&&(e.offsets.popper[a]-=r[a]-(p[l]-m)),p[a]+m>r[l]&&(e.offsets.popper[a]+=p[a]+m-r[l]);var h=p[a]+p[d]/2-m/2,g=h-c(e.offsets.popper)[a];return g=_(z(r[d]-m,g),0),e.arrowElement=o,e.offsets.arrow={},e.offsets.arrow[a]=Math.round(g),e.offsets.arrow[f]='',e},element:'[x-arrow]'},flip:{order:600,enabled:!0,fn:function(e,t){if(W(e.instance.modifiers,'inner'))return e;if(e.flipped&&e.placement===e.originalPlacement)return e;var o=w(e.instance.popper,e.instance.reference,t.padding,t.boundariesElement),i=e.placement.split('-')[0],n=L(i),r=e.placement.split('-')[1]||'',p=[];switch(t.behavior){case fe.FLIP:p=[i,n];break;case fe.CLOCKWISE:p=K(i);break;case fe.COUNTERCLOCKWISE:p=K(i,!0);break;default:p=t.behavior;}return p.forEach(function(s,d){if(i!==s||p.length===d+1)return e;i=e.placement.split('-')[0],n=L(i);var a=e.offsets.popper,f=e.offsets.reference,l=V,m='left'===i&&l(a.right)>l(f.left)||'right'===i&&l(a.left)<l(f.right)||'top'===i&&l(a.bottom)>l(f.top)||'bottom'===i&&l(a.top)<l(f.bottom),h=l(a.left)<l(o.left),c=l(a.right)>l(o.right),g=l(a.top)<l(o.top),u=l(a.bottom)>l(o.bottom),b='left'===i&&h||'right'===i&&c||'top'===i&&g||'bottom'===i&&u,y=-1!==['top','bottom'].indexOf(i),w=!!t.flipVariations&&(y&&'start'===r&&h||y&&'end'===r&&c||!y&&'start'===r&&g||!y&&'end'===r&&u);(m||b||w)&&(e.flipped=!0,(m||b)&&(i=p[d+1]),w&&(r=j(r)),e.placement=i+(r?'-'+r:''),e.offsets.popper=se({},e.offsets.popper,S(e.instance.popper,e.offsets.reference,e.placement)),e=N(e.instance.modifiers,e,'flip'))}),e},behavior:'flip',padding:5,boundariesElement:'viewport'},inner:{order:700,enabled:!1,fn:function(e){var t=e.placement,o=t.split('-')[0],i=e.offsets,n=i.popper,r=i.reference,p=-1!==['left','right'].indexOf(o),s=-1===['top','left'].indexOf(o);return n[p?'left':'top']=r[t]-(s?n[p?'width':'height']:0),e.placement=L(t),e.offsets.popper=c(n),e}},hide:{order:800,enabled:!0,fn:function(e){if(!F(e.instance.modifiers,'hide','preventOverflow'))return e;var t=e.offsets.reference,o=T(e.instance.modifiers,function(e){return'preventOverflow'===e.name}).boundaries;if(t.bottom<o.top||t.left>o.right||t.top>o.bottom||t.right<o.left){if(!0===e.hide)return e;e.hide=!0,e.attributes['x-out-of-boundaries']=''}else{if(!1===e.hide)return e;e.hide=!1,e.attributes['x-out-of-boundaries']=!1}return e}},computeStyle:{order:850,enabled:!0,fn:function(e,t){var o=t.x,i=t.y,n=e.offsets.popper,p=T(e.instance.modifiers,function(e){return'applyStyle'===e.name}).gpuAcceleration;void 0!==p&&console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');var s,d,a=void 0===p?t.gpuAcceleration:p,f=r(e.instance.popper),l=g(f),m={position:n.position},h={left:V(n.left),top:V(n.top),bottom:V(n.bottom),right:V(n.right)},c='bottom'===o?'top':'bottom',u='right'===i?'left':'right',b=B('transform');if(d='bottom'==c?-l.height+h.bottom:h.top,s='right'==u?-l.width+h.right:h.left,a&&b)m[b]='translate3d('+s+'px, '+d+'px, 0)',m[c]=0,m[u]=0,m.willChange='transform';else{var y='bottom'==c?-1:1,w='right'==u?-1:1;m[c]=d*y,m[u]=s*w,m.willChange=c+', '+u}var v={"x-placement":e.placement};return e.attributes=se({},v,e.attributes),e.styles=se({},m,e.styles),e},gpuAcceleration:!0,x:'bottom',y:'right'},applyStyle:{order:900,enabled:!0,fn:function(e){return U(e.instance.popper,e.styles),Y(e.instance.popper,e.attributes),e.offsets.arrow&&U(e.arrowElement,e.offsets.arrow),e},onLoad:function(e,t,o,i,n){var r=x(n,t,e),p=E(o.placement,r,t,e,o.modifiers.flip.boundariesElement,o.modifiers.flip.padding);return t.setAttribute('x-placement',p),U(t,{position:'absolute'}),o},gpuAcceleration:void 0}}},le});
//# sourceMappingURL=popper.min.js.map
;
/*!
* jQuery Cookie Plugin
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2011, Klaus Hartl
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://www.opensource.org/licenses/mit-license.php
* http://www.opensource.org/licenses/GPL-2.0
*/
(function ($) {
    $.cookie = function (key, value, options) {

        // key and at least value given, set cookie...
        if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
            options = $.extend({}, options);

            if (value === null || value === undefined) {
                options.expires = -1;
            }

            if (typeof options.expires === 'number') {
                var days = options.expires, t = options.expires = new Date();
                t.setDate(t.getDate() + days);
            }

            value = String(value);

            return (document.cookie = [
                encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
                options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
                options.path ? '; path=' + options.path : '',
                options.domain ? '; domain=' + options.domain : '',
                options.secure ? '; secure' : ''
            ].join(''));
        }

        // key and possibly options given, get cookie...
        options = value || {};
        var decode = options.raw ? function (s) { return s; } : decodeURIComponent;

        var pairs = document.cookie.split('; ');
        for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
            if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined
        }
        return null;
    };
})(jQuery);;


function clearlabels() {


    // CLEAR VALUE ON FOCUS
    $('.labelvalue').each(function () {

        var default_value = this.placeholder;
        $(this).focus(function () {
            
                this.placeholder = '';
            
        });
        $(this).blur(function () {
            if (this.placeholder == '') {
                this.placeholder = default_value;
            }
        });
    });

}


function initializeMap2(e, o, n, t) {
    var i = new google.maps.LatLng(e, o),
        a = {
            zoom: 13,
            center: i,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            scaleControl: !1,
            zoomControl: !1,
            mapTypeControl: !1,
            disableDefaultUI: !0
        };
    map2 = new google.maps.Map(t, a), marker2 = new google.maps.Marker({
        position: i,
        map: map2,
        title: n
    })
}

function setStoreInfoChange(e) {
    $("#storeInfoChange").show(), "" == $.trim($("#storeInfoChange").html()) ? $.ajax({
        url: "/assets/ajax/StoreChange.aspx",
         
        cache: !1
    }).done(function(e) {
        $("#storeInfoChange").html(e), setHTMLDropdowns(), $("#storeInfo").toggle(), void 0 !== map2 && (google.maps.event.trigger(map2, "resize"), map2.setCenter(marker2.getPosition()))
    }) : e && ($("#storeInfo").toggle(), void 0 !== map2 && (google.maps.event.trigger(map2, "resize"), map2.setCenter(marker2.getPosition()))), $("#storeInfo").is(":visible") && $("#storeInfo .modalTitle").focus()
}

function setFlyoutMenuPositioningiPad(e) {
    var o = $(e).children("div").first()[0],
        n = $(window).height() - 27,
        t = $(window).scrollTop(),
        i = $(o).height(),
        a = $(o).parent().offset().top,
        r = 0;
    i + a > n + $(window).scrollTop() && (r = -1 * i, t > a - -1 * (r += n + $(window).scrollTop() - (i + a) + i - $(o).parent().height()) && (r = -1 * (a - t))), $(o).css("top", r)
}

function setFlyoutMenuPositioning(i) {
    var o, t = Math.floor($("#primary ul .prodNav ul").offset().top),
        r = $(i).children("div").first()[0],
        e = $(window).height() - 27,
        h = $(window).scrollTop(),
        l = $(r).outerHeight(),
        p = $(i).offset().top,
        n = p - t,
        a = l / 2,
        u = $(i).index(),
        d = $("#primary ul .prodNav ul li").height();
    $(r).css("top", 0);
  
    var bottomofFlyout = l *1.1 + p;
    var bottomofWindow = $(window).height() + $(window).scrollTop();
    // console.log(bottomofFlyout);
    // console.log(bottomofWindow);

    if (bottomofFlyout > bottomofWindow) {
        // we need to try to readjust window by ancoring it to the bottom of the scrollable window.
  
       // console.log(bottomofFlyout);
        //console.log($(r).height());
        var movetop = bottomofFlyout - bottomofWindow - 10;
        var globalposition = p - movetop;

        // fist lets make sure it does not go above the scrollable window.
        if (globalposition < $(window).scrollTop())
        {
           movetop = p - $(window).scrollTop();
        }

        globalposition = p - movetop

        if (globalposition < 0) {
           movetop = p ;
        }

  
        $(r).css("top", -movetop);

    }
   

    //t = $("#primary ul .prodNav ul").height(), 200 > l && n + a > t ? (o = -(a + 2 * u), e += 27) : o = 0 > n - a ? -n : -a, a + p > e - d && (o = -1 * l, h > p - -1 * (o += e - (l + p) + l - $(r).parent().height()) && (o = -1 * (p - h))), 12 == u && (o -= 100), $(r).css("top", o)
}

var map2, marker2;
$(document).ready(function () {

    $(".MobileFramework #mainMenu").css("display", "block");

    $("ul.errors").hide(), $(".labelvalue").each(function() {
        var e = this.value;
        $(this).focus(function() {
            this.value == e && (this.value = "")
        }), $(this).blur(function() {
            "" == this.value && (this.value = e)
        })
    }), $('a[rel="external"]').click(function() {
        return window.open($(this).attr("href")), !1
    }), $(".clickable").click(function(e) {
        return e.ctrlKey || "external" == $(this).find("a").attr("rel") ? void window.open($(this).find("a").attr("href")) : (window.location = $(this).find("a").attr("href"), !1)
    }), $(".fade").hover(function() {
        $(this).animate({
            opacity: .7
        }, "fast")
    }, function() {
        $(this).animate({
            opacity: 1
        }, "fast")
    }),// $(".myStore .info a").click(function() {
    //    return $("#storeInfo").toggle(), $("#storeInfo").is(":visible") && $("#storeInfo .modalTitle").focus(), $(".changeLinkBtn").removeClass("hidden"), $(".changeLinkText").removeClass("hidden"), "029" == $("#storeInfo").data("store") && setStoreInfoChange(!1), !1
    //}), $(".myStore .title a").click(function() {
    //    return $("#storeInfo").show(), $("#storeInfo").is(":visible") && $("#storeInfo .modalTitle").focus(), $(".changeLinkBtn").removeClass("hidden"), $(".changeLinkText").removeClass("hidden"), "029" == $("#storeInfo").data("store") ? setStoreInfoChange(!1) : $("#storeInfoChange").hide(), !1
    //}), $(".MobileFramework .utilStoreInfo").click(function() {
    //    return $("#storeInfo").toggle(), $("#storeInfo").is(":visible") && $("#storeInfo .modalTitle").focus(), $(".changeLinkBtn").removeClass("hidden"), $(".changeLinkText").removeClass("hidden"), "029" == $("#storeInfo").data("store") ? setStoreInfoChange(!1) : $("#storeInfoChange").hide(), !1
    //}), $("#ucHeaderRegular_cart_headerContainer .utilStoreInfo").click(function() {
    //    return $("#storeInfo").toggle(), $("#storeInfo").is(":visible") && $("#storeInfo .modalTitle").focus(), $(".changeLinkBtn").removeClass("hidden"), $(".changeLinkText").removeClass("hidden"), "029" == $("#storeInfo").data("store") ? setStoreInfoChange(!1) : $("#storeInfoChange").hide(), !1
    //}), $("#ctl00_ucHeaderMCOL_oam_headerContainer .utilStoreInfo").click(function() {
    //    return $("#storeInfo").toggle(), $("#storeInfo").is(":visible") && $("#storeInfo .modalTitle").focus(), $(".changeLinkBtn").removeClass("hidden"), $(".changeLinkText").removeClass("hidden"), "029" == $("#storeInfo").data("store") ? setStoreInfoChange(!1) : $("#storeInfoChange").hide(), !1
    //}), $("#storeInfo .close").click(function() {
    //    return $("#storeInfo").removeClass("forceopen"), $("#storeInfo").hide(), $("#storeInfoChange").hide(), !1
    //}), $(".myStore .changeLoc").click(function() {
    //    return $(".changeLinkBtn").addClass("hidden"), $(".changeLinkText").addClass("hidden"), setStoreInfoChange(!0), !1
    //}), $("#selectedStoreChange").click(function() {
    //    $("#storeInfoChange").show()
    //}), $("#selectedStoreChangeAjax").click(function() {
    //    $(".changeLinkBtn").addClass("hidden"), $(".changeLinkText").addClass("hidden"), $.ajax({
    //        url: "/assets/ajax/StoreChange.aspx",
    //        cache: !1
    //    }).done(function(e) {
    //        $("#storeInfoChange").html(e), setHTMLDropdowns(), $("#storeInfoChange").show();
    //        $("#storeInfoChange .selectorHref").focus();

    //    })
    //}), $("#storeselect").change(function() {
    //    $(".loc.select").addClass("hidden"), $(".loc.store").removeClass("hidden"), $(".info").removeClass("hidden"), $(".changeLoc").removeClass("hidden")
    //}).change(), $("#ddlChangeStore").change(function() {
    //    return $("#storeselect").submit(), !1
        //}), 
        $("#subscribeForm").submit(function () {
        $("#subscribeForm input[name='EMAIL_ADDR']").val($("#subscribeForm input[name='email']").val())
    }), $(".quickView").fancybox({
        width: 670,
        idleTime: false,
        height: 640,
        "min-height": 620,
        autoScale: !1,
        transitionIn: "elastic",
        transitionOut: "fade",
        type: "iframe",
        scrolling: "no",
        afterShow: function () { $('.fancybox-button--close').focus(); }
    })
       
});;
// Needed globals
var currentCompare = "";
var timeoutTopMenuSub;
var itemprice = 0;
var adVehicleImpressions = [];
var addOnLayer;
var frequentlyBoughtLayer;
var bundleOptionsLayer;
var productsLayer;
var configuratorLayer;
var openboxLayer;
var sentProducts = false;
var sentAdOns = false;
var sentBundles = false;
var sentfrequentlybought = false;
var sentconfigurator = false;
var sentopenbox = false;
var geotargetcomplete = false;
var productclicked = false;
var hideIT = "";
var returnToIT = "";
var sentopenbox = false;
var closeStoreSelector = false;
var keyisdown = false;
var usingGA4 = false;
var usingGA3 = false;
var processedlists = [];
var processedPromolists = [];
var hasTouch = true;


var isLogin = "" + localStorage.getItem("login");
localStorage.setItem("login", "");


function isInViewport(element) {
    const rect = element.getBoundingClientRect();

    if ($(element).hasClass("slick-slide")) {

       rect = $(element).parent()[0].getBoundingClientRect()

        //if ($(element).data('list') == "Homepage PowerSpec Banner Ad") {
        //    console.log($(element).parent()[0].getBoundingClientRect());
        //}

        return (
            rect.top > 0 &&

            rect.top <= (window.innerHeight || document.documentElement.clientHeight)

         

        );

    }

    else {

       

        return (
            rect.top > 0 &&

            rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)

        );
    }
}



function ImgError(source) {
    var test = source.src;
    var newSRC = "/assets/images/noimage.gif";
    if (source.src.length > 0) {
        var list = test.split("/");
        if (list.length == 4) {
            var graphic = list[3].split(".");
            if (graphic.length == 2) {
                var pimg = graphic[0].split("_");
                if (pimg.length == 2) {
                    if (!isNaN(pimg[0]) && !isNaN(pimg[1])) {
                        newSRC = "/assets/images/noimageproduct.gif";
                    }
                }
            }
        }

    }
    source.src = newSRC;
    source.onerror = "";
    return true;
}


function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, '\\$&');
    var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, ' '));
}

function handleOnKeyDown(e, itm) {

    if (event.key == "Enter") {
        event.preventDefault();
        event.target.click();
    }

    //if (e.keyCode == 13 && itm.prop('tagName') != "A" && itm.prop('tagName') != "BUTTON" && itm.prop('tagName') != "INPUT") {
    //    itm.click();
    //}

}
function validatePhoneNumber(elementValue) {
    var phoneNumberPattern = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
    return phoneNumberPattern.test(elementValue);
}


function isEmail(email) {
    var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return regex.test(email);
}

function loadLazy() {


    $(".lazy-img").each(function () {
        if ($(this).attr("src") != $(this).data("full") && $(this).data("full") != "") {
            $(this).attr("src", $(this).data("full"));
        }
    });

}
//********  LoginModalItems
function setServiceButton() {

    // remm out whole function first...
    // before finding, lets see if the user is already logged in and if so, lets alter the a tag to the after login data value...
    //if ($("body").hasClass("isLoggedIn")) {
    //    // switch the links
    //    $(".serviceBtn a").each(function () {

    //        if (typeof $(this).data("after") !== "undefined")
    //        {
    //            $(this).attr("href", $(this).data("after"));



    //        }

    //    });

    //}

    // DO NOT USE ANY BELOW

    ////try {
    ////    $(".serviceBtn a").fancybox({
    ////        'width': 600,
    ////        'height': '95%',
    ////        'autoScale': false,
    ////        'transitionIn': 'elastic',
    ////        'transitionOut': 'fade',
    ////        'type': 'iframe',
    ////        'idleTime': false,
    ////        'baseClass': 'fbModalLogin'

    ////    });

    ////} catch (app) {

    ////}




    ////$(".serviceBtn a").click(function () {

    ////    var afterLogin = "";
    ////    if (typeof $(this).data("after") !== "undefined") {
    ////        afterLogin = $(this).data("after");
    ////    }

    ////    //console.log("adding Listener");
    ////    var mliframe = $($(".fbModalLogin .fancybox-iframe").contents()[0], window);
    ////    // var mliframe = $(".fbModalLogin .fancybox-iframe").contents();
    ////    window.addEventListener("message", function (event) {

    ////        if (event.origin !== "https://devaccount.microcenter.com") {

    ////            return;
    ////        }
    ////        else if (event.data.loginSuccess === true) {

    ////            if (afterLogin != "") {
    ////                $(".fbModalLogin .fancybox-iframe").attr("src", afterLogin);
    ////            }
    ////            else
    ////            {
    ////                localStorage.setItem("login", "true");
    ////                location.reload(true);
    ////            }
    ////            // Close modal window/redirect/reload page
    ////        }
    ////    }, false);



    ////});


}


function getUrlParameter(url, sParam) {



    var sPageURL = url.split('?')[0];

    var sURLVariables = url.split('?')[1].split('&');



    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0].toLowerCase() === sParam.toLowerCase()) {
            return typeof sParameterName[1] === undefined ? "" : decodeURIComponent(sParameterName[1]);
        }
    }

    return "";
};

function setModalLogin() {

    return;
    // rem out whole thing for now.
    // before finding, lets see if the user is already logged in and if so, lets alter the a tag to the after login data value...
    if ($("body").hasClass("isLoggedIn")) {
        // switch the links
        $(".login-modal").each(function () {

            if (typeof $(this).data("after") !== "undefined") {
                $(this).attr("href", $(this).data("after"));



            }

        });

    }


    try {
        $(".login-modal").fancybox({
            'width': 600,
            'height': '95%',
            'autoScale': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'type': 'iframe',
            'idleTime': false,
            'baseClass': 'fbModalLogin',
            'afterShow': function () { $('.fancybox-button--close').focus(); }

        });

    } catch (app) {

    }



    $(".login-modal").click(function () {


        try {
            $('#mainMenu').panel('close');
        }
        catch (ex) {

        }
        //console.log("adding Listener");
        var mliframe = $($(".fbModalLogin .fancybox-iframe").contents()[0], window);
        // var mliframe = $(".fbModalLogin .fancybox-iframe").contents();
        window.addEventListener("message", function (event) {

            if (event.origin.toLowerCase().indexOf(".microcenter.com") <= 0) {

                return;
            }
            else if (event.data.loginSuccess === true) {
                localStorage.setItem("login", "true");
                location.reload(true);
                // Close modal window/redirect/reload page
            }
        }, false);



    });
}

function resetLoading() {
    $(".body-loading").css("display", "none");
    $(".body-loading").css("background-color", "transparent");
}


//***********  share functions for Product Page

function copyFuncProduct() {

    if (usingGA4) {
        gtag('event', 'Configure Your PC', {
            'event_type': 'share',
            'event_action': 'copy_url'
        });
    }
    if (usingGA3) {
        ga('mc.send', 'event', 'Configure Your PC', 'share', 'copy_url');
    }

    var copyText = document.getElementById("shareURL");
    copyText.select();
    copyText.setSelectionRange(0, 99999);
    document.execCommand("copy");
    var tooltip = document.getElementById("myTooltip");
    tooltip.innerHTML = "Copied";

    $(".desktopShare .dropdown-menu").addClass("show");
    $(".desktopShare .dropdown").addClass("show");






    setTimeout(function () { tooltip.innerHTML = "<i class=\"fa fa-copy\"></i>Copy"; }, 3000);

    setTimeout(function () {
        $(".desktopShare .dropdown-menu").addClass("show");
        $(".desktopShare .dropdown").addClass("show");
    }, 100);

    $("#Actiontooltip").innerHTML = "<i class=\"fa fa-copy\"></i>Copy";

}
function outFuncProduct() {
    var tooltip = document.getElementById("myTooltip");

    if (tooltip.innerHTML != "Copied") {
        tooltip.innerHTML = "<i class=\"fa fa-copy\"></i>Copy";

    }
    $("#Actiontooltip").innerHTML = "<i class=\"fa fa-copy\"></i>Copy";

}


function bindSubmit() {
    $(".crtfrm").unbind('submit');

    $(".crtfrm").submit(function (e) {

       

        var carttype = "instore";
        thisForm = $(this);
        var isAjax = false;
        var thisAjax = $(this).find("input[name='ajax']");
        var actionType = $(this).find("input[name='cartType']");
        var na = $(this).find("input[name='na']");
        var noaddons = (na == null || na.val() == "" || na.val() == "true" );
        if (actionType.length) {
            carttype = actionType.val();
        }

        if (thisAjax.length && thisAjax.val() == "true") {




            isAjax = true;
            e.preventDefault();


        }



        var productIDs = "";
        var count = 0;
        var rulecount = 0;
        var rules = new Array();
        var rf = "";
        var existingCartIDs





        if ($(".crtfrm input[name='rf']").val() != null) {
            if ($(this).find("input[name='rf']").val().indexOf(",") < 0) {
                rf = $(this).find("input[name='rf']").val();
            }
        }



        if (rf == "Frequently Bought Together") {

            $("#FrequentyPurchasedTogether input[name='productIDsFB']:checked").each(function () {

                if (count > 0) {
                    productIDs += ",";
                }
                productIDs += $(this).val();


                count++;
                var myID = $(this).val();


            });
            $(this).find("input[name='productIDs']").val(productIDs);
        }

        else if (!noaddons) {

            try {


                $("#interstitialfrm input[name='productIDs']:checked").each(function () {

                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();



                    count++;
                    var myID = $(this).val();


                    var rulename = $("#productRule_" + myID).val();

                    if (rulename != null) {

                        if (rf.length > 0) {
                            rf = rf + ",";
                        }
                        rf = rf + rulename;
                    }
                    var masterSku = $("input[name = 'sku']").val();
                    // here we need to do the gaq push

                    if ($("#sku_" + myID).val() != null) {

                        // window.alert("Pushing: " + $("#source_" + myID).val() + " - " + $("#advehicle_" + myID).val() + "," + $("#sku_" + myID).val() + "," + 'from:' + masterSku + "," + $("#price_" + myID).val());

                        //   _gaq.push(['_trackEvent', $("#source_" + myID).val() + ' - ' + $("#advehicle_" + myID).val(), $("#sku_" + myID).val(), 'from:' + masterSku], $("#price_" + myID).val());

                    }


                });

                $("#serviceSkufrm input[name='productIDs']:checked").each(function () {

                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();



                    count++;
                    var myID = $(this).val();


                    var rulename = $("#productRule_" + myID).val();

                    if (rulename != null) {

                        if (rf.length > 0) {
                            rf = rf + ",";
                        }
                        rf = rf + rulename;
                    }
                    var masterSku = $("input[name = 'sku']").val();
                    // here we need to do the gaq push

                    if ($("#sku_" + myID).val() != null) {

                        // window.alert("Pushing: " + $("#source_" + myID).val() + " - " + $("#advehicle_" + myID).val() + "," + $("#sku_" + myID).val() + "," + 'from:' + masterSku + "," + $("#price_" + myID).val());

                        //   _gaq.push(['_trackEvent', $("#source_" + myID).val() + ' - ' + $("#advehicle_" + myID).val(), $("#sku_" + myID).val(), 'from:' + masterSku], $("#price_" + myID).val());

                    }


                });

                $("#interstitialfrm .productIDsRadio:checked").each(function () {

                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();
                    count++;
                    var myID = $(this).val();


                    var rulename = $("#productRule_" + myID).val();

                    if (rulename != null) {

                        if (rf.length > 0) {
                            rf = rf + ",";
                        }
                        rf = rf + rulename;
                    }
                    var masterSku = $("input[name = 'sku']").val();
                    // here we need to do the gaq push

                    if ($("#sku_" + myID).val() != null) {

                        // window.alert("Pushing2: " + $("#source_" + myID).val() + " - " + $("#advehicle_" + myID).val() + "," + $("#sku_" + myID).val() + "," + 'from:' + masterSku + "," + $("#price_" + myID).val());

                        //   _gaq.push(['_trackEvent', $("#source_" + myID).val() + ' - ' + $("#advehicle_" + myID).val(), $("#sku_" + myID).val(), 'from:' + masterSku], $("#price_" + myID).val());

                    }


                });
                $("#serviceSkufrm .productIDsRadio:checked").each(function () {

                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();
                    count++;
                    var myID = $(this).val();


                    var rulename = $("#productRule_" + myID).val();

                    if (rulename != null) {

                        if (rf.length > 0) {
                            rf = rf + ",";
                        }
                        rf = rf + rulename;
                    }
                    var masterSku = $("input[name = 'sku']").val();
                    // here we need to do the gaq push

                    if ($("#sku_" + myID).val() != null) {

                        // window.alert("Pushing2: " + $("#source_" + myID).val() + " - " + $("#advehicle_" + myID).val() + "," + $("#sku_" + myID).val() + "," + 'from:' + masterSku + "," + $("#price_" + myID).val());

                        //   _gaq.push(['_trackEvent', $("#source_" + myID).val() + ' - ' + $("#advehicle_" + myID).val(), $("#sku_" + myID).val(), 'from:' + masterSku], $("#price_" + myID).val());

                    }


                });


                $("#interstitialfrm1 input[name='productIDs']:checked").each(function () {

                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();
                    count++;
                    var myID = $(this).val();


                    var rulename = $("#productRule_" + myID).val();

                    if (rulename != null) {

                        if (rf.length > 0) {
                            rf = rf + ",";
                        }
                        rf = rf + rulename;
                    }
                    var masterSku = $("input[name = 'sku']").val();
                    // here we need to do the gaq push

                    if ($("#sku_" + myID).val() != null) {

                        // window.alert("Pushing3: " + $("#source_" + myID).val() + " - " + $("#advehicle_" + myID).val() + "," + $("#sku_" + myID).val() + "," + 'from:' + masterSku + "," + $("#price_" + myID).val());

                        //  _gaq.push(['_trackEvent', $("#source_" + myID).val() + ' - ' + $("#advehicle_" + myID).val(), $("#sku_" + myID).val(), 'from:' + masterSku], $("#price_" + myID).val());

                    }


                });



                $(this).find("input[name='productIDs']").val(productIDs);
                $(this).find("input[name='rf']").val(rf);



            } catch (err) {

            }

            try {


                $("#interstitialfrm1 input[name='productIDs']:checked").each(function () {

                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();
                    count++;


                });


                $(this).find("input[name='productIDs']").val(productIDs);


            } catch (err) {

            }



        }

        // now lets look for service plan


        try {

            if (!noaddons) {
                var serviceplan = $("#serviceplanfrm input[name='serviceplan']:checked").val();


                $(this).find("input[name='serviceplan']").val(serviceplan);
                if (count > 0) {
                    productIDs += ",";
                }
                productIDs += serviceplan;
                count++;
            }

        } catch (err) {

        }

       
       

        var prodID = $(this).find("input[name='productID']").val();
        var rf = $(this).find("input[name='rf']").val();
        var activeVal = $(document.activeElement).val()
    

        if (isAjax) {
            var isMini = $(this).hasClass("miniAjax");

            $("#Aria-Announcements").html("Adding Item To Cart Please Wait");
            window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 1000);
            $(".body-loading").css("display", "block");
            if (!isMini) {
                $(".body-loading").css("background-color", "#ffffff");
            }
            var btnpushed = $(this).find(".btn-add");
           
            $.ajax({
                url: "/store/add_productAjax.aspx?ismini=" + isMini,
                type: 'POST',
                async: true,
                data: thisForm.serialize(),
                success: function (op, textStatus, xhr) {

                    if (!isMini) {
                        $("#cartModal").html(op);
                        //$("#cartModal").show();
                        $('#cartModal').modal('show');
                        // $("#cartModal .close-button").focus();
                        // $("body").addClass("fancybox-is-open");
                        // $(".fancybox-bg").show();
                        //setFancyboxHeight();
                        Header.setCartQty($(".cartAjaxQty").html());

                        bindSubmit();
                        bindClickItemV2();
                        bindListClick();
                        

                            $("#cartModal .modal-interstitial-tabs").productTabs({
                                "speed": 200
                            });
                      
                        $(".body-loading").css("display", "none");
                        $(".body-loading").css("background-color", "transparent");
                        $(".crtfrm .big.STBTN").css("display", "block");
                    

                    }
                    else
                    {
                        productIDs = "";
                        var currentCartQty = parseInt($(".cartQTY").html()) + 1;
                        Header.setCartQty(currentCartQty);
                        $(".body-loading").css("display", "none");
                        $(".body-loading").css("background-color", "transparent");
                        
                    
                        btnpushed.addClass("addedToCart");
                        btnpushed.html(btnpushed.html().replace("ADD TO CART", "ITEM ADDED"));
                        btnpushed.html(btnpushed.html().replace("Add To List", "ITEM ADDED"));

                      //  $("#Aria-Announcements").html(btnpushed.html());
                      //  window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
                        //setTimeout(function () {
                        //    btnpushed.html(btnpushed.html().replace("ITEM ADDED", "ADD TO CART"));
                        
                        //    btnpushed.removeClass("addedToCart");
                        //}, 3000);
                    }
                },
                error: function (xhr, textStatus, errorThrown) {
                    alert("An error occurred.");
                    $(".body-loading").css("display", "none");
                    $(".body-loading").css("background-color", "transparent");
                    $(".crtfrm .big.STBTN").css("display", "block");
                }
            });


        }

       
            addToCartClick(prodID, productIDs, rf, activeVal, 0, carttype);

            $.when(addA1Event(prodID, productIDs, rf, activeVal, serviceplan, carttype))
                .then(function () {
                    return;
                });
       
        


    });

    
    $('.ajaxServicePlan').unbind();

    $(".ajaxServicePlan").click(function (e) {

     
        var spid = $(this).data("spid");
        var productid = $(this).data("productid");
        var serviceproductid = $(this).data("serviceproductid");
        var plandescription = $(this).data("plandescription");
       
        if (typeof $(this).data("spid") !== 'undefined' && typeof $(this).data("spid") !== 'undefined')
        {
           // ga('mc.send', 'event', 'AddServicePlanFromModal', plandescription, productid);
            
            $(".ajaxServicePlan").addClass("off");
            $(".ajaxServicePlan").removeClass("on");
            $(this).removeClass("off");
            $(this).addClass("on");
            $(".body-loading").css("display", "block");
            // now we need to add the service plan...
            $.ajax({
                type: "POST",
                url: "/store/add_protectionPlanAjax.aspx",
                data: { spid: spid, productid: productid, serviceproductid: serviceproductid, plandescription: plandescription },
                success: function (msg) {
                    if (msg.length > 2) {
                 
                    

                       // $(".protectionPlanTitle").html("Protect and Support " + msg);
                        $("#servicePlanInfo").html($("#planDetails" + serviceproductid).html());
                     
                    }
                    $(".body-loading").css("display", "none");
                    $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Protection Plan Added</div>');
                    window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
                }
            });

        }


    });
}

function bindClickItemV2() {
  
    
    $('.productClickItemV2').click(function (e) {
      
        // e.preventDefault();

        if (typeof $(this).data('id') !== 'undefined' ) {
            productclicked = true;

          

            var thislist = "Unknown";
            if (typeof $(this).data('list') !== 'undefined') {
                thislist = $(this).data('list');
            }



            if (usingGA4) {
                if (typeof (gtag) != 'undefined') {
                    gtag('event', 'select_item', {
                        'item_list_id': $(this).data('list').replace("\\\"", " "),
                        'item_list_name': $(this).data('list').replace("\\\"", " "),
                        'is_personalized': $(this).data('personalized'),
                        items: [
                            {
                                item_id: $(this).data('id'),
                                item_name: $(this).data('name').replace("\\\"", " "),
                                currency: "USD",
                                index: $(this).data('position'),
                                item_brand: $(this).data('brand').replace("\\\"", " "),
                                item_category: $(this).data('category').replace("\\\"", " "),

                                item_list_id: $(this).data('list').replace("\\\"", " "),
                                item_list_name: $(this).data('list').replace("\\\"", " "),

                                price: $(this).data('price'),
                               
                                quantity: 1
                            }
                        ]
                    });
                }
            }
            if (usingGA3) {
                if (typeof (ga) != 'undefined') {
                    ga('mc.ec:addProduct', {                              // Provide product details in a productFieldObject.
                        'id': $(this).data('id'),                   // Product ID (string).
                        'name': $(this).data('name'),               // Product name (string).
                        'category': $(this).data('category'),       // Product category (string).
                        'brand': $(this).data('brand'),             // Product brand (string).
                        'price': $(this).data('price'),
                        'position': $(this).data('position'),
                        'list': thislist

                    });

                    ga('mc.ec:setAction', 'click', { 'list': thislist });

                    ga('mc.send', 'event', 'eCommerce', 'click', thislist, {
                        'hitCallback': function () {
                            try {
                                if (!evt.ctrlKey) {

                                    //if ($(this).attr('href') != null) {
                                    //    document.location = $(this).attr('href');
                                    //} else if ($(this).data('href') != null) {
                                    //    document.location = $(this).data('href');
                                    //}
                                }
                            } catch (e) { }
                        }
                    });
                }
            }
          

        }

    });

    $('.eventClick').unbind();
    $('.eventClick').click(function (e) {


        var eventcategory = $(this).data("eventcategory");
        var eventaction = $(this).data("eventaction");
        var eventlabel = $(this).data("eventlabel");
        var eventvalue = $(this).data("eventvalue");
        var eventtype = $(this).data("eventname");

        if (eventtype != null && eventcategory != null) {
        
            if (usingGA4) {
                gtag('event', eventtype, {

                    'event_category': eventcategory,
                    'event_action': eventaction,
                    'event_label': eventlabel,
                    'event_value': eventvalue
                });
            }

            if (usingGA3 && $(this).attr("onClick") === undefined)
            {
                if (typeof (ga) != 'undefined') {
                    
                    ga('mc.send', { 'hitType': 'event', 'eventCategory': eventcategory, 'eventAction': eventaction, 'eventLabel': eventlabel, 'eventValue': eventvalue });

                }
            }

        }

        // e.preventDefault();

    

    });

    $('.promoClickItem').unbind();
    $('.promoClickItem').click(function (e) {

        // e.preventDefault();
   
        if ($(this).data('list') != null) {
            productclicked = true;

            var thislist = "Unknown";
            if ($(this).data('list') != null) {
                thislist = $(this).data('list');
            }

          
          

            if (usingGA4) {
                if (typeof (gtag) != 'undefined') {
                    var list = "[";
                   if ($(this).data('name') && $(this).data('brand') && $(this).data('category')) {
                   {
                    list += "{";

                    list += 'item_id: "' + $(this).data('id') + '",';
                    list += 'item_name: "' + $(this).data('name').replace('"', '\\\"') + '",';

                    list += 'index: ' + $(this).data('position') + ',';
                    list += ' item_brand: "' + $(this).data('brand').replace('"', '\\\"') + '",';
                    list += 'item_category: "' + $(this).data('category').replace('"', '\\\"') + '",';
                    list += 'currency: "USD",';

                           list += 'price:' + $(this).data('price') + ',';
                  
                    list += ' quantity: 1';





                    list += '}';
                   }
                }
             list += "]";
                    gtag('event', 'select_promotion', {
                        'promotion_id': $(this).data('list').replace("\\\"", " "),
                        'promotion_name': $(this).data('list').replace("\\\"", " "),
                        items: eval(list)
                    });
                }
            }
            if (usingGA3) {
                if (typeof (ga) != 'undefined') {

                    if ($(this).data('name') && $(this).data('brand') && $(this).data('category')) {
                        ga('mc.ec:addProduct', {                              // Provide product details in a productFieldObject.
                            'id': $(this).data('id'),                   // Product ID (string).
                            'name': $(this).data('name'),               // Product name (string).
                            'category': $(this).data('category'),       // Product category (string).
                            'brand': $(this).data('brand'),             // Product brand (string).
                            'price': $(this).data('price'),
                            'currency': 'USD',
                            'position': $(this).data('position'),
                            'list': thislist

                        });
                    }

                    ga('mc.ec:setAction', 'promoClick', { 'list': thislist });

                    ga('mc.send', 'event', 'eCommerce', 'promoClick', thislist, {
                        'hitCallback': function () {
                            try {
                                if (!evt.ctrlKey) {

                                    //if ($(this).attr('href') != null) {
                                    //    document.location = $(this).attr('href');
                                    //} else if ($(this).data('href') != null) {
                                    //    document.location = $(this).data('href');
                                    //}
                                }
                            } catch (e) { }
                        }
                    });
                }
            }


        }

    });

}


function bindListClick() {

    listView("Service Plan Add To Cart Modal");
    listView("Add Cart Ajax Key Add Ons");

    $(".listclick").click(function (e) {

        // e.preventDefault();
        var listname = $(this).data('list');
        var cnt = 0;
        if (usingGA4) {
            if (typeof (gtag) != 'undefined' && $('.productViewItem').length) {

                var list = "[";
                var pv = $('.productViewItem');
                
         
                var ispersonalized = "";

         
                $('.productViewItem').each(function () {
                    
                    if ($(this).data('list') == listname)
                    {
                       

                        if (cnt > 0) { list += ',' }

                        if (typeof $(this).data('name') !== 'undefined' && typeof $(this).data('brand') !== 'undefined' && typeof $(this).data('category') !== 'undefined') {
                            list += "{";

                            list += 'item_id: "' + $(this).data('id') + '",';
                            list += 'item_name: "' + $(this).data('name').replace('"', '\\\"') + '",';

                            list += 'index: ' + $(this).data('position') + ',';
                            list += ' item_brand: "' + $(this).data('brand').replace('"', '\\\"') + '",';
                            list += 'item_category: "' + $(this).data('category').replace('"', '\\\"') + '",';

                            list += 'item_list_id: "' + $(this).data('list') + '",';
                            list += 'item_list_name: "' + $(this).data('list') + '",';

                            list += 'price:' + $(this).data('price') + ',';
                            list += 'currency: "USD",';
                            list += ' quantity: 1';





                            list += '}';


                            cnt += 1;
                        }
                    }
                });

                list += ']';

                if (list != '[]') {
                    gtag("event", "view_item_list", {
                        'item_list_id': listname.replace('"', '\\\"'),
                        'item_list_name': listname.replace('"', '\\\"'),
                        items: eval(list)

                    });
                }





            }
        }

        if (usingGA3) {


            if (typeof ga != "undefined") {

    
                $('.productViewItem').each(function () {

                    if (listname == $(this).data('list')) {

                        ga('mc.ec:addImpression', {                     // Provide product details in a productFieldObject.
                            'id': $(this).data('id'),                   // Product ID (string).
                            'name': $(this).data('name'),               // Product name (string).
                            'category': $(this).data('category'),       // Product category (string).
                            'brand': $(this).data('brand'),             // Product brand (string).
                            'price': $(this).data('price'),
                            'position': $(this).data('position'),
                            'list': listname

                        });

                    }



                });
                if (listname != "") {

                    ga('mc.ec:setAction', 'detail');
                    ga('mc.send', 'event', 'eCommerce', listname, { nonInteraction: true });
                }

            }
        }

    });

    if ($('.listclick')) {
        $('.listclick').first().trigger('click');
    }

}


if (!("ontouchstart" in document.documentElement)) {
    hasTouch = false;
}


if (!("ontouchstart" in document.documentElement)) {
    hasTouch = false;
}

function serviceBVCheck() {
    $(".serviceReviews").hide();
    $(".serviceQA").hide();

    var refreshId = setInterval(function () {


        if ($(".serviceReviews #BVRRDisplayContentBodyID").length) {
            $(".serviceReviews").show();

        }

        if ($(".serviceReviews #BVRRDisplayContentID").length) {
            clearInterval(refreshId);
        }
    }, 1000);

    var refreshId2 = setInterval(function () {

        if ($(".serviceQA .BVQAQuestions").length) {
            $(".serviceQA").show();
        }

        if ($(".serviceQA #BVQAQuestionAndAnswerCountID").length) {

            clearInterval(refreshId2);
        }


    }, 1000);




}



$(document).ready(function () {

    $(".showAllAuthors").click(function () {
        $(".authorList .hide").show();
        $(".showAllAuthors").hide();
    });

    $(".seeAllCategories").click(function () {
        $(".allCategories").show();
        $(".seeAllCategories").hide();
    });

    $("#blogsearchbutton").click(function () {

        $("#blogsearchform").submit();
    });



    






    $('.bvinine_rating').click(function (event) {

        $('html, body').animate({
            scrollTop: $("#tab-reviews-bm").offset().top
        }, 100);
        
    });





    setTimeout(function () {
       
        checkCharlotte();
        checkMiami();

    },100);





    loadLazy();


    // add validation flag fixes.
    if ($('.needsValidation').length)
    {
        var validationInteraction = false;
        var validationcookie = readCookie("Mvalidation");

        if (typeof (validationcookie) != 'undefined' && validationcookie != null && validationcookie != "") {
            $(".needsValidation").hide();
        }
        $(".needsValidation").hover(function () {
            validationInteraction = true;
        });

        $(".closevalidation").click(function () {
            $(".needsValidation").hide();
            createCookie("Mvalidation", "closed", 1);
        });

        setTimeout(function () {
            if (!validationInteraction) {
                $(".needsValidation").hide();
            }

        }, 15000);
    }

    // add login flag fixes.

    if ($('.needsLogin').length) {



        var loginInteraction = false;
        var logincookie = readCookie("Mlogin");

        if (typeof (logincookie) != 'undefined' && logincookie != null && logincookie != "") {
            $(".needsLogin").hide();

        }
        else {

            if (($('.needsCharlotte') == null || !$('.needsCharlotte').is(":visible")) && ($('.needsMiami') == null || !$('.needsMiami').is(":visible"))) {

                $(".needsLogin").show();
                $(".closeloginrequest").focus();
                createCookie("Mlogin", "closed", 1);
                $(window).scroll(function () {
                    var MobileSignIn = $('.MobileFramework .needsLogin'),
                        scroll = $(window).scrollTop();
                    var headerTop = $('.MobileFramework .hdrRow4').offset().top;

                    if (scroll >= headerTop) {
                        MobileSignIn.addClass('stickySignIn');
                    }
                    else {
                        MobileSignIn.removeClass('stickySignIn');
                    }
                });


            }
        }

        $(".needsLogin").hover(function () {
            loginInteraction = true;
        });


        $(".closeloginrequest").click(function () {
            $(".needsLogin").hide();
            createCookie("Mlogin", "closed", 1);
        });

        setTimeout(function () {
            if (!loginInteraction) {
                $(".needsLogin").hide();
                createCookie("Mlogin", "closed", 1);
            }

        }, 30000);
    }

    else
    {
        createCookie("Mlogin", "closed", 1);
    }


  

   
   
    if ($('.needsCharlotte').length) {
        $("#storeInfo").removeClass("forceopen");
        var charlotteInteraction = false;
        var charlottecookie = readCookie("Mcharlotte");

        if (typeof (charlottecookie) != 'undefined' && charlottecookie != null && charlottecookie != "") {
            $(".needsCharlotte").hide();

        }
        else {
            $(".needsCharlotte").show();
            $(".closecharlotterequest").focus();
        }

        $(".needsCharlotte").hover(function () {
            charlotteInteraction = true;
        });


        $(".closecharlotterequest").click(function () {
            $(".needsCharlotte").hide();
            createCookie("Mcharlotte", "closed", 1);
        });

        $(".needsCharlotte .learnMoreButton").click(function () {
            $(".needsCharlotte").hide();
            createCookie("Mcharlotte", "closed", 1);
        });


        setTimeout(function () {
            if (!charlotteInteraction) {
                $(".needsCharlotte").hide();
                createCookie("Mcharlotte", "closed", 1);
            }

        }, 30000);
    }

    if ($('.needsMiami').length) {
        $("#storeInfo").removeClass("forceopen");
        var miamiInteraction = false;
        var miamicookie = readCookie("Mmiami");

        if (typeof (miamicookie) != 'undefined' && miamicookie != null && miamicookie != "") {
            $(".needsMiami").hide();

        }
        else {
            $(".needsMiami").show();
            $(".closemiamirequest").focus();
        }

        $(".needsMiami").hover(function () {
            miamiInteraction = true;
        });


        $(".closemiamirequest").click(function () {
            $(".needsMiami").hide();
            createCookie("Mmiami", "closed", 1);
        });

        $(".needsMiami .learnMoreButton").click(function () {
            $(".needsMiami").hide();
            createCookie("Mmiami", "closed", 1);
        });


        setTimeout(function () {
            if (!miamiInteraction) {
                $(".needsmiami").hide();
                createCookie("Mmiami", "closed", 1);
            }

        }, 30000);
    }
    productView();

    $(".shuffle").click(function () {

        var el = $(this).data("elements");

        $("." + el).shuffle();
        var max = Number($(this).data("max"));
        var cnt = 0;
        $("." + el + " hr").removeClass("hide-text");
        $("." + el).addClass("border-md-right");
        $("." + el).each(function () {
            cnt += 1;
            if (cnt == 1) {

                $(this).find("hr").addClass("hide-text");
            }
            if (cnt >= max) {


                $(this).removeClass("border-md-right");
            }
            if (cnt > max) {

                $(this).find("hr").addClass("hide-text");

            }


            if (cnt <= max) {
                $(this).show();
            }
            else {
                $(this).hide();
            }

        });


    });

    $(".seemore").click(function () {

        var el = $(this).data("elements");

        var totalcnt = 0;
        var cnt = 0;
        $("." + el).each(function () {
           
            if (!$(this).is(":visible") && cnt < 3) {
                $(this).show();
                if (!$(this).find("hr").is(":visible")) {
                    $(this).addClass("pt-50");
                }
                cnt += 1;
                totalcnt += 1;
            }
            if (cnt == 0) {
                totalcnt += 1;
            }
        });
        var max = Number($(this).data("max"));

       
        if (totalcnt >= $("." + el).length)
        {
            $(".seemore-" + el).hide();
        }
        cnt = 0;
        $("." + el + " hr").removeClass("hide-text");
        $("." + el).addClass("border-md-right");
        $("." + el).each(function () {
            cnt += 1;
            if (cnt == 1) {

                $(this).find("hr").addClass("hide-text");
            }
            if (cnt % 3 == 0) {


                $(this).removeClass("border-md-right");
            }
            if (cnt % 3 == 0) {

                // $(this).find("hr").addClass("hide-text");

            }


            //if (cnt <= max) {
            //    $(this).show();
            //}
            //else {
            //    $(this).hide();
            //}

        });


    });


   
    if (usingGA4) {
        // lets add listener for any a tag, div, button click with event sending
        $('a').click(function (e) {

          
            // e.preventDefault();

            if ($(this).data('eventname') != null && $(this).data('eventaction') != null && $(this).data('eventcategory') != null) {


             
                if (typeof (gtag) != 'undefined') {
                    gtag('event', $(this).data('eventname'), {
                        
                        'event_category': $(this).data('eventcategory'),
                        'event_action': $(this).data('eventaction'),
                        'event_label': $(this).data('eventlabel'),
                        'event_value': $(this).data('eventvalue')
                    });

                }
                   
                      
                    
               


            }

        });
    }


    if (navigator.share && $("body").hasClass("MobileFramework")) {
        $(".mobileShare").show();
        $(".desktopShare").hide();
        $(".mobileShareButton").click(function () {
            navigator.share({
                title: $(document).attr('title'),
                url: $(location).attr('href')


            });

        });

    }
    else {

        $(".mobileShare").hide();
        $(".desktopShare").show();
    }

    $(".clearAsus").click(function () {

        $(".asusCheckbox").prop('checked', false);

        $(".productIDsRadio").removeClass("isselectedItem");
        $(".productIDsRadio").prop('checked', false)

        setsummarytotal();
        return false;
    });

    // fix usabila and bizaar voice




    // add play buttons to sliders

    setTimeout(function () {
        $(".slick-dots").append("<li role='presentation' class='play'><a href='#' class='slick-play'><img src='https://60a99bedadae98078522-a9b6cded92292ef3bace063619038eb1.ssl.cf2.rackcdn.com/play-16.png' alt='play'><span class='hide-text'>Next</span></a></li><li role='presentation' class='pause'><a href='#' class='slick-pause' ><img src='https://60a99bedadae98078522-a9b6cded92292ef3bace063619038eb1.ssl.cf2.rackcdn.com/pause-16.png' alt='pause'><span class='hide-text'>pause</span></a></li>");
        // Play/Pause button
        $(".slick-play").click(function () {
            $(".slick-slider").slick('slickPlay');
            $(this).hide();
            $('.slick-pause').show();
            return false;
        })
        $(".slick-pause").click(function () {
            $(".slick-slider").slick('slickPause');
            $(this).hide();
            $('.slick-play').show();
            return false;
        })
    }, 500);



    // flip on async styles...

    $(".asyncStyle").each(function () {
        $(this).attr("media", "all");

    });

    // turn off reviews and Q and A in service pages if page has no
    if ($(".serviceReviews").length) {
        serviceBVCheck();
    }






    if (isLogin === "true") {

        resetLoading();

    }


    // lets prevent search unless there is content.

    $(".siteSearchForm").submit(function () {

        if (!$("#search-query").val()) {
            $("#search-query").focus();
            return false;
        }

    });



    function getQuerystringParameter() {
        var getUrlParameter = function getUrlParameter(sParam) {
            var sPageURL = window.location.search.substring(1),
                sURLVariables = sPageURL.split('&'),
                sParameterName,
                i;

            for (i = 0; i < sURLVariables.length; i++) {
                sParameterName = sURLVariables[i].split('=');

                if (sParameterName[0] === sParam) {
                    return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
                }
            }
            return false;
        };

        var searchValue = getUrlParameter('vkw');
        // console.log('searchValue = ' + searchValue);
    }




    $(".productSearch").click(function () {
        var searchValue = getQuerystringParameter();

        if (usingGA4) {
            gtag('event', 'searchChoices', {
                'event_type': 'ProductsSearch',
                'event_action': searchValue
            });
        }
        if (usingGA3) {

            ga("mc.send", "event", "searchChoices", "ProductsSearch", searchValue);
        }
        //  console.log("Handler for productSearch .click() called.");
    });

    $(".contentSearch").click(function () {
        var searchValue = getQuerystringParameter();
        if (usingGA4) {
            gtag('event', 'searchChoices', {
                'event_type': 'ContentSearch',
                'event_action': searchValue
            });
        }
        if (usingGA3) {

            ga("mc.send", "event", "searchChoices", "ContentSearch", searchValue);
        }
        //   console.log("Handler for contentSearch .click() called.");
    });

    $(".st-ui-result.__swiftype_result").click(function () {
        var linkValue = $(this).find(".resultType").text() + " - " + ($(this).find(".st-ui-type-heading").text());
        if (usingGA4) {
            gtag('event', 'contentResults', {
                'event_type': 'contentResultsLink',
                'event_action': linkValue
            });
        }
        if (usingGA3) {
            ga("mc.send", "event", "contentResults", "contentResultsLink", linkValue);
        }
        //  console.log("Handler for contentResultsLink .click() called.");
    });

    $("#hotdeals .hotdealItem .clickable.fade a").click(function () {
        var clickHotDeals = $(this).text();
        var index = clickHotDeals.indexOf(' ', clickHotDeals.indexOf(' ') + 1);
        var hotDealsCategory = clickHotDeals.substr(index + 1);


            if (usingGA4) {
                gtag('event', 'hmpg', {
                    'event_type': 'categories',
                    'event_action': hotDealsCategory
                });
            }
            if (usingGA3) {


                ga("mc.send", "event", "hmpg", "categories", hotDealsCategory);
            }
        
        //   console.log('hotDealsCategory = ' + hotDealsCategory);
    });

    $(".SearchDropdown .dropdown-item").click(function (e) {

        e.preventDefault();

        var nValue = $(this).data("n");
        var fieldname = $(this).data("fieldname");
        var target = $(this).data("target");
        var cat = $(this).data("cat");
        var url = $(this).attr("href");
        var title = $(this).html();

        if (fieldname == "keyword") {
            $("#swiftypeSearch").css("display", "flex");
            $("#standardSearch").hide();
            $("#site-search-query").focus();
        }
        else {
            $("#swiftypeSearch").css("display", "none");
            $("#standardSearch").show();
            $("#search-query").focus();

        }

        $(".siteSearchForm").attr("target", target);
        $(".siteSearchForm").attr("action", url);

        $(".siteSearchForm #search-nValue").val(nValue);
        $(".siteSearchForm #search-cat").val(cat);
        $(".siteSearchForm #search-query").attr("name", fieldname);

        $(".SearchDropdown #searchTitle").html(title);

        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Search changed to:' + title + ' Begin typing to start search.</div>')
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);

        $(".SearchDropdown .dropdown-menu").hide();





    });


    // lets do the new store selected button.


    $("#storeselectorHref").click(function () {


        if (!keyisdown) {
            if ($("#boosted .dropdown-menu").is(":visible")) {
                $("#boosted .dropdown-menu").hide();
                closeStoreSelector = false;
            }
            else {
                $("#boosted .dropdown-menu").show();
                closeStoreSelector = true;
                $("#boosted .dropdown-menu").focus();
            }
        }
    });

    $("#boosted #storeselectorHref").keydown(function (e) {
        keyisdown = true;
    });
    $("#boosted #storeselectorHref").keyup(function (e) {

        keyisdown = false;
        e.preventDefault;

        if (e.which === 13 || e.which === 40) {
            if ($("#boosted .dropdown-menu").is(":visible")) {
                $("#boosted .dropdown-menu").hide();
                closeStoreSelector = false;
            }
            else {
                $("#boosted .dropdown-menu").show();
                closeStoreSelector = true;
                $("#boosted .dropdown-menu").find("a").first().focus();
            }
        }


    });


    $("#boosted .dropdown-menu li a").keyup(function (e) {
        e.preventDefault();
        var focusElement = $(document.activeElement);
        var currentLI = focusElement.parent();
        if (e.which === 40) {


            if (currentLI != $("#boosted .dropdown-menu").find("li").last()) {
                currentLI.next().find("a").first().focus();
            }

        };


        if (e.which === 38) {

            if (currentLI != $("#boosted .dropdown-menu").find("li").first()) {
                currentLI.prev().find("a").first().focus();
            }
            else {
                $("#boosted .dropdown-menu").hide();
                closeStoreSelector = false;
                $("#storeselectorHref").focus();
            }

        };


        //38 up
        //40 down
    }
    );












    window.onclick = function (event) {


        try {

            if (!event.target.matches('#boosted') && !event.target.matches('#storeselectorHref')) {
                $("#boosted .dropdown-menu").hide();
                closeStoreSelector = false;
            }
        } catch (err) {

        }
    }



    $("#storeselector").change(function () {

        if ($("#storeselector option:selected").index() > 0) {
            $("#getstoreselectorButton").show();
        }
        else {
            $("#getstoreselectorButton").hide();
        }

    });

    if ($("#storeselector option:selected").index() > 0) {
        $("#getstoreselectorButton").show();
    }

    $('.mm14-products-viewed-wrapper').each(function () {

        try {
            addSliderEvent($(this));

        } catch (err) {

        }

    });

    //if ($('.mm14-products-viewed-wrapper').length > 0) 
    //{ 
    //    addSliderEvent();
    //}


    $("#skip-main-content").click(function (evt) {

        var thisID = $(this).attr('href');



        if ($(thisID + " h1").first().length) {


            $(thisID + " h1").first().attr('id', 'main-content-h1');
            $(thisID + " h1").first().attr('tabindex', '0');

            $(thisID + " h1").first().focus();
            return false;
        }



    });














    var ismobile = (jQuery.browser.mobile == true);

    // new type ahead custom roll below *************************************

    var typeAheadInput;
    var typeAheadTimeOut;
    var closeTypeAhead = true;




    // add the click events for search results
    $('.productClickItem').click(function (e) {
        e.preventDefault();
        productClick(this);

    });

    $('.inBundle-title a').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });

    $('.inBundle-image img').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });


    $('.products .image').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });


    $('.avProductClick').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });


    $('.addOnProductClick').click(function (evt) {
        evt.preventDefault();
        addOnClick(this, evt);


    });




    $('.pDescription h2 a').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });

    $('.SearchBannerProduct').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });

    $('.RightBannerProduct').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });

    $('.featureProduct').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });

    

    $('.SearchTower').click(function (evt) {
        promoClick(this, evt);
    });

    $('.SearchBanner').click(function (evt) {
        promoClick(this, evt);
    });


    // handle each of the tab click impressions...


    $("#tabClearance").click(function (evt) {
        sendOpenBoxImpression();
    });

    $('#tabInterstitial').click(function (evt) {


        sendaddOnImpression();


    });


    $('#frequentlyBoughtLabel').click(function (evt) {


        sendfrequentlyboughtImpression();


    });


    $('#ConfiguratorLabel').click(function (evt) {


        sendconfiguratorImpression();


    });


    $('#BundleLabel').click(function (evt) {


        sendBundleImpression();

    });



    $("#byProd2").click(function () {
        if (!$("#mainMenu").hasClass("ui-panel-open")) {
           // console.log($("#byProd"));

            window.setTimeout(function () { $("#byProd").focus(); }, 500);

        }

    });

    // add a handler for click within typeahead box
    $(".typeAheadAjax").hover(function () { closeTypeAhead = false; }, function () { closeTypeAhead = true; });

    // handle arrow down to access type ahead...

    $(document).on("keydown", function (e) {
        if (e.keyCode == 40 && $(".typeAheadAjax").is(":visible")) {
            e.preventDefault();

            $(".typeAheadResults li").first().find('a').first().focus();
        }

    });




    // add touch start handler to close typeahead on mobile device
    $('.typeAheadAjax').on('touchstart', function () {
        closeTypeAhead = false;
    });

    $('.typeAheadAjax').on('touchmove', function () {
        closeTypeAhead = false;
    });

    $('.typeAheadAjax').on('touchend', function () {
        window.setTimeout(function () {
            closeTypeAhead = true;
        }, 1000);

    });

    $('.typeAheadAjax').on('touchleave', function () {
        window.setTimeout(function () {
            closeTypeAhead = true;
        }, 1000);

    });

    // add a handler for the input with typing delay

    $("#search-query").keyup(function (e) {

        if (e.keyCode != 40) {
            window.clearTimeout(typeAheadTimeOut);
            $(".typeAheadAjax").hide();

            typeAheadInput = this.value;
            $("#search-query").removeClass('loading');
            typeAheadTimeOut = window.setTimeout(function () { loadTypeAhead(); }, 50);
        }
    });

    // add a handler for a click to close type ahead
    $(document).mousedown(function () {
        if (closeTypeAhead) {
            window.clearTimeout(typeAheadTimeOut);
            $(".typeAheadAjax").hide();
            $("#search-query").removeClass('loading');
        };


    });




    // add touch start handler to close typeahead on mobile device
    $(document).on('touchstart', function () {
        if (closeTypeAhead) {
            window.setTimeout(function () {
                window.clearTimeout(typeAheadTimeOut);
                $(".typeAheadAjax").hide();
                $("#search-query").removeClass('loading');
            }, 1000);
        };



    });



    // function for loading type ahead
    function loadTypeAhead() {

        var fieldName = $("#search-query").attr("name");

        if (fieldName.toLowerCase() == "ntt") {
            // we have a change
            if (typeAheadInput.length >= 2) {

                // we need to the loading graphic



                var nvalue = $("#search-nValue").val()
                // we need to call the ajax and fill the content
                $("#search-query").addClass("loading");

                $.ajax({
                    type: "POST",
                    url: "/assets/ajax/autosuggest.aspx",
                    data: "term=" + typeAheadInput + "&N=" + nvalue,
                    success: function (msg) {

                        if (msg.length >= 6 && msg.indexOf("0 suggestions found, 0 categories found, 0 brands found.") <= 0) {





                            $(".typeAheadAjax").html("<div class='typeAheadArrow'></div>" + msg);
                            $(".typeAheadAjax").show();

                            $("#Aria-Announcements").html('<div aria-live="polite" role="alert">' + $("#typeaheadanouncement").html() + ' Press down arrow to access suggestions.</div>')
                            window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);

                            returnToIT = "#search-query";
                            hideIT = ".typeAheadAjax";
                            // close loading graphic
                            $("#search-query").removeClass("loading");

                            // set click events on more buttons
                            $("#TA-articles .TA-more").click(function () { $("#TA-articles li").removeClass("TA-hide"); $(this).addClass("TA-hide"); });
                            $("#TA-suggestions .TA-more").click(function () { $("#TA-suggestions li").removeClass("TA-hide"); $(this).addClass("TA-hide"); });
                            $("#TA-categories .TA-more").click(function () { $("#TA-categories li").removeClass("TA-hide"); $(this).addClass("TA-hide"); });
                            $("#TA-brands .TA-more").click(function () { $("#TA-brands li").removeClass("TA-hide"); $(this).addClass("TA-hide"); });

                            $(".TA-Scroll").mCustomScrollbar({
                                mouseWheel: true,
                                advanced: {
                                    autoScrollOnFocus: false,
                                    updateOnContentResize: true,
                                    updateOnBrowserResize: false,
                                    contentTouchScroll: true
                                }
                            });

                            window.setTimeout(function () { $(".TA-Scroll").mCustomScrollbar("update"); }, 1500);


                        } else {
                            $("#search-query").removeClass("loading");
                        }



                    }
                });

                // close loading graphic



            }
            else {

                $(".typeAheadAjax").hide();


            }
        }
    }


    setCompareFeatures();



    setGridView();

    // need to set the base settings









    // More less on side nav

    bindMore();







    //$("#primary ul li.main").click(function () {
    // clearTimeout();
    //   try {
    //       $.next("ul").show();
    //       return false;
    //   }
    //   catch (err) {

    //   }
    // }
    //	);



    try {

        $("#configuratorTabs.tabs").productTabs({
            "speed": 200

        });

        $(".configurator .nav-link").click(function () {

            $(".configurator .nav-link").removeClass("active");


            $("." + $(this).attr("class").replace(" ", ".")).not("#" + $(this).attr("id")).addClass("active");

            if ($(this).parent().parent().attr("id") == "configuratorTabs2") {
                $('.ActionButtons').addClass("cnfSticky");
                $('.ActionButtonsContainer').addClass("cnfSticky");

                $('html,body').animate({ scrollTop: $("#configuratorWrapper").offset().top }, 'fast');

                $('.ActionButtons').removeClass("cnfSticky");
                $('.ActionButtonsContainer').removeClass("cnfSticky");
            }
        });


        $("#product.DesktopFramework .tabs").productTabs({
            "speed": 200

        });



        if (location.hash != null && location.hash.indexOf("tab") >= 0) {


            var thistab = "";

            if (location.hash == "#tab-specs") { thistab = "#tabSpecs"; }
            if (location.hash == "#tab-protectionplans") { thistab = "#tabProtectionplans"; }
            if (location.hash == "#tab-interstitial") { thistab = "#tabInterstitial"; }
            if (location.hash == "#tab-reviews") { thistab = "#tabReviews"; }
            if (location.hash == "#tab-qa") { thistab = "#tabQa"; }
            if (location.hash == "#tab-info") { thistab = "#tabInfo"; }
            if (location.hash == "#tab-support") { thistab = "#tabSupport"; }
            if (location.hash == "#tab-clearance") { thistab = "#tabClearance"; }
            if (location.hash == "#tab-rebate") { thistab = "#tabRebate"; }




            if (thistab != "") {

                $("#product.DesktopFramework #product-details .accTab a").removeClass("current");


                $("#product.DesktopFramework #product-details .accTab a").attr("aria-selected", "false");

                $("#product.DesktopFramework " + thistab).addClass("current");
                $("#product.DesktopFramework " + thistab).attr("aria-selected", "true");


                $("#product.DesktopFramework #product-details article").css("display", "none");
                $("#product.DesktopFramework #product-details article").attr("aria-hidden", "true");



                $(location.hash).css("display", "block");
                $(location.hash).attr("aria-hidden", "false");


            }
        }

        // set active product tab


    }
    catch (err) {

    }

    try {
        $("#quickview-content .tabs").productTabs({
            "speed": 200
        });

    }
    catch (err) {

    }

    try {


        var testProductStation = $("#product.productStation.MobileFramework .tabs");



        if (testProductStation.length <= 0) {

            $("#product.MobileFramework .tabs").accordion({ header: ".tabLink", active: false, collapsible: true, heightStyle: "content", change: function (event, ui) { $("#product.MobileFramework .tabs").show()[0].scrollIntoView(true); } });
        }
        else {

            $("#product.MobileFramework .tabs").productTabs({
                "speed": 200

            });
        }

    }
    catch (err) {

    }


    try {

        $(".DesktopFramework.techcenter .tabs").productTabs({
            "speed": 200
        });
    }
    catch (err) {

    }


    try {

        $(".MobileFramework.techcenter  .tabs").accordion({ header: ".tabLink", active: false, collapsible: true, heightStyle: "content", change: function (event, ui) { $(".techcenter .tabs").show()[0].scrollIntoView(true); } });

    }
    catch (err) {

    }

    try {
        $("#careproduct .tabs").organicTabs({
            "speed": 200
        });

    }
    catch (err) {

    }


    $("article.tabs section div").hide();
    $("article.tabs section:first article").show();
    $("article.tabs section:first").addClass("active");




    // INTERSTITIAL

    $("#intersticialTabs #isserviceplans").click(function () {

        activateServicePlans();

    });

    $("#intersticialTabs #zone1tab").click(function () {

        activateZone1();

    });

    $("#intersticialTabs #zone2tab").click(function () {
        activateZone2();

    });

    $("#intersticialContent input").each(function () {
        $(this).attr("checked", false);
    });


    // clear the rf value if regular form gets clicked
    $(".RWO-RESERVE").click(function () {

        $(".crtfrm input[name='IsQuick']").val("True");


    });

    $(".crtQty").change(function () {


        if (isNaN($(this).val())) {
            $(this).val(1);
        }

        if ($(this).val() > $(this).data("max")) {
            $(this).val($(this).data("max"));
        }
        if ($(this).val() < 0) {
            $(this).val(1);
        }

        $(".crtQty").val($(this).val());

    });

    // clear the rf value if regular form gets clicked
    $(".btn-add").click(function () {

        if ($(".crtfrm input[name='rf']").val() != "Interstitial Add Ons") {
            //  $(".crtfrm input[name='rf']").val("Add To Cart Form");
        }


    });

    // Add to cart submit button - bind interstial form selections
    $("#intersticialBtn").click(function () {

        $(".crtfrm input[name='rf']").val("Add Ons");
        $(".crtfrm").first().submit();
        return false;

    });

    // Add to cart submit button - bind frequently purchased

    $("#FrequentyPurchasedTogetherButton").click(function () {

        $("#cartModal").html('');
        $(".crtfrm input[name='rf']").val("Frequently Bought Together");
        $(".crtfrm").first().submit();

    });












    $(".crtfrm .big.STBTN").click(function (e) {



        $(".body-loading").each(function () {

            $(this).attr("style", "display:block !important; background-color:rgb(255,255,255); opacity:.8;");


        });


        $(".crtfrm .big.STBTN").css("display", "none");


        $(".RWOQuantity").val('');
        $("#cartModal").html('');
        var ajx = $(".crtfrm.ajaxForm").first().find("input[name='ajax']");
        if (ajx.length) {


            ajx.val("true");
            $(".crtfrm.ajaxForm").first().find("input[name='buyItNow']").val("false");

        }

        ajx = $(".crtfrm.ajaxForm").last().find("input[name='ajax']");
        if (ajx.length) {


            ajx.val("true");
            $(".crtfrm.ajaxForm").last().find("input[name='buyItNow']").val("false");

        }



    });
    $(".crtfrm .big.BUY-NOW").click(function (e) {

        $("#cartModal").html('');
        var ajx = $(".crtfrm.ajaxForm").first().find("input[name='ajax']");

        if (ajx.length) {

            ajx.val("false");
            $(".crtfrm.ajaxForm").first().find("input[name='buyItNow']").val("true");

        }

        ajx = $(".crtfrm.ajaxForm").last().find("input[name='ajax']");

        if (ajx.length) {

            ajx.val("false");
            $(".crtfrm.ajaxForm").last().find("input[name='buyItNow']").val("true");

        }

        $(".crtfrm.ajaxForm").first().submit();


    });


    // Add in buying options functions...
    $(".optionsContainer").click(function () {

        var optionID = $(this).attr("class");
        var isButton = $(this).is("button");
        $("#cartModal").hide();
        $("#cartModal").html('');


        if (isButton) {
            $(".optionsContainer").removeClass("Selected");
            $(this).addClass("Selected");

            $("Button.optionsContainer").attr("aria-pressed", "false");
            $(this).attr("aria-pressed", "true");

            if (optionID.indexOf("pickupOption") >= 0 && isButton) {
                $(".cartType").val("instore");
                $(".pickupOption").addClass("Selected");
                $(".crtfrm .big.STBTN").val("Add To Cart");
                $(".crtfrm .big.STBTN").html("Add To Cart");
                $(".crtfrm .big.BUY-NOW").html("Buy Now");
                $(".crtfrm").first().find(".big.BUY-NOW").parent().show();
                $(".mm-t007-sticky-bar .crtfrm .big.BUY-NOW").parent().show();
                $(".fixed-footer .crtfrm .big.BUY-NOW").parent().show();

            } else if (optionID.indexOf("shippingOption") >= 0 && isButton) {
                $(".cartType").val("shipout");

                $(".shippingOption").addClass("Selected");
                $(".crtfrm .big.STBTN").val("Add To Cart");
                $(".crtfrm .big.STBTN").html("Add To Cart");
                $(".crtfrm .big.BUY-NOW").html("Buy Now");
                $(".crtfrm").first().find(".big.BUY-NOW").parent().show();
                $(".mm-t007-sticky-bar .crtfrm .big.BUY-NOW").parent().show();
                $(".fixed-footer .crtfrm .big.BUY-NOW").parent().show();
            } else if (optionID.indexOf("listOption") >= 0 && isButton) {

                $(".listOption").addClass("Selected");
                $(".cartType").val("list");
                $(".crtfrm .big.STBTN").val("Add To List");
                $(".crtfrm .big.STBTN").html("Add To List");
                $(".crtfrm").first().find(".big.BUY-NOW").parent().hide();
                $(".mm-t007-sticky-bar .crtfrm .big.BUY-NOW").parent().hide();
                $(".fixed-footer .crtfrm .big.BUY-NOW").parent().hide();
            }
        }

        return false;
    });

    $(".ChangeCartType").click(function () {

        $(this).parent().parent().parent().find(".cartType").val($(this).data("carttype"));

    });

    $("#opAddToCart").click(function () {

        //alert('click add to cart');

        $("#cart-options.BuyingOptions input.btn-add").removeClass("opDisabled");

        $("#cart-options.BuyingOptions input.btn-add.grey.big.opPickupAtStore").addClass("opDisabled");

    });

    $("#opPickupRadio").click(function () {

        //alert('pick up at store')

        $("#cart-options.BuyingOptions input.btn-add").addClass("opDisabled");

        $("#cart-options.BuyingOptions input.btn-add.opPickupAtStore").removeClass("opDisabled");

    });



    $(".opDeliveryTypeRadio").click(function () {

        var storeID = 29;
        if ($(this).data("storeid") != null) {
            storeID = parseInt($(this).data("storeid"));
        }
        // set the store
        $(".crtfrm input[name='store_id']").val(storeID);

        $(".crtfrm").first().attr("action", "/store/add_product.aspx?storeid=" + storeID)

        if (storeID != 29) {
            // we need to turn on the button.

            $("#opPickupAtStore").removeClass("opDisabled");
            $("#opPickupAtStore").addClass("opEnabled");
            $("#opPickupAtStore").unbind();
            $("#opPickupAtStore").click(function () {

                $(".crtfrm").first().submit();
            });
        }
        else {
            $("#opPickupAtStore").addClass("opDisabled");
            $("#opPickupAtStore").removeClass("opEnabled");
            $("#opPickupAtStore").unbind();
            $("#opPickupAtStore").click(function () {
                return;
            });
        }

        // rebind the click...






    });


    // need to bind the subit to the buying options button.

    $('#topserviceplan input').attr('checked', false);
    $('#serviceplanfrm input').attr('checked', false);

    $("#topserviceplan input[name='topserviceplan']").click(function () {

        $("#serviceplanfrm input[name='serviceplan'][value='" + this.value + "']").attr("checked", "checked");

    });

    $('#moreprotectionplans').click(function () {


        $('#topserviceplan li').removeClass("hideitem");
        $('#moreprotectionplans').addClass("hideitem");
    });


    $("#serviceplanfrm input[name='serviceplan']").click(function () {

        $('#topserviceplan input').attr('checked', false);
        $("#topserviceplan input[name='topserviceplan'][value='" + this.value + "']").attr("checked", "checked");

    });

    // lets handle add ons radio buttons...

    $(".productIDsRadio").click(function () {


        var thisFormName = $(this).attr("name");


        var thisRemoveItem = $("input[name = '" + thisFormName + "'][value = '']");

        if (thisRemoveItem != null && thisRemoveItem.parent() != null) {
            thisRemoveItem.parent().show();
        }

        if ($(this).val() == '') {

            $(this).parent().hide();
        }



    });



    $(".startBuild").click(function () {


        var buildID = $(this).data('buildid')
        var buildName = $(this).data('buildname')
        var storeSelected = $(this).data('storeselected')
        var rulecount = 0;


        //ga('mc.ec:addProduct', {
        //    'id': $('.ProductLink_' + productId).data('id'),
        //    'name': $('.ProductLink_' + productId).data('name'),
        //    'category': $('.ProductLink_' + productId).data('category'),
        //    'brand': $('.ProductLink_' + productId).data('brand'),
        //    'price': price,
        //    'quantity': 1
        //});


        if (usingGA4) {
            gtag('event', 'start_build', {
                'event_type': 'start_build',
                'event_action': 'store:' + storeSelected,
                'build_id': '' + buildID
            });
        }
        if (usingGA3) {


            ga('mc.send', 'event', 'start_build', 'start_build', storeSelected);
        }


        $('.sku').each(function () {
            var bsku = $(this).html().replace('SKU: ', '');
            if (bsku == '583526' || bsku == '583559' || bsku == '583575' || bsku == '583609' || bsku == '583617' || bsku == '583757' || bsku == '583864' || bsku == '583872' || bsku == '583922' || bsku == '583955' || bsku == '584094' || bsku == '584110' || bsku == '584250' || bsku == '584318' ){
                $(this).parent().find('.stock').html('Special Order');
        }

        });


    });


    $(".openboxfrm").submit(function () {


        var productIDs = "";
        var count = 0;
        var rulecount = 0;
        var rules = new Array();

        var price = $(this).parent().parent().data('price');

        var productId = $(this).find("input[name='productID']").val();



        if (usingGA4) {
            gtag("event", "add_to_cart", {
                currency: "USD",
                value: price,
               
                items: [
                    {
                        item_id: $('.ProductLink_' + productId).data('id'),
                        item_name: $('.ProductLink_' + productId).data('name').replace("\\\"", " "),


                        index: 0,
                        item_brand: $('.ProductLink_' + productId).data('brand').replace("\\\"", " "),
                        item_category: $('.ProductLink_' + productId).data('category').replace("\\\"", " "),

                        item_list_id: "Add To Cart Click - Single Product Clearance",
                        item_list_name: "Add To Cart Click - Single Product Clearance",
                        is_personalized: $('.ProductLink_' + productId).data('personalized'),
                        price: price,
                        currency: "USD",
                        quantity: 1
                    }
                ]
            });
        }
        if (usingGA3) {


            ga('mc.ec:addProduct', {
                'id': $('.ProductLink_' + productId).data('id'),
                'name': $('.ProductLink_' + productId).data('name'),
                'category': $('.ProductLink_' + productId).data('category'),
                'brand': $('.ProductLink_' + productId).data('brand'),
                'price': price,
                'quantity': 1,
                'list': 'Add To Cart Click - Single Product Clearance'
            });




            ga('mc.ec:setAction', 'add', { list: 'Add To Cart Click - Single Product Clearance' });

        }



    });



    bindSubmit();
    bindClickItemV2();

    $(".proceedtocart").click(function () {

        $(".crtfrm").submit();

    });
    $(".proceedAjaxModal").click(function () {
        $("#crtfrmAjaxItems").submit();

    });



    // lets handle the Frequently purchased pricing updates and image removal


    $(".fbBundleProductCheckbox").click(function () {

        var addedTotal = 0

        $("#FrequentyPurchasedTogether input[name='ProductID']").each(function () {
            addedTotal = parseFloat($(this).data("price"));

        })

        $("#FrequentyPurchasedTogether input[name='productIDsFB']:checked").each(function () {


            addedTotal = addedTotal + parseFloat($(this).data("price"));


        });


        var displayTotal = addedTotal.toFixed(2).toString();

        $(".BundledPrice").html("$" + displayTotal);

        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Bundled Price Updated to $' + displayTotal + '</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);



        // now lets toggle displays
        if ($(this).is(':checked')) {
            //$(".recentImageItem" + $(this).data("id")).fadeIn(400);
            $(".recentImageItem" + $(this).data("id")).css("opacity", "1");
        }
        else {
            //$(".recentImageItem" + $(this).data("id")).fadeOut(400);
            $(".recentImageItem" + $(this).data("id")).css("opacity", ".6");
        }



    });








    $(".opClose").click(function () {

        $(".opClose").hide()
        $("#open_box_modal").hide()
        $("#openBox").show()
        $(".fbSmallButton").css("opacity", "1")
        $("input.btn-add.grey.big.STBTN").css("opacity", "1")
        $("input.btn-add.grey.big.RWO-ON").css("opacity", "1")
        $('#opReduceAttention').removeClass('btn-add grey big STBTN opReduceAttention').addClass('btn-add grey big STBTN');
        $('#opReduceAttention').removeClass('btn-add grey big opReduceAttention').addClass('btn-add grey big');
    }),

        $(".opChoose").click(function () {
            $(".RWO-RESERVE").prop("type", "button");
            $("#open_box_modal_container .btn-add").css("display", "none")
            $(this).parent().parent().find(".btn-add").css("display", "block")
            $(".opBuyNowArea").text('BUY NOW');
        }),

        $("#openBox").click(function () {
            return $("#product-details article").removeClass("active"),
                $("#openBox").hide(),
                $(".opClose").show(),
                $("#product-details article").hide(),
                $("#tab-clearance").fadeIn("fast"),
                $("#product-details ul.nav li a").removeClass("current"),
                $("#tabClearance").addClass("current"),
                $(".fbSmallButton").css("opacity", ".4"),
                $("input.btn-add.grey.big.STBTN").css("opacity", ".4"),
                $("input.btn-add.grey.big.BUY-NOW").css("opacity", ".4"),
                $("input.btn-add.grey.big.RWO-ON").css("opacity", ".4"),
                $("#open_box_modal").is(":visible") ? $("#open_box_modal").hide() : ($("#open_box_modal").show(),
                    $('#opReduceAttention').removeClass('btn-add grey big STBTN').addClass('btn-add grey big STBTN opReduceAttention'),
                    $('#opReduceAttention').removeClass('btn-add grey big').addClass('btn-add grey big opReduceAttention')
                ),
                sendOpenBoxImpression();
            //$.cookie( $(this).parents("article").attr('id'), $(this).html());
            return false;
        });

    if ($("#open_box_modal").not(":visible") && window.location.href.indexOf("ob=1") == -1) {


        //sendOpenBoxImpression();

        $("#open_box_modal").mCustomScrollbar({
            mouseWheel: true,
            advanced: {
                autoScrollOnFocus: false,
                updateOnContentResize: true,
                updateOnBrowserResize: false,
                contentTouchScroll: true
            }
        });
    }

    $("#afterRebate").click(function () {



        $("#product-details article").removeClass("active");
        $("#product-details article").hide();
        $("#tab-rebate").fadeIn("fast");


        $("#product-details ul.nav li a").removeClass("current");
        $("#tabRebate").addClass("current");


        //$.cookie( $(this).parents("article").attr('id'), $(this).html());
        return false;



    });

    try {


        $("article.tabs section h1").click(function () {
            $("article.tabs section").removeClass("active");
            $(this).parent("section").addClass("active");
            $("article.tabs section:not('.active') article").hide();
            $("section.active article").fadeIn("fast");
            //$.cookie( $(this).parents("article").attr('id'), $(this).html());
            return false;
        });
    } catch (app) {

    }


    // turning of the old method...


    $('div.summary .slides-container').slick({
        slidesToShow: 1,
        slidesToScroll: 1,
        dots: false,
        arrows: false,
        infinite: false,
        autoplay: false,
        fade: true

    })

    $('div.summary #thumbnails .image-slide:first-child').addClass('current');

    $('div.summary .slides-container').on('beforeChange', function (event, slick, currentSlide, nextSlide) {
        $('div.summary #thumbnails .image-slide').removeClass('current');

        $('div.summary #thumbnails .image-slide[data-slide-index="' + nextSlide + '"]').addClass('current');

    });

    $('div.summary #thumbnails .image-slide').click(function () {

        var index = $(this).data('slide-index');
        $('div.summary .slides-container').slick("slickGoTo", index);

    });



    //$('#product div.summary .photos #thumbnails').slick({
    //    slidesToShow: 8,
    //    slidesToScroll: 0,
    //    dots: false,
    //    arrows: false,
    //    infinite: true,
    //    autoplay: false,
    //    focusOnSelect: true,
    //    asNavFor: '#product div.summary .photos .slides-container'

    //})



    //try {
    //    // PRODUCT PHOTO GALLERY
    //    $('#product div.summary').slides({
    //        preload: true,
    //        preloadImage: '/assets/images/loading.gif',
    //        effect: 'fade',
    //        crossfade: true,
    //        slideSpeed: 350,
    //        fadeSpeed: 300,
    //        generateNextPrev: false,
    //        generatePagination: false
    //    });
    //} catch (app) {

    //}


    // lets fire up the zip code search


    $("#findStoreZip").change(function (e) {
        e.preventDefault();
        var zip = $("#findStoreZip").val();

        if (zip.length >= 3) {
            // we should fire the ajax...
            $.ajax({
                type: "POST",
                url: "/assets/ajax/storeZipCode.aspx",
                data: { zip: zip, url: window.location.href },
                success: function (msg) {
                    if (msg.length > 60) {
                        createCookie("searchZip", zip, 30);
                    }
                    $("#storeList").html(msg);
                    $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Located store lists opened</div>');
                    window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
                }
            });


        }
        else {
            eraseCookie("searchZip");
        }

    });

    $("#findStoreButton").click(function (e) {
        e.preventDefault();
        var zip = $("#findStoreZip").val();

        if (zip.length >= 3) {
            // we should fire the ajax...
            $.ajax({
                type: "POST",
                url: "/assets/ajax/storeZipCode.aspx",
                data: { zip: zip, url: window.location.href },
                success: function (msg) {
                    if (msg.length > 60) {
                        createCookie("searchZip", zip, 30);
                    }
                    $("#storeList").html(msg);
                    $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Located store lists opened</div>');
                    window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
                }
            });


        }
        else {
            // eraseCookie("searchZip");
        }

    });

    $(".zipCodeLookup form").submit(
        function (e) {
            e.preventDefault();
            var zip = $("#findStoreZip").val();

            if (zip.length >= 3) {
                // we should fire the ajax...
                $.ajax({
                    type: "POST",
                    url: "/assets/ajax/storeZipCode.aspx",
                    data: { zip: zip, url: window.location.href },
                    success: function (msg) {
                        if (msg.length > 60) {
                            createCookie("searchZip", zip, 30);
                        }
                        $("#storeList").html(msg);
                        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Located store lists opened</div>');
                        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
                    }
                });


            }

        }
    );




    // STORE LOCATION MODAL
    //$(".myStore .info").click(function (e) {

    //    e.preventDefault();
    //    $("#storeInfo").show();
    //    $("#storeInfo").addClass("show");
    //    $("#Aria-Announcements").html('<div aria-live="polite" role="alert">My store info dialog opening.</div>');
    //    window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
    //    $("#storeInfo .closeModal").focus();

    //});
    $("#My-Store").click(function (e) {

        e.preventDefault();
        $("#storeInfo").show();
        $("#storeInfo .dropdown-menu ").hide();
        //   $("#storeInfo").addClass("show");
        escapeTarget = $("#My-Store");
        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">My store info dialog opening.</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        $("#storeInfo .closeModal").focus();


    });

    $("#storeInfo .closeModal").click(function () {
        $("#storeInfo").removeClass("show");
        $("#storeInfo").removeClass("forceopen");
        $("#storeInfo").hide();
        $("#storeInfo .dropdown-menu ").hide();
        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Store info closed.</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        return false;
    });



    $("#hypSignInWrapper").click(function (e) {
        $("#storeInfo").hide();
        $("#storeInfo").removeClass("show");
        $("#storeInfo").removeClass("forceopen");
        e.preventDefault();
        $("#accountOptions").show();
        //$("#accountOptions").removeClass("hide");
        //$("#accountOptions").addClass("show");
        escapeTarget = $(document.activeElement);
        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">My account info dialog opening.</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        $("#accountOptions .closeModal").focus();


    });

    $("#hypMyAccount").click(function (e) {

        e.preventDefault();
        //    $("#accountOptions").removeClass("hide");
        //    $("#accountOptions").addClass("show");
        $("#accountOptions").show();
        escapeTarget = $(document.activeElement);
        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">My account info dialog opening.</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        $("#accountOptions .closeModal").focus();


    });



    $("#accountOptions .closeModal").click(function () {
        //$("#accountOptions").addClass("hide");
        // $("#accountOptions").removeClass("show");
        $("#accountOptions").hide()
        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">My account info dialog closed.</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        return false;
    });


    if (!hasTouch && !window.navigator.msPointerEnabled) {
        // SHOW 'ZOOM' TEXT
        $("#product div.slides-container a .productImageZoom").hover(
            function () {
                $(this).parent().append($("<p class='icons zoom replace'>Zoom</p>"));
            },
            function () {
                $(this).parent().find("p.zoom").remove();
            }
        );

        $(".hypMyAccountModal").hoverIntent({
            over: function () {
                $("#storeInfo").hide();
                $("#storeInfo").removeClass("show");
                $("#storeInfo").removeClass("forceopen");
                $("#accountOptions").show();
                // $("#accountOptions").removeClass("hide");
            },
            out: function () {

                //  $("#accountOptions").addClass("hide");
                $("#accountOptions").hide();
            },
            timeout: 300
        });



        $(".myStore").hoverIntent({
            over: function () {

                $("#storeInfo").show();
                //  $("#storeInfo").addClass("show");
            },
            out: function () {
                $("#storeInfo").hide();
                $("#storeInfo .dropdown-menu ").hide();
                //   $("#storeInfo").remove("show");
            },
            timeout: 300
        });





        //$(".hypMyAccountModal").hover(
        //    function () {
        //        $("#accountOptions").removeClass("hide");
        //    },
        //    function () {
        //        $("#accountOptions").addClass("hide");
        //    }
        //);

    }

    try {


        $('#careproduct div.summary').slides({
            preload: true,
            preloadImage: '/assets/images/loading.gif',
            effect: 'fade',
            crossfade: true,
            slideSpeed: 350,
            fadeSpeed: 300,
            generateNextPrev: false,
            generatePagination: false
        });
    } catch (app) {

    }

    // SHOW 'ZOOM' TEXT
    $("#careproduct div.slides-container a").hover(
        function () {
            $(this).append($("<p class='icons zoom replace'>Zoom</p>"));
        },
        function () {
            $(this).find("p.zoom").remove();
        }
    );


    $('#fader').fadeIn("fast");


    try {
        $('#fader').orbit({


            animation: 'fade',                  // fade, horizontal-slide, vertical-slide, horizontal-push
            animationSpeed: 1000,                // how fast animtions are
            timer: true, 			 // true or false to have the timer
            advanceSpeed: 5000, 		 // if timer is enabled, time between transitions 
            pauseOnHover: true, 		 // if you hover pauses the slider
            startClockOnMouseOut: true, 	 // if clock should start on MouseOut
            startClockOnMouseOutAfter: 100, 	 // how long after MouseOut should the timer start again
            directionalNav: false, 		 // manual advancing directional navs
            captions: false, 			 // do you want captions?
            captionAnimation: 'fade', 		 // fade, slideOpen, none
            captionAnimationSpeed: 800, 	 // if so how quickly should they animate in
            bullets: false, 		 // true or false to activate the bullet navigation
            bulletThumbs: false, 	 // thumbnails for the bullets
            bulletThumbLocation: '', 	 // location from this file where thumbs will be
            afterSlideChange: function () { }



        });

    } catch (app) {

    }


    try {

        $(".specialOptions").fancybox({
            baseClass: 'fancyOptions',
            width: 800,
            height: 640,
            idleTime: false,
            transitionIn: "elastic",
            transitionOut: "fade",
            type: "iframe",

            buttons: ["close"],
            'afterShow': function () { $('.fancybox-button--close').focus(); }

        });
    } catch (app) {

    }

    try {
        $(".fancyPhotos").fancybox({
            'opacity': true,
            'overlayShow': false,
            'hideOnContentClick': false,
            'transitionIn': 'fade',
            'transitionOut': 'fade',
            'scrolling': 'no',
            'padding': 20,
            'width': 500,
            'min-width': 320,
            'height': 500,
            'min-height': 320,
            'overlayColor': '#F0F0F0',
            'titleShow': false,
            'type': 'iframe',
            'idleTime': false,
            'iframe': { scrolling: 'no', preload: false },
            'aspectRatio': true,
            'afterLoad': function (instance, slide) {
                // console.log(instance);
                // console.log(slide);
                $('.fancybox-button--close').focus();
                if (slide.src.indexOf('youtube.com') > 0) {

                    slide.$slide.addClass('fancybox-slide--video');
                }
            }

        });
    } catch (app) {

    }


    try {



        $(".fancyVideo").fancybox({
            'opacity': true,
            'overlayShow': false,
            'hideOnContentClick': false,
            'transitionIn': 'fade',
            'transitionOut': 'fade',
            'scrolling': 'no',
            'padding': 20,
            'width': 1000,
            'min-width': 320,
            'height': 1000,
            'min-height': 320,
            'arrows': false,
            'infobar': false,
            'overlayColor': '#F0F0F0',
            'titleShow': false,
            'idleTime': false,


            'aspectRatio': true,
            'afterShow': function () { $('.fancybox-button--close').focus(); }

        });
    } catch (app) {

    }





    try {
        $(".fancyPhotosMobile").fancybox({
            'opacity': true,
            'overlayShow': false,
            'hideOnContentClick': false,
            'transitionIn': 'fade',
            'transitionOut': 'fade',
            'scrolling': 'no',
            'padding': 20,
            'width': 500,
            'min-width': 320,
            'height': 500,
            'min-height': 320,
            'overlayColor': '#F0F0F0',
            'titleShow': false,
            'idleTime': false,

            'aspectRatio': true,
            'afterLoad': function (instance, slide) {

                $('.fancybox-button--close').focus();
                //console.log(instance);
                //console.log(slide);
                if (slide.src.indexOf('youtube.com') > 0) {

                    slide.$slide.addClass('fancybox-slide--video');
                }
            }
        });
    } catch (app) {

    }
    $(".productImageZoom").click(function () {
        $(".zm-viewer.followViewerConfig").css("display", "none");
    });








    $("#tech a").attr('target', '_blank');

    try {
        $(".bio-modal").fancybox({
            'width': 830,
            'height': '95%',
            'autoScale': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'type': 'iframe',
            'idleTime': false,
            'baseClass': 'fbModalBio',
            'afterShow': function () { $('.fancybox-button--close').focus(); }

        });

    } catch (app) {

    }




    setModalLogin();
    setServiceButton();





    try {
        $(".pop-modal").fancybox({
            'width': 830,
            'height': '95%',
            'autoScale': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'type': 'iframe',
            'idleTime': false,
            'afterShow': function () { $('.fancybox-button--close').focus(); }

        });

    } catch (app) {

    }

    try {
        $(".pop-modal16x9").fancybox({
            'width': '95%',
            'fitToView': true,
            'height': '53%',
            'autoScale': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'type': 'iframe',
            'idleTime': false,
            'baseClass': 'modal16X9',
            'caption': '<a href="/site/customer-support/terms-conditions-site.aspx#tours" class="virtualDisclaimer">Product prices shown on the virtual tour are subject to change and may not be the current product price. </a>',

            'afterShow': function () {
                $('.fancybox-button--close').focus();

            }

        });

    } catch (app) {

    }

    try {
        $(".sms-modal").fancybox({

            'maxWidth': 440,
            'maxHeight': 560,
            'fitToView': false,
            'width': '88%',
            'height': 560,
            'autoSize': false,
            'closeClick': false,
            'openEffect': 'none',
            'closeEffect': 'none',
            'controls': 0,
            'showinfo': 0,
            'autoDimensions': false,
            'scrolling': 'no',
            'padding': 0,
            'type': 'iframe',
            'arrows': false,
            'infobar': false,
            'buttons': ["close"],
            'idleTime': false,

            'iframe': { scrolling: 'no', preload: true },
            'afterShow': function () { $('.fancybox-button--close').focus(); }


        });

    } catch (app) {

    }

    try {
        $("a.PlanDetailsLink").fancybox({
            'width': '620px',
            'height': '95%',
            'autoScale': false,
            'titleShow': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'idleTime': false,
            'afterShow': function () {

                $('.fancybox-button--close').focus();

                $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Protection Plan Information Opened</div>');
                window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);

            }
        });

    } catch (app) {

    }







    try {
        function openModal(name, skuIDs) {
            $.fancybox(
                {

                    'autoDimensions': false,
                    'width': 1000,
                    'height': '95%',
                    'autoScale': false,
                    'transitionIn': 'elastic',
                    'transitionOut': 'fade',
                    'type': 'iframe',
                    'idleTime': false,
                    'href': '/endeca/compare.aspx?skuIDs=' + skuIDs,
                    'afterShow': function () { $('.fancybox-button--close').focus(); }
                }
            );
        }

    } catch (app) {

    }


    ADAUpdates();


    // end ready

});



function setModalLoginFavorite() {



    // before finding, lets see if the user is already logged in and if so, lets alter the a tag to the after login data value...
    if ($("body").hasClass("isLoggedIn")) {
        // switch the links
        $(".login-modalFav").each(function () {

            if (typeof $(this).data("after") !== "undefined") {
                $(this).attr("href", $(this).data("after"));



            }

        });

    }


    //try {

    //    $(".login-modalFav").fancybox({
    //        'width': 600,
    //        'height': '95%',
    //        'autoScale': false,
    //        'transitionIn': 'elastic',
    //        'transitionOut': 'fade',
    //        'type': 'iframe',
    //        'idleTime': false,
    //        'baseClass': 'fbModalLogin',
    //        'afterShow': function () { $('.fancybox-button--close').focus(); }

    //    });

    //} catch (app) {

    //}



    //$(".login-modalFav").click(function () {


    //    var productID = $(this).data("productid");

    //    try {
    //        $('#mainMenu').panel('close');
    //    }
    //    catch (ex) {

    //    }
    //    //console.log("adding Listener");
    //    var mliframe = $($(".fbModalLogin .fancybox-iframe").contents()[0], window);
    //    // var mliframe = $(".fbModalLogin .fancybox-iframe").contents();
    //    window.addEventListener("message", function (event) {

    //        if (event.origin.toLowerCase().indexOf(".microcenter.com") <= 0) {

    //            return;
    //        }
    //        else if (event.data.loginSuccess === true) {
    //            localStorage.setItem("login", "true");

    //            window.location.href = "https://" + window.location.host + window.location.pathname + "?favID=" + productID;


    //            //location.reload(true);
    //            // Close modal window/redirect/reload page
    //        }
    //    }, false);



    //});
}

function sendOpenBoxImpression() {


    if (usingGA4) {
        if (typeof (OpenBoxLayer) != 'undefined' && !sentopenbox && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < OpenBoxLayer.length; ++cnt) {

                if (cnt > 0) { list += "," }
                list += "{";
                list += "item_id: " + OpenBoxLayer[cnt].name.replace("\\\"", " ") + ",";
                list += "item_name: " + OpenBoxLayer[cnt].id + ",";
                list += "index: " + OpenBoxLayer[cnt].position + ",";
                list += "item_brand: " + OpenBoxLayer[cnt].brand.replace("\\\"", " ") + ",";
                list += "item_category: " + OpenBoxLayer[cnt].category.replace("\\\"", " ") + ",";
                list += "item_list_id: " + OpenBoxLayer[cnt].list.replace("\\\"", " ") + ",";
                list += "item_list_name: " + OpenBoxLayer[cnt].list.replace("\\\"", " ") + ",";
               
                list += "price: " + OpenBoxLayer[cnt].price + ",";
                
                list += "currency: 'USD',";
                list += "quantity: " + 1 ;




                list += "}";



            }
            list += "]";

            gtag("event", "view_item_list", {
                item_list_id: "Single Product Clearance",
                item_list_name: "Single Product Clearance",
                items: eval(list)

            });


            sentopenbox = true;

        }
    }
    if (usingGA3) {


        if (typeof (OpenBoxLayer) != 'undefined' && !sentopenbox && typeof (ga) != 'undefined') {

            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < OpenBoxLayer.length; ++cnt) {
                ga('mc.ec:addImpression', OpenBoxLayer[cnt]);
            }

            sentopenbox = true;
            ga('mc.ec:setAction', 'detail');
            ga('mc.send', 'event', 'eCommerce', 'Single Product Clearance', { nonInteraction: true });


        }

    }
}

function sendfrequentlyboughtImpression() {

    if (usingGA4) {
        if (typeof (frequentlyBoughtLayer) != 'undefined' && !sentfrequentlybought && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < frequentlyBoughtLayer.length; ++cnt) {
                if (typeof (frequentlyBoughtLayer[cnt].name) != 'undefined' && typeof (frequentlyBoughtLayer[cnt].brand) != 'undefined' &&  typeof (frequentlyBoughtLayer[cnt].list) != 'undefined') {
                    if (cnt > 0) { list += "," }
                    list += "{";
                    list += "item_id: '" + frequentlyBoughtLayer[cnt].id + "',";
                    list += "item_name: '" + frequentlyBoughtLayer[cnt].name.replace("\\\"", " ")  + "',";
                    list += "index: " + frequentlyBoughtLayer[cnt].position + ",";
                    list += "item_brand: '" + frequentlyBoughtLayer[cnt].brand.replace("\\\"", " ") + "',";
                   
                    list += "item_list_id: '" + frequentlyBoughtLayer[cnt].list.replace("\\\"", " ") + "',";
                    list += "item_list_name: '" + frequentlyBoughtLayer[cnt].list.replace("\\\"", " ") + "',";
                    list += "price: " + frequentlyBoughtLayer[cnt].price + ",";
                    list += "currency: 'USD',";
                    list += "quantity: " + 1 + ",";




                    list += "}";
                }


            }
            list += "]";

            //gtag("event", "view_item_list", {
            //    item_list_id: "Frequently Bought Together",
            //    item_list_name: "Frequently Bought Together",
            //    items: eval(list)

            //});

            sentfrequentlybought = true;

        }
    }
    if (usingGA3) {
        if (typeof (frequentlyBoughtLayer) != 'undefined' && !sentfrequentlybought && typeof (ga) != 'undefined') {
            var listName = "Frequently Bought Together";
            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < frequentlyBoughtLayer.length; ++cnt) {
                ga('mc.ec:addImpression', frequentlyBoughtLayer[cnt]);
                listName = frequentlyBoughtLayer[cnt].list;
            }

            sentfrequentlybought = true;
            ga('mc.ec:setAction', 'detail');
            ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });


        }
    }

}

function sendconfiguratorImpression() {


    if (usingGA4) {
        if (typeof (configuratorLayer) != 'undefined' && !sentconfigurator && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < configuratorLayer.length; ++cnt) {

                if (cnt > 0) { list += "," }
                list += "{";
                list += "item_id: " + configuratorLayer[cnt].name.replace("\\\"", " ") + ",";
                list += "item_name: " + configuratorLayer[cnt].id + ",";
                list += "index: " + configuratorLayer[cnt].position.replace("\\\"", " ") + ",";
                list += "item_brand: " + configuratorLayer[cnt].brand.replace("\\\"", " ") + ",";
                list += "item_category: " + configuratorLayer[cnt].category.replace("\\\"", " ") + ",";
                list += "item_list_id: " + configuratorLayer[cnt].list.replace("\\\"", " ") + ",";
                list += "item_list_name: " + configuratorLayer[cnt].list.replace("\\\"", " ") + ",";
                list += "price: " + configuratorLayer[cnt].price + ",";
                list += "currency: 'USD',";
                list += "quantity: " + 1 + ",";




                list += "}";



            }
            list += "]";

            gtag("event", "view_item_list", {
                item_list_id: "Recommended Items",
                item_list_name: "Recommended Items",
                items: eval(list)

            });

            sentconfigurator = true;

        }
    }
    if (usingGA3) {


        if (typeof (sentconfigurator) != 'undefined' && !sentconfigurator && typeof (ga) != 'undefined') {


            var listName = "Recommended Items";
            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < configuratorLayer.length; ++cnt) {
                ga('mc.ec:addImpression', configuratorLayer[cnt]);
                listName = configuratorLayer[cnt].list;
            }

            sentconfigurator = true;
            ga('mc.ec:setAction', 'detail');
            ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });


        }
    }

}

function sendBundleImpression() {



    if (usingGA4) {
        if (typeof (bundleOptionsLayer) != 'undefined' && !sentBundles && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < bundleOptionsLayer.length; ++cnt) {

                if (cnt > 0) { list += "," }
                list += "{";
                list += "item_id: " + bundleOptionsLayer[cnt].name.replace("\\\"", " ") + ",";
                list += "item_name: " + bundleOptionsLayer[cnt].id + ",";
                list += "index: " + bundleOptionsLayer[cnt].position + ",";
                list += "item_brand: " + bundleOptionsLayer[cnt].brand.replace("\\\"", " ") + ",";
                list += "item_category: " + bundleOptionsLayer[cnt].category.replace("\\\"", " ") + ",";
                list += "item_list_id: " + bundleOptionsLayer[cnt].list.replace("\\\"", " ") + ",";
                list += "item_list_name: " + bundleOptionsLayer[cnt].list.replace("\\\"", " ") + ",";
                list += "price: " + bundleOptionsLayer[cnt].price + ",";
                list += "currency: 'USD',";
                list += "quantity: " + 1 + ",";




                list += "}";



            }
            list += "]";

            gtag("event", "view_item_list", {
                item_list_id: "Bundle Product Option",
                item_list_name: "Bundle Product Option",
                items: eval(list)

            });

            sentBundles = true;

        }
    }
    if (usingGA3) {


        if (typeof (bundleOptionsLayer) != 'undefined' && !sentBundles && typeof (ga) != 'undefined') {

            var listName = "Bundle Product Option";
            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < bundleOptionsLayer.length; ++cnt) {
                ga('mc.ec:addImpression', bundleOptionsLayer[cnt]);
                listName = bundleOptionsLayer[cnt].list;
            }

            sentBundles = true;
            ga('mc.ec:setAction', 'detail');
            ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });


        }
    }

}

function sendaddOnImpression() {

    if (usingGA4) {
        if (typeof (addOnLayer) != 'undefined' && !sentAdOns && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < addOnLayer.length; ++cnt) {

                if (cnt > 0) { list += "," }
                list += "{";
                list += "item_id: " + addOnLayer[cnt].name.replace("\\\"", " ") + ",";
                list += "item_name: " + addOnLayer[cnt].id + ",";
                list += "index: " + addOnLayer[cnt].position + ",";
                list += "item_brand: " + addOnLayer[cnt].brand.replace("\\\"", " ") + ",";
                list += "item_category: " + addOnLayer[cnt].category.replace("\\\"", " ") + ",";
                list += "item_list_id: " + addOnLayer[cnt].list.replace("\\\"", " ") + ",";
                list += "item_list_name: " + addOnLayer[cnt].list.replace("\\\"", " ") + ",";
                list += "price: " + addOnLayer[cnt].price + ",";
                list += "currency: 'USD',";
                list += "quantity: " + 1;




                list += "}";



            }
            list += "]";

            gtag("event", "view_item_list", {
                item_list_id: "Bundle Product Option",
                item_list_name: "Bundle Product Option",
                items: eval(list)

            });

            sentAdOns = true;

        }
    }
    else {

        if (typeof (addOnLayer) != 'undefined' && !sentAdOns && typeof (ga) != 'undefined') {
            var listName = "Ad Ons";
            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < addOnLayer.length; ++cnt) {
                ga('mc.ec:addImpression', addOnLayer[cnt]);
                listName = addOnLayer[cnt].list;
            }

            sentAdOns = true;
            ga('mc.ec:setAction', 'detail');
            ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });


        }

    }



}


function sendproductImpression() {



    if (usingGA4) {
        if (typeof (productsLayer) != 'undefined' && !sentProducts && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < productsLayer.length; ++cnt) {

                if (productsLayer[cnt].list != null && productsLayer[cnt].brand != null && productsLayer[cnt].name != null) {
                    if (cnt > 0) { list += "," }
                    list += "{";
                    list += "item_id: " + productsLayer[cnt].name.replace("\\\"", " ") + ",";
                    list += "item_name: " + productsLayer[cnt].id + ",";
                    list += "index: " + productsLayer[cnt].position + ",";
                    list += "item_brand: " + productsLayer[cnt].brand.replace("\\\"", " ") + ",";
                    list += "item_category: " + productsLayer[cnt].category.replace("\\\"", " ") + ",";
                    list += "item_list_id: " + productsLayer[cnt].list.replace("\\\"", " ") + ",";
                    list += "item_list_name: " + productsLayer[cnt].list.replace("\\\"", " ") + ",";
                    list += "price: " + addOnLayer[cnt].price + ",";
                    list += "currency: 'USD',";
                    list += "quantity: " + 1;




                    list += "}";

                }

            }
            list += "]";

            gtag("event", "view_item_list", {
                item_list_id: "Bundle Product Option",
                item_list_name: "Bundle Product Option",
                items: eval(list)

            });

            sentProducts = true;

        }
    }
    else {





        if (typeof (productsLayer) != 'undefined' && !sentProducts && typeof (ga) != 'undefined') {

            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < productsLayer.length; ++cnt) {
                if (productsLayer.length == 1) {
                    ga('mc.ec:addProduct', productsLayer[cnt]);
                }
                else {
                    ga('mc.ec:addImpression', productsLayer[cnt]);
                }

            }

            sentProducts = true;
            ga('mc.ec:setAction', 'detail');
            if (productsLayer.length > 1) {
                ga('mc.send', 'event', 'eCommerce', 'Products', { nonInteraction: true });
            }


        }
    }


}




function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    if (window.location.hostname == "localhost") {
        document.cookie = name + "=" + value + expires + ";path=/;domain=localhost;";

    }
    else {
        document.cookie = name + "=" + value + expires + "; path=/;secure;domain=.microcenter.com;";
    }



}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);

}

// **************************************************************
// Compare Functions
// *************************************************************
function setCompareFeatures() {

    // **********************************************************************





    // *************************************************************************
    // compare methods
    // *************************************************************************

    var skucheck = readCookie('compare');
    if (typeof (skucheck) != 'undefined' && skucheck != null && skucheck != "") {
        currentCompare = skucheck;
    }
    else {
        skucheck = currentCompare;
    }


    var foundsku = "";


    $('#compare-remove').click(function (e) {
        currentCompare = "";
        e.preventDefault();
        eraseCookie("compare");


        $('.inline-compare-text').css("display", "inline");
        $('.inline-compare-button').css("display", "none");
        $('.checkbox').prop('checked', false);
        $('.inline-compare-text').html('Select 2 to compare');
        set_compare_section('', '');
        return false;
    });

    $('.compare2023').click(function (e) {

        e.preventDefault();

        $("#compareSubmit").submit();

        //        var allIds = new Array();
        //        var productIDs = '0';
        //        productIDs = readCookie('compare');
        //        openModal('compare', productIDs);
    });

    $('.compare').click(function (e) {

        e.preventDefault();

        $("#compareSubmit").submit();

        //        var allIds = new Array();
        //        var productIDs = '0';
        //        productIDs = readCookie('compare');
        //        openModal('compare', productIDs);
    });

    $('#compare-over-alert a').click(function (e) {
        e.preventDefault();
        $('#compare-over-alert').hide();

    });




    if (typeof (skucheck) != 'undefined' && skucheck != null && skucheck != "") {
        var allskus = new Array();

        allskus = skucheck.split('|');

        set_compare_section('', '');

        if (allskus.length > 1) {
            $('.inline-compare-text').html('Add to compare');
        }
        else {
            $('.inline-compare-text').html('Select 2 to compare');
        }

        for (a in allskus) {
            foundsku = "";
            foundsku = allskus[a].split(':')[0];
            var foundproductID = allskus[a].split(':')[1];

            if (!isNaN(foundproductID)) {



                $('#button_productIDcheck' + foundproductID).css("display", "inline");

                if (window.location.pathname.toLowerCase().indexOf("/product") < 0) {


                    $('#text_productIDcheck' + foundproductID).css("display", "none");
                }
                else {

                    $('#text_productIDcheck' + foundproductID).html('Compare');
                }
                //$('.inline-compare-text').html('Add to compare');
                $('#productIDcheck' + foundproductID).prop('checked', true);



            }

        }


    }
    else {
        $('.inline-compare-text').html('Select 2 to compare');
    }






    /* lest set the featured item slider */


    try {
        $("div.featuredList").carousel({ dispItems: 1 });
    } catch (e) {

    }

    try {
        $("div.featuredItems").css('display', 'block');
    } catch (e) {

    }


}







function set_compare_section(sku_id, producttitle) {
    var cookie = readCookie('compare');

    if (typeof (cookie) != 'undefined' && cookie != null && cookie != "") {
        currentCompare = cookie;
    }
    else {
        cookie = currentCompare;
    }

    var compareON = false;

    if (cookie && cookie.search('c26ba48acbfa28c59f170514c27aea07') != -1) {
        cookie = cookie.replace(/%7C/, '|');
        var allskus = new Array();
        allskus = cookie.split('|');



        for (var skuCount = 1; skuCount < 5; skuCount++) {


            if (allskus.length > skuCount) {
                compareON = true;
                thisSku = Right('000000' + allskus[skuCount].split(":")[0], 6);

                thisProductId = Right('0000000' + allskus[skuCount].split(":")[1], 7);


                var compareHtml = '<img src="https://90a1c75758623581b3f8-5c119c3de181c9857fcb2784776b17ef.ssl.cf2.rackcdn.com/' + thisProductId + '_' + thisSku + '.jpg" alt="' + producttitle + '">';
                compareHtml = compareHtml + '<div><a href="#" onclick="removeCompare(\'' + allskus[skuCount].split(":")[0] + ':' + allskus[skuCount].split(":")[1] + '\');return false;">X<span class="hide-text"> Remove Compare Item - ' + producttitle + '</span></a></div>';
                $('#compare-item' + skuCount).html(compareHtml);


            }
            else {
                $('#compare-item' + skuCount).html('');

            }


        }

        if (sku_id != "") {

            // lets animate the picture...


            var thisSku = Right('000000' + sku_id.split(":")[0], 6);

            var thisProductId = Right('0000000' + sku_id.split(":")[1], 7);

            $('.compare-section').show();
            var compareAnimationImg = '<img id=\"compareAnimationImg\" src="https://90a1c75758623581b3f8-5c119c3de181c9857fcb2784776b17ef.ssl.cf2.rackcdn.com/' + thisProductId + '_' + Right('0000000' + thisSku, 6) + '.jpg">';


            var compareAnimationPosition = $('#text_productIDcheck' + sku_id.split(":")[1]).parent().parent().parent().parent().position();
           // console.log(compareAnimationPosition.top + " " + compareAnimationPosition.left);

            var compareDestinationPosition = $('#compare-item' + (allskus.length - 1)).position();




            $('#compareAnimation').css("top", (compareAnimationPosition.top + 30) + 'px');
            $('#compareAnimation').css("left", (compareAnimationPosition.left + 20) + 'px');
            $('#compareAnimation').css("width", '120px');
            $('#compareAnimation').css("height", '120px');
            $('#compareAnimation').html(compareAnimationImg);
            $('#compareAnimation').show();

            $('#compare-item' + (allskus.length - 1) + ' img').hide();
            $('#compareAnimation').animate({ width: '36px', height: '36px', top: '-44px', left: compareDestinationPosition.left + 'px' }, 1000);


            setTimeout(function () { $('.compare-section #compare-item' + (allskus.length - 1) + ' img').show(); $('#compareAnimation').hide(); }, 1000);

            $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Compare item added or changed ' + producttitle + '.  Tab then press enter to load compare page in new window.</div>')
            window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        }

    } else {
        $('.compare-item').html('');
        $("#productGridAnnouncement").focus();
    }

    if (compareON) {
        $('.compare-section').show();
    } else {
        $('.inline-compare-text').css("display", "inline");
        $('.inline-compare-button').css("display", "none");
        $('.checkbox').prop('checked', false);
        $('.compare-section').hide();


    }

}

function removeCompare(sku_id) {

    var cookie = readCookie('compare');
    if (typeof (cookie) != 'undefined' && cookie != null && cookie != "") {
        currentCompare = cookie;
    }
    else {
        cookie = currentCompare;
    }
    var newCookie = "c26ba48acbfa28c59f170514c27aea07";

    if (cookie && cookie.search('c26ba48acbfa28c59f170514c27aea07') != -1) {
        cookie = cookie.replace(/%7C/, '|');
        var allskus = new Array();
        allskus = cookie.split('|');
        for (var skuCount = 1; skuCount < allskus.length; skuCount++) {

            if (allskus[skuCount] != sku_id) {

                newCookie = newCookie + "|" + allskus[skuCount];
            }

        }




        var foundsku = parseInt(sku_id.split(':')[0]);
        var foundproductID = sku_id.split(':')[1];
        $('#button_productIDcheck' + foundproductID).css("display", "none");
        $('#text_productIDcheck' + foundproductID).css("display", "inline");
        //$('.inline-compare-text').html('Add to compare');


        $('#productIDcheck' + foundproductID).prop('checked', false);


        if (allskus.length > 2) {
            $('.inline-compare-text').html('Add to compare');
        }
        else {


            $('.inline-compare-text').html('Select 2 to compare');
        }

        createCookie('compare', newCookie, 7);

        var et = "Compare Item Removed";

        ga('mc.send', 'event', et, sku_id, 'X selected');

        set_compare_section('', '');

    }



}


function set_compare_items(thisForm, sku_id, producttitle, searchResult, productPage ) {

    if (searchResult == null)
    {
        searchResult = true;
    }

    if (productPage == null) {
        productPage = false;
    }


    $('#compare-over-alert').hide();

    var cookie = readCookie('compare');

    if (typeof (cookie) != 'undefined' && cookie != null && cookie != "") {
        currentCompare = cookie;
    }
    else {
        cookie = currentCompare;
    }
    var allskus = new Array();


    if (cookie == '' && currentCompare == '') {

        var date = new Date();
        var minutes = -1;
        date.setTime(date.getTime() - 1);
        $.cookie(name, null, { domain: window.location.hostname, expires: date });
        $.cookie(name, null, { domain: '.microcenter.com', expires: date });


    }


    if (cookie && cookie.search('c26ba48acbfa28c59f170514c27aea07') != -1) {
        cookie = cookie.replace(/%7C/, '|');

        allskus = cookie.split('|');

        if (allskus.length > 4 && thisForm.elements[0].checked) {
            var thisPosition = $('#text_productIDcheck' + sku_id.split(":")[1]).parent().parent().parent().parent().position();

            $('#compare-over-alert').css("top", (thisPosition.top + 30) + 'px');
            $('#compare-over-alert').css("left", (thisPosition.left + 30) + 'px');

            $('#compare-over-alert').show();
            thisForm.elements[0].checked = false;
            return;
        }
    }

    var foundsku = sku_id.split(':')[0];
    var foundproductID = sku_id.split(':')[1];

    if (cookie) {
        cookie = cookie.replace(/%7C/, '|');

        if (cookie.search('c26ba48acbfa28c59f170514c27aea07') != -1) {
            if (thisForm.elements[0].checked) {

                // checkbox was checked
                if (cookie.search(sku_id) == -1) {
                    // if cookie does not contain product_id
                    createCookie('compare', cookie + '|' + sku_id, 7);
                } else {
                    // cookie already contains product_id
                }


                $('#button_productIDcheck' + foundproductID).css("display", "inline");
                if (!productPage) {
                    $('#text_productIDcheck' + foundproductID).css("display", "none");
                    $('.inline-compare-text').html('Add to compare');
                }
                else {
                    $('#text_productIDcheck' + foundproductID).css("display", "inline");
                    $('.inline-compare-text').html('Compare');
                }
            } else {
                // checkbox was un-checked
                $('#button_productIDcheck' + foundproductID).css("display", "none");
                $('#text_productIDcheck' + foundproductID).css("display", "inline");
                new_cookie = cookie.replace("|" + sku_id, '');
                createCookie('compare', new_cookie, 7);
                var allskus = new Array();
                sku_id = '';
                allskus = new_cookie.split('|');
                if (productPage) {
                    $('.inline-compare-text').html('Add To Compare');
                }
                if (allskus.length < 2) {
                    if (productPage) {
                        $('.inline-compare-text').html('Add To Compare');
                    }
                    else {
                        $('.inline-compare-text').html('Select 2 to compare');
                    }

                }
            }

        } else {
            createCookie('compare', 'c26ba48acbfa28c59f170514c27aea07|' + sku_id, 7);
            $('#button_productIDcheck' + foundproductID).css("display", "inline");
            $('#text_productIDcheck' + foundproductID).css("display", "none");
            $('.inline-compare-text').html('Add to compare');
        }


    } else {
        createCookie('compare', 'c26ba48acbfa28c59f170514c27aea07|' + sku_id, 7);

        $('#button_productIDcheck' + foundproductID).css("display", "inline");
        $('#text_productIDcheck' + foundproductID).css("display", "none");
        $('.inline-compare-text').html('Add to compare');
    }

    // send ping to analytics
    var et = "Compare Item Removed";
    if (thisForm.elements[0].checked) {
        et = "Compare Item Added";
    }
    ga('mc.send', 'event', et, sku_id, producttitle);

    if (searchResult) {
        set_compare_section(sku_id, producttitle);
    }


}



// END ON READY


var serviceplantotal = 0;
var addonstotal = 0;
var servicestotal = 0;


function checkCharlotte() {


    if (readCookie("charlotteDistance") == null || readCookie("charlotteDistance") == "" || readCookie("charlotteDistance") == "0") {


        $.ajax({
            url: "/assets/ajax/StoreDistanceCheck.aspx",
            type: "GET",
            data: {
                slat: "35.174430", slong: "-80.877650"
            }
        }).done(function (msg) {



            createCookie("charlotteDistance", msg);

            if (!isNaN(msg)) {

                if (Number(msg) <= 175) {
                    $("body").addClass("isCharlotte");
                }
            }



        });

    }

    if (readCookie("charlotteDistance") != null && !isNaN(readCookie("charlotteDistance"))) {

        if (Number(readCookie("charlotteDistance")) <= 175) {
            $("body").addClass("isCharlotte");
            $(".needsLogin").hide();
        }

    }

}

function checkMiami() {


    if (readCookie("miamiDistance") == null || readCookie("miamiDistance") == "" || readCookie("miamiDistance") == "0") {



        $.ajax({
            url: "/assets/ajax/StoreDistanceCheck.aspx",
            type: "GET",
            data: {
                slat: "25.773740", slong: "-80.322460"
            }
        }).done(function (msg) {



            createCookie("miamiDistance", msg);

            if (!isNaN(msg)) {

                if (Number(msg) <= 200) {
                    $("body").addClass("isMiami");
                }
            }



        });

    }

    if (readCookie("miamiDistance") != null && !isNaN(readCookie("miamiDistance"))) {

        if (Number(readCookie("miamiDistance")) <= 200) {
            $("body").addClass("isMiami");
            $(".needsLogin").hide();
        }

    }

}



function SelectServicePlan(serviceplan, price) {
    var currentServicePlanValue = parseFloat($('input[name="servicePlanValue"]').val());
    var currentServicePaanId = parseFloat($('input[name="servicePlanId"]').val());


    $("#summaryserviceplans .summaryserviceplans").hide();
    $("#summaryserviceplans #plan" + serviceplan).show();
    serviceplantotal = price;
    if (serviceplantotal > 0) {

        $("#interstitialSummary #serviceplanprice").html('<a href="#" onclick="SummaryToggle(\'summaryserviceplans\'); return false;">+ Protection Plan:</a> $' + price);
        $("#interstitialSummary #serviceplanprice").show();
    }
    else {
        $("#interstitialSummary #serviceplanprice").hide();
    }


    // now lets set the prices with adjustments
    $('.spHolder').each(function (index) {

        var thisId = $(this).val();
        var thisPrice = 0;
        if (thisId > 0) {
            thisPrice = $('input[name="spPrice_' + thisId + '"]').val();

            var displayPrice = "";
            var correctedSPPrice = parseFloat((parseFloat(thisPrice) - parseFloat(price))).toFixed(2);

            if (correctedSPPrice >= 0) {
                displayPrice = "(+$" + correctedSPPrice + ")";
            }
            else {
                displayPrice = "(-$" + Math.abs(correctedSPPrice).toFixed(2) + ")";

            }
            // lets record the price
            $('#servicePlanCalculatedPrice_' + thisId).html(displayPrice);

            if (price > 0) {
                $('#servicePlanCalculatedPrice_' + thisId).show();
                $('#servicePlanPrice_' + thisId).hide();

            }
            else {

                $('#servicePlanCalculatedPrice_' + thisId).hide();
                $('#servicePlanPrice_' + thisId).show();

            }

            if (thisId == serviceplan) {
                $('#servicePlanCalculatedPrice_' + thisId).hide();
                $('#servicePlanPrice_' + thisId).hide();
            }
        }

    });




    $('input[name="servicePlanValue"]').val(price);
    $('input[name="servicePlanId"]').val(serviceplan);


    setsummarytotal();

}

var newwindow;
function popBargainBinWindow(url) {
    newwindow = window.open(url, 'name', 'height=300,width=300,left=100,top=100,resizable=yes,scrollbars=yes');
    if (window.focus) {
        newwindow.focus();
    }
}

function printFancybox() {
    $("#fancybox-frame").get(0).contentWindow.print();
}




function SelectProduct(productid, price, ischecked, isservice) {

    isservice = (typeof isservice !== 'undefined') ? isservice : false;




    if (ischecked) {

        if (!isservice) {
            addonstotal += price;
            addonstotal = (Math.round(addonstotal * 100)) / 100;
            $("#interstitialSummary #addonsprice").html('<a href="#" onclick="SummaryToggle(\'summarypricing\'); return false;">+ Add Ons:</a> $' + addonstotal);
            $("#interstitialSummary #addonsprice").show();
            $("#summarypricing #product" + productid).first().show();
        }
        else {
            servicestotal += price;
            servicestotal = (Math.round(servicestotal * 100)) / 100;
            $("#interstitialSummary #serviceprice").html('<a href="#" onclick="SummaryToggle(\'serviceprice\'); return false;">+ Services:</a> $' + servicestotal);
            $("#interstitialSummary #serviceprice").show();
            $("#servicepricing #product" + productid).first().show();

        }


    }

    else {



        if (!isservice) {
            $("#summarypricing #product" + productid).first().hide();
            addonstotal = addonstotal - price;
            addonstotal = (Math.round(addonstotal * 100)) / 100;

            if (addonstotal > 0) {
                $("#interstitialSummary #addonsprice").html('<a href="#" onclick="SummaryToggle(\'summarypricing\'); return false;">+ Add Ons:</a> $' + addonstotal);
                $("#interstitialSummary #addonsprice").show();
            }
            else {
                $("#interstitialSummary #addonsprice").hide();
            }
        }
        else {
            $("#servicepricing #product" + productid).first().hide();
            servicestotal = servicestotal - price;
            servicestotal = (Math.round(servicestotal * 100)) / 100;

            if (servicestotal > 0) {
                $("#interstitialSummary #serviceprice").html('<a href="#" onclick="SummaryToggle(\'serviceprice\'); return false;">+ Services:</a> $' + servicestotal);
                $("#interstitialSummary #serviceprice").show();
            }
            else {
                $("#interstitialSummary #serviceprice").hide();
            }
        }
    }

    // addonstotal = addonstotal.toFixed(2);
    // servicestotal = (Math.round(servicestotal * 100)) / 100;

    setsummarytotal();
}



function SelectProductRadio(productid, price, ischecked, radioCount, isservice) {


    var isAsus = false;
    if ($('#interstitialSummary .price strong').length)         // use this if you are using id to check
    {
        thisprice = $("#interstitialSummary .price strong").html();
    }
    else {
        isAsus = true;
        thisprice = "$" + $("#summaryprice").data("buildprice");
    }

    isservice = (typeof isservice !== 'undefined') ? isservice : false;
    // first we need to reduce the total
    var currentValue = 0;
    var currentProductID = 0;
    if (parseFloat($("#radioGroup_" + radioCount + "_CP").val()) > 0) {
        currentValue = parseFloat($("#radioGroup_" + radioCount + "_CP").val());
    }

    if (parseFloat($("#radioGroup_" + radioCount + "_CPID").val()) > 0) {
        currentProductID = parseFloat($("#radioGroup_" + radioCount + "_CPID").val());
    }

    if (isAsus) {


        if ($("#checkID_" + productid).hasClass("isselectedItem")) {

            $("#checkID_" + productid).removeClass("isselectedItem");
            $("#checkID_" + productid).prop('checked', false);
            $("#radioGroup_" + radioCount + "_CP").val(0);
            $("#radioGroup_" + radioCount + "_CPID").val(0);


        }
        else {
            // need to turn off all of the others in this group.


            $("input[type='radio'][name='productIDs_R" + radioCount + "']").removeClass("isselectedItem");
            $("#checkID_" + productid).addClass("isselectedItem");
            $("#radioGroup_" + radioCount + "_CP").val(price);
            $("#radioGroup_" + radioCount + "_CPID").val(productid);
        }

    }


    if (!isservice) {
        // reduce the tot
        addonstotal = addonstotal - currentValue;
    }
    else {
        // reduce the total
        servicestotal = servicestotal - currentValue;
    }

    if (!isservice) {

        $("#summarypricing #product" + currentProductID).first().hide();

    }
    else {
        $("#servicepricing #product" + currentProductID).first().hide();

    }



    if (!isservice) {
        addonstotal = addonstotal + price;
        addonstotal = addonstotal.toFixed(2);


        $("#interstitialSummary #addonsprice").html('<a href="#" onclick="SummaryToggle(\'summarypricing\'); return false;">+ Add Ons:</a> $' + addonstotal);
        $("#interstitialSummary #addonsprice").show();


    }
    else {
        servicestotal = servicestotal + price;
        servicestotal = servicestotal.toFixed(2);


        $("#interstitialSummary #serviceprice").html('<a href="#" onclick="SummaryToggle(\'serviceprice\'); return false;">+ Services:</a> $' + servicestotal);
        $("#interstitialSummary #serviceprice").show();
    }

    if (!isservice) {
        $("#summarypricing #product" + productid).first().show();
    }
    else {
        $("#servicepricing #product" + productid).first().show();
    }


    $("#radioGroup_" + radioCount + "_CPID").val(productid);
    $("#radioGroup_" + radioCount + "_CP").val(price);



    // now lets set the prices with adjustments
    $('input[name="productIDs_R' + radioCount + '"]').each(function (index) {

        var thisId = $(this).val();
        var thisPrice = 0;
        if (thisId > 0) {
            thisPrice = $('input[name="productPrice_' + thisId + '"]').val();

            var displayPrice = "";
            var correctedPrice = (thisPrice - price).toFixed(2);

            if (correctedPrice >= 0) {
                displayPrice = "(+$" + correctedPrice + ")";
            }
            else {
                displayPrice = "(-$" + Math.abs(correctedPrice).toFixed(2) + ")";

            }
            // lets record the price
            $('#CalculatedPrice_' + thisId).html(displayPrice);

            if (price > 0) {
                $('#CalculatedPrice_' + thisId).show();
                $('#Price_' + thisId).hide();

            }
            else {


                $('#CalculatedPrice_' + thisId).hide();
                $('#Price_' + thisId).show();


            }

            if (thisId == productid) {
                $('#CalculatedPrice_' + thisId).hide();
                $('#Price_' + thisId).hide();
            }
        }

    });

    if (!isAsus) {
        if (price > 0) {
            // we need to turn on the calculated prices and removal checkbox
            $('#noItem_R' + radioCount).show();

        } else {
            $('#noItem_R' + radioCount).hide();
        }
    }
    setsummarytotal();
}


function SummaryToggle(myToggle) {

    if (myToggle == "summarypricing") {
        $('#summaryserviceplans').hide();
        $('#servicepricing').hide();
        if ($('#summarypricing').is(':visible')) {
            $('#summarypricing').hide();
        } else {
            $('#summarypricing').show();
        }

    }

    if (myToggle == "serviceprice") {
        $('#summaryserviceplans').hide();
        $('#summarypricing').hide();

        if ($('#servicepricing').is(':visible')) {
            $('#servicepricing').hide();
        } else {
            $('#servicepricing').show();
        }

    }


    if (myToggle == "summaryserviceplans") {
        $('#summarypricing').hide();
        $('#servicepricing').hide();

        if ($('#summaryserviceplans').is(':visible')) {
            $('#summaryserviceplans').hide();
        } else {
            $('#summaryserviceplans').show();
        }

    }

    $('.closeItem').show();



}

function SummaryClose() {


    $('#summaryserviceplans').hide();
    $('#summarypricing').hide();
    $('#servicepricing').hide();



}


function setsummarytotal() {




    try {

        var thisprice = "";
        var isAsus = false;
        if ($('#interstitialSummary .price strong').length)         // use this if you are using id to check
        {
            thisprice = $("#interstitialSummary .price strong").html();
        }
        else {
            isAsus = true;
            thisprice = "$" + $("#summaryprice").data("buildprice");
        }



        if (thisprice.indexOf('$') >= 0) {
            itemprice = parseFloat(thisprice.replace('$', '').replace(',', '')).toFixed(2);
        }

        var totalprice = 0;
        var totalItems = 0;
        servicestotal = 0;
        addonstotal = 0;
        $(".productIDsRadio").each(function () {
            if ($(this).is(':checked')) {
                if (isAsus) {
                    $(this).parent().parent().parent().addClass("isSelected");

                }
                totalItems += 1;
                if ($(this).data("service") == "yes") {
                    servicestotal = servicestotal + parseFloat($('input[name="productPrice_' + $(this).val() + '"]').first().val());

                }
                else {
                    addonstotal = addonstotal + parseFloat($('input[name="productPrice_' + $(this).val() + '"]').first().val());
                }

            }
            else {
                if (isAsus) {
                    $(this).parent().parent().parent().removeClass("isSelected");
                }
            }

        });



        $("input[name=productIDs]:checked").each(function () {
            if (isAsus) {
                $(this).parent().parent().parent().addClass("isSelected");

            }
            totalItems += 1;
            if ($(this).data("service") == "yes") {

                servicestotal = servicestotal + parseFloat($('#ProductPrice_' + $(this).val()).first().val().replace('$', '').replace(',', ''));
            }
            else {

                addonstotal = addonstotal + parseFloat($('#ProductPrice_' + $(this).val()).first().val().replace('$', '').replace(',', ''));

            }

        });

        if (isAsus) {
            $("input[name=productIDs]:not(:checked)").each(function () {
                $(this).parent().parent().parent().removeClass("isSelected");
            });
        }

        addonstotal = addonstotal.toFixed(2);
        servicestotal = servicestotal.toFixed(2);


        $("#totalSelected").html(totalItems);

        $("#interstitialSummary #addonsprice").html('<a href="#" onclick="SummaryToggle(\'summarypricing\'); return false;">+ Add Ons:</a> $' + addonstotal);
        if (addonstotal > 0) {
            $("#interstitialSummary #addonsprice").show();
        }
        else {
            $("#interstitialSummary #addonsprice").hide();
        }

        $("#interstitialSummary #serviceprice").html('<a href="#" onclick="SummaryToggle(\'serviceprice\'); return false;">+ Services:</a> $' + servicestotal);
        if (servicestotal > 0) {
            $("#interstitialSummary #serviceprice").show();
        }
        else {
            $("#interstitialSummary #serviceprice").hide();
        }

        totalprice = parseFloat(parseFloat(itemprice) + parseFloat(addonstotal) + parseFloat(servicestotal) + parseFloat(serviceplantotal)).toFixed(2);
        //alert(itemprice + "+" + addonstotal + "+" + serviceplantotal + " = " + totalprice);

        if (totalprice >= parseFloat(itemprice) && parseFloat(itemprice) > 0) {
            if (!isAsus) {
                $("#summaryprice").html('Total With Add Ons: $' + totalprice);
                $("#summaryprice").show();
            }
            else {
                $("#summaryprice").html('$' + totalprice);
                $("#summaryprice").show();
            }

        } else {
            if (!isAsus) {
                $("#summaryprice").hide();
            }
        }

        if (parseFloat(addonstotal) <= 0) {
            $("#addonsprice").hide();
        }

    }
    catch (e) {



    }
}
function Right(str, n) {
    if (n <= 0)
        return "";
    else if (n > String(str).length)
        return str;
    else {
        var iLen = String(str).length;
        return String(str).substring(iLen, iLen - n);
    }
}




function addSliderEvent(thisSlider) {


    var position;
    var STEP_SIZE_X;
    var $root;
    var PRODUCT_COUNTS;
    function toDecimal(x) {
        return (x).toFixed(2) * 1;
    }

    function getViewSizeByPercent() {

        //    alert(thisSlider.width() + " " + thisSlider.find('.mm14-products-viewed').width() * 100 + " " + STEP_SIZE_X);
        //    alert(toDecimal(thisSlider.width() / thisSlider.find('.mm14-products-viewed').width() * 100 / STEP_SIZE_X));
        return toDecimal(thisSlider.width() / thisSlider.find('.mm14-products-viewed').width() * 100 / STEP_SIZE_X);
    }



    function move(step) {
        var viewingProducts = getViewSizeByPercent();

        //var viewingProducts = 4;
        var x;
        position += viewingProducts * step;
        if (position >= PRODUCT_COUNTS) {
            position = PRODUCT_COUNTS;
        } else if (position < 0) {
            position = 0;
        }

        // Hide / Show - swipe elements
        thisSlider.parent().find('.mm14-carousel-next').show();
        thisSlider.parent().find('.mm14-carousel-prev').show();



        if (position + viewingProducts >= PRODUCT_COUNTS) {
            thisSlider.parent().find('.mm14-carousel-next').addClass('disable');
        } else {
            thisSlider.parent().find('.mm14-carousel-next').removeClass('disable');
        }

        if (position - viewingProducts < 0) {
            thisSlider.parent().find('.mm14-carousel-prev').addClass('disable');
        } else {
            thisSlider.parent().find('.mm14-carousel-prev').removeClass('disable');
        }
        if (viewingProducts >= PRODUCT_COUNTS) {
            thisSlider.parent().find('.mm14-carousel-prev').hide();
            thisSlider.parent().find('.mm14-carousel-next').hide();
        }

        if (step === 1) {
            if (position + viewingProducts > PRODUCT_COUNTS) {
                position = PRODUCT_COUNTS - viewingProducts;
            }
        } else if (step === -1) {
            if (position - viewingProducts < 0) {
                position = 0;
            }
        }


        x = toDecimal(STEP_SIZE_X * position);


        thisSlider.find('.mm14-products-viewed').css('transform', 'translateX(' + -x + '%)');
    }

    function init() {


        position = 0;

        var itemsPerPage = Math.floor(thisSlider.width() / thisSlider.find('.recent-item').first().width());


        STEP_SIZE_X = 100 / itemsPerPage;



        $root = thisSlider.find('.mm14-products-viewed');
        PRODUCT_COUNTS = thisSlider.find('.recent-item').length;

        //
        $root.css('transform', 'translateX(0%)');
        thisSlider.parent().find('.mm14-carousel-next').show();
        thisSlider.parent().find('.mm14-carousel-prev').show();
        move(0);
    }

    init();

    thisSlider.parent().find('.mm14-carousel-prev').click(function () {
        move(-1);
    });

    thisSlider.parent().find('.mm14-carousel-next').click(function () {
        move(1);
    });

    $(window).resize(function () {
        init();
    });
}


function categoryRender() {
    if ($('.recentlyViewed').length === 0) {
        $('.DesktopFramework #ads')
            .prepend(getTemplate('category', {
                products: campaign.scope.productsViewed,
            }));
    }
}

setTimeout(function () {
    if ($("#home").length != 0) {
        $('#pnlMainAds h2#tcb002').prependTo('#hotdeals');

        //$('.recentlyViewed .recent-item .recent-item-link').each(function () {
        //    var linkTextHome = $(this).html();
        //    var linkLengthHome = $(this).html().length;

        //    if (linkLengthHome > 40) {
        //        $(this).html(linkTextHome.substring(0, 40) + '...');
        //    }
        //});




        $('.mm14-products-viewed-wrapper').each(function () {


            addSliderEvent($(this));
        });
    }
    else if ($("#product").length != 0) {
        $('.recently-viewed-title').html('You recently viewed');


        //$('.recent-item .recent-item-link').each(function () {
        //    var linkText = $(this).html();
        //    var linkLength = $(this).html().length;
        //    if (linkLength > 32) {
        //        $(this).html(linkText.substring(0, 32) + '...');
        //    }
        //});

        //  $('.DesktopFramework #recentlyViewed').appendTo('#product-details-control .summary');
    }

}, 1000);


function setGridView() {
    // list and grid view

    $(".grView").click(function () {
        $(".grView").addClass("on");
        $(".lsView").removeClass("on");
        $("#productGrid").removeClass("col1");
        $("#productGrid").addClass("col3");



        eraseCookie('viewtype');
        createCookie('viewtype', 'grid', 1);


        // need to write the cookie

    });


    $(".lsView").click(function () {
        $(".lsView").addClass("on");
        $(".grView").removeClass("on");
        $("#productGrid").removeClass("col3");
        $("#productGrid").addClass("col1");

        eraseCookie('viewtype');
        createCookie('viewtype', 'list', 1);




        // need to write the cookie

    });

    try {






        var viewtype = readCookie('viewtype');



        if (viewtype == null) {

            var im = readCookie('isMobile');

            if ((im != null && im == "true") || ($("body").hasClass("MobileFramework"))) {
                viewtype = "list";
                createCookie('viewtype', 'list', 1);
            }
            else {
                viewtype = "grid";
                createCookie('viewtype', 'grid', 1);
            }

        }




        if (viewtype == 'list') {

            $("#productGrid").removeClass("col3");
            $("#productGrid").addClass("col1");
            $(".lsView").addClass("on");
            $(".grView").removeClass("on");

        } else {
            $("#productGrid").removeClass("col1");
            $("#productGrid").addClass("col3");
            $(".lsView").removeClass("on");
            $(".grView").addClass("on");
        }

        $("#productGrid.eset").removeClass("col1");
        $("#productGrid.eset").addClass("col3");


    } catch (e) {



    }
}

function productClick(productObj, evt) {

    // console.log(productObj);

    if ($(productObj).data('id') != null && !productclicked) {
        productclicked = true;

        var thislist = "Search Results";
        if ($(productObj).data('list') != null) {
            thislist = $(productObj).data('list');
        }

        if (usingGA4) {
            if (typeof (gtag) != 'undefined') {

                gtag("event", "view_item", {
                    currency: "USD",
                    value: $(productObj).data('price'),
                    items: [
                        {
                            item_id: $(productObj).data('id'),
                            item_name: $(productObj).data('name'),


                            index: $(productObj).data('position'),
                            item_brand: $(productObj).data('brand'),
                            item_category: $(productObj).data('category'),

                            item_list_id: thislist,
                            item_list_name: thislist,

                            price: $(productObj).data('price'),
                            currency: "USD",
                            quantity: 1
                        }
                    ]

                });
            }
            try {




                if ($(productObj).attr('href') != null) {
                    document.location = $(productObj).attr('href');
                } else if ($(productObj).data('href') != null) {
                    document.location = $(productObj).data('href');
                }

            } catch (e) { }
        }
        if (usingGA3) {
            if (typeof (ga) != 'undefined') {
                ga('mc.ec:addProduct', {                              // Provide product details in a productFieldObject.
                    'id': $(productObj).data('id'),                   // Product ID (string).
                    'name': $(productObj).data('name'),               // Product name (string).
                    'category': $(productObj).data('category'),       // Product category (string).
                    'brand': $(productObj).data('brand'),             // Product brand (string).
                    'price': $(productObj).data('price'),
                    'position': $(productObj).data('position'),
                    'list': thislist

                });

                ga('mc.ec:setAction', 'click', { 'list': thislist });

                ga('mc.send', 'event', 'eCommerce', 'click', thislist, {
                    'hitCallback': function () {
                        try {




                            if ($(productObj).attr('href') != null) {
                                document.location = $(productObj).attr('href');
                            } else if ($(productObj).data('href') != null) {
                                document.location = $(productObj).data('href');
                            }

                        } catch (e) { }
                    }
                });
            }
        }


        //        dataLayer.push({
        //            'event': 'productClick',
        //            'ecommerce': {
        //                'click': {
        //                    'actionField': { 'list': 'Search Results' },      // Optional list property.
        //                    'products': [{
        //                        'name': $(productObj).data('name'),                      // Name or ID is required.
        //                        'id': $(productObj).data('id'),
        //                        'price': $(productObj).data('price'),
        //                        'brand': $(productObj).data('brand'),
        //                        'category': $(productObj).data('category')
        //                    }]
        //                }
        //            },
        //            'eventCallback': function () {
        //                if ($(productObj).attr('href') != null) {
        //                    document.location = $(productObj).attr('href');
        //                } else if ($(productObj).data('href') != null) {
        //                    document.location = $(productObj).data('href');
        //                }
        //            }
        //        });
    }
    


}

function listView(list_id) {


    var eventlist = [];

    //$('.productViewItem').each(function () {
    //    eventlist.push([$(this).data('list'), $(this).data('id'), $(this).data('name'), $(this).data('position'), $(this).data('brand'), $(this).data('category'), $(this).data('price')]);
    //});

    //console.log(eventlist);
    // lets do the product list 

    if (usingGA4) {
        if (typeof (gtag) != 'undefined' && $('.productViewItem').length) {

            var list = "[";
            var pv = $('.productViewItem');
            var cnt = 0;
            var listname = list_id;
            var ispersonalized = "";


            $('.productViewItem').each(function () {

                if ($(this).data('list') == list_id)
                {





                    if (cnt > 0) { list += ',' }

                    if (typeof $(this).data('name') !== 'undefined' && typeof $(this).data('brand') !== 'undefined' && typeof $(this).data('category') !== 'undefined') {
                        list += "{";

                        list += 'item_id: "' + $(this).data('id') + '",';
                        list += 'item_name: "' + $(this).data('name').replace('"', '\\\"') + '",';

                        list += 'index: ' + $(this).data('position') + ',';
                        list += ' item_brand: "' + $(this).data('brand').replace('"', '\\\"') + '",';
                        list += 'item_category: "' + $(this).data('category').replace('"', '\\\"') + '",';

                        list += 'item_list_id: "' + $(this).data('list') + '",';
                        list += 'item_list_name: "' + $(this).data('list') + '",';

                        list += 'price:' + $(this).data('price') + ',';
                        list += 'currency: "USD",';
                        list += ' quantity: 1';





                        list += '}';


                        cnt += 1;
                    }
                }
            });
              
            list += ']';

            if (list != '[]') {
                gtag("event", "view_item_list", {
                    'item_list_id': listname.replace('"', '\\\"'),
                    'item_list_name': listname.replace('"', '\\\"'),
                    items: eval(list)

                });
            }





        }
    }

    if (usingGA3) {


        if (typeof ga != "undefined") {

            var listName = "";
            $('.productViewItem').each(function () {

                if (listName != $(this).data('list') && listName != "") {

                    ga('mc.ec:setAction', 'detail');
                    ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
                }

                ga('mc.ec:addImpression', {                     // Provide product details in a productFieldObject.
                    'id': $(this).data('id'),                   // Product ID (string).
                    'name': $(this).data('name'),               // Product name (string).
                    'category': $(this).data('category'),       // Product category (string).
                    'brand': $(this).data('brand'),             // Product brand (string).
                    'price': $(this).data('price'),
                    'position': $(this).data('position'),
                    'list': $(this).data('list')

                });

                listName = $(this).data('list');



            });
            if (listName != "") {

                ga('mc.ec:setAction', 'detail');
                ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
            }

        }
    }

    //lets do the promo list


    if (usingGA4) {

        if (typeof (gtag) != 'undefined' && $('.promoViewItem').length) {

            var list = "[";
            var pv = $('.promoViewItem');
            var cnt = 0;
            var listname = "";


            $('.promoViewItem').each(function () {

                if (listname != $(this).data('list') && listname != "") {

                  //  console.log(list);

                    // we need to push the list
                    list += ']';
                    gtag("event", "view_promotion", {
                        'promotion_name': listname.replace('"', '\\\"'),
                        'promotion_id': listname.replace('"', '\\\"'),
                        items: eval(list)

                    });
                    cnt = 0;
                    list = '[';
                }
                listname = $(this).data('list');

                if (cnt > 0) { list += ',' }

                if ($(this).data('name') && $(this).data('brand') && $(this).data('category')) {
                    list += "{";

                    list += 'item_id: "' + $(this).data('id') + '",';
                    list += 'item_name: "' + $(this).data('name').replace('"', '\\\"') + '",';

                    list += 'index: ' + $(this).data('position') + ',';
                    list += ' item_brand: "' + $(this).data('brand').replace('"', '\\\"') + '",';
                    list += 'item_category: "' + $(this).data('category').replace('"', '\\\"') + '",';



                    list += 'price:' + $(this).data('price') + ',';
                    list += 'currency: "USD",';
                    list += ' quantity: 1';





                    list += '}';

                    cnt += 1;
                }

            });

            list += ']';

            if (list != '[]') {
                gtag("event", "view_promotion", {
                    'promotion_name': listname.replace('"', '\\\"'),
                    'promotion_id': listname.replace('"', '\\\"'),
                    items: eval(list)

                });
            }





        }
    }

    if (usingGA3) {


        if (typeof ga != "undefined") {

            var listName = "";
            $('.promoViewItem').each(function () {

                if (listName != $(this).data('list') && listName != "") {

                    ga('mc.ec:setAction', 'detail');
                    ga('mc.send', 'event', 'PromoView', listName, { nonInteraction: true });
                }

                if ($(this).data('name') && $(this).data('brand') && $(this).data('category')) {
                    ga('mc.ec:addImpression', {                     // Provide product details in a productFieldObject.
                        'id': $(this).data('id'),                   // Product ID (string).
                        'name': $(this).data('name'),               // Product name (string).
                        'category': $(this).data('category'),       // Product category (string).
                        'brand': $(this).data('brand'),             // Product brand (string).
                        'price': $(this).data('price'),
                        'position': $(this).data('position'),
                        'list': $(this).data('list')

                    });
                }
                listName = $(this).data('list');



            });
            if (listName != "") {

                ga('mc.ec:setAction', 'detail');
                ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
            }

        }
    }

}
// this function will send all product lists on page that are in view.
function sendGA4ViewList() {


    if (usingGA4) {
        if (typeof (gtag) != 'undefined' && $('.productViewItem').length) {

            var list = "[";
            var pv = $('.productViewItem');
            var cnt = 0;
            var listname = "";
            var ispersonalized = "";

            var visiblelists = [];

            $('.productViewItem').each(function () {
                
                if (isInViewport(this) && visiblelists.indexOf($(this).data('list')) < 0 && processedlists.indexOf($(this).data('list')) < 0)
                {
                    visiblelists.push($(this).data('list'));
                }
            });



            $('.productViewItem').each(function () {

                if (visiblelists.indexOf($(this).data('list')) >= 0)
                {
                    processedlists.push($(this).data('list'));

                    if (listname != $(this).data('list') && listname != "") {

                        $(this).data('processed', 'true');
                        //  console.log(list);
                        // we need to push the list
                        list += ']';


                        gtag("event", "view_item_list", {
                            'item_list_id': listname,
                            'item_list_name': listname,
                            'is_personalized': $(this).data('personalized'),
                            items: eval(list)

                        });
                        cnt = 0;
                        list = '[';
                    }
                    listname = $(this).data('list');

                    if (cnt > 0) { list += ',' }

                    if (typeof $(this).data('name') !== 'undefined' && typeof $(this).data('brand') !== 'undefined' && typeof $(this).data('category') !== 'undefined') {
                        list += "{";

                        list += 'item_id: "' + $(this).data('id') + '",';
                        list += 'item_name: "' + $(this).data('name').replace('"', '\\\"') + '",';

                        list += 'index: ' + $(this).data('position') + ',';
                        list += ' item_brand: "' + $(this).data('brand').replace('"', '\\\"') + '",';
                        list += 'item_category: "' + $(this).data('category').replace('"', '\\\"') + '",';

                        list += 'item_list_id: "' + $(this).data('list') + '",';
                        list += 'item_list_name: "' + $(this).data('list') + '",';

                        list += 'price:' + $(this).data('price') + ',';
                        list += 'currency: "USD",';
                        list += ' quantity: 1';





                        list += '}';


                        cnt += 1;
                    }
                }
            });

            list += ']';

            if (list != '[]') {
                gtag("event", "view_item_list", {
                    'item_list_id': listname.replace('"', '\\\"'),
                    'item_list_name': listname.replace('"', '\\\"'),
                    items: eval(list)

                });
            }





        }
    }
}


// this function will send all promo lists on page that are in view
function sendGA4PromoViewList() {

    if (usingGA4) {

        if (typeof (gtag) != 'undefined' && $('.promoViewItem').length) {

            var list = "[";
            var pv = $('.promoViewItem');
            var cnt = 0;
            var listname = "";

            var visiblepromos = [];
            $('.promoViewItem').each(function () {

                if (isInViewport(this) && visiblepromos.indexOf($(this).data('list')) < 0 && processedPromolists.indexOf($(this).data('list')) < 0) {
          
                    visiblepromos.push($(this).data('list'));
                }
            });

            $('.promoViewItem').each(function () {
                if (visiblepromos.indexOf($(this).data('list')) >= 0) {
                    processedPromolists.push($(this).data('list'));
                if (listname != $(this).data('list') && listname != "") {

                    //  console.log(list);

                    // we need to push the list
                    list += ']';
                    gtag("event", "view_promotion", {
                        'promotion_name': listname.replace('"', '\\\"'),
                        'promotion_id': listname.replace('"', '\\\"'),
                        items: eval(list)

                    });
                    cnt = 0;
                    list = '[';
                }
                listname = $(this).data('list');

                if (cnt > 0) { list += ',' }

                    if ($(this).data('name') && $(this).data('brand') && $(this).data('category')) {
                        list += "{";

                        if ($(this).data('id')) {
                            list += 'item_id: "' + $(this).data('id') + '",';
                        }
                        if ($(this).data('name')) {
                            list += 'item_name: "' + $(this).data('name').replace('"', '\\\"') + '",';
                        }
                        if ($(this).data('position')) {
                            list += 'index: ' + $(this).data('position') + ',';
                        }
                        if ($(this).data('brand')) {
                            list += ' item_brand: "' + $(this).data('brand').replace('"', '\\\"') + '",';
                        }
                        if ($(this).data('category')) {
                            list += 'item_category: "' + $(this).data('category').replace('"', '\\\"') + '",';
                        }



                        if ($(this).data('price')) {
                            list += 'price:' + ('' + $(this).data('price')).replace('$', '') + ',';
                            list += 'currency: "USD",';
                        }
                        list += ' quantity: 1';





                        list += '}';

                        cnt += 1;
                    }
                }

            });

            list += ']';


            try {
                if (list != '[]') {
                    gtag("event", "view_promotion", {
                        'promotion_name': listname.replace('"', '\\\"'),
                        'promotion_id': listname.replace('"', '\\\"'),
                        items: eval(list)

                    });
                }
            }
            catch (ex) { }




        }
    }
}

function productView() {

   
    var eventlist = [];

    //$('.productViewItem').each(function () {
    //    eventlist.push([$(this).data('list'), $(this).data('id'), $(this).data('name'), $(this).data('position'), $(this).data('brand'), $(this).data('category'), $(this).data('price')]);
    //});

    //console.log(eventlist);
    // lets do the product list 


    sendGA4ViewList();


    sendGA4PromoViewList();


    $(window).on("resize scroll", function (e) {
        sendGA4ViewList();
        sendGA4PromoViewList();
    });
    

    if (usingGA3) {


        if (typeof ga != "undefined") {

            var listName = "";
            $('.productViewItem').each(function () {

                if (listName != $(this).data('list') && listName != "") {

                    ga('mc.ec:setAction', 'detail');
                    ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
                }

                ga('mc.ec:addImpression', {                     // Provide product details in a productFieldObject.
                    'id': $(this).data('id'),                   // Product ID (string).
                    'name': $(this).data('name'),               // Product name (string).
                    'category': $(this).data('category'),       // Product category (string).
                    'brand': $(this).data('brand'),             // Product brand (string).
                    'price': $(this).data('price'),
                    'position': $(this).data('position'),
                    'list': $(this).data('list')

                });

                listName = $(this).data('list');



            });
            if (listName != "") {

                ga('mc.ec:setAction', 'detail');
                ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
            }

        }
    }

    //lets do the promo list

   

    if (usingGA3 ) {


        if (typeof ga != "undefined" ) {

            var listName = "";
            $('.promoViewItem').each(function () {

                if (listName != $(this).data('list') && listName != "") {
                    
                    ga('mc.ec:setAction', 'detail');
                    ga('mc.send', 'event', 'PromoView', listName, { nonInteraction: true });
                }

                if ($(this).data('name') && $(this).data('brand') && $(this).data('category')) {
                    ga('mc.ec:addImpression', {                     // Provide product details in a productFieldObject.
                        'id': $(this).data('id'),                   // Product ID (string).
                        'name': $(this).data('name'),               // Product name (string).
                        'category': $(this).data('category'),       // Product category (string).
                        'brand': $(this).data('brand'),             // Product brand (string).
                        'price': $(this).data('price'),
                        'position': $(this).data('position'),
                        'list': $(this).data('list')

                    });
                }
                listName = $(this).data('list');



            });
            if (listName != "") {

                ga('mc.ec:setAction', 'detail');
                ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
            }

        }
    }

}

function addOnClick(productObj, evt) {



    if ($(productObj).data('id') != null && !productclicked) {
        productclicked = true;


        if (usingGA4) {
            if (typeof (gtag) != 'undefined') {
                gtag('event', 'select_item', {
                    'item_list_id': $(productObj).data('list'),
                    'item_list_name': $(productObj).data('list'),
                    items: eval([
                        {
                            item_id: $(productObj).data('id'),
                            item_name: $(productObj).data('name'),

                            index: $(productObj).data('position'),
                            item_brand: $(productObj).data('brand'),
                            item_category: $(productObj).data('category'),

                            item_list_id: $(productObj).data('list'),
                            item_list_name: $(productObj).data('list'),

                            price: $(productObj).data('price'),
                            currency: "USD",
                            quantity: 1
                        }
                    ])
                });
            }
        }
        if (usingGA3) {


            dataLayer.push({
                'event': 'productClick',
                'ecommerce': {
                    'click': {
                        'actionField': { 'list': $(productObj).data('list') },      // Optional list property.
                        'products': [{
                            'name': $(productObj).data('name'),                      // Name or ID is required.
                            'id': $(productObj).data('id'),
                            'price': $(productObj).data('price'),
                            'brand': $(productObj).data('brand'),
                            'category': $(productObj).data('category'),
                            'position': $(productObj).data('position')
                        }]
                    }
                },
                'eventCallback': function () {

                    if (!evt.ctrlKey) {
                        if ($(productObj).attr('href') != null) {
                            document.location = $(productObj).attr('href');
                        } else if ($(productObj).data('href') != null) {
                            document.location = $(productObj).data('href');
                        }
                    }
                }
            });
        }
    }



}

function promoClick(promoObj, evt) {

    if (usingGA4) {
        if (typeof (gtag) != 'undefined') {

            gtag("event", "select_promotion", {
                creative_name: $(promoObj).data('creative'),
                creative_slot: $(promoObj).data('position'),
                promotion_id: $(promoObj).data('id'),
                promotion_name: $(promoObj).data('name')

            });
        }
    }
    if (usingGA3) {


        ga('mc.ec:addPromo', [{
            'id': $(promoObj).data('id'),
            'name': $(promoObj).data('name'),
            'creative': $(promoObj).data('creative'),
            'position': $(promoObj).data('position')
        }]);

        ga('mc.ec:setAction', 'promo_click');

        ga('mc.send', 'event', 'Internal Promotions', 'click', $(promoObj).data('name'), {
            'hitCallback': function () {

                if (!evt.ctrlKey) {
                    document.location = $(promoObj).attr('href');
                }
            }
        });
    }
    //    dataLayer.push({
    //        'event': 'promotionClick',
    //        'ecommerce': {
    //            'promoClick': {
    //                'promotions': [{
    //                    'id': $(promoObj).data('id'),
    //                    'name': $(promoObj).data('name'),
    //                    'creative': $(promoObj).data('creative'),
    //                    'position': $(promoObj).data('position')
    //                }]
    //            }
    //        },
    //        'eventCallback': function () {
    //            document.location = $(promoObj).attr('href');
    //        }
    //    });



}

function addA1Event(productId, productIds, analyticslist, isQuick, serviceplan, carttype) {

    if (carttype == null) {
        carttype = "instore";
    }
    var ct = "cartUpdated";

    if (carttype == "list") {
        ct = "listUpdated";
    }

    if (carttype == "favorite") {
        ct = "favoriteUpdated";
    }


    var dfd = $.Deferred();
    setTimeout(function () {
        if (typeof $A1 != 'undefined') {


            if (typeof isQuick == 'undefined' || isQuick.toLowerCase().indexOf("pickup") <= 0) {



                $.ajax({
                    type: "Get",
                    url: "/store/getcartproducts.aspx?carttype=" + carttype,
                    async: false,
                    success: function (msg) {
                        existingCartIDs = msg;
                        var productList = [];
                        var listcount = 0;
                        if (productId != null && analyticslist.indexOf("Interstitial Add Ons") < 0) {
                            // add the main id to the list
                            productList[listcount] = $A1.Target({ SourceProductNumber: String(productId) });
                            listcount += 1;
                            //  alert(analyticslist + " sending main productID");
                        }


                        if (serviceplan != null) {

                            var planID = serviceplan.split(':');

                            if (planID.length == 2) {
                                productList[listcount] = $A1.Target({ SourceProductNumber: String(planID[1]) });
                                listcount += 1;
                            }
                        }


                        if (productIds != null) {
                            // add the product Ids
                            var splitIds = productIds.split(",");
                            splitIds.forEach(function (pid) {
                                if (pid != "" && pid != productId) {
                                    productList[listcount] = $A1.Target({ SourceProductNumber: String(pid) });
                                    listcount += 1;
                                }

                            });
                        }


                        if (existingCartIDs != null) {
                            // add the product Ids

                            existingCartIDs.forEach(function (pid) {
                                productList[listcount] = $A1.Target({ SourceProductNumber: String(pid) });
                                listcount += 1;
                            });
                        }



                        //console.log(productList[1]);
                        productList[listcount] = $A1.Target({
                            subType: "",
                            c_clientId: a1clientId
                        });

                        console.log("Pushing: " + productId + " and selected items " + productIds + " and existing cart items " + existingCartIDs + " for " + ct);

                        ga(function () {
                            myEvent = $A1.Event({
                                type: ct,
                                customer: currentVisitor,
                                targets: productList
                            }).send();
                        });


                        dfd.resolve();

                    }
                });
                // now lets work on our a1 push
            } else {
                dfd.resolve();
            }
        }
    });
    return dfd.promise();
}

function addToCartClick(productId, productIds, analyticslist, isQuick, totalValue, carttype) {

    setTimeout(function () {
        if (carttype == null) {
            carttype = "instore";
        }
        var ct = "add to cart";
        var ga4Action = "add_to_cart";

        var islist = false;


        if (carttype == "list") {
            ct = "add to list";
            islist = true;
            //  ga4Action = "add_to_wishlist";
        }


        if (totalValue === undefined) {
            totalValue = 0;
        }
        doPush = false;

        //alert("Asdfasdf" + analyticslist);

        var listAction = analyticslist;

        if (listAction == "") {
            listAction = "Add To Cart Click";
        }

        if (isQuick.toLowerCase().indexOf("pickup") > 0) {
            //   listAction = "Quick Pickup Click";
        }



        var itemDetail = $('.ProductLink_' + productId);

        if (!(itemDetail != null && itemDetail.data('id') != null)) {

            itemDetail = $(".productViewItem[data-id='" + productId + "']").first();


        }
        if (usingGA4) {
            itemDetail = $('[data-id=' + productId + ']').first();
        }






        if (productId != null) {

            if (itemDetail != null && itemDetail.data('id') != null && (typeof (ga) != 'undefined' || usingGA4 || usingGA3)) {
                doPush = true;

                if (usingGA4) {

                    if (itemDetail.data('list') != null) {
                        listAction = itemDetail.data('list');
                    }
                    var indx = 0;
                    if (itemDetail.data('position') != null) {
                        indx = itemDetail.data('position');
                    }

                    var list = "";
                    list += "{";

                    list += 'item_id: "' + itemDetail.data('id') + '",';
                    list += 'item_name: "' + itemDetail.data('name').replace('"', '\\\"') + '",';

                    list += 'index: ' + itemDetail.data('position') + ',';
                    list += ' item_brand: "' + itemDetail.data('brand').replace('"', '\\\"') + '",';
                    list += 'item_category: "' + itemDetail.data('category').replace('"', '\\\"') + '",';

                    list += 'item_list_id: "' + itemDetail.data('list') + '",';
                    list += 'item_list_name: "' + itemDetail.data('list') + '",';
                    if (islist) {
                        list += 'is_list: "' + islist + '",';
                    }
                    list += 'price:' + itemDetail.data('price') + ',';
                    list += ' quantity: 1';
                    list += '}';


                    if (productIds != null && productIds != "") {
                        SplitIds = productIds.split(',');

                        for (cnt = 0; cnt < SplitIds.length; ++cnt) {


                            var classkey = SplitIds[cnt];
                            if (classkey.indexOf(":") > 0) {
                                classkey = classkey.split(':')[1];

                            }

                            itemDetail = $('[data-id=' + classkey + ']').first();

                            if (itemDetail != null && itemDetail.data('id') != null) {

                                list += ",{";

                                list += 'item_id: "' + itemDetail.data('id') + '",';
                                list += 'item_name: "' + itemDetail.data('name').replace('"', '\\\"') + '",';

                                list += 'index: ' + itemDetail.data('position') + ',';
                                list += ' item_brand: "' + itemDetail.data('brand').replace('"', '\\\"') + '",';
                                list += 'item_category: "' + itemDetail.data('category').replace('"', '\\\"') + '",';

                                list += 'item_list_id: "' + itemDetail.data('list') + '",';
                                list += 'item_list_name: "' + itemDetail.data('list') + '",';
                                if (islist) {
                                    list += 'is_list: "' + islist + '",';
                                }
                                list += 'price:' + itemDetail.data('price') + ',';
                                list += 'currency: "USD",';
                                list += ' quantity: 1';
                                list += '}';



                            }
                        }
                    }





                    gtag("event", ga4Action, {
                        currency: "USD",
                        value: itemDetail.data('price'),
                        items: eval('[' + list + ']')

                    });
                }


                if (usingGA3) {


                    if ($('.ProductLink_' + productId)) {
                        ga('mc.ec:addProduct', {
                            'id': itemDetail.data('id'),
                            'name': itemDetail.data('name'),
                            'category': itemDetail.data('category'),
                            'brand': itemDetail.data('brand'),
                            'price': itemDetail.data('price'),
                            'list': itemDetail.data('list'),
                            'quantity': 1
                        });
                    }
                    else if ($(".ProductViewItem").filter("[data-id='" + productId + "']")) {
                        ga('mc.ec:addProduct', {
                            'id': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('id'),
                            'name': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('name'),
                            'category': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('category'),
                            'brand': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('brand'),
                            'price': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('price'),
                            'quantity': 1,
                            'list': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('list')
                        });

                    }


                    if (analyticslist != "") {

                        // we need to get the first element only.
                        // lets check to see if this is a single product page click

                        var primarylist = analyticslist.split(">")[0];
                        listAction = primarylist.split(",")[0];



                        if (listAction == "Product Page" || listAction == "Frequently Bought Together" || listAction == "Add Ons") {
                            ga('mc.ec:setAction', 'add');
                            listAction = "Product Page";
                        }
                        else {
                            var thisList = analyticslist.split(",", 1)[0]
                            if (isQuick.toLowerCase().indexOf("pickup") > 0) {
                                thisList = "quick pickup form";
                                listAction = "quick pickup form";
                            }


                            ga('mc.ec:setAction', 'add', { list: thisList });
                        }
                    }
                    else {
                        // ga('mc.ec:setAction', 'add');
                    }
                    // alert(listAction);
                    ga('mc.send', 'event', 'eCommerce', listAction, ct);
                }
            }


        }

        var productcount = 1;

        primarylist = analyticslist.split(">")[0];
        listAction = primarylist.split(",")[0];
        if (listAction == "") {
            listAction = "Add To Cart Click";
        }




        if (listAction == "Product Page") { listAction = "Add Ons"; }

        if (productIds != null && productIds != "") {
            SplitIds = productIds.split(',');
            productcount = productcount + SplitIds.length;

            if (usingGA3) {
                if (analyticslist.split(",", 1)[0] == "Interstitial Add Ons") {
                    ga('mc.ec:setAction', 'add', { list: 'Interstitial Add Ons' });
                }
                else {
                    ga('mc.ec:setAction', 'add', { list: listAction });
                }
            }

            var thislist = listAction;
            if (listAction.indexOf("Configurator") >= 0) {
                thislist = listAction;
            }

            for (cnt = 0; cnt < SplitIds.length; ++cnt) {


                var classkey = SplitIds[cnt];
                if (classkey.indexOf(":") > 0) {
                    classkey = classkey.split(':')[1];

                }
                var itemDetail = $('.ProductLink_' + classkey);
                if (usingGA4) {
                    itemDetail = $('[data-id=' + classkey + ']').first();
                }


                if (itemDetail != null && itemDetail.data('id') != null && (typeof (ga) != 'undefined' || usingGA4)) {
                    doPush = true;
                    if (usingGA4 && false) {
                        gtag("event", ga4Action, {
                            currency: "USD",
                            value: $('.ProductLink_' + classkey).data('price'),
                            items: [
                                {
                                    item_id: itemDetail.data('id'),
                                    item_name: itemDetail.data('name').replace("\\\"", " "),
                                    item_list_id: thislist,
                                    item_list_name: thislist,

                                    index: 0,
                                    item_brand: itemDetail.data('brand').replace("\\\"", " "),
                                    item_category: itemDetail.data('category').replace("\\\"", " "),

                                    price: itemDetail.data('price'),
                                    currency: "USD",
                                    quantity: 1
                                }
                            ]
                        });
                    }
                    if (usingGA3) {

                        ga('mc.ec:addProduct', {
                            'id': $('.ProductLink_' + classkey).data('id'),
                            'name': $('.ProductLink_' + classkey).data('name'),
                            'category': $('.ProductLink_' + classkey).data('category'),
                            'brand': $('.ProductLink_' + classkey).data('brand'),
                            'price': $('.ProductLink_' + classkey).data('price'),
                            'position': $('.ProductLink_' + classkey).data('position'),
                            'quantity': 1,
                            'list': thislist
                        });




                    }
                }
            }

            if (doPush && typeof (ga) != 'undefined' && usingGA3) {
                if (productcount > 1) {
                    if (analyticslist.split(",", 1)[0] == "Interstitial Add Ons") {
                        ga('mc.ec:setAction', 'add', { list: 'Interstitial Add Ons' });
                    }
                    else {
                        ga('mc.ec:setAction', 'add', { list: listAction });
                    }

                    var thislist = listAction;
                    if (listAction.indexOf("Configurator") >= 0) {
                        thislist = listAction;
                    }

                    // need to add total NEED TO GET TOTAL in from configurator.
                    if (totalValue > 0) {
                        ga('mc.send', 'event', 'eCommerce', thislist, ct, totalValue);
                    }
                    else {
                        ga('mc.send', 'event', 'eCommerce', thislist, ct);
                    }

                }

            }
        }
    });
}


var Header = {

    setCartQty: function (quantity) {

        $(".header2022 .cartQTY").html(quantity);

    }
}



function setHTMLDropdowns() {


    // lets do the any hrev drop down from ul li list.
    $(".selectorHref").unbind("click");

    $(".selectorHref").click(function () {

        var thisDropdownMenu = $(this).parent().parent().find(".dropdown-menu");

        //$(".dropdown-menu").hide();
        //$(".dropdown-menu").data("closeSelector", false);

        if (!keyisdown) {


            if ($(thisDropdownMenu).css('display') == 'block' || $(thisDropdownMenu).css('display') == 'flex') {
                thisDropdownMenu.hide();
                thisDropdownMenu.data("closeSelector", false);
            }
            else {
                $(".boosted .dropdown-menu").hide();
                thisDropdownMenu.show();
                thisDropdownMenu.data("closeSelector", true);
                thisDropdownMenu.focus();
            }
        }
    });

    $(".boosted .selectorHref").keydown(function (e) {
        $(this).data("keyisdown", true);

    });


    $(document).bind("mouseup touchend", function (e) {

        needhide = false;

        $(".dropdown-menu").each(function () {
            if ($(this).data("closeSelector")) {
                needhide = true;
            }
        });



        if (needhide && !hasTouch && document.activeElement.className.indexOf('hasTouch') < 0 && document.activeElement.className.indexOf('modal') < 0 && document.activeElement.className.indexOf('ui-page') < 0 && document.activeElement.className.indexOf('dropdown-menu') < 0 && document.activeElement.className.indexOf('dropdown-item') < 0 && document.activeElement.className.indexOf('dropdown-itemLI') < 0 && document.activeElement.className.indexOf('selectorHref') < 0 && document.activeElement.className.indexOf('dropdown') < 0 && document.activeElement.className.indexOf('sortByText') < 0) {

            $(".boosted .dropdown-menu").hide();
            $(".dropdown-menu").data("closeSelector", false);


        }


    });

    //$(".boosted").mouseleave(function (e) {
    //    $(".dropdown-menu").hide();
    //    $(".dropdown-menu").data("closeSelector", false);

    //});


    $(".boosted .selectorHref").keyup(function (e) {

        $(this).data("keyisdown", false);

        e.preventDefault;
        var thisDropdownMenu = $(this).parent().parent().find(".dropdown-menu");

        $(".boosted .dropdown-menu").hide();
        $(".boosted .dropdown-menu").data("closeSelector", false);

        if (e.which === 13 || e.which === 40) {


            if (thisDropdownMenu.is(":visible") && e.which != 13) {
                thisDropdownMenu.hide();
                thisDropdownMenu.data("closeSelector", false);

            }
            else {
                thisDropdownMenu.show();
                thisDropdownMenu.data("closeSelector", true);
                thisDropdownMenu.find("a").first().focus();

            }
        }


    });


    $(".boosted .dropdown-menu li a").keyup(function (e) {
        e.preventDefault();
        var focusElement = $(document.activeElement);


        var currentLI = focusElement.parent();

        var thisDropdownMenu = currentLI.parent();
        if (e.which === 27) {
            $(".boosted .dropdown-menu").hide();
            $(".boosted .dropdown-menu").data("closeSelector", false);
            thisDropdownMenu.parent().find(".dropdown .selectorHref").focus();
        }

        if (e.which != 13 && e.which != 27) {



            var currentHref = currentLI.find("a").first().attr("href");
            var lastHref = thisDropdownMenu.find("li").last().find("a").first().attr("href");
            var firstHref = thisDropdownMenu.find("li").first().find("a").first().attr("href");


            if (e.which === 40) {

                // console.log(currentLI);
                // console.log(thisDropdownMenu.find("li").last());
                if (currentHref != lastHref) {

                    currentLI.next().find("a").first().focus();
                }

            };


            if (e.which === 38) {

                if (currentHref != firstHref) {
                    currentLI.prev().find("a").first().focus();
                }
                else {

                    thisDropdownMenu.hide();
                    thisDropdownMenu.data("closeSelector", false);
                    thisDropdownMenu.parent().find(".dropdown .selectorHref").focus();
                }

            };
        }

        //38 up
        //40 down
    }
    );
}


function bindMore() {


    setHTMLDropdowns();


    $('.guided').each(function (index) {

        var dimname = $(this).data("dimname");

        var index = 10;

        var licount = $(this).find('li').length;

        if (licount > index) {

            var hideindex = index - 1;
            $(this).find('li:gt(' + hideindex + ')').hide();
            $(this).append('<li class="more"><a href="#"> + MORE<span class=\"hide-text\"> ' + dimname + '</span></a></li>');
            $(this).append('<li class="less"><a href="#"> - LESS<span class=\"hide-text\"> ' + dimname + '</span></a></li>');

            $(this).find('li.less').hide();



            $(this).find('li.more:eq(0)').click(function () {

                var revealindex = 9;
                $(this).parent().find('li:gt(' + revealindex + ')').show();
                $(this).parent().find('li.less').show();


                $(this).parent().find('li:eq(' + (revealindex + 1) + ')').find('a').first().focus();
                var thishtml = $(this).parent().find('li:eq(' + (revealindex + 1) + ')').find('a').html();

                $("#Aria-Announcements").html(thishtml);

                $(this).hide();
                return false;


            });


            $(this).find('li.less:eq(0)').click(function () {


                $(this).parent().find('li:gt(' + hideindex + ')').hide();
                $(this).parent().find('li.more').show();

                $(this).hide();
                return false;


            });








        }


    });
}


function closeDropdowns() {

    $("#storeInfo").hide();
    $("#accountOptions").hide();
    // $("#hypMyAccountModal").addClass("hide");
    // $("#accountOptions").removeClass("show");
    // $("#accountOptions").addClass("hide");
    //$("#storeInfo").removeClass("show");

    if (!$("body").is("#home") || ($("section").css("width") == "720px")) {
        $(this).find("#mainNavLvl").css("left", "-9999px");
    };

    $(".generalNav ul").css("left", "-9999px");

    $(".brandNav ul").css("left", "-9999px");
}


function ADAUpdates() {



    //  lets add in the observer to force change when dom updates

    const observer = new MutationObserver(function (mutations_list) {


        try {

            if ($(".usabilla_live_button_container").length) {

                $(".usabilla_live_button_container").removeAttr("role");

            }
            $("a:not([href])").each(function () {


                $(this).attr("href", "#");

            });


            $("[onmouseover]").each(function () {


                var attr = $(this).attr("onfocus");

                if (typeof attr !== "undefined" && attr !== false) {

                }
                else {


                    $(this).attr("onfocus", $(this).attr("onmouseover").replace("onMouseOver", "onFocus"));
                    // need to add the attribute for onfocus
                }



            });

            $("[onmouseout]").each(function () {


                var attr = $(this).attr("onblur");

                if (typeof attr !== "undefined" && attr !== false) {

                }
                else {


                    $(this).attr("onblur", $(this).attr("onmouseout").replace("onMouseOut", "onBlur"));

                    // need to add the attribute for onfocus
                }



            });




            // iframe titles

            $("iframe").each(function () {
                var iframeTitle = $(this).attr('title');

                if (typeof iframeTitle == 'undefined' || iframeTitle == false) {

                    $(this).attr('title', 'external ad content');
                }

            });

            if ($("#guided").length && !$("#pnlGuidedNavigation").length) {
                $("#guided").removeAttr("aria-labelledby");
            }

            //mutations_list.forEach(function (mutation) {

            //});
        } catch (ex) {

        }
    });

    observer.observe(document.querySelector("body"), { subtree: false, childList: true });






    // usabilia
    if ($(".usabilla_live_button_container").length) {

        $(".usabilla_live_button_container").removeAttr("role");

    }

    // bizarvoice and missing hrefs and missing alt tags

    $("a:not([href])").each(function () {


        $(this).attr("href", "#");

    });


    $("img").each(function () {

        if ($(this).attr("src") == "https://microcenter.ugc.bazaarvoice.com/static/3520-en_us/profileSnapshotLoading.gif") {

            $(this).attr("src", "/assets/images/blank.gif");
        }
        // fix blank alt
        if ($(this).attr("alt") == "") {
            $(this).attr("alt", "");
        }
    });

    // fix missing alt
    $("img:not([alt])").each(function () {


        $(this).attr("alt", "");

    });



    $("[onmouseover]").each(function () {


        var attr = $(this).attr("onfocus");

        if (typeof attr !== "undefined" && attr !== false) {

        }
        else {


            $(this).attr("onfocus", $(this).attr("onmouseover").replace("onMouseOver", "onFocus"));
            // need to add the attribute for onfocus
        }



    });

    $("[onmouseout]").each(function () {


        var attr = $(this).attr("onblur");

        if (typeof attr !== "undefined" && attr !== false) {

        }
        else {


            $(this).attr("onblur", $(this).attr("onmouseout").replace("onMouseOut", "onBlur"));

            // need to add the attribute for onfocus
        }



    });




    // iframe titles

    $("iframe").each(function () {
        var iframeTitle = $(this).attr('title');

        if (typeof iframeTitle == 'undefined' || iframeTitle == false) {

            $(this).attr('title', 'external ad content');
        }

    });



    // fix general image alts
    $("img:not([alt])").each(function () {


        $(this).attr("alt", "");

    });
    // empty guided nav
    if ($("#guided").length && !$("#pnlGuidedNavigation").length) {
        $("#guided").removeAttr("aria-labelledby");
    }
}



// jquery custom scroll bar
/*mousewheel*/
(function (a) { function d(b) { var c = b || window.event, d = [].slice.call(arguments, 1), e = 0, f = !0, g = 0, h = 0; return b = a.event.fix(c), b.type = "mousewheel", c.wheelDelta && (e = c.wheelDelta / 120), c.detail && (e = -c.detail / 3), h = e, c.axis !== undefined && c.axis === c.HORIZONTAL_AXIS && (h = 0, g = -1 * e), c.wheelDeltaY !== undefined && (h = c.wheelDeltaY / 120), c.wheelDeltaX !== undefined && (g = -1 * c.wheelDeltaX / 120), d.unshift(b, e, g, h), (a.event.dispatch || a.event.handle).apply(this, d) } var b = ["DOMMouseScroll", "mousewheel"]; if (a.event.fixHooks) for (var c = b.length; c;) a.event.fixHooks[b[--c]] = a.event.mouseHooks; a.event.special.mousewheel = { setup: function () { if (this.addEventListener) for (var a = b.length; a;) this.addEventListener(b[--a], d, !1); else this.onmousewheel = d }, teardown: function () { if (this.removeEventListener) for (var a = b.length; a;) this.removeEventListener(b[--a], d, !1); else this.onmousewheel = null } }, a.fn.extend({ mousewheel: function (a) { return a ? this.bind("mousewheel", a) : this.trigger("mousewheel") }, unmousewheel: function (a) { return this.unbind("mousewheel", a) } }) })(jQuery);
/*custom scrollbar*/
(function (c) { var b = { init: function (e) { var f = { set_width: false, set_height: false, horizontalScroll: false, scrollInertia: 950, mouseWheel: true, mouseWheelPixels: "auto", autoDraggerLength: true, autoHideScrollbar: false, scrollButtons: { enable: false, scrollType: "continuous", scrollSpeed: "auto", scrollAmount: 40 }, advanced: { updateOnBrowserResize: true, updateOnContentResize: false, autoExpandHorizontalScroll: false, autoScrollOnFocus: true, normalizeMouseWheelDelta: false }, contentTouchScroll: true, callbacks: { onScrollStart: function () { }, onScroll: function () { }, onTotalScroll: function () { }, onTotalScrollBack: function () { }, onTotalScrollOffset: 0, onTotalScrollBackOffset: 0, whileScrolling: function () { } }, theme: "light" }, e = c.extend(true, f, e); return this.each(function () { var m = c(this); if (e.set_width) { m.css("width", e.set_width) } if (e.set_height) { m.css("height", e.set_height) } if (!c(document).data("mCustomScrollbar-index")) { c(document).data("mCustomScrollbar-index", "1") } else { var t = parseInt(c(document).data("mCustomScrollbar-index")); c(document).data("mCustomScrollbar-index", t + 1) } m.wrapInner("<div class='mCustomScrollBox mCS-" + e.theme + "' id='mCSB_" + c(document).data("mCustomScrollbar-index") + "' style='position:relative; height:100%; overflow:hidden; max-width:100%;' />").addClass("mCustomScrollbar _mCS_" + c(document).data("mCustomScrollbar-index")); var g = m.children(".mCustomScrollBox"); if (e.horizontalScroll) { g.addClass("mCSB_horizontal").wrapInner("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />"); var k = g.children(".mCSB_h_wrapper"); k.wrapInner("<div class='mCSB_container' style='position:absolute; left:0;' />").children(".mCSB_container").css({ width: k.children().outerWidth(), position: "relative" }).unwrap() } else { g.wrapInner("<div class='mCSB_container' style='position:relative; top:0;' />") } var o = g.children(".mCSB_container"); if (c.support.touch) { o.addClass("mCS_touch") } o.after("<div class='mCSB_scrollTools' style='position:absolute;'><div class='mCSB_draggerContainer'><div class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' style='position:relative;'></div></div><div class='mCSB_draggerRail'></div></div></div>"); var l = g.children(".mCSB_scrollTools"), h = l.children(".mCSB_draggerContainer"), q = h.children(".mCSB_dragger"); if (e.horizontalScroll) { q.data("minDraggerWidth", q.width()) } else { q.data("minDraggerHeight", q.height()) } if (e.scrollButtons.enable) { if (e.horizontalScroll) { l.prepend("<a class='mCSB_buttonLeft' oncontextmenu='return false;'></a>").append("<a class='mCSB_buttonRight' oncontextmenu='return false;'></a>") } else { l.prepend("<a class='mCSB_buttonUp' oncontextmenu='return false;'></a>").append("<a class='mCSB_buttonDown' oncontextmenu='return false;'></a>") } } g.bind("scroll", function () { if (!m.is(".mCS_disabled")) { g.scrollTop(0).scrollLeft(0) } }); m.data({ mCS_Init: true, mCustomScrollbarIndex: c(document).data("mCustomScrollbar-index"), horizontalScroll: e.horizontalScroll, scrollInertia: e.scrollInertia, scrollEasing: "mcsEaseOut", mouseWheel: e.mouseWheel, mouseWheelPixels: e.mouseWheelPixels, autoDraggerLength: e.autoDraggerLength, autoHideScrollbar: e.autoHideScrollbar, scrollButtons_enable: e.scrollButtons.enable, scrollButtons_scrollType: e.scrollButtons.scrollType, scrollButtons_scrollSpeed: e.scrollButtons.scrollSpeed, scrollButtons_scrollAmount: e.scrollButtons.scrollAmount, autoExpandHorizontalScroll: e.advanced.autoExpandHorizontalScroll, autoScrollOnFocus: e.advanced.autoScrollOnFocus, normalizeMouseWheelDelta: e.advanced.normalizeMouseWheelDelta, contentTouchScroll: e.contentTouchScroll, onScrollStart_Callback: e.callbacks.onScrollStart, onScroll_Callback: e.callbacks.onScroll, onTotalScroll_Callback: e.callbacks.onTotalScroll, onTotalScrollBack_Callback: e.callbacks.onTotalScrollBack, onTotalScroll_Offset: e.callbacks.onTotalScrollOffset, onTotalScrollBack_Offset: e.callbacks.onTotalScrollBackOffset, whileScrolling_Callback: e.callbacks.whileScrolling, bindEvent_scrollbar_drag: false, bindEvent_content_touch: false, bindEvent_scrollbar_click: false, bindEvent_mousewheel: false, bindEvent_buttonsContinuous_y: false, bindEvent_buttonsContinuous_x: false, bindEvent_buttonsPixels_y: false, bindEvent_buttonsPixels_x: false, bindEvent_focusin: false, bindEvent_autoHideScrollbar: false, mCSB_buttonScrollRight: false, mCSB_buttonScrollLeft: false, mCSB_buttonScrollDown: false, mCSB_buttonScrollUp: false }); if (e.horizontalScroll) { if (m.css("max-width") !== "none") { if (!e.advanced.updateOnContentResize) { e.advanced.updateOnContentResize = true } } } else { if (m.css("max-height") !== "none") { var s = false, r = parseInt(m.css("max-height")); if (m.css("max-height").indexOf("%") >= 0) { s = r, r = m.parent().height() * s / 100 } m.css("overflow", "hidden"); g.css("max-height", r) } } m.mCustomScrollbar("update"); if (e.advanced.updateOnBrowserResize) { var i, j = c(window).width(), u = c(window).height(); c(window).bind("resize." + m.data("mCustomScrollbarIndex"), function () { if (i) { clearTimeout(i) } i = setTimeout(function () { if (!m.is(".mCS_disabled") && !m.is(".mCS_destroyed")) { var w = c(window).width(), v = c(window).height(); if (j !== w || u !== v) { if (m.css("max-height") !== "none" && s) { g.css("max-height", m.parent().height() * s / 100) } m.mCustomScrollbar("update"); j = w; u = v } } }, 150) }) } if (e.advanced.updateOnContentResize) { var p; if (e.horizontalScroll) { var n = o.outerWidth() } else { var n = o.outerHeight() } p = setInterval(function () { if (e.horizontalScroll) { if (e.advanced.autoExpandHorizontalScroll) { o.css({ position: "absolute", width: "auto" }).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({ width: o.outerWidth(), position: "relative" }).unwrap() } var v = o.outerWidth() } else { var v = o.outerHeight() } if (v != n) { m.mCustomScrollbar("update"); n = v } }, 300) } }) }, update: function () { var n = c(this), k = n.children(".mCustomScrollBox"), q = k.children(".mCSB_container"); q.removeClass("mCS_no_scrollbar"); n.removeClass("mCS_disabled mCS_destroyed"); k.scrollTop(0).scrollLeft(0); var y = k.children(".mCSB_scrollTools"), o = y.children(".mCSB_draggerContainer"), m = o.children(".mCSB_dragger"); if (n.data("horizontalScroll")) { var A = y.children(".mCSB_buttonLeft"), t = y.children(".mCSB_buttonRight"), f = k.width(); if (n.data("autoExpandHorizontalScroll")) { q.css({ position: "absolute", width: "auto" }).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({ width: q.outerWidth(), position: "relative" }).unwrap() } var z = q.outerWidth() } else { var w = y.children(".mCSB_buttonUp"), g = y.children(".mCSB_buttonDown"), r = k.height(), i = q.outerHeight() } if (i > r && !n.data("horizontalScroll")) { y.css("display", "block"); var s = o.height(); if (n.data("autoDraggerLength")) { var u = Math.round(r / i * s), l = m.data("minDraggerHeight"); if (u <= l) { m.css({ height: l }) } else { if (u >= s - 10) { var p = s - 10; m.css({ height: p }) } else { m.css({ height: u }) } } m.children(".mCSB_dragger_bar").css({ "line-height": m.height() + "px" }) } var B = m.height(), x = (i - r) / (s - B); n.data("scrollAmount", x).mCustomScrollbar("scrolling", k, q, o, m, w, g, A, t); var D = Math.abs(q.position().top); n.mCustomScrollbar("scrollTo", D, { scrollInertia: 0, trigger: "internal" }) } else { if (z > f && n.data("horizontalScroll")) { y.css("display", "block"); var h = o.width(); if (n.data("autoDraggerLength")) { var j = Math.round(f / z * h), C = m.data("minDraggerWidth"); if (j <= C) { m.css({ width: C }) } else { if (j >= h - 10) { var e = h - 10; m.css({ width: e }) } else { m.css({ width: j }) } } } var v = m.width(), x = (z - f) / (h - v); n.data("scrollAmount", x).mCustomScrollbar("scrolling", k, q, o, m, w, g, A, t); var D = Math.abs(q.position().left); n.mCustomScrollbar("scrollTo", D, { scrollInertia: 0, trigger: "internal" }) } else { k.unbind("mousewheel focusin"); if (n.data("horizontalScroll")) { m.add(q).css("left", 0) } else { m.add(q).css("top", 0) } y.css("display", "none"); q.addClass("mCS_no_scrollbar"); n.data({ bindEvent_mousewheel: false, bindEvent_focusin: false }) } } }, scrolling: function (h, p, m, j, w, e, A, v) { var k = c(this); if (!k.data("bindEvent_scrollbar_drag")) { var n, o; if (c.support.msPointer) { j.bind("MSPointerDown", function (H) { H.preventDefault(); k.data({ on_drag: true }); j.addClass("mCSB_dragger_onDrag"); var G = c(this), J = G.offset(), F = H.originalEvent.pageX - J.left, I = H.originalEvent.pageY - J.top; if (F < G.width() && F > 0 && I < G.height() && I > 0) { n = I; o = F } }); c(document).bind("MSPointerMove." + k.data("mCustomScrollbarIndex"), function (H) { H.preventDefault(); if (k.data("on_drag")) { var G = j, J = G.offset(), F = H.originalEvent.pageX - J.left, I = H.originalEvent.pageY - J.top; D(n, o, I, F) } }).bind("MSPointerUp." + k.data("mCustomScrollbarIndex"), function (x) { k.data({ on_drag: false }); j.removeClass("mCSB_dragger_onDrag") }) } else { j.bind("mousedown touchstart", function (H) { H.preventDefault(); H.stopImmediatePropagation(); var G = c(this), K = G.offset(), F, J; if (H.type === "touchstart") { var I = H.originalEvent.touches[0] || H.originalEvent.changedTouches[0]; F = I.pageX - K.left; J = I.pageY - K.top } else { k.data({ on_drag: true }); j.addClass("mCSB_dragger_onDrag"); F = H.pageX - K.left; J = H.pageY - K.top } if (F < G.width() && F > 0 && J < G.height() && J > 0) { n = J; o = F } }).bind("touchmove", function (H) { H.preventDefault(); H.stopImmediatePropagation(); var K = H.originalEvent.touches[0] || H.originalEvent.changedTouches[0], G = c(this), J = G.offset(), F = K.pageX - J.left, I = K.pageY - J.top; D(n, o, I, F) }); c(document).bind("mousemove." + k.data("mCustomScrollbarIndex"), function (H) { if (k.data("on_drag")) { var G = j, J = G.offset(), F = H.pageX - J.left, I = H.pageY - J.top; D(n, o, I, F) } }).bind("mouseup." + k.data("mCustomScrollbarIndex"), function (x) { k.data({ on_drag: false }); j.removeClass("mCSB_dragger_onDrag") }) } k.data({ bindEvent_scrollbar_drag: true }) } function D(G, H, I, F) { if (k.data("horizontalScroll")) { k.mCustomScrollbar("scrollTo", (j.position().left - (H)) + F, { moveDragger: true, trigger: "internal" }) } else { k.mCustomScrollbar("scrollTo", (j.position().top - (G)) + I, { moveDragger: true, trigger: "internal" }) } } if (c.support.touch && k.data("contentTouchScroll")) { if (!k.data("bindEvent_content_touch")) { var l, B, r, s, u, C, E; p.bind("touchstart", function (x) { x.stopImmediatePropagation(); l = x.originalEvent.touches[0] || x.originalEvent.changedTouches[0]; B = c(this); r = B.offset(); u = l.pageX - r.left; s = l.pageY - r.top; C = s; E = u }); p.bind("touchmove", function (x) { x.preventDefault(); x.stopImmediatePropagation(); l = x.originalEvent.touches[0] || x.originalEvent.changedTouches[0]; B = c(this).parent(); r = B.offset(); u = l.pageX - r.left; s = l.pageY - r.top; if (k.data("horizontalScroll")) { k.mCustomScrollbar("scrollTo", E - u, { trigger: "internal" }) } else { k.mCustomScrollbar("scrollTo", C - s, { trigger: "internal" }) } }) } } if (!k.data("bindEvent_scrollbar_click")) { m.bind("click", function (F) { var x = (F.pageY - m.offset().top) * k.data("scrollAmount"), y = c(F.target); if (k.data("horizontalScroll")) { x = (F.pageX - m.offset().left) * k.data("scrollAmount") } if (y.hasClass("mCSB_draggerContainer") || y.hasClass("mCSB_draggerRail")) { k.mCustomScrollbar("scrollTo", x, { trigger: "internal", scrollEasing: "draggerRailEase" }) } }); k.data({ bindEvent_scrollbar_click: true }) } if (k.data("mouseWheel")) { if (!k.data("bindEvent_mousewheel")) { h.bind("mousewheel", function (H, J) { var G, F = k.data("mouseWheelPixels"), x = Math.abs(p.position().top), I = j.position().top, y = m.height() - j.height(); if (k.data("normalizeMouseWheelDelta")) { if (J < 0) { J = -1 } else { J = 1 } } if (F === "auto") { F = 100 + Math.round(k.data("scrollAmount") / 2) } if (k.data("horizontalScroll")) { I = j.position().left; y = m.width() - j.width(); x = Math.abs(p.position().left) } if ((J > 0 && I !== 0) || (J < 0 && I !== y)) { H.preventDefault(); H.stopImmediatePropagation() } G = x - (J * F); k.mCustomScrollbar("scrollTo", G, { trigger: "internal" }) }); k.data({ bindEvent_mousewheel: true }) } } if (k.data("scrollButtons_enable")) { if (k.data("scrollButtons_scrollType") === "pixels") { if (k.data("horizontalScroll")) { v.add(A).unbind("mousedown touchstart MSPointerDown mouseup MSPointerUp mouseout MSPointerOut touchend", i, g); k.data({ bindEvent_buttonsContinuous_x: false }); if (!k.data("bindEvent_buttonsPixels_x")) { v.bind("click", function (x) { x.preventDefault(); q(Math.abs(p.position().left) + k.data("scrollButtons_scrollAmount")) }); A.bind("click", function (x) { x.preventDefault(); q(Math.abs(p.position().left) - k.data("scrollButtons_scrollAmount")) }); k.data({ bindEvent_buttonsPixels_x: true }) } } else { e.add(w).unbind("mousedown touchstart MSPointerDown mouseup MSPointerUp mouseout MSPointerOut touchend", i, g); k.data({ bindEvent_buttonsContinuous_y: false }); if (!k.data("bindEvent_buttonsPixels_y")) { e.bind("click", function (x) { x.preventDefault(); q(Math.abs(p.position().top) + k.data("scrollButtons_scrollAmount")) }); w.bind("click", function (x) { x.preventDefault(); q(Math.abs(p.position().top) - k.data("scrollButtons_scrollAmount")) }); k.data({ bindEvent_buttonsPixels_y: true }) } } function q(x) { if (!j.data("preventAction")) { j.data("preventAction", true); k.mCustomScrollbar("scrollTo", x, { trigger: "internal" }) } } } else { if (k.data("horizontalScroll")) { v.add(A).unbind("click"); k.data({ bindEvent_buttonsPixels_x: false }); if (!k.data("bindEvent_buttonsContinuous_x")) { v.bind("mousedown touchstart MSPointerDown", function (y) { y.preventDefault(); var x = z(); k.data({ mCSB_buttonScrollRight: setInterval(function () { k.mCustomScrollbar("scrollTo", Math.abs(p.position().left) + x, { trigger: "internal", scrollEasing: "easeOutCirc" }) }, 17) }) }); var i = function (x) { x.preventDefault(); clearInterval(k.data("mCSB_buttonScrollRight")) }; v.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", i); A.bind("mousedown touchstart MSPointerDown", function (y) { y.preventDefault(); var x = z(); k.data({ mCSB_buttonScrollLeft: setInterval(function () { k.mCustomScrollbar("scrollTo", Math.abs(p.position().left) - x, { trigger: "internal", scrollEasing: "easeOutCirc" }) }, 17) }) }); var g = function (x) { x.preventDefault(); clearInterval(k.data("mCSB_buttonScrollLeft")) }; A.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", g); k.data({ bindEvent_buttonsContinuous_x: true }) } } else { e.add(w).unbind("click"); k.data({ bindEvent_buttonsPixels_y: false }); if (!k.data("bindEvent_buttonsContinuous_y")) { e.bind("mousedown touchstart MSPointerDown", function (y) { y.preventDefault(); var x = z(); k.data({ mCSB_buttonScrollDown: setInterval(function () { k.mCustomScrollbar("scrollTo", Math.abs(p.position().top) + x, { trigger: "internal", scrollEasing: "easeOutCirc" }) }, 17) }) }); var t = function (x) { x.preventDefault(); clearInterval(k.data("mCSB_buttonScrollDown")) }; e.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", t); w.bind("mousedown touchstart MSPointerDown", function (y) { y.preventDefault(); var x = z(); k.data({ mCSB_buttonScrollUp: setInterval(function () { k.mCustomScrollbar("scrollTo", Math.abs(p.position().top) - x, { trigger: "internal", scrollEasing: "easeOutCirc" }) }, 17) }) }); var f = function (x) { x.preventDefault(); clearInterval(k.data("mCSB_buttonScrollUp")) }; w.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", f); k.data({ bindEvent_buttonsContinuous_y: true }) } } function z() { var x = k.data("scrollButtons_scrollSpeed"); if (k.data("scrollButtons_scrollSpeed") === "auto") { x = Math.round((k.data("scrollInertia") + 100) / 40) } return x } } } if (k.data("autoScrollOnFocus")) { if (!k.data("bindEvent_focusin")) { h.bind("focusin", function () { h.scrollTop(0).scrollLeft(0); var x = c(document.activeElement); if (x.is("input,textarea,select,button,a[tabindex],area,object")) { var G = p.position().top, y = x.position().top, F = h.height() - x.outerHeight(); if (k.data("horizontalScroll")) { G = p.position().left; y = x.position().left; F = h.width() - x.outerWidth() } if (G + y < 0 || G + y > F) { k.mCustomScrollbar("scrollTo", y, { trigger: "internal" }) } } }); k.data({ bindEvent_focusin: true }) } } if (k.data("autoHideScrollbar")) { if (!k.data("bindEvent_autoHideScrollbar")) { h.bind("mouseenter", function (x) { h.addClass("mCS-mouse-over"); d.showScrollbar.call(h.children(".mCSB_scrollTools")) }).bind("mouseleave touchend", function (x) { h.removeClass("mCS-mouse-over"); if (x.type === "mouseleave") { d.hideScrollbar.call(h.children(".mCSB_scrollTools")) } }); k.data({ bindEvent_autoHideScrollbar: true }) } } }, scrollTo: function (n, u) { var r = c(this), k = { moveDragger: false, trigger: "external", callbacks: true, scrollInertia: r.data("scrollInertia"), scrollEasing: r.data("scrollEasing") }, u = c.extend(k, u), j, i = r.children(".mCustomScrollBox"), s = i.children(".mCSB_container"), q = i.children(".mCSB_scrollTools"), h = q.children(".mCSB_draggerContainer"), t = h.children(".mCSB_dragger"), g = draggerSpeed = u.scrollInertia, m, f, l, e; if (!s.hasClass("mCS_no_scrollbar")) { r.data({ mCS_trigger: u.trigger }); if (r.data("mCS_Init")) { u.callbacks = false } if (n || n === 0) { if (typeof (n) === "number") { if (u.moveDragger) { j = n; if (r.data("horizontalScroll")) { n = t.position().left * r.data("scrollAmount") } else { n = t.position().top * r.data("scrollAmount") } draggerSpeed = 0 } else { j = n / r.data("scrollAmount") } } else { if (typeof (n) === "string") { var p; if (n === "top") { p = 0 } else { if (n === "bottom" && !r.data("horizontalScroll")) { p = s.outerHeight() - i.height() } else { if (n === "left") { p = 0 } else { if (n === "right" && r.data("horizontalScroll")) { p = s.outerWidth() - i.width() } else { if (n === "first") { p = r.find(".mCSB_container").find(":first") } else { if (n === "last") { p = r.find(".mCSB_container").find(":last") } else { p = r.find(n) } } } } } } if (p.length === 1) { if (r.data("horizontalScroll")) { n = p.position().left } else { n = p.position().top } j = n / r.data("scrollAmount") } else { j = n = p } } } if (r.data("horizontalScroll")) { if (r.data("onTotalScrollBack_Offset")) { f = -r.data("onTotalScrollBack_Offset") } if (r.data("onTotalScroll_Offset")) { e = i.width() - s.outerWidth() + r.data("onTotalScroll_Offset") } if (j < 0) { j = n = 0; clearInterval(r.data("mCSB_buttonScrollLeft")); if (!f) { m = true } } else { if (j >= h.width() - t.width()) { j = h.width() - t.width(); n = i.width() - s.outerWidth(); clearInterval(r.data("mCSB_buttonScrollRight")); if (!e) { l = true } } else { n = -n } } d.mTweenAxis.call(this, t[0], "left", Math.round(j), draggerSpeed, u.scrollEasing); d.mTweenAxis.call(this, s[0], "left", Math.round(n), g, u.scrollEasing, { onStart: function () { if (u.callbacks && !r.data("mCS_tweenRunning")) { o("onScrollStart") } if (r.data("autoHideScrollbar")) { d.showScrollbar.call(q) } }, onUpdate: function () { if (u.callbacks) { o("whileScrolling") } }, onComplete: function () { if (u.callbacks) { o("onScroll"); if (m || (f && s.position().left >= f)) { o("onTotalScrollBack") } if (l || (e && s.position().left <= e)) { o("onTotalScroll") } } t.data("preventAction", false); r.data("mCS_tweenRunning", false); if (r.data("autoHideScrollbar")) { if (!i.hasClass("mCS-mouse-over")) { d.hideScrollbar.call(q) } } } }) } else { if (r.data("onTotalScrollBack_Offset")) { f = -r.data("onTotalScrollBack_Offset") } if (r.data("onTotalScroll_Offset")) { e = i.height() - s.outerHeight() + r.data("onTotalScroll_Offset") } if (j < 0) { j = n = 0; clearInterval(r.data("mCSB_buttonScrollUp")); if (!f) { m = true } } else { if (j >= h.height() - t.height()) { j = h.height() - t.height(); n = i.height() - s.outerHeight(); clearInterval(r.data("mCSB_buttonScrollDown")); if (!e) { l = true } } else { n = -n } } d.mTweenAxis.call(this, t[0], "top", Math.round(j), draggerSpeed, u.scrollEasing); d.mTweenAxis.call(this, s[0], "top", Math.round(n), g, u.scrollEasing, { onStart: function () { if (u.callbacks && !r.data("mCS_tweenRunning")) { o("onScrollStart") } if (r.data("autoHideScrollbar")) { d.showScrollbar.call(q) } }, onUpdate: function () { if (u.callbacks) { o("whileScrolling") } }, onComplete: function () { if (u.callbacks) { o("onScroll"); if (m || (f && s.position().top >= f)) { o("onTotalScrollBack") } if (l || (e && s.position().top <= e)) { o("onTotalScroll") } } t.data("preventAction", false); r.data("mCS_tweenRunning", false); if (r.data("autoHideScrollbar")) { if (!i.hasClass("mCS-mouse-over")) { d.hideScrollbar.call(q) } } } }) } if (r.data("mCS_Init")) { r.data({ mCS_Init: false }) } } } function o(v) { this.mcs = { top: s.position().top, left: s.position().left, draggerTop: t.position().top, draggerLeft: t.position().left, topPct: Math.round((100 * Math.abs(s.position().top)) / Math.abs(s.outerHeight() - i.height())), leftPct: Math.round((100 * Math.abs(s.position().left)) / Math.abs(s.outerWidth() - i.width())) }; switch (v) { case "onScrollStart": r.data("mCS_tweenRunning", true).data("onScrollStart_Callback").call(r, this.mcs); break; case "whileScrolling": r.data("whileScrolling_Callback").call(r, this.mcs); break; case "onScroll": r.data("onScroll_Callback").call(r, this.mcs); break; case "onTotalScrollBack": r.data("onTotalScrollBack_Callback").call(r, this.mcs); break; case "onTotalScroll": r.data("onTotalScroll_Callback").call(r, this.mcs); break } } }, stop: function () { var g = c(this), e = g.children().children(".mCSB_container"), f = g.children().children().children().children(".mCSB_dragger"); d.mTweenAxisStop.call(this, e[0]); d.mTweenAxisStop.call(this, f[0]) }, disable: function (e) { var j = c(this), f = j.children(".mCustomScrollBox"), h = f.children(".mCSB_container"), g = f.children(".mCSB_scrollTools"), i = g.children().children(".mCSB_dragger"); f.unbind("mousewheel focusin mouseenter mouseleave touchend"); h.unbind("touchstart touchmove"); if (e) { if (j.data("horizontalScroll")) { i.add(h).css("left", 0) } else { i.add(h).css("top", 0) } } g.css("display", "none"); h.addClass("mCS_no_scrollbar"); j.data({ bindEvent_mousewheel: false, bindEvent_focusin: false, bindEvent_content_touch: false, bindEvent_autoHideScrollbar: false }).addClass("mCS_disabled") }, destroy: function () { var e = c(this); e.removeClass("mCustomScrollbar _mCS_" + e.data("mCustomScrollbarIndex")).addClass("mCS_destroyed").children().children(".mCSB_container").unwrap().children().unwrap().siblings(".mCSB_scrollTools").remove(); c(document).unbind("mousemove." + e.data("mCustomScrollbarIndex") + " mouseup." + e.data("mCustomScrollbarIndex") + " MSPointerMove." + e.data("mCustomScrollbarIndex") + " MSPointerUp." + e.data("mCustomScrollbarIndex")); c(window).unbind("resize." + e.data("mCustomScrollbarIndex")) } }, d = { showScrollbar: function () { this.stop().animate({ opacity: 1 }, "fast") }, hideScrollbar: function () { this.stop().animate({ opacity: 0 }, "fast") }, mTweenAxis: function (g, i, h, f, o, y) { var y = y || {}, v = y.onStart || function () { }, p = y.onUpdate || function () { }, w = y.onComplete || function () { }; var n = t(), l, j = 0, r = g.offsetTop, s = g.style; if (i === "left") { r = g.offsetLeft } var m = h - r; q(); e(); function t() { if (window.performance && window.performance.now) { return window.performance.now() } else { if (window.performance && window.performance.webkitNow) { return window.performance.webkitNow() } else { if (Date.now) { return Date.now() } else { return new Date().getTime() } } } } function x() { if (!j) { v.call() } j = t() - n; u(); if (j >= g._time) { g._time = (j > g._time) ? j + l - (j - g._time) : j + l - 1; if (g._time < j + 1) { g._time = j + 1 } } if (g._time < f) { g._id = _request(x) } else { w.call() } } function u() { if (f > 0) { g.currVal = k(g._time, r, m, f, o); s[i] = Math.round(g.currVal) + "px" } else { s[i] = h + "px" } p.call() } function e() { l = 1000 / 60; g._time = j + l; _request = (!window.requestAnimationFrame) ? function (z) { u(); return setTimeout(z, 0.01) } : window.requestAnimationFrame; g._id = _request(x) } function q() { if (g._id == null) { return } if (!window.requestAnimationFrame) { clearTimeout(g._id) } else { window.cancelAnimationFrame(g._id) } g._id = null } function k(B, A, F, E, C) { switch (C) { case "linear": return F * B / E + A; break; case "easeOutQuad": B /= E; return -F * B * (B - 2) + A; break; case "easeInOutQuad": B /= E / 2; if (B < 1) { return F / 2 * B * B + A } B--; return -F / 2 * (B * (B - 2) - 1) + A; break; case "easeOutCubic": B /= E; B--; return F * (B * B * B + 1) + A; break; case "easeOutQuart": B /= E; B--; return -F * (B * B * B * B - 1) + A; break; case "easeOutQuint": B /= E; B--; return F * (B * B * B * B * B + 1) + A; break; case "easeOutCirc": B /= E; B--; return F * Math.sqrt(1 - B * B) + A; break; case "easeOutSine": return F * Math.sin(B / E * (Math.PI / 2)) + A; break; case "easeOutExpo": return F * (-Math.pow(2, -10 * B / E) + 1) + A; break; case "mcsEaseOut": var D = (B /= E) * B, z = D * B; return A + F * (0.499999999999997 * z * D + -2.5 * D * D + 5.5 * z + -6.5 * D + 4 * B); break; case "draggerRailEase": B /= E / 2; if (B < 1) { return F / 2 * B * B * B + A } B -= 2; return F / 2 * (B * B * B + 2) + A; break } } }, mTweenAxisStop: function (e) { if (e._id == null) { return } if (!window.requestAnimationFrame) { clearTimeout(e._id) } else { window.cancelAnimationFrame(e._id) } e._id = null }, rafPolyfill: function () { var f = ["ms", "moz", "webkit", "o"], e = f.length; while (--e > -1 && !window.requestAnimationFrame) { window.requestAnimationFrame = window[f[e] + "RequestAnimationFrame"]; window.cancelAnimationFrame = window[f[e] + "CancelAnimationFrame"] || window[f[e] + "CancelRequestAnimationFrame"] } } }; d.rafPolyfill.call(); c.support.touch = !!("ontouchstart" in window); c.support.msPointer = window.navigator.msPointerEnabled; var a = ("https:" == document.location.protocol) ? "https:" : "http:"; c.event.special.mousewheel || document.write('<script src="' + a + '//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.0.6/jquery.mousewheel.min.js"><\/script>'); c.fn.mCustomScrollbar = function (e) { if (b[e]) { return b[e].apply(this, Array.prototype.slice.call(arguments, 1)) } else { if (typeof e === "object" || !e) { return b.init.apply(this, arguments) } else { c.error("Method " + e + " does not exist") } } } })(jQuery);


(function ($) {

    $.fn.shuffle = function () {

        var allElems = this.get(),
            getRandom = function (max) {
                return Math.floor(Math.random() * max);
            },
            shuffled = $.map(allElems, function () {
                var random = getRandom(allElems.length),
                    randEl = $(allElems[random]).clone(true)[0];
                allElems.splice(random, 1);
                return randEl;
            });

        this.each(function (i) {
            $(this).replaceWith($(shuffled[i]));
        });

        return $(shuffled);

    };

})(jQuery);



;

var escapeTarget = null;


function processEscape() {

 
    if (escapeTarget != null) {
      //  console.log(escapeTarget);
        escapeTarget.focus();
        closeDropdowns();
        escapeTarget = null;
        $(".topLvl").removeClass("open");
    }

    else if (returnToIT == "#byProd") {
        $("#mainNavLvl").css("left", "-9999px");
        $(returnToIT).focus();

    }
    else if (hideIT == ".brandNav ul") {
        $(hideIT).css("left", "-9999px");
        $(returnToIT).focus();
    }
    else {
        if (returnToIT != "") {

            $(returnToIT).focus();

            $(".topLvl").removeClass("open");




        }

        if (hideIT != "") {
            $(hideIT).hide();
        }



    }
    // if (hideIT == "#primary ul .prodNav ul li.topLvl .listContainer" && ((!$("body").is("#home") || ($("section").css("width") == "720px")))) {

    if (hideIT == "#primary ul .prodNav ul li.topLvl .listContainer") {
        returnToIT = "#byProd";
        hideIT = "#mainNavLvl";
    }
    else {
        hideIT = "";
        returnToIT = "";
    }


}
function topMenuCloseSubMenu() {
    $("#primary ul li ul").hide();      // Hide all old top nav's
}



$(document).ready(function () {

   

   

   

   



    // lets trap the escape key.





    $(document).on("keyup", function (e) {


        if (e.keyCode == 27) {
            // we have an escape.
            processEscape();


            if (closeStoreSelector) {
                $("#boosted .dropdown-menu").hide();
                closeStoreSelector = false;
                $("#storeselectorHref").focus();

            }



        }


    });


    // lets trap the arrow keys




    // set to clear focus on elements in new header nav




    $("#byProd").focus(function () { closeDropdowns(); });
    $("#byBrand").focus(function () { closeDropdowns(); });
    $(".upperNav").focus(function () { closeDropdowns(); });

    //$(".topLink").click(function (e) {
    //    e.preventDefault();
    //    alert("here");
    //    $(this).parent().children(".listContainer").find(".tertiary").first().find(".tertiaryLvl").first().find("h4").first().find("a").first().focus();


    //});

    $(document).on("keydown", function (e) {


        e = e || window.event;

        var focusElement = $(document.activeElement);
        var nextElement = focusElement.parent().next();
        var prevElement = focusElement.parent().prev();

        //  console.log('before ' + focusElement.attr("class"));

        //  alert(e.keyCode + " " + focusElement.attr("id") + " " + focusElement.attr("class"));
        //tab
        if (e.keyCode == 9 || e.keyCode == 39) {

            // console.log(focusElement);
            if (focusElement.attr("id") != null && focusElement.attr("id") == "byProd") {

                if (!e.shiftKey) {
                    focusElement.parent().next('li').children("a").focus();
                    e.preventDefault();
                }



            }
            if (focusElement.attr("id") != null && focusElement.attr("id") == "byBrand") {

                if (!e.shiftKey) {
                    focusElement.parent().next('li').children("a").focus();
                    e.preventDefault();
                }
                else {
                    focusElement.parent().prev('li').children("a").focus();
                    e.preventDefault();
                }
            }

            if (focusElement.attr("class") != null && focusElement.attr("class").includes("upperNav")) {

                if (!e.shiftKey) {
                    if (focusElement.parent().next('li').length) { e.preventDefault(); }
                    focusElement.parent().next('li').children("a").focus();
                }
                else {
                    focusElement.parent().prev('li').children("a").focus();
                    e.preventDefault();

                }



            }


        }
        if (e.keyCode == 40) {
            // we have a down link

            if (focusElement.attr("class") != null && focusElement.attr("class").includes("upperNav")) {
                focusElement.parent().find("ul").css("left", "0px")
                focusElement.parent().find("ul").find("li").first().find("a").first().focus();
                escapeTarget = focusElement;
                // $(this).find("ul").css("left", "0px");

                e.preventDefault();
            }

            if (focusElement.attr("class") != null && focusElement.attr("class").includes("upperDropNav")) {

                focusElement.parent().next("li").find("a").first().focus();
                e.preventDefault();

            }


            // lets do the product menu

            if (focusElement.attr("id") != null && focusElement.attr("id") == "byProd") {
                escapeTarget = null;
                focusElement.trigger({ type: 'click' });
                e.preventDefault();
            }

            if (focusElement.attr("class") != null && focusElement.attr("class").includes("topLink") && nextElement.find("a").first() != null && nextElement.find("a").first().attr("class").includes("topLink")) {
                escapeTarget = null;
                nextElement.find("a").first().focus();
                e.preventDefault();
            }

            var lastMainNav = $("#mainNavLvl .topLvl:last-child a").html();

            if (focusElement.attr("class") != null && focusElement.attr("class").includes("topLink") && focusElement.html() == lastMainNav) {
                $("#mainNavLvl li:first-child a").focus();
                e.preventDefault();
            }

            var lastBrandNav = $(".brandNav ul .brandLink:last-child a").html();



            if (focusElement.parent().attr("class") != null && focusElement.parent().hasClass("brandLink") && focusElement.html() == lastBrandNav) {


                $(".brandNav ul .brandLink:first-child a").focus();
                e.preventDefault();
            }


            if (focusElement.attr("class") != null && focusElement.attr("class").includes("listContainer")) {

                focusElement.find(".tertiary .tertiaryLvl h4 .tertiaryLink").first().focus();
                e.preventDefault();
            }

            if (focusElement.attr("class") != null && focusElement.attr("class").includes("tertiaryLink")) {
                focusElement.parent().parent().find(".nextLvl li a").first().focus();
                e.preventDefault();
            }


            if (focusElement.attr("class") != null && focusElement.attr("class").includes("plink")) {



                if (focusElement.parent().index() != focusElement.parent().parent().find(".plinkLI").last().index()) {
                    focusElement.parent().next().find("a").first().focus();
                }
                else {
                    focusElement.parent().parent().parent().next().find("h4 a").first().focus();
                }
                e.preventDefault();
            }


            // lets do the brand menu
            if (focusElement.attr("id") != null && focusElement.attr("id") == "byBrand") {
                focusElement.trigger({ type: 'click' });
                e.preventDefault();
            }


            if (focusElement.parent().attr("class") != null && focusElement.parent().attr("class").includes("brandLink")) {
                focusElement.parent().next().find("a").first().focus();
                e.preventDefault();
            }

        }
        if (e.keyCode == 38) {
            // we have a up link

            if (focusElement.attr("class") != null && focusElement.attr("class").includes("tertiaryLink")) {
                if (focusElement.parent().parent().parent().parent().parent().find("li h4 a").html() == focusElement.html()) {
                    processEscape();

                }
            }


            if (focusElement.attr("class") != null && focusElement.attr("class").includes("upperDropNav")) {

                //  console.log(focusElement.parent().parent().find("li:first").find("a").first().attr("id"));   
                //  console.log(focusElement.parent().find("a").first().attr("id"));

                if (focusElement.parent().parent().find("li:first").find("a").first().attr("id") == focusElement.parent().find("a").first().attr("id")) {
                    processEscape();
                }
                else {
                    focusElement.parent().prev("li").find("a").first().focus();
                }
                e.preventDefault();




            }

            // lets do the product nav
            if (focusElement.attr("class") != null && focusElement.attr("class").includes("topLink")) {

                if (prevElement.attr("class") != null) {
                    prevElement.find("a").first().focus();
                }
                else {

                    processEscape();
                }
                e.preventDefault();
            }

            if (focusElement.attr("class") != null && focusElement.attr("class").includes("plink")) {


                if (focusElement.parent().index() != 0) {
                    focusElement.parent().prev().find("a").first().focus();
                }
                else {
                    focusElement.parent().parent().parent().find("h4 a").first().focus();
                }
                e.preventDefault();
            }

            if (focusElement.attr("class") != null && focusElement.attr("class").includes("tertiaryLink")) {
                if (focusElement.parent().parent().prev() != null) {
                    focusElement.parent().parent().prev().find(".nextLvl .plinkLI").last().find("a").first().focus();
                }
                else {
                    processEscape();
                }
                e.preventDefault();
            }


            if (focusElement.parent().attr("class") != null && focusElement.parent().attr("class").includes("brandLink")) {
                if (focusElement.parent().prev().attr("class") != null) {
                    focusElement.parent().prev().find("a").first().focus();
                }
                else {
                    processEscape();
                }
                e.preventDefault();
            }

        }

        if (e.keyCode == 32) {
            // we have a space...

            if (focusElement.attr("class") != null && focusElement.attr("class").includes("upperNav")) {
                focusElement.parent().find("ul").css("left", "0px")
                focusElement.parent().find("ul").find("li").first().find("a").first().focus();
                escapeTarget = focusElement;
                // $(this).find("ul").css("left", "0px");

                e.preventDefault();
            }

            if (focusElement.attr("class") != null && focusElement.attr("class").includes("topLink")) {
                focusElement.trigger({ type: 'click' });
                escapeTarget = null;
                e.preventDefault();
            }

            if (focusElement.attr("id") != null && focusElement.attr("id").includes("byProd")) {

                focusElement.trigger({ type: 'click' });
                escapeTarget = null;
                e.preventDefault();
            }

            // lets do the brand menu
            if (focusElement.attr("id") != null && focusElement.attr("id").includes("byBrand")) {
                focusElement.trigger({ type: 'click' });
                escapeTarget = null;
                e.preventDefault();
            }



        }

        if (e.keyCode == 39) {
            // we have a right link
            if (focusElement.attr("id") != null && focusElement.attr("id").includes("byBrand")) {

                focusElement.parent().next('li').children("a").focus();
                // $("#byProd").focus();
                e.preventDefault();
            }

            // need to handle the new nav next to brands...
            if (focusElement.attr("class") != null && focusElement.attr("class").includes("upperNav")) {
                focusElement.parent().next('li').children("a").focus();
                escapeTarget = null;
            }

            // lets do the product nav
            if (focusElement.attr("class") != null && focusElement.attr("class").includes("topLink")) {

                focusElement.trigger({ type: 'click' });
                $(this).parent().children(".listContainer").find(".tertiary").first().find(".tertiaryLvl").first().find("h4 .tertiaryLink").focus();

                e.preventDefault();
            }
            if (focusElement.attr("class") != null && focusElement.attr("class").includes("listContainer")) {
                focusElement.find(".tertiary .tertiaryLvl h4 .tertiaryLink").first().focus();
                e.preventDefault();
            }
            // process flyout main nav right
            if (focusElement.attr("class") != null && focusElement.attr("class").includes("tertiaryLink")) {
                focusElement.parent().parent().next().find("h4 .tertiaryLink").first().focus();
                e.preventDefault();
            }
            // move to next main ul
            if (focusElement.attr("class") != null && focusElement.attr("class").includes("plink")) {
                focusElement.parent().parent().parent().next().find("h4 a").first().focus();
                e.preventDefault();
            }

        }

        if (e.keyCode == 37) {
            // we have a left link


            if (focusElement.attr("class") != null && focusElement.attr("class").includes("tertiaryLink")) {

                if (focusElement.parent().parent().parent().parent().parent().find("li h4 a").html() == focusElement.html()) {
                    processEscape();

                }
            }
            console.log(focusElement);
            if (focusElement.attr("id") != null && focusElement.attr("id") == "byBrand") {
                // alert("here");
                $("#byProd").focus();
                escapeTarget = null;
                e.preventDefault();
            }

            // need to handle the new nav next to brands...
            if (focusElement.attr("class") != null && focusElement.attr("class").includes("upperNav")) {
                focusElement.parent().prev('li').children("a").focus();
                escapeTarget = null;

            }

            if (focusElement.attr("id") != null && focusElement.attr("id") == "byProd") {
                // turning this off
                //$("#byBrand").focus();
                e.preventDefault();
                escapeTarget = null;
            }

            // lets do the product nav
            if (focusElement.attr("class") != null && focusElement.attr("class").includes("listContainer")) {
                processEscape();
                e.preventDefault();
            }
            // porcess flyout main nav left
            if (focusElement.attr("class") != null && focusElement.attr("class").includes("tertiaryLink")) {

                if (focusElement.parent().parent().prev().find("h4 .tertiaryLink").first() != null) {
                    focusElement.parent().parent().prev().find("h4 .tertiaryLink").first().focus();
                    e.preventDefault();
                }
                else {
                    focusElement.parent().parent().parent().parent().focus();
                    // processEscape();
                    e.preventDefault();
                    // handle the top escape
                }
            }
            // move to next main ul
            if (focusElement.attr("class") != null && focusElement.attr("class").includes("plink")) {
                focusElement.parent().parent().parent().prev().find("h4 a").first().focus();
                e.preventDefault();
            }


        }

        focusElement = $(document.activeElement);
        // console.log('after ' + focusElement.attr("class"));

    });



});
;
