/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.4.0 Release Candidate 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(S){var Q=F(S.target),R=Q.closest(".js-comp-menu-dropdown");if(!R.length){C(F(".js-comp-menu-dropdown"))}}function A(){var U=false,X,V,T,S;function Q(Y){U=new Date();X=Y.originalEvent.touches[0].pageX;V=Y.originalEvent.touches[0].pageY;T=0;S=0}function W(Y){T=X-Y.originalEvent.touches[0].pageX;S=V-Y.originalEvent.touches[0].pageY}function R(Z){var Y=(new Date())-U;if(Y<=400&&!T&&!S){M.call(this,Z)}}F(document).off("touchstart",Q).on("touchstart",Q).off("touchmove",W).on("touchmove",W).off("touchend",R).on("touchend",R)}function H(S){var R=F(S.target).closest(".js-comp-menu-dropdown");if(R.is(".b-comp-menu-dropdown--open")){C(R)}else{G(R)}var Q=F(".js-comp-menu-dropdown").filter(function(){return(F(this).get(0)!=R.get(0))});C(Q);return false}function B(R){var Q=F(R.target).closest(".js-comp-menu-dropdown");if(Q.length&&Q.is(".b-comp-menu-dropdown--open")){C(Q)}}function D(R){var Q=F(R.target);Q.closest(".js-comp-menu-dropdown").find(".js-comp-menu-dropdown__trigger-text").text(Q.text())}function O(Q,R,W){var V=R.find(".b-comp-menu-dropdown__content-item");W=Math.min(W,K);if(W>1){R.addClass("b-comp-menu-dropdown__content--"+W+"-column");var Y=!Q.is(".b-comp-menu-dropdown--open"),S="",U="";V.removeClass("b-comp-menu-dropdown__content-item--column-first b-comp-menu-dropdown__content-item--column-trailing");if(Y){Q.addClass("b-comp-menu-dropdown--open")}V.each(function(){var a=F(this),Z=a.position(),b=parseInt(Z.top,10);if(S===""){S=b}if(U===""){U=b}S=Math.min(S,b);U=Math.max(U,b)});V.each(function(){var a=F(this),Z=a.position(),b=parseInt(Z.top,10);if(b<=S){a.addClass("b-comp-menu-dropdown__content-item--column-first")}});var T=V.last();if(T.position().top<U){T.addClass("b-comp-menu-dropdown__content-item--column-trailing")}if(Y){Q.removeClass("b-comp-menu-dropdown--open")}}else{var X=K;while(X>1){R.removeClass("b-comp-menu-dropdown__content--"+X+"-column");--X}V.removeClass("b-comp-menu-dropdown__content-item--column-first b-comp-menu-dropdown__content-item--column-trailing")}}function J(T,R){if(T.is(".b-comp-menu-dropdown--open")){var S=R.outerHeight(),Q=R.outerWidth()}else{T.addClass("b-comp-menu-dropdown--open");var S=R.outerHeight(),Q=R.outerWidth();T.removeClass("b-comp-menu-dropdown--open")}return{width:Q,height:S}}function L(U){var V=F(window),Q=V.width(),S=V.height(),T=V.scrollLeft(),R=F(document).height();U.each(function(r,e){var d=F(e),z=d.offset(),t=d.find(".js-comp-menu-dropdown__trigger").outerHeight(),Y=d.find(".js-comp-menu-dropdown__trigger").outerWidth(),j=d.find(".js-comp-menu-dropdown__content"),h=j.find(".b-comp-menu-dropdown__content-item");j.css("width","auto");O(d,j,1);var AD=J(d,j),y=AD.height,u=AD.width;var AC=Math.max(Math.min(Math.floor(h.length/15),K),1);var Z=100,AB=Math.ceil(y/(S-Z));var b=Math.floor((Q-0)/u);b=Math.max(b,1);var s=Math.max(AC,AB);s=Math.min(s,K);s=Math.min(s,b);O(d,j,s);AD=J(d,j);y=AD.height;u=AD.width;var i=j.css("margin-top"),k=parseInt(i,10),x=t+y+k,v=z.top,l=R-v,AE=v>=y,p=l>=x,n=z.left,w=n-T+Y,g=Q-w+Y,c=w>=u,o=g>=u,a=[];if(AE&&!p){d.addClass("b-comp-menu-dropdown--direction-up");a.push("Forced up")}else{if(p&&!AE){d.removeClass("b-comp-menu-dropdown--direction-up");a.push("Forced down")}}var AA="",X="",q=0,m=0,W=0;if(c&&!o){j.removeClass("b-comp-menu-dropdown__content--left").addClass("b-comp-menu-dropdown__content--right");AA="right";X="left";a.push("Forced right alignment (opens left)")}else{if(o&&!c){j.removeClass("b-comp-menu-dropdown__content--right").addClass("b-comp-menu-dropdown__content--left");AA="left";X="right";a.push("Forced left alignment (opens right)")}else{if(!o&&!c){if(w>=g){j.removeClass("b-comp-menu-dropdown__content--left").addClass("b-comp-menu-dropdown__content--right");AA="right";X="left";m=u-w;W=g-Y;q=Math.min(m,W);a.push("Forced right alignment (opens left) (More space on left)")}else{j.removeClass("b-comp-menu-dropdown__content--right").addClass("b-comp-menu-dropdown__content--left");AA="left";X="right";m=u-g;W=w-Y;q=Math.min(m,W);a.push("Forced left alignment (opens right) (More space on right)")}}}}if(AA&&X){if(q>0){j.css(AA,"-"+q+"px");j.css(X,"auto")}else{j.css(AA,"0");j.css(X,"auto")}}var f=(W<m);if(f){j.css("width",Q).find(".b-comp-menu-dropdown__content-item").addClass("ellipsis").find("> a").addClass("ellipsis")}})}function E(){var Q=F(".js-comp-menu-dropdown").filter(function(){return(F(this).is(".b-comp-menu-dropdown--open"))});L(Q)}function N(){var R=F(".js-select-on-xsmall, .js-select-on-small"),S=F("body").is(".l-small"),Q=F("body").is(".l-xsmall");R.each(function(){var V=F(this),T=(V.data("vb-using-select")||"0")=="1",U=((V.is(".js-select-on-xsmall")&&Q)||(V.is(".js-select-on-small")&&S));if(U&&!T){I(V).removeClass("h-hide-imp").selectBox();V.addClass("h-hide-imp").data("vb-using-select","1")}else{if(!U&&T){I(V).selectBox("destroy").addClass("h-hide-imp");V.removeClass("h-hide-imp").data("vb-using-select","0")}}})}function I(S){var Q=S.data("vb-select-el");if(!Q){Q=F("<select></select>");F("<option></option>").text(S.find(".js-comp-menu-dropdown__trigger").text()).appendTo(Q);S.find(".js-comp-menu-dropdown__content .b-comp-menu-dropdown__content-item").each(function(T,X){var Y=F(this),U=Y.is(".b-comp-menu-dropdown__content-item--current"),V=Y.find("> a"),W=V.html()||Y.html();F("<option></option>").html(W).data("vb-option-link",V).appendTo(Q);if(U){Q.get(0).selectedIndex=T}});Q.addClass("b-comp-menu-dropdown__select").on("change",function(U){var T=U.target;idx=T.selectedIndex,opt=T.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(V){var W=$link.data("href");if(W){window.location.href=W;V.preventDefault()}});$link.click()}}).insertAfter(S);var R=S.data("add-classes-to-select-el");if(R){Q.addClass(R)}S.data("vb-select-el",Q)}return Q}function G(Q){L(Q);Q.addClass("b-comp-menu-dropdown--open");Q.find(".js-comp-menu-dropdown__trigger-arrow").removeClass("b-icon--disabled")}function C(Q){Q.removeClass("b-comp-menu-dropdown--open");Q.find(".js-comp-menu-dropdown__trigger-arrow").addClass("b-icon--disabled")}function P(){var R=F(".js-comp-menu-dropdown__trigger").filter(function(){return(F(this).data("comp-menu-dropdown-initialized")!="1")});R.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();R.each(function(T,V){var S=F(V);if(S.is(".b-comp-menu-dropdown__trigger--arrow")){var U=S.find(".js-comp-menu-dropdown__trigger-arrow");if(U.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(S)}}});F(".js-comp-menu-dropdown").removeClass("b-comp-menu-dropdown--open-on-hover");N();var Q=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")});Q.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(N)}window.vBulletin.jsexec.css_b_comp_menu_dropdown.init++}vBulletin.CompMenuDropdown.init=P;vBulletin.CompMenuDropdown.updateMenuFormat=E;vBulletin.CompMenuDropdown.updateMenuAsSelectElement=N;F(P)})(jQuery);