var XWiki=(function(b){Object.extend(b,{userprofile:{init:function(){this.crtCategory="";this.tabsContainer=$("user-vertical-menu");if(!this.tabsContainer){return}this.tabsContainer.select(".category-tab").each(function(c){c.observe("click",function(d){Event.stop(d);this.switchTab(c.id,true)}.bindAsEventListener(this))}.bind(this));this.tabsContainer.select(".category-tab.current").each(function(c){this.updateCategoryFields(c.id);document.fire("xwiki:profile:switchedCategory",{category:c.id})}.bind(this));this.handleCancelAction();window.addEventListener("popstate",function(c){if(c.state&&c.state.category){this.switchTab("vertical-menu-"+c.state.category)}}.bindAsEventListener(this));history.replaceState({category:window.location.search.toQueryParams().category||"profile"},document.title,document.location.href)},switchTab:function(d,c){var e=d.substring(14);$("user-page-content").select("div.user-page-pane").each(function(f){f.addClassName("hidden")});$(e+"Pane").removeClassName("hidden");$("user-vertical-menu").select("span.category-tab").each(function(f){f.removeClassName("current")});$(d).addClassName("current");this.updateCategoryFields(d);if(c){this.updateURL(e)}document.fire("xwiki:profile:switchedCategory",{category:d})},updateCategoryFields:function(c){c=c.substring(14);this.crtCategory=c;this.updateField("xredirect",b.currentDocument.getURL("view","category="+c));this.updateField("xcontinue",b.currentDocument.getURL("edit","editor=inline&category="+c));this.updateField("category",c)},updateURL:function(c){if(history.pushState){var e=window.location.search.toQueryParams();e.category=c;newQueryString=Object.toQueryString(e);var d=window.location.protocol+"//"+window.location.host+window.location.pathname+"?"+newQueryString;window.history.pushState({category:c},"",d)}},updateField:function(e,d){var c=$$("input[name="+e+"]");if(c&&c.size()>0){c[0].value=d}},handleCancelAction:function(){var d=$$("form .buttons input[type=submit][name=action_cancel]");if(d&&d.size()>0){var c=d[0];Event.stopObserving(c,"click");c.observe("click",function(e){e.stop();window.location=b.currentDocument.getURL("view","category="+this.crtCategory)}.bindAsEventListener(this))}}}});var a=function(){b.userprofile.init();return true};(b.domIsLoaded&&a())||document.observe("xwiki:dom:loaded",a);document.observe("lightbox:userprofile:loaded",a);return b}(XWiki||{}));