AJS.toInit(function(a){AJS.applySearchPlaceholders=function(c){var b=a(".quick-search-query, input[type=search]",c);if(!b.length){return}b.each(function(){var d=a(this);d.data("quicksearch",{placeholder:d.attr("placeholder")||d.closest("form").find("input[type='submit']").val(),placeholded:true})});if(!a.browser.safari){b.val(b.data("quicksearch").placeholder);b.addClass("placeholded");b.focus(function(){var d=a(this);if(d.data("quicksearch").placeholded){d.data("quicksearch").placeholded=false;d.val("");d.removeClass("placeholded")}});b.blur(function(){var d=a(this);if(d.data("quicksearch").placeholder&&(/^\s*$/).test(d.val())){d.val(d.data("quicksearch").placeholder);d.data("quicksearch").placeholded=true;d.addClass("placeholded")}})}else{b.each(function(){this.type="search"});b.attr("results",10);b.attr("placeholder",b.data("quicksearch").placeholder);b.val("")}};AJS.applySearchPlaceholders();a("#messageContainer .confluence-messages").each(function(){var b=this;if(!getCookie(b.id)){a(b).show();a(".message-close-button",b).click(function(){a(b).slideUp();setCookie(b.id,true)})}})});AJS.General={getContextPath:Confluence.getContextPath,getBaseUrl:Confluence.getBaseUrl};(function(){var a={};AJS.I18n={keys:{},get:function(g,b,c){var e=true,d=Confluence.getContextPath()+"/rest/prototype/1/i18n",h={locale:AJS.params.userLocale};if(AJS.$.isArray(g)){for(var f in g){if(!a[f]){e=false}}h.pluginKeys=g}else{e=a[g];d+="/"+g}if(e){if(typeof b=="function"){b(AJS.I18n.keys)}return}AJS.$.ajax({url:d,data:h,dataType:"json",success:function(i){AJS.I18n.load(i);a[g]=true;if(typeof b=="function"){b(i)}},error:function(i,j){AJS.log("Error loading I18n for "+g+":"+j);if(typeof c=="function"){c(j)}}})},load:function(b){AJS.$.extend(AJS.I18n.keys,b)},getText:function(b,c){var d=AJS.params["i18n."+b]||AJS.I18n.keys[b]||b;if(!c){return d}if(arguments.length==2&&c instanceof Array){c.unshift(d)}else{c=Array.prototype.slice.call(arguments,0);c[0]=d}return AJS.format.apply(AJS,c)}}})();jQuery.fn.selectableEffects=function(a,b,c){var e=jQuery,d=e(this);if(c){d.data("properties",c)}d.click(function(g){var f=e(this);if(b){b(this,f.data("properties"))}a.find(".selected").removeClass("selected");f.addClass("selected");return AJS.stopEvent(g)});d.hover(function(){e(this).addClass("hover")},function(){e(this).removeClass("hover")})};jQuery.fn.shortenUntil=function(d){var b=jQuery;var c=0;while(!d()&&c<this.length){var a=b(this[c]).text();if(a=="\u2026"){c++;continue}b(this[c]).text(a.replace(/[^\u2026]\u2026?$/,"\u2026"))}return this};
AJS.html=function(a){var b=new String(a);b.isHtml=true;return b};AJS.toInit(function(b){var a={};AJS.loadTemplateScripts=function(e){e=e||document;b("script",e).each(function(){if(this.type=="text/x-template"){a[this.title]=AJS.html(this.text)}})};AJS.loadTemplateScripts();AJS.getTemplate=function(e){return a[e]};var d={"&":"&amp;","<":"&lt;",">":"&gt;","'":"&#39;",'"':"&quot;"};AJS.escapeEntities=function(e){if(e==null){return e}if(e.isHtml){return""+e}return(""+e).replace(/[&<>'"]/g,function(f){return d[f]||f})};function c(f){var e=arguments;return f.replace(/\{(\d+)\}/g,function(j,g){var h=e[parseInt(g,10)+1];return h!=null?h:j})}AJS.renderTemplate=function(e,f){if(!AJS.getTemplate(e)){return""}if(!b.isArray(f)){f=Array.prototype.slice.call(arguments,1)}var j=AJS.getTemplate(e).toString();var h=[j];for(var g=0;g<f.length;g++){h.push(AJS.escapeEntities(f[g]))}return c.apply(this,h)};AJS.loadTemplatesFromUrl=function(e,g){var f=AJS.Meta.get("static-resource-url-prefix");if(e.indexOf("http")!=0&&e.indexOf(f)!=0){e=f+e}b.ajax({url:e,data:{locale:AJS.params.userLocale},dataType:"html",success:function(h){var i=AJS("div").append(h);AJS.loadTemplateScripts(i);g&&g()}})};AJS.loadWebResourceTemplates=function(e,g,h){var f="/download/resources/"+e+"/"+g;return this.loadTemplatesFromUrl(f,h)}});
AJS.menuShowCount=0;jQuery.fn.ajsMenu=function(i){i=i||{};var c=jQuery;var g=null;var f=function(j){if(typeof AJS.dropDownTimer!="undefined"&&AJS.dropDownHider){clearTimeout(AJS.dropDownTimer);delete AJS.dropDownTimer;AJS.dropDownHider();AJS.dropDownHider=null}};var d=function(){return c(".ajs-menu-bar.menu-bar-open").length>0};var h=function(j){c(j).closest(".ajs-menu-bar").find(".ajs-drop-down").each(function(k){this.hide()})};var e=function(j){return c(j).closest(".ajs-menu-bar").hasClass("menu-bar-open")};var b=function(j){c(j).closest(".ajs-menu-bar").addClass("menu-bar-open")};var a=function(j){c(j).closest(".ajs-menu-bar").removeClass("menu-bar-open")};c(".ajs-button",this).each(function(){c(this).mouseover(function(){var k=this;var m=e(k);h(k);if(m){var l=c(document);var j=function(){a(k);return false};l.unbind("click.menu");setTimeout(function(){l.one("click.menu",j)},1);b(k)}})});c(".ajs-menu-item",this).each(function(){var l=this,j=c(this),p=c(".ajs-drop-down",l);if(!p.length){return}p=p[0];p.hidden=true;p.focused=-1;p.hide=function(){if(!this.hidden){j.toggleClass("opened");var t=c(l.parentNode);if(t.find(".opened").length==0){a(l)}var s=c("a",this);c(this).toggleClass("assistive");this.hidden=true;c(document).unbind("click",this.fhide).unbind("keydown",this.fmovefocus).unbind("keypress",this.blocker);if(this.focused+1){c(s[this.focused]).removeClass("active")}this.focused=-1}};p.show=function(){if(typeof this.hidden=="undefined"||this.hidden){var s=this,w=c(this);w.toggleClass("assistive");j.toggleClass("opened");b(l);this.hidden=false;this.timer=setTimeout(function(){c(document).click(s.fhide)},1);c(document).keydown(s.fmovefocus).keypress(s.blocker);var t=c("a",s);t.each(function(y){var x=this.parentNode.parentNode;c(this).hover(function(z){if(x.focused+1){c(t[x.focused].parentNode).removeClass("active")}c(this.parentNode).addClass("active");x.focused=y},function(z){if(x.focused+1){c(t[x.focused].parentNode).removeClass("active")}x.focused=-1})});var v=(window.pageYOffset||document.documentElement.scrollTop);var u=v+c(window).height();w.removeClass("above");if(!i.isFixedPosition){if(w.offset().top+w.height()>u){w.addClass("above");if(w.offset().top<v){w.removeClass("above")}}}}};p.isMenuBarOpened=function(){return e(p)};p.closeOthers=function(){h(p)};p.fmovefocus=function(s){p.movefocus(s)};p.fhide=function(s){p.hide(s);return AJS.$(s.target).closest(".ajs-drop-down").length>0};p.blocker=function(s){var t=s.which;if(t==40||t==38){return false}};p.movefocus=function(u){var x=u.which,t=this.getElementsByTagName("a"),w=this.focused,s=(x==9),v;do{switch(x){case 40:case 9:if(u.shiftKey){this.focused--}else{this.focused++}break;case 38:this.focused--;break;case 27:this.hide();return false;default:return true}v=(this.focused<0||this.focused>t.length-1)}while(!v&&c(t[this.focused].parentNode).hasClass("assistive"));if(s&&v){if(w!=-1){c(t[w].parentNode).removeClass("active")}this.focused=-1;this.hide();return false}else{if(!s){if(this.focused<0){this.focused=t.length-1}else{if(this.focused>t.length-1){this.focused=0}}}}if(w>=0){c(t[w].parentNode).removeClass("active")}t[this.focused].focus();c(t[this.focused].parentNode).addClass("active");u.stopPropagation();u.preventDefault();return false};p.show();clearTimeout(p.timer);var m=c(p),k=m.offset();p.hide();var o=c(".trigger",l);if(o.length){var q=function(){clearTimeout(AJS.dropDownTimer);delete AJS.dropDownTimer;AJS.dropDownHider();AJS.dropDownHider=null;p.show()};var r=function(t){var s=typeof AJS.dropDownTimer!="undefined";g=p;if(s){q()}else{AJS.dropDownShower=function(){p.show();delete AJS.dropDownShowerTimer};AJS.dropDownShowerTimer=setTimeout(AJS.dropDownShower,t)}};var n=function(s){var t=typeof AJS.dropDownShowerTimer!="undefined";if(t){clearTimeout(AJS.dropDownShowerTimer);delete AJS.dropDownShowerTimer}if(typeof AJS.dropDownTimer!="undefined"){clearTimeout(AJS.dropDownTimer);delete AJS.dropDownHider}AJS.dropDownHider=function(){p.hide();delete AJS.dropDownTimer};AJS.dropDownTimer=setTimeout(AJS.dropDownHider,s)};j.mouseover(function(){if(p.isMenuBarOpened()){if(p.hidden){h(p);p.show()}}else{j.addClass("hover")}});j.mouseout(function(){if(!p.isMenuBarOpened()){j.removeClass("hover")}});o.click(function(){if(p.hidden){o.parent("li").removeClass("hover");var s=d();p.show();return s}else{p.hide();o.parent("li").addClass("hover");return false}})}})};AJS.toInit(function(c){c("#view-user-history-link").click(function(j){window.open(this.href,(this.id+"-popupwindow").replace(/-/g,"_"),"width=600, height=400, scrollbars, resizable");j.preventDefault();return false});var d=function(j,k){var l=c("#ajax-error");if(l.length==0){c("#com-atlassian-confluence").prepend("<div id='ajax-error'></div>");l=c("#ajax-error")}l.append("<span class='error'>"+j+"<a class='close'>Close</a></span>");l.find("a.close").click(function(){var m=c(this).parent();c(m).slideUp(1000,function(){c(m).remove();if(c("#ajax-error").children(".error").length==0){c("#ajax-error").remove()}});return false});k.removeClass("waiting")};c("#page-favourite").click(function(l){var k=c(this);if(k.hasClass("waiting")){return AJS.stopEvent(l)}k.addClass("waiting");var j=Confluence.getContextPath()+"/json/addfavourite.action";if(k.hasClass("selected")){j=Confluence.getContextPath()+"/json/removefavourite.action"}AJS.safeAjax({url:j,type:"POST",dataType:"json",data:{entityId:AJS.params.pageId},success:function(n){if(n.actionErrors){for(var m=0;m<n.actionErrors.length;m++){d(n.actionErrors,k)}return}if(n.errorMessage){d(n.errorMessage,k);return}k.removeClass("waiting");k.toggleClass("selected");k.toggleClass("ie-page-favourite-selected")},error:function(m){d("Server error while updating favourite",k)}});return AJS.stopEvent(l)});var h=c("#page-watch"),i=c("#page-unwatch"),e=c(h.parent("li")),g=c(i.parent("li"));if(h.hasClass("inactive")){e.addClass("assistive")}if(i.hasClass("inactive")){g.addClass("assistive")}var f=function(j,k,l){k.addClass("waiting");AJS.safe.ajax({url:j,type:"POST",dataType:"json",data:{entityId:AJS.params.pageId},success:function(n){if(n.actionErrors){for(var m=0;m<n.actionErrors.length;m++){d(n.actionErrors,k)}return}if(n.errorMessage){d(n.errorMessage,k);return}k.removeClass("waiting");k.toggleClass("inactive");l.toggleClass("inactive");k.parent("li").toggleClass("assistive");l.parent("li").toggleClass("assistive")},error:function(m){k.removeClass("waiting");d("Server error while updating favourite",menuItem)}})};h.click(function(j){f(Confluence.getContextPath()+"/pages/startwatching.action",h,i);h.addClass("waiting");return AJS.stopEvent(j)});i.click(function(j){f(Confluence.getContextPath()+"/pages/stopwatching.action",i,h);i.addClass("waiting");return AJS.stopEvent(j)});var a=c("#action-menu-link"),b=c("#add-menu-link");if(a.length){a.next().addClass("most-right-menu-item")}else{if(b.length){b.next().addClass("most-right-menu-item")}}c(".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")}})});
jQuery.fn.simpleScrollTo=function(c){var e=jQuery;var a=e(this[0]);var b=e(c).position().top;var d=b+e(c).outerHeight()-a.outerHeight();if(b<0){a.scrollTop(a.scrollTop()+b)}else{if(d>0){a.scrollTop(a.scrollTop()+d)}}return this};
AJS.toInit(function(a){a("a#websudo-drop.drop-non-websudo").click(function(){a.getJSON(a(this).attr("href"),function(){a("li#confluence-message-websudo-message").slideUp()});return false})});

