/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.4.1
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2018 vBulletin Solutions Inc. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
window.vBulletin=window.vBulletin||{};window.vBulletin.phrase=window.vBulletin.phrase||{};window.vBulletin.phrase.precache=window.vBulletin.phrase.precache||[];window.vBulletin.phrase.precache=$.merge(window.vBulletin.phrase.precache,[]);window.vBulletin.CompMenuDropdown=window.vBulletin.CompMenuDropdown||{};window.vBulletin.jsexec=window.vBulletin.jsexec||{};window.vBulletin.jsexec.css_b_comp_menu_dropdown=window.vBulletin.jsexec.css_b_comp_menu_dropdown||{exec:0,init:0};window.vBulletin.jsexec.css_b_comp_menu_dropdown.exec++;(function(F){var K=4;function M(T){var R=F(T.target),S=R.closest(".js-comp-menu-dropdown");if(!S.length){C(F(".js-comp-menu-dropdown"))}}function A(){var V=false,Y,W,U,T;function R(Z){V=new Date();Y=Z.originalEvent.touches[0].pageX;W=Z.originalEvent.touches[0].pageY;U=0;T=0}function X(Z){U=Y-Z.originalEvent.touches[0].pageX;T=W-Z.originalEvent.touches[0].pageY}function S(a){var Z=(new Date())-V;if(Z<=400&&!U&&!T){M.call(this,a)}}F(document).off("touchstart",R).on("touchstart",R).off("touchmove",X).on("touchmove",X).off("touchend",S).on("touchend",S)}function H(T){var S=F(T.target).closest(".js-comp-menu-dropdown");if(S.is(".b-comp-menu-dropdown--open")){C(S)}else{G(S)}var R=F(".js-comp-menu-dropdown").filter(function(){return(F(this).get(0)!=S.get(0))});C(R);return false}function B(S){var R=F(S.target).closest(".js-comp-menu-dropdown");if(R.length&&R.is(".b-comp-menu-dropdown--open")){C(R)}}function D(S){var R=F(S.target);R.closest(".js-comp-menu-dropdown").find(".js-comp-menu-dropdown__trigger-text").text(R.text())}function P(R,S,X){var W=S.find(".b-comp-menu-dropdown__content-item");X=Math.min(X,K);if(X>1){S.addClass("b-comp-menu-dropdown__content--"+X+"-column");var Z=!R.is(".b-comp-menu-dropdown--open"),T="",V="";W.removeClass("b-comp-menu-dropdown__content-item--column-first b-comp-menu-dropdown__content-item--column-trailing");if(Z){R.addClass("b-comp-menu-dropdown--open")}W.each(function(){var b=F(this),a=b.position(),c=parseInt(a.top,10);if(T===""){T=c}if(V===""){V=c}T=Math.min(T,c);V=Math.max(V,c)});W.each(function(){var b=F(this),a=b.position(),c=parseInt(a.top,10);if(c<=T){b.addClass("b-comp-menu-dropdown__content-item--column-first")}});var U=W.last();if(U.position().top<V){U.addClass("b-comp-menu-dropdown__content-item--column-trailing")}if(Z){R.removeClass("b-comp-menu-dropdown--open")}}else{var Y=K;while(Y>1){S.removeClass("b-comp-menu-dropdown__content--"+Y+"-column");--Y}W.removeClass("b-comp-menu-dropdown__content-item--column-first b-comp-menu-dropdown__content-item--column-trailing")}}function J(U,S){if(U.is(".b-comp-menu-dropdown--open")){var T=S.outerHeight(),R=S.outerWidth()}else{U.addClass("b-comp-menu-dropdown--open");var T=S.outerHeight(),R=S.outerWidth();U.removeClass("b-comp-menu-dropdown--open")}return{width:R,height:T}}function L(V){var W=F(window),R=W.width(),T=W.height(),U=W.scrollLeft(),S=F(document).height();V.each(function(s,f){var e=F(f),AA=e.offset(),u=e.find(".js-comp-menu-dropdown__trigger").outerHeight(),Z=e.find(".js-comp-menu-dropdown__trigger").outerWidth(),k=e.find(".js-comp-menu-dropdown__content"),i=k.find(".b-comp-menu-dropdown__content-item");k.css("width","auto");P(e,k,1);var AE=J(e,k),z=AE.height,v=AE.width;var AD=Math.max(Math.min(Math.floor(i.length/15),K),1);var a=100,AC=Math.ceil(z/(T-a));var c=Math.floor((R-0)/v);c=Math.max(c,1);var t=Math.max(AD,AC);t=Math.min(t,K);t=Math.min(t,c);P(e,k,t);AE=J(e,k);z=AE.height;v=AE.width;var j=k.css("margin-top"),l=parseInt(j,10),y=u+z+l,w=AA.top,m=S-w,AF=w>=z,q=m>=y,o=AA.left,x=o-U+Z,h=R-x+Z,d=x>=v,p=h>=v,b=[];if(AF&&!q){e.addClass("b-comp-menu-dropdown--direction-up");b.push("Forced up")}else{if(q&&!AF){e.removeClass("b-comp-menu-dropdown--direction-up");b.push("Forced down")}}var AB="",Y="",r=0,n=0,X=0;if(d&&!p){k.removeClass("b-comp-menu-dropdown__content--left").addClass("b-comp-menu-dropdown__content--right");AB="right";Y="left";b.push("Forced right alignment (opens left)")}else{if(p&&!d){k.removeClass("b-comp-menu-dropdown__content--right").addClass("b-comp-menu-dropdown__content--left");AB="left";Y="right";b.push("Forced left alignment (opens right)")}else{if(!p&&!d){if(x>=h){k.removeClass("b-comp-menu-dropdown__content--left").addClass("b-comp-menu-dropdown__content--right");AB="right";Y="left";n=v-x;X=h-Z;r=Math.min(n,X);b.push("Forced right alignment (opens left) (More space on left)")}else{k.removeClass("b-comp-menu-dropdown__content--right").addClass("b-comp-menu-dropdown__content--left");AB="left";Y="right";n=v-h;X=x-Z;r=Math.min(n,X);b.push("Forced left alignment (opens right) (More space on right)")}}}}if(AB&&Y){if(r>0){k.css(AB,"-"+r+"px");k.css(Y,"auto")}else{k.css(AB,"0");k.css(Y,"auto")}}var g=(X<n);if(g){k.css("width",R).find(".b-comp-menu-dropdown__content-item").addClass("ellipsis").find("> a").addClass("ellipsis")}})}function E(){var R=F(".js-comp-menu-dropdown").filter(function(){return(F(this).is(".b-comp-menu-dropdown--open"))});L(R)}function O(){var S=F(".js-select-on-xsmall, .js-select-on-small"),T=F("body").is(".l-small"),R=F("body").is(".l-xsmall");S.each(function(){var W=F(this),U=(W.data("vb-using-select")||"0")=="1",V=((W.is(".js-select-on-xsmall")&&R)||(W.is(".js-select-on-small")&&T));if(V&&!U){I(W).removeClass("h-hide-imp").selectBox();W.addClass("h-hide-imp").data("vb-using-select","1")}else{if(!V&&U){I(W).selectBox("destroy").addClass("h-hide-imp");W.removeClass("h-hide-imp").data("vb-using-select","0")}}})}function I(T){var R=T.data("vb-select-el");if(!R){R=F("<select></select>");var U=(T.find(".b-comp-menu-dropdown__content-item.b-comp-menu-dropdown__content-item--current").length==1);if(!U){F("<option></option>").addClass("js-noop-label").text(T.find(".js-comp-menu-dropdown__trigger").text()).appendTo(R)}T.find(".js-comp-menu-dropdown__content .b-comp-menu-dropdown__content-item").each(function(V,Z){var a=F(this),W=a.is(".b-comp-menu-dropdown__content-item--current"),X=a.find("> a"),Y=X.html()||a.html();F("<option></option>").html(Y).data("vb-option-link",X).appendTo(R);if(W){R.get(0).selectedIndex=V}});R.addClass("b-comp-menu-dropdown__select").on("change",function(W){var V=W.target;idx=V.selectedIndex,opt=V.options[idx],$link=F(opt).data("vb-option-link"),linkHref=$link?$link.attr("href"):null;if(linkHref&&linkHref.substr(0,1)!="#"){window.location.href=linkHref}else{$link.one("click",function(X){var Y=$link.data("href");if(Y){window.location.href=Y;X.preventDefault()}});$link.click()}}).insertAfter(T);var S=T.data("add-classes-to-select-el");if(S){R.addClass(S)}T.data("vb-select-el",R)}return R}function N(){var R=F(".js-select-on-xsmall, .js-select-on-small");R.each(function(){var T=F(this),S=T.data("vb-select-el");if(S){var U=S.nextAll(".selectBox");U=U.not(U.first());U.remove()}})}function G(R){R.addClass("b-comp-menu-dropdown--open");L(R);R.find(".js-comp-menu-dropdown__trigger-arrow").removeClass("b-icon--disabled")}function C(R){R.removeClass("b-comp-menu-dropdown--open");R.find(".js-comp-menu-dropdown__trigger-arrow").addClass("b-icon--disabled")}function Q(){var S=F(".js-comp-menu-dropdown__trigger").filter(function(){return(F(this).data("comp-menu-dropdown-initialized")!="1")});S.off("click",H).on("click",H).attr("tabindex","0").addClass("js-button").data("comp-menu-dropdown-initialized","1");F(document).off("click",M).on("click",M);A();S.each(function(U,W){var T=F(W);if(T.is(".b-comp-menu-dropdown__trigger--arrow")){var V=T.find(".js-comp-menu-dropdown__trigger-arrow");if(V.length<1){F('<span class="vb-icon b-icon__arrow-down-s b-icon--disabled js-comp-menu-dropdown__trigger-arrow h-align-middle"></span>').appendTo(T)}}});F(".js-comp-menu-dropdown").removeClass("b-comp-menu-dropdown--open-on-hover");O();F(document).off("vb-filterposts",N).on("vb-filterposts",N);var R=F(".b-comp-menu-dropdown__content-item:not(.js-comp-menu-dropdown__content-maintain-menu)").filter(function(){return(F(this).data("comp-menu-dropdown__content-close-menu-initialized")!="1")});R.off("click",B).on("click",B).attr("data-comp-menu-dropdown__content-close-menu-initialized","1");F(".js-comp-menu-dropdown--display-current").off("click",".b-comp-menu-dropdown__content-item",D).on("click",".b-comp-menu-dropdown__content-item",D);if(window.vBulletin.jsexec.css_b_comp_menu_dropdown.init<1){vBulletin.Responsive.Debounce.registerCallback(E);vBulletin.Responsive.Debounce.registerCallback(O)}window.vBulletin.jsexec.css_b_comp_menu_dropdown.init++}vBulletin.CompMenuDropdown.init=Q;vBulletin.CompMenuDropdown.updateMenuFormat=E;vBulletin.CompMenuDropdown.updateMenuAsSelectElement=O;vBulletin.CompMenuDropdown.setMenuColumnCount=P;F(Q)})(jQuery);