AJS.menuShowCount=0;jQuery.fn.ajsMenu=function(A){A=A||{};var B=jQuery;var D=null;var C=function(E){if(typeof AJS.dropDownTimer!="undefined"&&AJS.dropDownHider){clearTimeout(AJS.dropDownTimer);delete AJS.dropDownTimer;AJS.dropDownHider();AJS.dropDownHider=null}};B(".ajs-button",this).each(function(){B(this).mouseover(C)});B(".ajs-menu-item",this).each(function(){var G=this,E=B(this),K=B(".ajs-drop-down",G);if(!K.length){return }K=K[0];K.hidden=true;K.focused=-1;K.hide=function(){if(!this.hidden){E.toggleClass("opened");B(G.parentNode).toggleClass("menu-bar-open");var N=B("a",this);B(this).toggleClass("hidden");this.hidden=true;B(document).unbind("click",this.fhide).unbind("keydown",this.fmovefocus).unbind("keypress",this.blocker);if(this.focused+1){B(N[this.focused]).removeClass("active")}this.focused=-1}};K.show=function(){if(typeof this.hidden=="undefined"||this.hidden){var N=this,R=B(this);R.toggleClass("hidden");E.toggleClass("opened");B(G.parentNode).toggleClass("menu-bar-open");this.hidden=false;this.timer=setTimeout(function(){B(document).click(N.fhide)},1);B(document).keydown(N.fmovefocus).keypress(N.blocker);var O=B("a",N);O.each(function(T){var S=this.parentNode.parentNode;B(this).hover(function(U){if(S.focused+1){B(O[S.focused].parentNode).removeClass("active")}B(this.parentNode).addClass("active");S.focused=T},function(U){if(S.focused+1){B(O[S.focused].parentNode).removeClass("active")}S.focused=-1})});var Q=(window.pageYOffset||document.documentElement.scrollTop);var P=Q+B(window).height();R.removeClass("above");if(!A.isFixedPosition){if(R.offset().top+R.height()>P){R.addClass("above");if(R.offset().top<Q){R.removeClass("above")}}}}};K.fmovefocus=function(N){K.movefocus(N)};K.fhide=function(N){K.hide(N)};K.blocker=function(N){var O=N.which;if(O==40||O==38){return false}};K.movefocus=function(P){var S=P.which,O=this.getElementsByTagName("a"),R=this.focused,N=(S==9),Q;do{switch(S){case 40:case 9:if(P.shiftKey){this.focused--}else{this.focused++}break;case 38:this.focused--;break;case 27:this.hide();return false;default:return true}Q=(this.focused<0||this.focused>O.length-1)}while(!Q&&B(O[this.focused].parentNode).hasClass("hidden"));if(N&&Q){if(R!=-1){B(O[R].parentNode).removeClass("active")}this.focused=-1;this.hide();return false}else{if(!N){if(this.focused<0){this.focused=O.length-1}else{if(this.focused>O.length-1){this.focused=0}}}}if(R>=0){B(O[R].parentNode).removeClass("active")}O[this.focused].focus();B(O[this.focused].parentNode).addClass("active");P.stopPropagation();P.preventDefault();return false};K.show();clearTimeout(K.timer);var H=B(K),F=H.offset();K.hide();if(F.left+H.width()>B(window).width()){H.css("margin-left","-"+((H.width())-(E.width()))+"px")}var J=B(".trigger",G);if(J.length){var L=function(){clearTimeout(AJS.dropDownTimer);delete AJS.dropDownTimer;AJS.dropDownHider();AJS.dropDownHider=null;K.show()};var M=function(O){var N=typeof AJS.dropDownTimer!="undefined";D=K;if(N){L()}else{AJS.dropDownShower=function(){K.show();delete AJS.dropDownShowerTimer};AJS.dropDownShowerTimer=setTimeout(AJS.dropDownShower,O)}};var I=function(N){var O=typeof AJS.dropDownShowerTimer!="undefined";if(O){clearTimeout(AJS.dropDownShowerTimer);delete AJS.dropDownShowerTimer}if(typeof AJS.dropDownTimer!="undefined"){clearTimeout(AJS.dropDownTimer);delete AJS.dropDownHider}AJS.dropDownHider=function(){K.hide();delete AJS.dropDownTimer};AJS.dropDownTimer=setTimeout(AJS.dropDownHider,N)};E.mouseover(function(){M(500)});E.mouseout(function(){I(300)});J.click(function(){if(K.hidden){K.show()}else{K.hide()}})}})};AJS.toInit(function(D){var B=["action-view-source-link","view-user-history-link"];for(var E=B.length;E--;){D("#"+B[E]).click(function(L){window.open(this.href,(this.id+"-popupwindow").replace(/-/g,"_"),"width=600, height=400, scrollbars, resizable");L.preventDefault();return false})}var F=function(L,M){var N=D("#ajax-error");if(N.length==0){D("#com-atlassian-confluence").prepend("<div id='ajax-error'></div>");N=D("#ajax-error")}N.append("<span class='error'>"+L+"<a class='close'>Close</a></span>");N.find("a.close").click(function(){var O=D(this).parent();D(O).slideUp(1000,function(){D(O).remove();if(D("#ajax-error").children(".error").length==0){D("#ajax-error").remove()}});return false});M.removeClass("waiting")};D("#page-favourite").click(function(N){var M=D(this);if(M.hasClass("waiting")){return AJS.stopEvent(N)}M.addClass("waiting");var L=AJS.Confluence.getContextPath()+"/json/addfavourite.action";if(M.hasClass("selected")){L=AJS.Confluence.getContextPath()+"/json/removefavourite.action"}AJS.safeAjax({url:L,type:"POST",dataType:"json",data:{entityId:AJS.params.pageId},success:function(P){if(P.actionErrors){for(var O=0;O<P.actionErrors.length;O++){F(P.actionErrors,M)}return }if(P.errorMessage){F(P.errorMessage,M);return }M.removeClass("waiting");M.toggleClass("selected");M.toggleClass("ie-page-favourite-selected")},error:function(O){F("Server error while updating favourite",M)}});return AJS.stopEvent(N)});var J=D("#page-watch"),K=D("#page-unwatch"),H=D(J.parent("li")),I=D(K.parent("li"));if(J.hasClass("inactive")){H.addClass("assistive")}if(K.hasClass("inactive")){I.addClass("assistive")}var G=function(L,M,N){M.addClass("waiting");AJS.safe.ajax({url:L,type:"POST",dataType:"json",data:{entityId:AJS.params.pageId},success:function(P){if(P.actionErrors){for(var O=0;O<P.actionErrors.length;O++){F(P.actionErrors,M)}return }if(P.errorMessage){F(P.errorMessage,M);return }M.removeClass("waiting");M.toggleClass("inactive");N.toggleClass("inactive");M.parent("li").toggleClass("assistive");N.parent("li").toggleClass("assistive")},error:function(O){M.removeClass("waiting");F("Server error while updating favourite",menuItem)}})};J.click(function(L){G(AJS.Confluence.getContextPath()+"/pages/startwatching.action",J,K);J.addClass("waiting");return AJS.stopEvent(L)});K.click(function(L){G(AJS.Confluence.getContextPath()+"/pages/stopwatching.action",K,J);K.addClass("waiting");return AJS.stopEvent(L)});var A=D("#action-menu-link"),C=D("#add-menu-link");if(A.length){A.next().addClass("most-right-menu-item")}else{if(C.length){C.next().addClass("most-right-menu-item")}}D(".ajs-menu-bar").ajsMenu({isFixedPosition:true})});AJS.$(function(A){A("#header-menu-bar .ajs-menu-item").each(function(){var C=A(this),D=A(".ajs-drop-down",this),B=C.width();if(B>D.width()){D.width(B.valueOf()+50);AJS.log("Dropdown width override occurred")}})});