var c={GetChanges:["pagetime","filetime","permtime","foldertime","commenttime"],GetFileUsers:["permtime"],GetFolderUsers:["permtime"],GetHypotheticalUsers:["permtime","foldertime"],GetObjectsNOM:["foldertime","pagetime","filetime","permtime"],GetPage:["pagetime","foldertime","permtime"],GetPageUsers:["permtime"],GetTags:["tagtime"],GetUsersInfos:["permtime","grouptime"],ListNetworkGroupUsers:["net_grouptime","net_permtime"],ListWorkspaceGroupUsers:["grouptime","permtime"],Search:["pagetime","filetime","permtime","foldertime"],SetPageLock:["pagetime"]};var PBcacheability=PBcacheability||c;if(Object.extend){Object.extend(PBcacheability,c)}var c={kEditorV3PrefsKey:"v3p",kPolicyPageSizeWarning:51200,kPolicyConvertSupportedDocumentRegex:"/\\.(csv|doc|docx|ods|odt|rtf|txt|wpd|xls|xlsx)$/",kInvalidPageCharacters:".[]?&|/\\+#%",kPolicySimpleTimeFormat:"%l:%M %p",kFoldersDefaultHeight:200,kRecentChangesNumber:7,kRecentChangesMax:12,kWorkspaceTreeOpenNodes:"workspace_open_folders",kScrollAreaBlockSize:50,kSendALinkAllUsersWithAccess:"all-users-with-access",kSendALinkType:{Page:"page",File:"file",Folder:"folder",Milestone:"milestone",Task:"task",Unknown:"item"}};var PBconst=PBconst||c;if(Object.extend){Object.extend(PBconst,c)}PBwiki.Components=PBwiki.Components||{};PBwiki.Components.ScrollArea=Class.create({initialize:function(A){this.options=Object.extend({distanceThreshold:1,blockSize:PBconst.kScrollAreaBlockSize,scrollInterval:300,endInterval:200},A);try{this.setup(A.count,A.itm)}catch(B){this.options.elm.update(B.message+" "+B.line)}},onScroll:function(A){if(this.endTimeout){clearTimeout(this.endTimeout);delete this.endTimeout}this.endTimeout=setTimeout(this.checkAddBlocks.bind(this),this.options.endInterval);if(!this.scrollTimeout&&this.doScrollLoading){this.scrollTimeout=setTimeout(function(){delete this.scrollTimeout;this.checkAddBlocks()}.bind(this),this.options.scrollInterval)}},posToNodeNumber:function(A){return Math.round(A/this.options.height)+Math.round(this.numVisible/2)},nodeNumToBlockNum:function(A){return(A>this.options.count)?Math.floor(this.options.count/this.options.blockSize):Math.floor(A/this.options.blockSize)},posToBlockNum:function(A){return this.nodeNumToBlockNum(this.posToNodeNumber(A))},checkAddBlocks:function(){var A=Math.max(0,this.options.elm.scrollTop-(this.options.visibleHeight*this.options.distanceThreshold));var B=Math.min(this.totalHeight,this.options.elm.scrollTop+this.options.visibleHeight+(this.options.visibleHeight*this.options.distanceThreshold));var C=$R(this.posToBlockNum(A),this.posToBlockNum(B));C.each(function(D){if(this.blocks[D]){return }this.loadBlock(D)},this)},loadBlock:function(C,B){var A=Object.clone(this.options.args);if(B){A.anchor=B;delete A.offset}else{A.offset=C*this.options.blockSize}A.count=this.options.blockSize;new PBwiki.APIRequest(this.options.op,A,{onSuccess:this.blockLoaded.bind(this,C),cacheability:this.options.cacheTimes,key:this.options.key})},blockLoaded:function(B,E){var A=E._block||B;var D=A*this.options.blockSize;this.blocks[A]=true;this.lastAPIResult=E;if(E._total_count!==this.options.count){this.setCount(E._total_count)}if(!this.firstBlockLoaded){this.firstBlockLoaded=true;this.notify("onFirstBlock",E)}if(E._anchor){var F=E._anchor*this.options.height;this.options.elm.setAttribute("_scrollTop",F);this.options.elm.scrollTop=F}for(var C=0;C<E[this.options.dataKey].length;C++){this.loadNode(D+C,E[this.options.dataKey][C])}if(!E._total_count){this.setEmptyMsg();return }this.setLoadingStatus(false)},loadNode:function(B,A){if(this.nodes[B]){return }this.nodes[B]=new Element("div").addClassName(this.options.nodeClass).setStyle({zoom:1,position:"absolute",top:(B*this.options.height)+"px"});if(B%2==1){this.nodes[B].addClassName("alternate")}this.container.appendChild(this.nodes[B]);this.notify("onRowRender",this.nodes[B],A,null,B)},setup:function(A,B){this.nodes={};this.blocks={};this.options.count=A;if(A===0){return this.setEmptyMsg()}if(!this.container){this.container=new Element("div");this.options.elm.appendChild(this.container);this.scrollHandler=this.onScroll.bind(this);this.options.elm.observe("scroll",this.scrollHandler);this.setLoadingStatus(true)}this.setVisibleHeight();this.doScrollLoading=PBwiki.Data.getInstance("DOMObjectListNOM")&&PBwiki.Data.getInstance("DOMObjectListNOM").hasData();this.notify("onLoaded");if(A){this.setCount(A)}else{this.totalHeight=this.options.height}if(B){this.loadBlock(false,B)}else{this.checkAddBlocks()}},setLoadingStatus:function(A){if(A&&!this.loading){this.loading=new Element("div",{"class":"loading"}).setStyle({position:"absolute",left:"33%"}).update("Loading&hellip;");this.container.appendChild(this.loading)}else{if(!A&&this.loading){try{this.container.removeChild(this.loading)}catch(B){}}}},setEmptyMsg:function(){this.clear();if(!this.options.hideEmptyMsg){this.options.elm.appendChild(new Element("span").update(this.options.emptyMsg).addClassName("empty"))}this.notify("onLoaded")},setCount:function(A){this.totalHeight=A*this.options.height;this.container.setStyle({position:"relative",height:this.totalHeight+"px"});this.notify("onRowCount",this.lastAPIResult)},setVisibleHeight:function(A){if(A){this.options.visibleHeight=A}this.numVisible=Math.round(this.options.visibleHeight/this.options.height);this.options.elm.setStyle({height:this.options.visibleHeight+"px"})},clear:function(){if(this.container){this.options.elm.update("");this.options.elm.stopObserving("scroll",this.scrollHandler)}this.nodes={}}});Object.Event.extend(PBwiki.Components.ScrollArea);PBwiki.SideBar={itemList:{},initialize:function(){if(!$("sidebarModules")){return }$("sidebarModules").select("div.sidebox").each(function(D){if(D.id.indexOf("-")==-1){return }var C=D.id.split("-");var A=C[1];var E=PBwiki.SideBar[A.capitalize()+"Item"];try{if(E){PBwiki.SideBar.itemList[A]=new E(D,Object.clone(PBinfo.GetUserPrefs.sidebar[A]||{}))}}catch(B){PBwiki.error(B);PBinfo.CurrentWiki.debug=true;PBwiki.jsDebug(B.message)}});Sortable.SERIALIZE_RULE=/^[^_\-](?:[A-Za-z0-9\-\_]*)[-](.*)$/;Sortable.create("sidebarModules",{tag:"div",handle:"header",onUpdate:function(){Util.tracking("sidebar-reorder");PBwiki.SideBar.saveState()}})},saveState:function(){if(!PBwiki.getUID()){return }var A={};Sortable.sequence("sidebarModules").each(function(B){if(B){A[B]=PBwiki.SideBar.itemList[B].getValidOptions()}});PBwiki.UserPrefs.set("sidebar",A)},navigatorRoot:function(){return"NestedFolderView"}};PBwiki.SideBar.Module=Class.create({validOptions:["collapsed","ysize","numChanges"],initialize:function(C,A){this.elm=C;this.title=C.down("h3");this.closeToggle=C.down("a.togglemodule");this.header=C.down("div.header");this.content=C.down("div.content");this.footer=C.down("div.footer");this.options=A;try{this.init();if(!this.options.collapsed){this.refresh()}}catch(B){this.content.update(B.message);PBinfo.CurrentWiki.debug=true;PBwiki.jsDebug(B.message)}if(this.closeToggle){this.closeToggle.observe("mousedown",this.toggle.bind(this))}this.header.observe("dblclick",this.toggle.bind(this))},loading:function(){this.content.setStyle({height:this.getModuleHeight()+"px"});this.content.update("");this.content.appendChild(new Element("div",{"class":"loading"}).update("Loading&hellip;"))},getModuleHeight:function(){return this.options.ysize},setupModuleResize:function(A){this.clearModuleResize();this.resizeOpts=A;this.footer.addClassName("resizeable");this.resizeDownFunction=this.resizeDown.bind(this);this.footer.observe("mousedown",this.resizeDownFunction)},resizeDown:function(A){A.stop();this.startY=Event.pointerY(A);this.resizeMoveFunction=this.resizeMove.bind(this);document.observe("mousemove",this.resizeMoveFunction);this.resizeUpFunction=this.resizeUp.bind(this);document.observe("mouseup",this.resizeUpFunction);document.onselectstart=function(){return false};Element.setStyle(document.body,{cursor:"row-resize"});this.resizeOpts.onStart()},resizeUp:function(B){document.stopObserving("mousemove",this.resizeMoveFunction);document.stopObserving("mouseup",this.resizeUpFunction);B.stop();var A=Event.pointerY(B);var C=A-this.startY;document.onselectstart=null;Element.setStyle(document.body,{cursor:"default"});this.resizeOpts.onSize(C);this.resizeOpts.onFinish(C)},resizeMove:function(B){B.stop();var A=Event.pointerY(B);var C=A-this.startY;this.resizeOpts.onSize(C)},clearModuleResize:function(){this.footer.removeClassName("resizeable");this.footer.stopObserving("mousedown",this.resizeDownFunction)},toggle:function(A){A.stop();if(this.elm.hasClassName("minimized")){this.elm.removeClassName("minimized");delete this.options.collapsed;this.onMaximized()}else{this.elm.addClassName("minimized");this.options.collapsed=true;this.onMinimized()}Util.tracking("sidebar-toggle");PBwiki.SideBar.saveState()},getValidOptions:function(){var A={};for(itm in this.options){if(this.validOptions.indexOf(itm)!=-1){A[itm]=this.options[itm]}}return A},init:function(){},refresh:function(){},onMinimized:function(){this.content.hide()},onMaximized:function(){this.content.show()}});PBwiki.SideBar.FoldersItem=Class.create(PBwiki.SideBar.Module,{name:"folders",title:"Navigator",minResizeHeight:100,init:function(){this.elm.addClassName("minibrowser")},selectView:function(B,A){if(this.view&&this.view.isLoading){return }delete this.view;this.view=new PBwiki.SideBar.FoldersItem[B](A,this).refresh()},getFolderObjectCount:function(B,D){if(!B||B==""){var A=0;D.split(",").each(function(E){A+=PBinfo.GetFolders["unfiled_"+E+"count"]});return A}var C=PBinfo.GetFolders.folders.find(function(E){return E.name==B});var A=0;D.split(",").each(function(E){if(C){A+=C[E+"count"]}});return A},getModuleHeight:function(){return(this.options.ysize||PBconst.kFoldersDefaultHeight)},refresh:function(){if(this.view){this.view.refresh()}else{this.selectView(PBwiki.SideBar.navigatorRoot(),{slide:false,folder:PBinfo.CurrentPage.folder||""})}this.setupNavigatorResize()},setupNavigatorResize:function(){this.setupModuleResize({onStart:function(){if(!this.view||this.view.isLoading){return }this.startHeight=this.getModuleHeight()-this.view.getControlHeight()}.bind(this),onSize:function(B){if(!this.view||this.view.isLoading){return }var A=this.startHeight+B;if(A+this.view.getControlHeight()<100){A=100-this.view.getControlHeight()}this.view.setHeight(A)}.bind(this),onFinish:function(A){if(!this.view||this.view.isLoading){return }this.options.ysize=this.view.newContent.getHeight();PBwiki.SideBar.saveState()}.bind(this)})},onMinimized:function(){this.clearModuleResize();this.content.hide()},onMaximized:function(){if(this.view){this.content.show();this.setupNavigatorResize()}else{this.refresh()}}});PBwiki.SideBar.FoldersItem.ObjectView=Class.create({requestOpts:{},objectHeight:27,controlHeight:28,initialize:function(B,A){this.mb=A;this.content=A.content;this.isLoading=true;this.effectsActive=(typeof document.body.style.maxHeight!="undefined");this.visibleHeight=(this.mb.options.ysize||PBconst.kFoldersDefaultHeight);this.newContent=new Element("div",{"class":"content"});this.newList=new Element("div",{"class":"mblist"});this.newContent.appendChild(this.newList);this.setHeight();this.param=B;return this},refresh:function(){if(this.param.slide&&this.effectsActive){new PBEffect.SlideLeft({elm:this.content,onFinish:function(){this.isLoading=false}.bind(this),newElm:this.newContent,reverse:this.param.reverse})}else{this.content.parentNode.replaceChild(this.newContent,this.content);this.isLoading=false}return this},onLoaded:function(){var A=this.newContent.down("div.mblist");if(A){A.scrollTop=A.getAttribute("_scrollTop")||0;if(Prototype.Browser.IE){setTimeout(function(){A.setStyle({position:"relative"})},50)}}this.mb.content=this.newContent},setHeight:function(A){if(!A){A=this.visibleHeight-this.getControlHeight()}this.newList.setStyle({height:A+"px"})},createFolderHeading:function(D){this.heading=new Element("div",{"class":"heading"});var B=(D.length>28)?D.toString().substring(0,28).escapeHTML()+"&hellip;":D.toString().escapeHTML();this.folderTitle=new Element("a",{"class":(D=="")?"iconbutton unfiled":"iconbutton folder",href:Util.getFolderLink(D)}).update(B||"Unfiled Items");var C,A;this.backButton=new Element("span",{"class":"folder_back"}).update("&nbsp;").observe("click",this.backLink.bind(this));this.heading.appendChild(this.backButton);this.heading.appendChild(this.folderTitle);this.newContent.insertBefore(this.heading,this.newContent.firstChild)},backLink:function(){backDestination="NestedFolderView";backOptions={folder:this.param.parent_folder,object_types:this.param.object_types,slide:true,reverse:true};this.mb.selectView(backDestination,backOptions)},createTabs:function(D,B){this.tabs=new Element("div",{"class":"tabs"});var C=new Element("a",{"class":"pages-tab"}).addClassName("filter_link").update("Pages");var A=new Element("a",{"class":"files-tab"}).addClassName("filter_link").update("Files");C.observe("click",this.selectTab.bindAsEventListener(this,"NestedFolderView",{parent_folder:this.param.parent_folder,object_types:"folder,page",slide:true}));A.observe("click",this.selectTab.bindAsEventListener(this,"NestedFolderView",{parent_folder:this.param.parent_folder,object_types:"folder,file",slide:true}));C.href=A.href="";(D=="pages")?C.addClassName("active"):A.addClassName("active");this.optionsLink=new Element("a",{"class":"folder_properties",href:B||Util.getFolderLink(this.param.folder)});this.optionsLink.appendChild(new Element("span"));this.optionsLink.appendChild(document.createTextNode("options"));this.tabs.appendChild(this.optionsLink);if(D){this.tabs.appendChild(C);this.tabs.appendChild(A)}this.newContent.appendChild(this.tabs)},getControlHeight:function(){var A=0;if(this.tabs){A+=this.controlHeight}if(this.heading){A+=this.controlHeight}return A},renderObjectRow:function(F,D,A,G){if(!A){A=D.type||this.type}F.className="mb"+A;if(G%2==(this.param.folder?1:0)){F.addClassName("alternate")}if(A=="folder"){F.observe("click",this.folderLink.bind(this,D));F.appendChild(new Element("a",{href:"javascript:void(0);","class":"iconbutton folder"}).update(D.name.toString().escapeHTML()))}else{if(A=="page"){var B="/"+Util.dashified_link(D.name.toString());if(PBwiki.feature("wikipage_controller")){B="/w/page"+B}var E=new Element("a",{href:B}).update(D.name.toString().escapeHTML());F.appendChild(E);if(PBinfo.CurrentPage.page==D.name){E.setStyle({fontWeight:"bold"})}if(this.starredPages&&this.starredPages.indexOf(D.name)!==-1){F.addClassName("starred")}}else{if(A=="file"){var C=Util.iconMap[Util.getFileExtension(D.name.toString())];F.appendChild(new Element("a",{href:encodeURI("/f/"+D.name)}).addClassName("iconbutton").addClassName(C).update(D.name.toString().escapeHTML()));Util.addObjectTooltip(F,D)}}}return F},setupScrollableArea:function(){this.requestOpts.folder=this.param.folder;this.scrollable=new PBwiki.Components.ScrollArea({visibleHeight:this.visibleHeight-this.getControlHeight(),elm:this.newList,height:this.objectHeight,count:this.getObjectCount(),op:this.apiMethod,args:this.getRequestOpts(),dataKey:this.dataKey||this.type+"s",cacheTimes:this.cacheTimes,nodeClass:"mb"+this.type,onRowRender:this.renderObjectRow.bind(this),onLoaded:this.onLoaded.bind(this),emptyMsg:"No "+this.type+"s",itm:(this.param.folder==PBinfo.CurrentPage.folder)?PBinfo.CurrentPage.page:false,key:this.key})},selectTab:function(C,A,B){C.stop();Object.extend(B,{folder:this.param.folder,slide:false});this.mb.selectView.bind(this.mb,A,B)()},getRequestOpts:function(){return this.requestOpts}});PBwiki.SideBar.FoldersItem.NestedFolderView=Class.create(PBwiki.SideBar.FoldersItem.ObjectView,{apiMethod:"GetObjectsNOM",dataKey:"objects",requestOpts:{sortby:"name",object_types:"folder,page"},cacheTimes:["foldertime","filetime","pagetime","permtime"],folderLink:function(A){this.mb.selectView.bind(this.mb,"NestedFolderView",{parent_folder:this.param.folder,object_types:this.param.object_types,folder:A.name,count:A.count,slide:true})()},starredLink:function(){this.mb.selectView.bind(this.mb,"StarredView",{slide:true})()},refresh:function($super){$super();if(this.param.folder){this.createFolderHeading(this.param.folder)}PBwiki.UserPrefs.Stars.get_starred_objects(function(C){this.starredPages=C}.bind(this));if(PBwiki.getUID()&&!this.param.folder){var B=new Element("div").setStyle({position:"relative",height:"27px"});var A=new Element("div",{"class":"mbfolder"}).observe("click",this.starredLink.bind(this,{name:""}));A.setStyle({position:"absolute",top:0});A.appendChild(new Element("a",{href:"javascript:void(0);","class":"iconbutton starred"}).update("Starred Pages"));B.appendChild(A);this.newList.appendChild(B)}this.newContent.appendChild(this.newList);this.createTabs(this.param.object_types=="folder,file"?"files":"pages");this.setupScrollableArea();this.setHeight();return this},setupScrollableArea:function(){this.requestOpts.folder=this.param.folder;this.scrollable=new PBwiki.Components.ScrollArea({visibleHeight:this.visibleHeight-this.getControlHeight(),elm:this.newList,height:this.objectHeight,op:this.apiMethod,args:this.getRequestOpts(),dataKey:this.dataKey||this.type+"s",cacheTimes:this.cacheTimes,onRowRender:this.renderObjectRow.bind(this),onLoaded:this.onLoaded.bind(this),onFirstBlock:function(A){if(A.parents&&A.parents.length>0){this.param.parent_folder=A.parents[A.parents.length-1].name}if(this.newContent.down("a.files-tab")){this.newContent.down("a.files-tab").update(A._total_file?"Files":"No Files")}}.bind(this),emptyMsg:"No "+(this.param.object_types=="folder,file"?"files":"pages"),itm:(this.param.folder==PBinfo.CurrentPage.folder)?PBinfo.CurrentPage.page:false,key:this.key})},getRequestOpts:function(){if(this.param.object_types){this.requestOpts.object_types=this.param.object_types}return Object.extend(this.requestOpts,{folder:this.param.folder})},getObjectCount:function(){return this.mb.getFolderObjectCount(this.param.folder,this.param.object_types||"folder,page")}});PBwiki.SideBar.FoldersItem.StarredView=Class.create(PBwiki.SideBar.FoldersItem.ObjectView,{type:"page",createStarredHeading:function(){this.heading=new Element("div",{"class":"heading"});this.starredTitle=new Element("a",{"class":"iconbutton starred",href:""}).update("Starred Pages");this.backButton=new Element("span",{"class":"folder_back"}).update("&nbsp;").observe("click",this.mb.selectView.bind(this.mb,PBwiki.SideBar.navigatorRoot(),{folder:"",slide:true,reverse:true})).update(" ");this.heading.appendChild(this.backButton);this.heading.appendChild(this.starredTitle);this.newContent.insertBefore(this.heading,this.newContent.firstChild)},refresh:function($super){$super();PBwiki.UserPrefs.Stars.get_starred_objects(function(A){this.createStarredHeading();this.starredPages=A;A.each(function(B){this.newList.appendChild(this.renderObjectRow(new Element("div",{"class":"mbpage"}),{name:B}))}.bind(this));if(A.length==0){this.newList.appendChild(new Element("span").update("No Starred Items").addClassName("empty"))}if(PBwiki.getUID()){this.createTabs(false,"/user/"+PBwiki.getUID())}this.setHeight();this.onLoaded()}.bind(this));return this},getObjectCount:function(){return PBinfo.CurrentWiki.starredcount}});PBwiki.SideBar.SidebarItem=Class.create(PBwiki.SideBar.Module,{name:"sidebar"});PBwiki.SideBar.RecentactivityItem=Class.create(PBwiki.SideBar.Module,{name:"recentactivity",title:"Recent Activity",cacheTimes:["pagetime","filetime","permtime","foldertime","commenttime"],changeOpIcons:{added:"createpage","added via email":"emailicon",removed:"pageremovedicon","revision removed":"revisionremoved",deleted:"revisionremoved",changed:"pageediticon",edited:"pageediticon",completed:"pageediticon",reverted:"reverticon",uploaded:"uploadfiles","commented on":"commenticon"},template:'<ul id="recentactivity">#{changeItems}</ul><a class="moreactivity" href="/changes.php">More activity...</a>',row:'<li class="#{icon}"><a class="ellipses preview" time="#{time}" href="#{url}">#{escapedName}</a>#{op_word} by #{userLink}</li>',rowUserUpdate:'<li class="#{icon} user_update">#{userLink} &#8220;<span class="user_update">#{updateMessage}</span>&#8221;</li>',init:function(){document.observe("event:_list",this.mergeNewEvents.bindAsEventListener(this));document.observe("live:changelist",this.liveChangeListener.bindAsEventListener(this));if(!this.options){this.options={}}if(!this.options.ysize){this.options.ysize=90}if($("new-recent-activity-refresh")){$("new-recent-activity-refresh").observe("click",function(A){if(A){A.stop()}$("new-recent-activity").hide();this.loading();this.refresh()}.bindAsEventListener(this))}},liveChangeListener:function(A){if(PBinfo.CurrentWiki&&A.memo&&A.memo.context&&A.memo.context.wiki===PBinfo.CurrentWiki.name&&!this.alreadyInChanges(A.memo)){this.checkNewActivityCount()}},alreadyInChanges:function(A){if(!this.changes||!A.change||!A.change.hash){return true}return this.changes.pluck("hash").include(A.change.hash)},checkNewActivityCount:function(){if(!this.changes||!this.changes.length>0){return }new PBwiki.APIRequest("GetChanges",{after_hash:this.changes.pluck("hash")[0]},{onSuccess:function(A){this.setNewRecentActivityCount(A.changes.length)}.bind(this),onFailure:this.setNewRecentActivityCount.bind(this,0)})},setNewRecentActivityCount:function(A){if(this.options.collapsed){return }if(A>0){$("new-recent-activity-count").update(A);if(A==1){$("new-recent-activity-plural").update("")}else{$("new-recent-activity-plural").update("s")}$("new-recent-activity").show()}else{$("new-recent-activity").hide();$("new-recent-activity-count").update(A)}},refresh:function(){new PBwiki.APIRequest("GetChanges",{count:this.getNumberChanges()},{cacheability:this.cacheTimes,onSuccess:this.update.bind(this),onFailure:this.showNoChanges.bind(this)})},getNumberChanges:function(){return(parseInt(this.options.numChanges)||PBconst.kRecentChangesNumber)},mergeNewEvents:function(B){if(B.memo.length>0){var A=B.memo.reverse();var C=0;var D=this.changes[0].toJSON();A.each(function(E){if(E.toJSON()===D){throw $break}else{C++}});this.changes.splice(-C);this.update({changes:A.splice(0,C).concat(this.changes)})}},update:function(F){$("new-recent-activity").hide();$("new-recent-activity-count").update("0");var B="";var E=new Template(this.row);var D=new Template(this.rowUserUpdate);var C=0;this.changes=F.changes;F.changes.each(function(H){try{if(H.type=="userupdate"){H.icon="pageicon";H.updateMessage=H.data.escapeHTML();H.userClass="user";H.userLink=Util.authorLinkFromObject(H);B+=D.evaluate(H)}else{H.icon=this.changeOpIcons[H.op_word]||"pageicon";if(H.type=="folder"){H.icon="foldericon"}H.escapedName=H.title.toString().escapeHTML();H.userClass="user";H.userLink=Util.authorLinkFromObject(H);B+=E.evaluate(H)}}catch(G){PBwiki.error(G)}C++;if(C==this.getNumberChanges()){throw $break}}.bind(this));if(F.changes.length==0){this.showNoChanges()}else{this.content.update(new Template(this.template).evaluate({changeItems:B}))}Tooltips.addLinkTooltips(this.content);this.currentChanges=this.content.down("ul");this.content.setStyle({height:""});var A=(this.content.down("a"))?this.content.down("a").getHeight():0;this.currentHeight=this.content.getHeight()-(parseInt(this.content.getStyle("paddingTop"))*2)-A;this.clearModuleResize();this.setupModuleResize({onStart:function(){this.currentChanges.setStyle({position:"relative",overflow:"hidden",marginBottom:"5px"})}.bind(this),onSize:function(G){this.currentChanges.setStyle({height:(this.currentHeight+G)+"px"})}.bind(this),onFinish:function(H){this.options.numChanges=Math.round((this.currentHeight+H)/52);if(this.options.numChanges>PBconst.kRecentChangesMax){this.options.numChanges=PBconst.kRecentChangesMax}var G=(this.content.down("a"))?this.content.down("a").getHeight():0;this.content.setStyle({height:(this.options.numChanges*52)+G+"px",position:"static",overflow:"",marginBottom:""});this.refresh();PBwiki.SideBar.saveState()}.bind(this)})},showNoChanges:function(){this.content.update("There are no recent changes on this workspace.")},onMinimized:function(){this.content.update("");$("new-recent-activity").hide();this.clearModuleResize()},onMaximized:function(){this.refresh()}});PBwiki.SideBar.AddusersItem=Class.create(PBwiki.SideBar.Module,{name:"addusers",refresh:function(){this.errMsg=this.content.down("p.validation-error");this.email=this.content.down(".add_user_email");new InputText(this.email);this.content.down(".add_user_form").observe("submit",function(C){C.stop();var A=this.email.value;if(this.email.value==this.email.getAttribute("placeholder")){this.doErrorMessage("Please enter an email address");return }var B=Util.is_valid_email(A);if(B!==true){this.doErrorMessage(B);return }new PBwiki.APIRequest("AddUser",{email:A,perm:"write",invite:true,demote:false},{onSuccess:this.addUserSuccess.bind(this),onFailure:this.doErrorMessage.bind(this)});Util.tracking("share-this-workspace")}.bind(this))},doErrorMessage:function(A){this.errMsg.update(A).show();if(this.errTimer){clearTimeout(this.errTimer)}this.errTimer=setTimeout(function(){this.errMsg.hide();this.errTimer=null}.bind(this),5000)},addUserSuccess:function(A){if(A.info=="added"||A.info=="created"||A.info=="accepted"){this.appendToAddList("Added "+A.email)}else{this.appendToAddList(A.email+" already exists")}this.email.value="";this.email.focus();this.errMsg.hide()},appendToAddList:function(B){if(!this.emailList){this.emailList=new Element("ul",{className:"added-emails"});this.errMsg.insert({after:this.emailList})}var A=new Element("li",{className:"iconbutton accepticon"}).update(B);this.emailList.appendChild(A);setTimeout(function(){A.style.display="none"},4000)},onMaximized:function(){this.refresh()}});PBwiki.init(PBwiki.SideBar);if(typeof (PBEffect)=="undefined"){var PBEffect={}}PBEffect.SlideLeft=Class.create({step:40,initialize:function(B){this.options=B;this.elm=B.elm;this.newElm=B.newElm;this.width=this.end=this.elm.getWidth();this.height=this.elm.getHeight();this.reverse=B.reverse;var A=this.elm.down("div.mblist");var C=(A)?A.scrollTop:0;this.container=new Element("div").setStyle({position:"relative",overflow:"hidden",width:this.width+"px",height:this.height+"px"});this.wrapper=new Element("div").setStyle({position:"relative"});this.elm.parentNode.insertBefore(this.container,this.elm);this.wrapper.appendChild(this.elm);this.wrapper.appendChild(this.newElm);this.container.appendChild(this.wrapper);this.elm.setStyle({position:"absolute",top:"0px",left:"0px",width:this.width+"px"});this.newElm.setStyle({position:"absolute",top:"0px",width:this.width+"px",left:(((this.reverse)?-1:1)*this.width)+"px"});if(A){if(Prototype.Browser.Gecko){A.setStyle({overflow:"hidden"})}A.scrollTop=C}this.duration=B.duration||300;this.time=0;this.effectTimer=setInterval(this.slide.bind(this),this.step)},checkListFix:function(){if(this.listFixed){return }var A=this.newElm.down("div.mblist");if(A){A.setStyle({overflow:"hidden"});this.listFixed=true}},slide:function(){if(this.time<this.duration){var C=this.time/this.duration;var D=(-Math.cos(C*Math.PI)/2)+0.5;var B=D*this.width;this.wrapper.setStyle({left:(((this.reverse)?1:-1)*B)+"px"});if(Prototype.Browser.Gecko){this.checkListFix()}this.time+=this.step}else{clearInterval(this.effectTimer);this.newElm.setStyle({position:"",left:0});this.wrapper.parentNode.replaceChild(this.newElm,this.wrapper);this.container.parentNode.replaceChild(this.newElm,this.container);this.elm.remove();var A=this.newElm.down("div.mblist");if(A){A.setStyle({overflow:""});A.scrollTop=A.getAttribute("_scrollTop")}this.notify("onFinish",this.height)}}});Object.Event.extend(PBEffect.SlideLeft);var Page={};Page.AccessKeys=Class.create({functions:{searchfocus:function(A){$("input-search").focus();$("input-search").fire("focus");PBwiki.debug("focus on search");Event.stop(A)},edit:function(B){if(PBinfo.CurrentPage.editor_v3){document.fire("ui:changeview",{view:"edit",offset:document.documentElement.scrollTop-$("wikicontent").cumulativeOffset()[1]})}else{if(!Page.AjaxEdit.modeEnabled){var A=$$("#edit-tab a");if(A[0]){Event.stop(B);window.location=A[0].href;PBwiki.debug("editing")}}else{document.fire("ui:editview")}}},newtask:function(A){if(PBinfo.CurrentWiki){PBwiki.ResourceLoader.loadManifest("extras.js",function(){new PBwiki.DialogCommands.NewAction({on_empty_create_milestone:true})})}}},map:{},initialize:function(){this.addShortCut("¿",this.functions.searchfocus);this.addShortCut("e",this.functions.edit);if(PBwiki.userCanCreateTask()){this.addShortCut("k",this.functions.newtask)}},addShortCut:function(A,B){if(A.length==1){this.map[A]=B}}});Page.absolutizeUserContextSection=function(){if(!$("top-content")){return }document.body.appendChild($("top-content").addClassName("abs"))};Page.EditPage={cancel:false,FCKeditor:null,isLoaded:false,onFCKComplete:function(B){var A=B.memo.editorInstance;Page.EditPage.startEdit(A)},getEditor:function(){if(typeof (FCKeditorAPI)!="undefined"){return FCKeditorAPI.GetInstance("content")}},startEdit:function(A){PBwiki.debug("Page.EditPage: fck complete");$$("#edit-toolbar input, #edit-toolbar button, #edit-toolbar a").each(function(B){B.disabled=false;B.removeClassName("disabled")});Page.EditPage.handleTagEdit();$("edit-toolbar-outer").show();Event.observe(window,"resize",Page.EditPage.resizeContentPanel2);Page.EditPage.resizeContentPanel2()},resizeContentPanel2:function(){var C=$("content___Frame");var D=$("page-footer");var B=D?D.offsetTop+D.scrollHeight+parseInt(D.getStyle("marginBottom")):0;var A=C.clientHeight+document.documentElement.clientHeight-B;A=(A<310?310:A);C.style.height=A+"px";$("edit-toolbar").down(".iconbutton").style.position="relative";if(C.contentWindow.onresize){C.contentWindow.onresize()}},resizeContentPanel:function(){try{var E=$("page-col-2");var D=$("page-side-toolbar");var A=D.clientHeight+D.offsetTop-$("inner-page").offsetTop;var B=$$(".inlinepage.")[0];B.style.minHeight=A+"px"}catch(C){}},handleTagEdit:function(){if(window.location.hash=="#tags"&&$("tagfield")){$("tagfield").focus();var A=$("tag-settings").cumulativeOffset().top;window.scrollTo(0,A)}},initialize:function(){if(PBwiki.feature("ajaxedit")&&window.location.search.toString().indexOf("edit=")==-1){return }if($("content___Frame")){Page.EditPage.isLoaded=true;Event.observe(window,"resize",Page.EditPage.resizeContentPanel);document.observe("ui:fckeditor_oncomplete",Page.EditPage.onFCKComplete);Page.EditPage.resizeContentPanel();Page.EditPage.handleTagEdit();Page.setDefaultInputFocus();Page.EditPage.Tags.initialize();Page.Thingbar.doLoad();Page.EditPage.AutoSave.start();if(!Page.AjaxEdit.modeEnabled){window.onbeforeunload=Page.EditPage.beforeUnload;UserPrefs.Manager.goFullWidth()}}else{}},beforeUnload:function(A){A=A||window.event;try{if(!Page.EditPage.cancel){var C="You have unsaved changes. Continue and discard those changes?";A.returnValue=C;return C}}catch(B){}}};Page.EditPage.AutoSave={defaultSaveInterval:45,saveInterval:45,maxSaveInterval:150,pbSpelling:false,numWords:0,stop:function(){if(this.apiRequest){this.apiRequest.abortRequest()}if(this.timer){clearTimeout(this.timer);delete this.timer}if(this.reportTimer){clearTimeout(this.reportTimer);delete this.reportTimer}document.stopObserving("ui:autosaveTrigger",this.trigger);this.enabled=false},start:function(A){if(this.enabled){return }if(!A){A={}}this.useDrafts=!!A.draft;if(this.useDrafts){this.draft=A.draft;this.saveInterval=A.saveInterval}else{this.saveInterval=this.defaultSaveInterval}this.enabled=true;this.reportTimer=setInterval(this.report.bind(this),this.saveInterval*1000);this.enableEdit();this.timer=setTimeout(this.autoSaveTrigger.bind(this),this.saveInterval*1000);this.trigger=this.autoSaveTrigger.bind(this);document.observe("ui:autosaveTrigger",this.trigger)},autoSaveTrigger:function(){if(!Page.EditPage.AutoSave.enabled||(Page.AjaxEdit.modeEnabled&&!Page.AjaxEdit.editMode)){return }delete this.timer;PBwiki.debug("AutoSave: autosaving...");var A=Page.EditPage.getEditor().GetHTML();if(this.lastHTML&&this.saveTime&&this.lastHTML==A&&PBwiki.getTimestamp()-(this.saveTime.getTime()/1000)<this.maxSaveInterval&&!this.pbSpelling){this.refresh();return }if(this.useDrafts&&!this.pbSpelling){this.saveToDraft(A)}else{this.saveToAutosave(A)}},saveToAutosave:function(B){var C={onSuccess:this.onSuccess.bind(this,B),onFailure:this.autosaveFailure.bind(this)};var A={page:PBwiki.getPageName()};var D="PutAutosave";Page.AjaxEdit.checkSizeWarning(B.length);if(this.lastHTML&&this.lastHTML==B&&!this.pbSpelling){D="SetPageLock"}else{A.spellcheck=this.pbSpelling;C.parameters={html:B}}this.apiRequest=new PBwiki.APIRequest(D,A,C)},saveToDraft:function(D,A){var E={onSuccess:this.onSuccess.bind(this,D),onFailure:this.draftFailure.bind(this)};var C={draft_id:this.draft.draft_id,page:PBwiki.getPageName()};var F="PutDraft";if(!A){var B=new diff_match_patch();E.parameters={delta:B.diff_toDelta(B.diff_main(this.lastHTML,D)),version:this.draft.v}}else{E.parameters={html:D}}this.apiRequest=new PBwiki.APIRequest(F,C,E)},draftFailure:function(B,A){if(A===600){this.saveToDraft(Page.EditPage.getEditor().GetHTML(),true);return }else{}if(!this.enabled){return }this.report();this.refresh()},refresh:function(){if(!this.timer){this.timer=setTimeout(this.autoSaveTrigger.bind(this),this.saveInterval*1000)}},pageChanged:function(){return Page.EditPage.getEditor().IsDirty()},onSuccess:function(A,B){this.lastHTML=A;if(B.spellcheck){this.spellcheck=B.spellcheck;Page.EditPage.AutoSave.pbSpelling=false;document.fire("spellcheck:update",this.spellcheck)}if(B.draft){this.draft=B.draft}if(!B.lockinfo.hasLock){document.fire("ui:edit_lock_stolen",B.lockinfo)}else{this.saveTime=new Date();if(B.wordcount){this.numWords=B.wordcount}this.report();document.fire("ui:autosaveSuccess");this.refresh()}},autosaveFailure:function(A){if(!this.enabled){return }document.fire("ui:autosaveFailure",A);this.report();this.refresh()},disableEdit:function(){var A=$$("#edit-toolbar a.button")[0];A.addClassName("disabled");A.onclick=null;A.setAttribute("href","javascript:void(0);");$("cancelButton").onclick=null;$("cancelButton").addClassName("disabled");Page.EditPage.cancel=true},enableEdit:function(){var A=$$("#edit-toolbar a.button")[0];if(A.hasClassName("disabled")){A.removeClassName("disabled");$("cancelButton").removeClassName("disabled");Page.EditPage.cancel=false}},report:function(){if(!this.saveTime){return }var A=((new Date()-this.saveTime)/1000/60).toFixed();if(this.numWords){var B="Saved "+this.numWords+" word"+((this.numWords>1)?"s":"")+" at "}else{var B="Draft saved "}B+=new Date(this.saveTime).strftime(PBconst.kPolicySimpleTimeFormat);B+=" ("+((A==0)?"less than a ":A);B+=" minute"+((A>1)?"s":"")+" ago)";$("autosave_msg").innerHTML=B}};Page.WikiPage=Class.create({initialize:function(){this.initAccessKeys();this.initStar();this.accessKeyFunctions=new Page.AccessKeys();if(PBwiki.feature("event_polling")){this.lastUpdate=PBwiki.getTimestamp();document.observe("event:mod",this.notifyOfEdit.bindAsEventListener(this));document.observe("event:com",this.notifyOfComment.bindAsEventListener(this));this.changePoller=new PeriodicalExecuter(this.pollForChanges.bind(this),60)}if($("revert-page")){$("revert-page").observe("click",this.onRevertPageClicked.bind(this))}},onRevertPageClicked:function(C){C.stop();if(!confirm("Are you sure you wish to revert the page to this version?")){return }var A=C.element().getAttribute("ui:page");var B=C.element().getAttribute("ui:revision");new PBwiki.APIRequest("RevertPage",{page:A,revision:B},{onSuccess:function(){window.location="/w/page/"+encodeURIComponent(A)},onFailure:function(D){alert("An error occurred while trying to revert this page.")}.bind(this)})},initAccessKeys:function(){document.observe("keydown",function(B){var A=String.fromCharCode(B.charCode?B.charCode:B.keyCode).toLowerCase();if(B.ctrlKey&&this.accessKeyFunctions.map[A]){this.accessKeyFunctions.map[A](B);B.stop()}}.bind(this),true)},onStarClick:function(A){if(A){A.stop()}this.toggleStarState();$("pb-page-star").addClassName("working");PBwiki.UserPrefs.Stars.set_object_starred({name:PBinfo.CurrentPage.page,starred:this.starred,onFailure:this.starPageError.bind(this),onSuccess:this.didStarPage.bind(this)})},onUnstarFromLink:function(){var A=new PBwiki.Components.UnstarBubble();A.show()},initStar:function(){if(!$("pb-page-star")){return }this.starred=$("pb-page-star").hasClassName("starred");Event.observe("pb-page-star","click",this.onStarClick.bind(this));document.observe("data:objectStarred",function(A){if(A.memo){this.starred=A.memo.starred;this.updateVisualState()}}.bind(this));if(PBwiki.History.getKey("unstar").getValue()){PBwiki.History.removeKey("unstar");if(this.starred){window.setTimeout(this.onUnstarFromLink.bind(this),500)}}},didStarPage:function(A){$("pb-page-star").removeClassName("working")},starPageError:function(A){this.toggleStarState()},toggleStarState:function(A){this.starred=!this.starred;this.updateVisualState()},updateVisualState:function(){if(this.starred){$("pb-page-star").addClassName("starred")}else{$("pb-page-star").removeClassName("starred")}document.fire("ui:hideBubbles")},pollForChanges:function(){new PBwiki.APIRequest("GetChanges",{after:this.lastUpdate,reverse:false},{onSuccess:function(A){A.changes.each(function(B){document.fire("event:"+B.op,B)});document.fire("event:_list",A.changes)}});this.lastUpdate=PBwiki.getTimestamp()},notifyOfComment:function(B){if(B.memo.title!==PBwiki.getPageName()){return }var D=$("comments").down("h3");var A=D.down("a");if(!A){var C=' &mdash; <a href="#" class="reload">New comments available</a>';D.insert(C);D.down("a").observe("click",function(E){window.location.reload()})}},notifyOfEdit:function(A){if(A.memo.title!==PBwiki.getPageName()){return }if($("new-revision-available")){var B='<a href="#" class="reload">New revision available as of '+Util.time_ago(PBwiki.getTimestamp()-A.memo.time-PBwiki.timeOffset)+" ago</a>";$("new-revision-available").update(B);$("new-revision-available").show();$("new-revision-available").down("a").observe("click",function(C){window.location.reload()})}}});Page.setDefaultInputFocus=function(){$$("input[type=text], input[type=password]").each(function(A){if(A.getAttribute("ui:defaultfocus")){A.focus()}})};PBwiki.init(function(){$$("a.pb-delete-revision").invoke("observe","click",function(){if(!confirm("Are you sure you want to delete the revision?")){return }(new PBwiki.APIRequest("DeletePage",{page:this.getAttribute("page"),revision:this.getAttribute("rev")},{onSuccess:function(A){if(A.revcount==0){window.location.href="/browse/"}else{window.location.reload()}},onFailure:function(A){alert(A)},waitCursor:true,method:"post"}))})});PBwiki.init(function(){if($$("ul.searchlist").length>0){Tooltips.addLinkTooltips($$("ul.searchlist")[0])}});Page.EditPage.Tags={tagCloud:null,tagField:null,getTagObject:function(A){if(!Page.EditPage.Tags.tagObj||A){var B=Page.EditPage.Tags.tagField.value.strip().gsub(/(\s*,\s*)+/,",");B=B.gsub(/,\s*$|^,\s*/,"");Page.EditPage.Tags.tagObj=(B.blank()?[]:B.split(","))}return Page.EditPage.Tags.tagObj},writeTagObject:function(){Page.EditPage.Tags.tagField.value=Page.EditPage.Tags.getTagObject().join(", ")},initialize:function(){this.tagCloud=$("tagcloud");if(!this.tagCloud){return }this.tagField=$("tagfield");this.editTags=$("edit_tags");Page.EditPage.Tags.initialValue=$("tagfield").value;this.editTags.observe("click",function(A){A.stop();if(!PBinfo.CurrentPage.editor_v3){this.editTags.hide();$("tag-settings").show()}this.loadAllTags()}.bind(this))},IsDirty:function(){return(Page.EditPage.Tags.initialValue!=$("tagfield").value)},loadAllTags:function(){new PBwiki.APIRequest("GetTags",{},{cacheability:["tagtime"],onSuccess:this.onLoaded.bind(this)})},onLoaded:function(A){this.tagCloud.update("");if(A.tags&&!Object.isArray(A.tags)){$H(A.tags).each(function(B){this.tagCloud.appendChild(new Element("a",{href:"#"}).update(B.key.escapeHTML()));this.tagCloud.appendChild(document.createTextNode(",  "))}.bind(this));if(PBinfo.CurrentPage.editor_v3){PBwiki.currentView.resizeChromeHeight()}else{Page.AjaxEdit.resizeContentPanel()}}this.start()},start:function(){Page.EditPage.Tags.writeTagObject();Page.EditPage.Tags.unselectedLinks=$A(Page.EditPage.Tags.tagCloud.getElementsByTagName("a"));Page.EditPage.Tags.unselectedLinks.each(function(A){A=$(A);A.observe("click",Page.EditPage.Tags.handleTagClick);A.addClassName("unselected")});Page.EditPage.Tags.tagField.observe("keyup",Page.EditPage.Tags.handleFieldChange);Page.EditPage.Tags.tagField.observe("keydown",function(A){if(A.keyCode==13){Event.stop(A)}});Page.EditPage.Tags.handleFieldChange()},handleFieldChange:function(C){var D="#"+Page.EditPage.Tags.tagCloud.id+" a";var A=$$(D);var B=Page.EditPage.Tags.getTagObject(true);A.each(function(E){E.className="unselected";B.each(function(F){linkText=E.innerHTML;if(linkText==F){E.className="selected"}})})},addTag:function(A){Page.EditPage.Tags.tagObj.push(A)},removeTag:function(A){Page.EditPage.Tags.tagObj=Page.EditPage.Tags.tagObj.without(A)},handleTagClick:function(D){var C=Event.element(D);var A=C.firstChild.textContent||C.innerText;var B=Page.EditPage.Tags.getTagObject();(B.include(A)?Page.EditPage.Tags.removeTag(A):Page.EditPage.Tags.addTag(A));C.toggleClassName("selected").toggleClassName("unselected").blur();Page.EditPage.Tags.writeTagObject();Event.stop(D)}};Page.EditBubble={initialize:function(){var A=$("edit-tab");Page.EditBubble.bubble=editBubble=$("edit-button-bubble");if(!A||!editBubble||!A.hasClassName("logintoedit")){return false}editBubble.getElementsBySelector("a.close")[0].observe("click",function(B){editBubble.hide();B.stop()});A.down().observe("click",Page.EditBubble.show);document.observe("click",function(){Page.EditBubble.bubble.hide()})},reposition:function(){var D=$("edit-tab");var B=D.cumulativeOffset();var C=D.getWidth();var A=(Page.EditBubble.bubble.getHeight()/2)-(D.getHeight()/2);B.left+=C;B.top-=A;Page.EditBubble.bubble.setStyle({top:B.top+"px",left:B.left+"px"})},show:function(A){Page.EditBubble.reposition();Page.EditBubble.bubble.show();Event.stop(A)}};Page.ImportFeedback={initialize:function(){if(!$("import-feedback")){return }$("import-feedback-close").observe("click",function(A){A.stop();$("import-feedback").hide()}.bind(this),true);$("import-feedback-no").observe("click",function(A){A.stop();new PBwiki.Components.ImportFeedbackBubble({convertID:$("import-feedback").readAttribute("ui:convert-id")})})}};Page.LastEditedDisplay=Class.create({updateInterval:60,initialize:function(){if(!$("page-history-ago")||!PBinfo.GetPage||!PBinfo.GetPage.mtime){return }PBwiki.timeOffset=Math.round(PBwiki.getTimestamp()-PBinfo.CurrentPage.requesttime);setInterval(this.update.bind(this),this.updateInterval*1000);document.observe("ui:last_edited_update",this.update.bind(this))},update:function(){$("page-history-ago").update(Util.time_ago(PBwiki.getTimestamp()-PBinfo.GetPage.mtime-PBwiki.timeOffset)+" ago")}});Page.FixIPMPositioning=Class.create({initialize:function(){if(!$("notifications")||!$("main-tools")){return }$("main-tools").style.minHeight=$("notifications").getDimensions().height+"px"}});PBwiki.init(Page.WikiPage);PBwiki.init(Page.EditPage);PBwiki.init(Page.setDefaultInputFocus);PBwiki.init(Page.EditBubble);PBwiki.init(Page.ImportFeedback.initialize.bind(Page.ImportFeedback));PBwiki.init(Page.LastEditedDisplay);PBwiki.init(Page.FixIPMPositioning);PBwiki.CustomSecurity=Class.create({roles:[{index:0,value:"read",text:"Reader"},{index:1,value:"write",text:"Writer"},{index:2,value:"edit",text:"Editor"}],initialize:function(){if(!this.form){return }this.show_user_cards=true;this.user_map=new Object();this.group_roles=new Object();this.group_users=new Object();this.removed_users=new Array();this.removed_groups=new Array();this.api_requests_outstanding=0;this.unsaved_changes=false;this.unsaved_user_ids=new Array();this.unsaved_group_ids=new Array();this.table.style.visibility="hidden";this.loading_div.show();this.markAPIRequestStarted();new PBwiki.APIRequest("GetUsersInfos",{perm:"admin"},{allowDefer:true,method:"get",onSuccess:this.adminsReceived.bind(this),onFailure:function(B){alert(B);this.markAPIRequestReceived()}});var A=$$("form#"+this.form.id+" div.radio-container").first();new RadioButtonSelector(A);if(this.add_user_button){this.add_user_button.observe("click",this.addUserListener.bindAsEventListener(this))}if(this.add_group_button){this.add_group_button.observe("click",this.addGroupListener.bindAsEventListener(this))}this.save_button.observe("click",this.submitHandler.bindAsEventListener(this));if(this.starting_user_rules){this.starting_user_rules.each(this.addUser.bind(this))}if(this.starting_group_rules){this.starting_group_rules.each(function(B){var C=PBwiki.feature("network_user_groups")?"ListNetworkGroupUsers":"ListWorkspaceGroupUsers";this.markAPIRequestStarted();new PBwiki.APIRequest(C,{group_id:B.group_id},{method:"get",onSuccess:this.groupDataReceived.bind(this,B,B.role),onFailure:function(D){alert(D);this.markAPIRequestReceived()}})}.bind(this))}$$("a.security-warn").invoke("observe","click",this.linkListener.bindAsEventListener(this));$$("input[name=securitymode]").invoke("observe","click",this.radioListener.bindAsEventListener(this))},adminsReceived:function(A){this.admins=new Array();A.uids.each(function(C){this.admins.push(C.uid);var B=this.user_map[C.uid];if(!B){return }if(B.standalone&&$("user-"+C.uid)){this.changeToAdmin($("user-"+C.uid))}B.groups.each(function(D){this.changeToAdmin($("group-user-"+D+"-"+C.uid))}.bind(this))}.bind(this));this.markAPIRequestReceived()},changeToAdmin:function(B){B.select("select, input, a").each(function(C){C.up("td").remove(C)});var A=B.select("td");A[1].update("Administrator");if(A.length>2){A[2].update("&nbsp;")}},disableForm:function(){this.form_disabled=true;this.form.select("input, select").each(function(A){A.disabled=true})},enableForm:function(){this.form_disabled=false;this.form.select("input, select").each(function(A){A.disabled=false})},submitHandler:function(B){if(B){B.stop()}this.disableForm();var A=this.getSubmitAPIReqs();new PBwiki.MultiAPIRequest(A,{onAllComplete:this.submitComplete.bind(this)})},cancelHandler:function(A){if(A&&this.form_disabled){A.stop()}},radioListener:function(A){this.unsaved_changes=true},linkListener:function(A){if(!A||!this.unsaved_changes){return }var B=window.confirm("You have unsaved changes. Are you sure you want to leave this page?");if(!B){A.stop()}},addUserListener:function(C){var A=this.users_select;var B={uid:A.getValue(),username:A.options[A.selectedIndex].text,role:"read"};if(this.userHasPerms(B.uid)){alert(B.username+" is already in the table");return }this.addUser(B);this.unsaved_user_ids.push(B.uid);this.unsaved_changes=true},removeUserListener:function(B,A){B.stop();this.removeUser(A);this.unsaved_user_ids.push(A);this.unsaved_changes=true},addUser:function(A){var B=this.createTableRow({id:A.uid,name:A.username,role:this.userIsAdmin(A.uid)?"admin":A.role,remove_listener:this.removeUserListener.bindAsEventListener(this,A.uid),role_listener:this.userRoleListener.bindAsEventListener(this,A.uid),usercard:true,uid:A.uid});B.id="user-"+A.uid;this.table.down("tbody.users").appendChild(B);if(!this.user_map[A.uid]){this.user_map[A.uid]={standalone:false,groups:new Array()}}this.user_map[A.uid].standalone=true;this.removed_users=this.removed_users.without(A.uid)},removeUser:function(A){var B=$("user-"+A);if(!B){return }B.remove();this.updateRowColors();if(this.user_map[A]){this.user_map[A].standalone=false}this.removed_users.push(A)},updateRowColors:function(){var A=0;var B=this.table.select("tbody tr");B.each(function(C){C.className=(A%2?"even":"odd");A++})},userRoleListener:function(D,A){if(PBwiki.feature("network_user_groups")){var C=D.element();if(C.tagName.toLowerCase()!=="select"){C=C.up("select")}var B=C.options[C.selectedIndex].value;this.synchronizeUserPermission(A,B)}this.unsaved_user_ids.push(A);this.unsaved_changes=true},synchronizeUserPermission:function(B,A){var C=$$("table#securitytable select").findAll(function(E){return(E.id.indexOf(B)>-1)});if(C.length==0){return }var D="read";C.each(function(E){var G=E.id.split("-");if(G.length!==3){return }var I=G[1];var H=$("select-"+I);var F=H.options[H.selectedIndex].value;D=this.maxRole(D,F)}.bind(this));C.each(function(E){this.resetSelectOptions(E,D,A)}.bind(this))},resetSelectOptions:function(A,B,D){A.options.length=0;var C=0;this.roles.each(function(E){if(this.roleCmp(B,E.value)===-1){return }A.options[A.options.length]=new Option(E.text,E.value);if(D===E.value){C=A.options.length-1}}.bind(this));A.selectedIndex=C},addGroupListener:function(C){var A=this.groups_select;var E={group_id:A.getValue(),name:A.options[A.selectedIndex].text};var D=$("group-"+E.group_id);if(D){alert(E.name+" is already in the table");return }var B="read";this.addGroup(E,B);this.unsaved_group_ids.push(E.group_id);this.unsaved_changes=true},removeGroupListener:function(B,A){if(B){B.stop()}this.removeGroup(A);this.unsaved_group_ids.push(A);this.unsaved_changes=true;this.group_users[A].each(function(C){this.synchronizeUserPermission(C.uid,null)}.bind(this))},groupDataReceived:function(C,B,A){this.group_users[C.group_id]=A.users;this.addGroup(C,B);this.markAPIRequestReceived()},addGroup:function(B,D){if(!this.group_users[B.group_id]){var C=PBwiki.feature("network_user_groups")?"ListNetworkGroupUsers":"ListWorkspaceGroupUsers";this.markAPIRequestStarted();new PBwiki.APIRequest(C,{group_id:B.group_id},{method:"get",onSuccess:this.groupDataReceived.bind(this,B,D),onFailure:function(E){alert(E);this.markAPIRequestReceived()}});return }var A=this.createTableRow({id:B.group_id,name:B.name,role:D,remove_listener:this.removeGroupListener.bindAsEventListener(this,B.group_id),role_listener:this.groupRoleListener.bindAsEventListener(this,B.group_id)});A.id="group-"+B.group_id;this.table.down("tbody.groups").appendChild(A);this.group_users[B.group_id].each(function(H){var G=D;var F=$("select-"+H.uid);var E=F?F.options[F.selectedIndex].value:false;if(PBwiki.feature("network_user_groups")){$$("table#securitytable select").each(function(J){if(J.id.indexOf(H.uid)==-1){return }E=this.maxRole(E,J.options[J.selectedIndex].value);var L=J.id.split("-")[1];var K=$("select-"+L);G=this.maxRole(G,K.options[K.selectedIndex].value)}.bind(this))}var I=this.maxRole(E,D);this.appendGroupUserRow(B,H,I,G)}.bind(this));this.group_roles[B.group_id]=D;this.removed_groups=this.removed_groups.without(B.group_id)},appendGroupUserRow:function(E,C,F,B){if($("user-"+C.uid)){var A=$("user-"+C.uid);A.remove();this.user_map[C.uid].standalone=false}var D=this.createTableRow({id:E.group_id+"-"+C.uid,name:C.name||C.email||C.username,role:this.userIsAdmin(C.uid)?"admin":F,role_listener:this.userRoleListener.bindAsEventListener(this,C.uid),minimum_role:B,usercard:true,uid:C.uid,indent:"20px"});D.id="group-user-"+E.group_id+"-"+C.uid;this.table.down("tbody.groups").appendChild(D);if(!this.user_map[C.uid]){this.user_map[C.uid]={standalone:false,groups:new Array()}}this.user_map[C.uid].groups.push(E.group_id);this.removed_users=this.removed_users.without(C.uid)},groupRoleListener:function(D,C){var B=$("select-"+C);var E=B.options[B.selectedIndex].value;var A=this.group_roles[C];this.group_users[C].each(function(I){if(this.userIsAdmin(I.uid)){return }var G=$("select-"+C+"-"+I.uid);var F=G.options[G.selectedIndex].value;var H;if(this.maxRole(A,E)==E){H=this.maxRole(E,F)}else{if(F==A){H=E}else{H=F}}this.resetSelectOptions(G,E,H);this.synchronizeUserPermission(I.uid,H)}.bind(this));this.group_roles[C]=E;this.unsaved_group_ids.push(C);this.unsaved_changes=true},removeGroup:function(A){var B=$("group-"+A);if(!B){return }B.remove();this.removed_groups.push(A);this.updateRowColors();this.group_users[A].each(function(D){var C=D.uid;$("group-user-"+A+"-"+C).remove();this.user_map[C].groups=this.user_map[C].groups.without(A)}.bind(this));delete this.group_roles[A]},markAPIRequestStarted:function(){this.api_requests_outstanding++;if(!this.form_disabled){this.disableForm()}},markAPIRequestReceived:function(){this.api_requests_outstanding--;if(this.api_requests_outstanding===0){this.enableForm();this.loading_div.hide();this.table.style.visibility="visible"}},userHasPerms:function(A){return this.user_map[A]&&(this.user_map[A].standalone||this.user_map[A].groups.length>0)},maxRole:function(B,A){return(this.roleCmp(B,A)===-1)?B:A},roleCmp:function(D,C){var B=this.roles.find(function(G){return G.value===D});var A=this.roles.find(function(G){return G.value===C});var F=(B)?B.index:0;var E=(A)?A.index:0;return(F>E)?-1:(F<E)?1:0},createTableRow:function(B){if(!B.minimum_role){B.minimum_role="read"}var G=new Element("td");if(this.show_user_cards&&B.usercard&&B.uid){var C=new Element("a",{className:"usercard_trigger securitytable-username","ui:uid":B.uid,href:"javascript:void(0)"});C.update(B.name.escapeHTML());G.appendChild(C)}else{G.appendChild(document.createTextNode(B.name))}if(B.indent){G.style.paddingLeft=B.indent}var E=new Element("td");if(B.role==="admin"){E.appendChild(document.createTextNode("Administrator"))}else{var F=new Element("select",{name:"select-"+B.id,id:"select-"+B.id});var H=0;this.resetSelectOptions(F,B.minimum_role,B.role);if(B.role_listener){F.observe("change",B.role_listener)}E.appendChild(F)}var D=new Element("td");if(B.remove_listener){var A=new Element("a",{className:"iconbutton deleteicon",href:"javascript:void(0);",onclick:"void(0)"}).update("&nbsp;");A.observe("click",B.remove_listener)}else{var A=document.createTextNode(" ")}D.appendChild(A);var I=new Element("tr");I.setAttribute("ui:uid",B.uid);I.setAttribute("ui:name",B.name);I.appendChild(G);I.appendChild(E);I.appendChild(D);return I},userIsAdmin:function(A){if(this.admins){return(this.admins.indexOf(A)>-1)}else{return false}},getCustomAPIReqs:function(){var B=new Array();var A=new Array();this.table.select("tr").each(function(I){if(!I.down("select")){return }var C=I.down("select");var F=C.options[C.selectedIndex].value;if(I.id.startsWith("group-user-")){var H=I.id.substring(11,I.id.length-41);var E=I.id.substring(I.id.length-40);var G=$("group-"+H).down("select");var D=G.options[G.selectedIndex].value;if(F!==D&&this.unsaved_user_ids.indexOf(E)!==-1){A.push(this.getUserAPIRequest(E,F))}}else{if(I.id.startsWith("user-")){var E=I.id.substring(I.id.length-40);if(this.unsaved_user_ids.indexOf(E)!==-1){A.push(this.getUserAPIRequest(E,F))}}else{if(I.id.startsWith("group-")){var H=I.id.substring(6);if(this.unsaved_group_ids.indexOf(H)!==-1){B.push(this.getGroupAPIRequest(H,F))}}}}}.bind(this));B=this.removed_groups.map(function(C){return this.getGroupAPIRequest(C,"deny")}.bind(this)).concat(B);A=this.removed_users.map(function(C){return this.getUserAPIRequest(C,"deny")}.bind(this)).concat(A);return B.concat(A)}});PBwiki.PageSecurity=Class.create(PBwiki.CustomSecurity,{initialize:function($super){if(!PBwiki.feature("page_security")){return }if(!$("foldersecurityform")){return }this.page=PBinfo.CurrentPage.page;this.form=$("foldersecurityform");this.table=$("securitytable");this.loading_div=$("securitytable-loading");this.users_select=$("foldersecurityusers");this.add_user_button=$("securityadduserbutton");this.groups_select=$("foldersecuritygroups");this.add_group_button=$("securityaddgroupbutton");this.save_button=$("security-save");this.cancel_button=$("security-cancel");if(window.user_security_rules){this.starting_user_rules=window.user_security_rules}else{this.starting_user_rules=new Array()}if(window.group_security_rules){this.starting_group_rules=window.group_security_rules}else{this.starting_group_rules=new Array()}$super()},getSubmitAPIReqs:function(){var B=this.form.select("input[type=radio]");var C=B.find(function(F){return F.checked});var E=C.value;var A=new Array();var D={page:this.page,securitytype:E};if($("published")){D.published=$("published").checked}if(PBwiki.feature("additive_custom_security")&&E=="custom"){D.default_perm=$("default_perm").value}A.push(["SetPageSecurityType",D,{onFailure:function(F){alert(F);this.enableForm()}.bind(this)}]);if(E=="custom"){A=A.concat(this.getCustomAPIReqs())}return A},getUserAPIRequest:function(A,B){return["SetPageUserPermission",{page:this.page,uid:A,perm:B},{onFailure:function(C){alert(C);this.enableForm()}.bind(this)}]},getGroupAPIRequest:function(B,A){return["SetPageGroupPermission",{page:this.page,group_id:B,perm:A},{onFailure:function(C){alert(C);this.enableForm()}.bind(this)}]},submitComplete:function(){if(this.form_disabled){document.location.href="/"+Util.dashified_link(this.page)+"?securitymsg=true"}}});PBwiki.FolderSecurity=Class.create(PBwiki.CustomSecurity,{initialize:function($super,A){if(!PBwiki.feature("folder_security")){return }if(!$("foldersecurityform")){return }this.options=A;this.form=$("foldersecurityform");this.table=$("securitytable");this.loading_div=$("securitytable-loading");this.users_select=$("foldersecurityusers");this.add_user_button=$("securityadduserbutton");this.groups_select=$("foldersecuritygroups");this.add_group_button=$("securityaddgroupbutton");this.save_button=$("foldersecuritysubmit");this.cancel_button=$("security-cancel");$super();this.show_user_cards=false},getSubmitAPIReqs:function(){var C=this.form.select("input[type=radio]");var D=C.find(function(F){return F.checked});var E=D.value;var B=new Array();var A={folder:this.options.folder,enabled:(E=="custom")};if(PBwiki.feature("additive_custom_security")&&E=="custom"){A.default_perm=$("default_perm").value}B.push(["SetFolderHasCustomSecurity",A,{onFailure:function(F){alert(F);this.enableForm()}.bind(this)}]);B.push(["SetFolderPublic",{folder:this.options.folder,"public":$("foldersecuritypublished").checked},{onFailure:function(F){alert(F);this.enableForm()}.bind(this)}]);if(E=="custom"){B=B.concat(this.getCustomAPIReqs())}return B},getUserAPIRequest:function(A,B){return["SetFolderUserPermission",{folder:this.options.folder,uid:A,perm:B},{onFailure:function(C){alert(C);this.enableForm()}.bind(this)}]},getGroupAPIRequest:function(B,A){return["SetFolderGroupPermission",{folder:this.options.folder,group_id:B,perm:A},{onFailure:function(C){alert(C);this.enableForm()}.bind(this)}]},submitComplete:function(){if(this.form_disabled){if(this.options.onSaveComplete){this.options.onSaveComplete()}PBwiki.DialogFactory.close()}}});PBwiki.WhoCanSee=Class.create({kMaxUsers:500,initialize:function(B){if(B&&B.page){this.page=B.page}else{if(B&&B.folder){this.folder=B.folder}else{if(!PBinfo||!PBinfo.CurrentPage){return }this.page=PBinfo.CurrentPage.page}}var A=$$("div.who-can-see div.expand a");if(A.length===0){return }A.each(function(F){var C=F.up("div.who-can-see");var E=C.id.substring(12);F.observe("click",this.expandHandler.bindAsEventListener(this,E));var D=$("who-can-see-"+E+"-close");if(D){D.hide()}}.bind(this));if(this.page&&$("published")){$("published").observe("click",this.publishedHandler.bindAsEventListener(this));this.publishedHandler()}else{if(this.folder&&$("foldersecuritypublished")){$("foldersecuritypublished").observe("click",this.folderPublishedHandler.bindAsEventListener(this));this.folderPublishedHandler()}}if(PBwiki.feature("additive_custom_security")){$$("#who-can-see-custom-expand a").first().observe("click",function(){$("who-can-see-custom-expand").hide();$("customsecurity").hide()});$("who-can-see-custom-close").observe("click",function(){$("customsecurity").show();$("who-can-see-custom-close").hide();$("who-can-see-custom-content").hide();$("who-can-see-custom-expand").show()})}$$("div.selectrow").each(function(C){var D=C.down("div.who-can-see div.content");if(!D){return }C.observe("ui:select",function(){D.scrollTop=0;var E=D.down("ul.rolehelp");if(E){E.hide()}}.bind(this))}.bind(this));if(this.folder&&$("who-can-see-default-public")&&$("who-can-see-default-publicedit")){if(PBinfo.CurrentWiki.isPublic){$("who-can-see-default-public").show();if(PBinfo.CurrentWiki.publicedit){$("who-can-see-default-publicedit").show()}}}},publishedHandler:function(A){if($("published").checked){if($("who-can-see-default-folder-published")){$("who-can-see-default-folder-published").hide()}if($("who-can-see-locked-folder-published")){$("who-can-see-locked-folder-published").hide()}if($("who-can-see-default-page-published")){$("who-can-see-default-page-published").show()}if($("who-can-see-locked-page-published")){$("who-can-see-locked-page-published").show()}if($("who-can-see-custom-page-published")){$("who-can-see-custom-page-published").show()}if($("who-can-see-custom-page-published-edit-mode")){$("who-can-see-custom-page-published-edit-mode").show()}}else{if($("who-can-see-default-page-published")){$("who-can-see-default-page-published").hide()}if($("who-can-see-locked-page-published")){$("who-can-see-locked-page-published").hide()}if($("who-can-see-custom-page-published")){$("who-can-see-custom-page-published").hide()}if($("who-can-see-custom-page-published-edit-mode")){$("who-can-see-custom-page-published-edit-mode").hide()}if($("who-can-see-default-folder-published")){$("who-can-see-default-folder-published").show()}if($("who-can-see-locked-folder-published")){$("who-can-see-locked-folder-published").show()}}},folderPublishedHandler:function(A){if($("foldersecuritypublished").checked&&!PBinfo.CurrentWiki.isPublic){if($("who-can-see-default-folder-published")){$("who-can-see-default-folder-published").show()}if($("who-can-see-custom-folder-published")){$("who-can-see-custom-folder-published").show()}}else{if($("who-can-see-default-folder-published")){$("who-can-see-default-folder-published").hide()}if($("who-can-see-custom-folder-published")){$("who-can-see-custom-folder-published").hide()}}},expandHandler:function(B,A){if(B){B.stop()}var C;if(this.page){C={security_type:A,page:this.page}}else{if(this.folder){C={security_type:A,folder:this.folder}}else{PBwiki.error("Neither page nor folder present");return }}if(A=="custom"&&$("default_perm")){C.default_perm=$("default_perm").value}new PBwiki.APIRequest("GetHypotheticalUsers",C,{method:"get",onSuccess:this.dataHandler.bind(this,A),onFailure:function(D){alert(D)}})},dataHandler:function(C,D){var A=$("who-can-see-"+C);if(C=="custom"){D.users=$(D.users).reject(function(E){return !!$("user-"+E.uid)}.bind(this));$("securitytable").down(".users").select("tr").each(function(F){var E={uid:F.getAttribute("ui:uid"),name:F.getAttribute("ui:name"),perm:F.down("select").value,has_wiki_perm:true,role:PBwiki.UserPermissions[F.down("select").value]};D.users.push(E)})}if(D.users.length>this.kMaxUsers){this.drawText(A.down("table"),D)}else{this.drawTable(A.down("table"),D)}if(this.page){if(D.folder_published){A.addClassName("folder-published")}else{A.removeClassName("folder-published")}}A.down("div.expand").hide();A.down("div.content").scrollTop=0;A.down("div.content").show();var B=A.down("input.close");if(B){B.show()}PBwiki.DialogFactory.recenter()},drawTable:function(L,F){var B=L.id.substring(0,L.id.length-5);var G;var I=0;var A=0;var H=L.down("tbody");H.update("");F.users.each(function(M){var N;if(M.name&&!M.name.empty()){N=M.name}else{if(M.email&&!M.email.empty()){N=M.email}else{if(M.username&&!M.username.empty()){N=M.username}else{N="Anonymous user"}}}var P=new Element("td",{style:"padding-left: 10px;"});P.appendChild(document.createTextNode(N));var O=new Element("td");O.appendChild(document.createTextNode(M.role));var Q=new Element("tr",{id:B+M.uid});if(!M.wiki_perm&&!M.has_wiki_perm){Q.hide();Q.addClassName("network-user");P.style.paddingLeft="25px";if(M.network_perm==="admin"){A++}else{I++}if(!G){G=Q}}Q.appendChild(P);Q.appendChild(O);H.appendChild(Q)}.bind(this));if(I+A>0){var E=new Element("td",{style:"padding-left: 10px;"});var D=new Element("a",{href:"javascript: void(0);",className:"who-can-see-show-all"});D.update("show all");D.observe("click",this.showNetworkUsers.bindAsEventListener(this,H));var K=(I+A)+" additional network "+(I>0?"users":"administrators")+" (";E.appendChild(document.createTextNode(K));E.appendChild(D);E.appendChild(document.createTextNode(")"));var C=new Element("td",{className:"who-can-see-show-all-role"});C.appendChild(document.createTextNode(I>0?"Reader":"Administrator"));var J=new Element("tr");J.appendChild(E);J.appendChild(C);H.insertBefore(J,G)}},showNetworkUsers:function(B,A){if(B){B.stop()}if(this.showing_all){A.select("tr.network-user").invoke("hide");A.down("a.who-can-see-show-all").update("show all");A.down("td.who-can-see-show-all-role").update("Reader");delete this.showing_all}else{A.select("tr.network-user").invoke("show");A.down("a.who-can-see-show-all").update("hide");A.down("td.who-can-see-show-all-role").update("");this.showing_all=true}},drawText:function(C,D){var F="";var A="";var G=0;var B=0;D.users.each(function(H){if(!H.wiki_perm){if(H.network_perm==="admin"){G++}else{B++}return }if(H.role!==A){A=H.role;if(F.length>0){F=F+"\n"}F=F+"Page "+H.role+"s:\n"}var I=(H.name&&!H.name.empty())?H.name:(H.email&&!H.email.empty())?H.email:"Anonymous user";F=F+"    "+I+"\n"});if(G>0&&B==0){F=F+"\n"+G+" administrators of your network will also have access,\nbecause the workspace is open to the network."}else{if(G+B>0){F=F+"\n"+(B+G)+" additional members of your network will also have access,\nbecause the workspace is open to the network."}}var E=new Element("pre");E.appendChild(document.createTextNode(F));C.replace(E)}});PBwiki.RoleHelp=Class.create({initialize:function(A){if(A){this.options=A}else{this.options={}}$$("a.rolehelp").each(function(B){var C;if(B.hasClassName("rolehelp-default")){C=$("rolehelp-default")}else{if(B.hasClassName("rolehelp-locked")){C=$("rolehelp-locked")}else{if(B.hasClassName("rolehelp-hidden")){C=$("rolehelp-hidden")}else{if(B.hasClassName("rolehelp-custom")){C=$("rolehelp-custom")}}}}if(!C){return }B.observe("click",this.clickHandler.bindAsEventListener(this,C))}.bind(this))},clickHandler:function(B,A){if(B){if(this.options.never_follow_links){B.stop()}else{if(A.up("div.content")){B.stop()}else{if(A.up("table")&&A.up("table").down("tbody")&&A.up("table").down("tbody").childElementCount<=5){B.stop()}}}}A.up("div.selectrow").select("a.rolehelp.hide-when-opened").invoke("hide");A.show()}});PBwiki.init(PBwiki.PageSecurity);PBwiki.init(PBwiki.WhoCanSee);PBwiki.init(PBwiki.RoleHelp);PBwiki.Settings={initialize:function(){this.Panels.each(function(A){A.value.initialize.bind(this.Panels.get(A.key))()}.bind(this))},Panels:new Hash({Security:{initialize:function(){if(!$("securitysettings_publicrow")||$("welcome_wiki_viewers_anyone")){return }this.selections={};try{$w("viewers editors").each(function(C){this[C]={anyone:{},invitees:{}};this[C].anyone.radio=$("wiki_"+C+"_anyone");this[C].invitees.radio=$("wiki_"+C+"_invitees");try{this[C].anyone.label=$$("label[for="+this[C].anyone.radio.id+"]").first();this[C].invitees.label=$$("label[for="+this[C].invitees.radio.id+"]").first()}catch(B){}this[C].radioGroup=$$("input[name=whocan"+C.substr(0,4)+"]");this[C].getValue=function(){return this.radioGroup.find(function(D){return D.checked}).value}.bind(this[C])}.bind(this.selections))}catch(A){return }this.selections.requestAccessCheckbox=$("requestaccess_enabled");this.selections.requestAccessLabel=this.selections.requestAccessCheckbox.up().down("label");this.selections.inviteesLabelText=["Only people I invite","or approve"];if(this.requestAccessCheckbox=$("requestaccess_enabled")){(onRequestAccessChange=function(){var B=(this.requestAccessCheckbox.checked?this.selections.inviteesLabelText.join(" "):this.selections.inviteesLabelText.first());try{this.selections.viewers.invitees.label.innerHTML=B;this.selections.editors.invitees.label.innerHTML=B}catch(C){}}.bind(this))();$("requestaccess_enabled").observe("click",onRequestAccessChange)}[this.selections.viewers.radioGroup,this.selections.editors.radioGroup].flatten().each(function(B){B.observe("click",function(){document.fire("viewersecurity:changed")}.bind(this))}.bind(this.selections));(this.selections.editors.onViewSettingChanged=function(C){var B=this.editors.anyone;if(parseInt(this.viewers.getValue())){B.radio.enable();B.label.removeClassName("aux");if(this.editors.getValue()==1){this.requestAccessCheckbox.disabled=true;this.requestAccessLabel.addClassName("aux")}else{this.requestAccessLabel.removeClassName("aux");this.requestAccessCheckbox.disabled=false}}else{B.radio.disable();B.label.addClassName("aux");this.editors.invitees.radio.checked=true;this.requestAccessCheckbox.disabled=false;this.requestAccessLabel.removeClassName("aux")}}.bind(this.selections))();document.observe("viewersecurity:changed",this.selections.editors.onViewSettingChanged)}}})};PBwiki.init(PBwiki.Settings.initialize.bind(PBwiki.Settings));var FolderSelector=Class.create({initialize:function(A){this.element=$(A);if(!this.element){return }this.link=this.element.down("a");this.selector=this.element.down("select");this.startLength=this.selector.length;this.link.observe("click",this.linkOnclick.bind(this));this.selector.observe("change",this.selectChanged.bind(this));this.element.observe("ui:folderchanged",this.folderChanged.bind(this));PBwiki.History.onLoadCheck("#folders=1",this.linkOnclick.bind(this))},linkOnclick:function(A){if(A){Event.stop(A)}this.link.update("Choose a folder:").blur();this.loadFolderList();this.selector.show()},loadFolderList:function(){this.selector.length=this.startLength;new PBwiki.APIRequest("GetFolders",{verbose:true},{cacheability:["foldertime","filetime","pagetime","permtime"],onSuccess:function(A){if(A.folders){A.folders=PBwiki.APIRequest.sortResultObjectByParents(A.folders);A.folders.each(function(C){var D=!C.indent?C.name:"&nbsp;".times(C.indent*3)+C.name;var B=new Element("option",{value:C.name}).update(D);this.selector.appendChild(B);if(C.name==PBinfo.CurrentPage.folder){B.selected=true}},this)}}.bind(this)})},selectChanged:function(B){var A=$F(this.selector);if(A.startsWith("Create")){this.handleCreateFolder()}else{this.selector.fire("ui:folderchanged",A)}},handleCreateFolder:function(){var B="Folder name";var A="Please name your folder";while(folderName=prompt(A,B)){if(!folderName){continue}var A=Util.is_valid_folder_name(folderName);if(A===true){break}}folderName=folderName.strip();if(folderName){this.selector.fire("ui:folderchanged",folderName)}else{this.selector.selectedIndex=this.selector.oldIndex}},folderChanged:function(B){if(typeof B.memo!="string"){B.memo=""}var A={page:PBinfo.CurrentPage.page,create_if_missing:true};if(B.memo){A.folder=B.memo}else{A.remove=true}new PBwiki.APIRequest("SetPageFolder",A,{incUsess:true,onSuccess:function(C){setTimeout(function(){window.location.reload()},1000)},onFailure:function(D,C){document.fire("ui:onNotifyUser",{message:"Failed to set page folder: "+D,mode:"error"})}})}});PBwiki.init(FolderSelector,"folderselector");Page.Tags={editorActive:false,placeHolderTxt:"e.g. report, new release",initialize:function(){if($("edittags")){$("edittags").observe("click",Page.Tags.toggleEditor.bind(Page.Tags));Page.Tags.tagMsg=$("ajaxtags").down(".tagsmsg");Page.Tags.tagError=$("ajaxtags").down(".validation-error");PBwiki.History.onLoadCheck("#tags=1",Page.Tags.toggleEditor.bind(Page.Tags))}},toggleEditor:function(B){if(B){Event.stop(B)}if(this.isToggling){return }this.isToggling=true;var D=$("tagList");if(!this.editorActive){this.tagInput=new Element("input",{id:"input-tags"});this.tagInput.setAttribute("type","text");this.tagInput.setAttribute("placeholder",Page.Tags.placeHolderTxt);this.tagInput.className="text";this.tagInput.style.width="165px";this.tagInput.observe("blur",this.toggleEditor.bind(this));this.tagInput.observe("keypress",this.keyDown.bind(this));var F=D.getElementsByTagName("A");this.savedTagStr=D.innerHTML;var I=this.getTagStr();this.tagInput.value=I;this.tagButton=new Element("input");this.tagButton.setAttribute("type","button");this.tagButton.setAttribute("value","OK");this.tagButton.style.marginLeft="2px";this.tagButton.observe("click",this.toggleEditor.bind(this));D.innerHTML="";D.appendChild(this.tagInput);D.appendChild(this.tagButton);new InputText(this.tagInput);this.editorActive=true;this.isToggling=false}else{var J=this.tagInput.value;if(J==Page.Tags.placeHolderTxt){J=""}var E=J.split(",");var G=false;D.innerHTML="";for(var A=0;A<E.length;A++){var H=E[A].strip();if(H==""){continue}if(G){D.appendChild(document.createTextNode(", "))}var C=new Element("a");C.setAttribute("href","/tags.php?ptag="+H);C.appendChild(document.createTextNode(H));D.appendChild(C);G=true}if(G){$("edittags").innerHTML="Edit Tags:"}else{$("edittags").innerHTML="Add Tags"}this.updateTags();this.editorActive=false}},getTagStr:function(){var A=$("tagList").getElementsByTagName("A");var C="";for(var B=0;B<A.length;B++){if(B!=0){C+=","}C+=A[B].firstChild.nodeValue}return C},keyDown:function(A){if(!A){A=window.event}if(A.keyCode==13){this.toggleEditor()}},updateTags:function(){var A=this.getTagStr();new PBwiki.APIRequest("SetPageTags",{page:PBwiki.getPageName(),tags:A},{incUsess:true,onSuccess:this.tagSuccess.bind(this),onFailure:this.tagFail.bind(this),onComplete:function(){this.isToggling=false}.bind(this)});if($("tagfield")){$("tagfield").value=A}},tagFail:function(A){$("tagList").innerHTML=this.savedTagStr;this.tagError.innerHTML=A;this.tagError.style.display="block";setTimeout(function(){this.tagError.style.display="none"}.bind(this),30000)},tagSuccess:function(){this.tagMsg.style.display="block";setTimeout(function(){this.tagMsg.style.display="none"}.bind(this),5000)}};PBwiki.init(Page.Tags.initialize);FormPost={post:function(D,A){var B=Object.extend({action:"",validate:function(){return true},method:"post"},A);if(B.validate()){var C=FormPost.constructForm(D);C.method=B.method;C.action=B.action;document.body.appendChild(C);C.submit()}},constructForm:function(B){var A=new Element("form");$H(B).each(function(D){PBwiki.debug("creating hidden input for %s:%s",D.key,D.value);var C=new Element("input",{type:"hidden",name:D.key,value:D.value,style:"display:none"});A.appendChild(C)});return A}};var PostCommand=Class.create({initialize:function(A){this.element=$(A);this.element.observe("click",this.onclick.bind(this))},onclick:function(F){var G=this.element.getAttribute("ui:validation");var E=this.element.getAttribute("ui:action")||this.element.href;var C=this.element.getAttribute("ui:query");var B=this.element.getAttribute("ui:confirm");var D=Util.parseQueryString(C);var A={action:E};if(G){A.validate=window[G]}PBwiki.debug(A);Event.stop(F);if(B==""||confirm(B)){FormPost.post(D,A)}}});PostCommand.initialize=function(){PostCommand.selector=".postcommand";try{$$(PostCommand.selector).each(function(B){new PostCommand(B)})}catch(A){PBwiki.warn("PostCommand: error: "+A)}};PBwiki.AddUserBehavior=Class.create({initialize:function(A){return },handleEnterOnEmailField:function(A){if(A.keyCode==Event.KEY_RETURN){this.sendAddRequest();Event.stop(A)}},sendAddRequest:function(){var A=$F(this.emailInput);var D=this.emailInput.getAttribute("placeholder");if(A!=D){var E=this.emailInput.name;var C=this.permInput.name;var B=Util.is_valid_email(A);if(B!==true){this.doErrorMessage(B);return }new PBwiki.APIRequest("AddUser",{email:A,perm:this.permInput.value,invite:true,demote:false},{onSuccess:this.addUserSuccess.bind(this),incUsess:true,onFailure:this.doErrorMessage.bind(this)});this.errMsg.hide()}},addUserSuccess:function(A){if(A.info=="added"||A.info=="created"||A.info=="accepted"){this.appendToAddList("Added "+A.email)}else{this.appendToAddList(A.email+" already exists")}this.emailInput.value="";this.emailInput.focus();this.errMsg.hide()},doErrorMessage:function(A){this.emailInput.focus();this.emailInput.select();this.errMsg.innerHTML=A;this.errMsg.style.display="block";setTimeout(function(){this.errMsg.hide()}.bind(this),5000)},appendToAddList:function(B){if(!this.emailList){this.emailList=new Element("ul",{className:"added-emails"});this.errMsg.insert({after:this.emailList})}var A=new Element("li",{className:"iconbutton accepticon"});A.innerHTML=B;this.emailList.appendChild(A);setTimeout(function(){A.style.display="none"},4000)}});RadioButtonSelector=Class.create({initialize:function(B){this.element=$(B);this.selectrows=this.element.getElementsBySelector(".selectrow");this.selectors=this.element.getElementsBySelector("label, input[type=radio]");this.selectrows.invoke("observe","ui:select",this.selectEvent);var A=this.selectors.invoke("observe","click",this.fireSelectEvent.bind(this)).find(function(C){return C.checked});this.fireSelectEvent(A)},selectEvent:function(A){if(A.memo.descendantOf(this)){this.addClassName("selected");this.down("input").checked=true}else{this.removeClassName("selected")}},fireSelectEvent:function(A){this.selectrows.invoke("fire","ui:select",(A.element?A.element():A))}});CommentValidator={initialize:function(){if(!$("comment-form")){return }$("comment-form").observe("submit",CommentValidator.validate)},validate:function(A){if(Page.HTMLComments&&Page.HTMLComments.started){return }maxlength=2000;var B=$("comment-form-value");val=B.value;if(val.length>=maxlength){alert("Your comments must be "+maxlength+" characters or less. This comment is "+val.length+" characters.");B.focus();A.stop()}else{if(val.length==0){alert("Your comment cannot be empty.");B.focus();A.stop()}}$$("#comment-form .primarybutton").each(function(C){C.disable()})}};PBwiki.init(PostCommand);PBwiki.init(CommentValidator);PBwiki.init(PBwiki.AddUserBehavior,"module:addusers");function insert_sig(){var A=FCKeditorAPI.GetInstance("content");var D=new Date();var E=D.getMonth()+1;var B=D.getDate();var C=D.getYear()-100;A.InsertHtml("-- Brian Kirchoff "+E+"/"+B+"/"+C)}function insert_file_into_editor(D,C,B){var A=FCKeditorAPI.GetInstance("content");var E=insert_get_selection();if(E==""){E='<img border="0" src="'+C+'" /></a>&nbsp;<a href="'+D+'">'+B}A.InsertHtml('<a href="'+D+'">'+E+"</a>");return false}function insert_newlink_into_editor(){document.fire("ui:insertlink")}function insert_newimage_into_editor(){var A=prompt("Enter the URL of the image to insert into the editor");if(A){insert_image_into_editor(A)}}function insert_image_into_editor(B){var C='<img src="'+B+'" />';if(typeof (FCKeditorAPI)!="undefined"){var A=FCKeditorAPI.GetInstance("content");A.InsertHtml(C)}else{PBwiki.currentEditor.editor.execCommand("mceInsertContent",false,C)}return false}function tagCloudToggle(B){var A=$("tagcloud");if(A.getStyle("display")=="none"){A.setStyle({display:"block"});B.innerHTML="Hide all tags"}else{A.setStyle({display:"none"});B.innerHTML="Show all tags"}}var g_pb_Enable_focus_changes=true;function insert_pagelink_into_editor(E,D){if(typeof D=="undefined"){D=E}var A=FCKeditorAPI.GetInstance("content");var C=insert_get_selection();if(C==""){C=D}var B=g_pb_Enable_focus_changes;g_pb_Enable_focus_changes=false;A.InsertHtml('<a href="/'+E+'" >'+C+"</a>");g_pb_Enable_focus_changes=B}function insert_get_selection(){var B=FCKeditorAPI.GetInstance("content");var A=B.Selection;if(A.GetType()=="Text"){if(document.all){return B.EditorDocument.selection.createRange().text}else{return B.EditorWindow.getSelection()}}return""}function load_real_thumbnail(B,A){var C=B.getAttribute("realsrc");if(C){B.setAttribute("src",C)}A.onmouseover=null}function load_all_files(){new Ajax.Updater("thingbarfiles","/api_v2/op/GetFileListAsHtml/_type/html")}function load_all_pages(){new Ajax.Updater("thingbarpages","/api_v2/op/GetPageListAsHtml/_type/html")}document.observe("ui:fckeditor_oncomplete",function(B){var A=B.memo.editorInstance;if(g_pb_Enable_focus_changes){A.Events.AttachEvent("OnSelectionChange",CheckFocusForNbsp)}});function CheckFocusForNbsp(C){if(!g_pb_Enable_focus_changes){return }var D=C.Selection.GetBoundaryParentElement();var E=C.Selection.GetSelection();if(!D||!E){return }var A=(E.createRange)?E.createRange().text:E.toString();if((!A||A=="")&&(D.innerHTML.length>0&&D.innerHTML.replace("&nbsp;","")==""||encodeURIComponent(D.innerHTML)=="%C2%A0")){if(C.EditorWindow.getSelection){E.collapse(D,false)}else{var B=E.createRange();B.moveToElementText(D);B.collapse(true);B.select()}}}Page.Notifications={cookieName:"pbNotifications",notificationList:[],initialize:function(){if(!$("notifications")||!$("notifications").hasClassName("ipm")){return }var C=$("notifications").select("li");var A=C.id;this.notificationList=new Array();for(var B=0;B<C.length;B++){this.notificationList.push(new Notification(C[B]))}this.updateDisplay()},addNotification:function(A){var B=this.findNotification($("notification-"+A.id));if(!B){this.notificationList.push(new Notification(null,A))}this.updateDisplay()},addError:function(B){var A={icon:"interstitial"};Object.extend(A,B);this.addNotification(A)},removeNotification:function(A){this.notificationList=$A(this.notificationList).without(A);this.updateDisplay()},findNotification:function(B){for(var A=0;A<this.notificationList.length;A++){if(this.notificationList[A].elm==B){return this.notificationList[A]}}},updateDisplay:function(){if(this.notificationList.length==0){$("notifications").style.display="none"}var B=$("notifications").select("li");for(var A=0;A<B.length;A++){if(A==B.length-1){B[A].addClassName("last")}else{B[A].removeClassName("last")}}}};var Notification=Class.create({initialize:function(B,A){if(B){if(B.hasClassName("dismiss")){this.dismissControl=B.down(".dismisscontrol");this.dismissControl.observe("click",this.dismiss.bind(this))}this.elm=B;this.contentElm=$(this.elm.childNodes[2]);this.id=B.id.replace("notification-","")}else{this.elm=new Element("li").addClassName("notification");if(A.dismiss){this.dismissControl=new Element("div").addClassName("dismisscontrol");this.elm.addClassName("dismiss");this.elm.appendChild(this.dismissControl)}if(A.icon){this.elm.addClassName("page-"+A.icon)}this.contentElm=new Element("p");if(A.html){this.contentElm.innerHTML=A.html}this.elm.appendChild(this.contentElm);$("notifications").appendChild(this.elm)}},setMessage:function(A){this.contentElm.innerHTML=A},remove:function(){this.elm.remove();Page.Notifications.removeNotification(this)},dismiss:function(){Messaging.Link({id:this.id,dismiss:1});this.remove()}});var Messaging={url:"/messaging.php?",Link:function(D){var C={mId:D.id};if(D.dismiss&&D.dismiss!="no"){C.dismiss=1;var B=Messaging.url+Object.toQueryString(C);new Ajax.Request(B);var A=$("notification-"+D.id);var E=Page.Notifications.findNotification(A);Page.Notifications.removeNotification(E)}if(D.url){C.url=D.url;var B=Messaging.url+Object.toQueryString(C);if(D.target=="_blank"){window.open(B)}else{window.location.href=B}}}};PBwiki.init(Page.Notifications.initialize.bind(Page.Notifications));var SWFUpload;if(SWFUpload==undefined){SWFUpload=function(A){this.initSWFUpload(A)}}SWFUpload.prototype.initSWFUpload=function(B){try{this.customSettings={};this.settings=B;this.eventQueue=[];this.movieName="SWFUpload_"+SWFUpload.movieCount++;this.movieElement=null;SWFUpload.instances[this.movieName]=this;this.initSettings();this.loadFlash();this.displayDebugInfo()}catch(A){delete SWFUpload.instances[this.movieName];throw A}};SWFUpload.instances={};SWFUpload.movieCount=0;SWFUpload.version="2.2.0 2009-03-25";SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,FILE_EXCEEDS_SIZE_LIMIT:-110,ZERO_BYTE_FILE:-120,INVALID_FILETYPE:-130};SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,MISSING_UPLOAD_URL:-210,IO_ERROR:-220,SECURITY_ERROR:-230,UPLOAD_LIMIT_EXCEEDED:-240,UPLOAD_FAILED:-250,SPECIFIED_FILE_ID_NOT_FOUND:-260,FILE_VALIDATION_FAILED:-270,FILE_CANCELLED:-280,UPLOAD_STOPPED:-290};SWFUpload.FILE_STATUS={QUEUED:-1,IN_PROGRESS:-2,ERROR:-3,COMPLETE:-4,CANCELLED:-5};SWFUpload.BUTTON_ACTION={SELECT_FILE:-100,SELECT_FILES:-110,START_UPLOAD:-120};SWFUpload.CURSOR={ARROW:-1,HAND:-2};SWFUpload.WINDOW_MODE={WINDOW:"window",TRANSPARENT:"transparent",OPAQUE:"opaque"};SWFUpload.completeURL=function(A){if(typeof (A)!=="string"||A.match(/^https?:\/\//i)||A.match(/^\//)){return A}var C=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"");var B=window.location.pathname.lastIndexOf("/");if(B<=0){path="/"}else{path=window.location.pathname.substr(0,B)+"/"}return path+A};SWFUpload.prototype.initSettings=function(){this.ensureDefault=function(B,A){this.settings[B]=(this.settings[B]==undefined)?A:this.settings[B]};this.ensureDefault("upload_url","");this.ensureDefault("preserve_relative_urls",false);this.ensureDefault("file_post_name","Filedata");this.ensureDefault("post_params",{});this.ensureDefault("use_query_string",false);this.ensureDefault("requeue_on_error",false);this.ensureDefault("http_success",[]);this.ensureDefault("assume_success_timeout",0);this.ensureDefault("file_types","*.*");this.ensureDefault("file_types_description","All Files");this.ensureDefault("file_size_limit",0);this.ensureDefault("file_upload_limit",0);this.ensureDefault("file_queue_limit",0);this.ensureDefault("flash_url","swfupload.swf");this.ensureDefault("prevent_swf_caching",true);this.ensureDefault("button_image_url","");this.ensureDefault("button_width",1);this.ensureDefault("button_height",1);this.ensureDefault("button_text","");this.ensureDefault("button_text_style","color: #000000; font-size: 16pt;");this.ensureDefault("button_text_top_padding",0);this.ensureDefault("button_text_left_padding",0);this.ensureDefault("button_action",SWFUpload.BUTTON_ACTION.SELECT_FILES);this.ensureDefault("button_disabled",false);this.ensureDefault("button_placeholder_id","");this.ensureDefault("button_placeholder",null);this.ensureDefault("button_cursor",SWFUpload.CURSOR.ARROW);this.ensureDefault("button_window_mode",SWFUpload.WINDOW_MODE.WINDOW);this.ensureDefault("debug",false);this.settings.debug_enabled=this.settings.debug;this.settings.return_upload_start_handler=this.returnUploadStart;this.ensureDefault("swfupload_loaded_handler",null);this.ensureDefault("file_dialog_start_handler",null);this.ensureDefault("file_queued_handler",null);this.ensureDefault("file_queue_error_handler",null);this.ensureDefault("file_dialog_complete_handler",null);this.ensureDefault("upload_start_handler",null);this.ensureDefault("upload_progress_handler",null);this.ensureDefault("upload_error_handler",null);this.ensureDefault("upload_success_handler",null);this.ensureDefault("upload_complete_handler",null);this.ensureDefault("debug_handler",this.debugMessage);this.ensureDefault("custom_settings",{});this.customSettings=this.settings.custom_settings;if(!!this.settings.prevent_swf_caching){this.settings.flash_url=this.settings.flash_url+(this.settings.flash_url.indexOf("?")<0?"?":"&")+"preventswfcaching="+new Date().getTime()}if(!this.settings.preserve_relative_urls){this.settings.upload_url=SWFUpload.completeURL(this.settings.upload_url);this.settings.button_image_url=SWFUpload.completeURL(this.settings.button_image_url)}delete this.ensureDefault};SWFUpload.prototype.loadFlash=function(){var A,B;if(document.getElementById(this.movieName)!==null){throw"ID "+this.movieName+" is already in use. The Flash Object could not be added"}A=document.getElementById(this.settings.button_placeholder_id)||this.settings.button_placeholder;if(A==undefined){throw"Could not find the placeholder element: "+this.settings.button_placeholder_id}B=document.createElement("div");B.innerHTML=this.getFlashHTML();A.parentNode.replaceChild(B.firstChild,A);if(window[this.movieName]==undefined){window[this.movieName]=this.getMovieElement()}};SWFUpload.prototype.getFlashHTML=function(){return['<object id="',this.movieName,'" type="application/x-shockwave-flash" data="',this.settings.flash_url,'" width="',this.settings.button_width,'" height="',this.settings.button_height,'" class="swfupload">','<param name="wmode" value="',this.settings.button_window_mode,'" />','<param name="movie" value="',this.settings.flash_url,'" />','<param name="quality" value="high" />','<param name="menu" value="false" />','<param name="allowScriptAccess" value="always" />','<param name="flashvars" value="'+this.getFlashVars()+'" />',"</object>"].join("")};SWFUpload.prototype.getFlashVars=function(){var B=this.buildParamString();var A=this.settings.http_success.join(",");return["movieName=",encodeURIComponent(this.movieName),"&amp;uploadURL=",encodeURIComponent(this.settings.upload_url),"&amp;useQueryString=",encodeURIComponent(this.settings.use_query_string),"&amp;requeueOnError=",encodeURIComponent(this.settings.requeue_on_error),"&amp;httpSuccess=",encodeURIComponent(A),"&amp;assumeSuccessTimeout=",encodeURIComponent(this.settings.assume_success_timeout),"&amp;params=",encodeURIComponent(B),"&amp;filePostName=",encodeURIComponent(this.settings.file_post_name),"&amp;fileTypes=",encodeURIComponent(this.settings.file_types),"&amp;fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),"&amp;fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),"&amp;fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),"&amp;fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),"&amp;debugEnabled=",encodeURIComponent(this.settings.debug_enabled),"&amp;buttonImageURL=",encodeURIComponent(this.settings.button_image_url),"&amp;buttonWidth=",encodeURIComponent(this.settings.button_width),"&amp;buttonHeight=",encodeURIComponent(this.settings.button_height),"&amp;buttonText=",encodeURIComponent(this.settings.button_text),"&amp;buttonTextTopPadding=",encodeURIComponent(this.settings.button_text_top_padding),"&amp;buttonTextLeftPadding=",encodeURIComponent(this.settings.button_text_left_padding),"&amp;buttonTextStyle=",encodeURIComponent(this.settings.button_text_style),"&amp;buttonAction=",encodeURIComponent(this.settings.button_action),"&amp;buttonDisabled=",encodeURIComponent(this.settings.button_disabled),"&amp;buttonCursor=",encodeURIComponent(this.settings.button_cursor)].join("")};SWFUpload.prototype.getMovieElement=function(){if(this.movieElement==undefined){this.movieElement=document.getElementById(this.movieName)}if(this.movieElement===null){throw"Could not find Flash element"}return this.movieElement};SWFUpload.prototype.buildParamString=function(){var C=this.settings.post_params;var B=[];if(typeof (C)==="object"){for(var A in C){if(C.hasOwnProperty(A)){B.push(encodeURIComponent(A.toString())+"="+encodeURIComponent(C[A].toString()))}}}return B.join("&amp;")};SWFUpload.prototype.destroy=function(){try{this.cancelUpload(null,false);var A=null;A=this.getMovieElement();if(A&&typeof (A.CallFunction)==="unknown"){for(var C in A){try{if(typeof (A[C])==="function"){A[C]=null}}catch(E){}}try{A.parentNode.removeChild(A)}catch(B){}}window[this.movieName]=null;SWFUpload.instances[this.movieName]=null;delete SWFUpload.instances[this.movieName];this.movieElement=null;this.settings=null;this.customSettings=null;this.eventQueue=null;this.movieName=null;return true}catch(D){return false}};SWFUpload.prototype.displayDebugInfo=function(){this.debug(["---SWFUpload Instance Info---\n","Version: ",SWFUpload.version,"\n","Movie Name: ",this.movieName,"\n","Settings:\n","\t","upload_url:               ",this.settings.upload_url,"\n","\t","flash_url:                ",this.settings.flash_url,"\n","\t","use_query_string:         ",this.settings.use_query_string.toString(),"\n","\t","requeue_on_error:         ",this.settings.requeue_on_error.toString(),"\n","\t","http_success:             ",this.settings.http_success.join(", "),"\n","\t","assume_success_timeout:   ",this.settings.assume_success_timeout,"\n","\t","file_post_name:           ",this.settings.file_post_name,"\n","\t","post_params:              ",this.settings.post_params.toString(),"\n","\t","file_types:               ",this.settings.file_types,"\n","\t","file_types_description:   ",this.settings.file_types_description,"\n","\t","file_size_limit:          ",this.settings.file_size_limit,"\n","\t","file_upload_limit:        ",this.settings.file_upload_limit,"\n","\t","file_queue_limit:         ",this.settings.file_queue_limit,"\n","\t","debug:                    ",this.settings.debug.toString(),"\n","\t","prevent_swf_caching:      ",this.settings.prevent_swf_caching.toString(),"\n","\t","button_placeholder_id:    ",this.settings.button_placeholder_id.toString(),"\n","\t","button_placeholder:       ",(this.settings.button_placeholder?"Set":"Not Set"),"\n","\t","button_image_url:         ",this.settings.button_image_url.toString(),"\n","\t","button_width:             ",this.settings.button_width.toString(),"\n","\t","button_height:            ",this.settings.button_height.toString(),"\n","\t","button_text:              ",this.settings.button_text.toString(),"\n","\t","button_text_style:        ",this.settings.button_text_style.toString(),"\n","\t","button_text_top_padding:  ",this.settings.button_text_top_padding.toString(),"\n","\t","button_text_left_padding: ",this.settings.button_text_left_padding.toString(),"\n","\t","button_action:            ",this.settings.button_action.toString(),"\n","\t","button_disabled:          ",this.settings.button_disabled.toString(),"\n","\t","custom_settings:          ",this.settings.custom_settings.toString(),"\n","Event Handlers:\n","\t","swfupload_loaded_handler assigned:  ",(typeof this.settings.swfupload_loaded_handler==="function").toString(),"\n","\t","file_dialog_start_handler assigned: ",(typeof this.settings.file_dialog_start_handler==="function").toString(),"\n","\t","file_queued_handler assigned:       ",(typeof this.settings.file_queued_handler==="function").toString(),"\n","\t","file_queue_error_handler assigned:  ",(typeof this.settings.file_queue_error_handler==="function").toString(),"\n","\t","upload_start_handler assigned:      ",(typeof this.settings.upload_start_handler==="function").toString(),"\n","\t","upload_progress_handler assigned:   ",(typeof this.settings.upload_progress_handler==="function").toString(),"\n","\t","upload_error_handler assigned:      ",(typeof this.settings.upload_error_handler==="function").toString(),"\n","\t","upload_success_handler assigned:    ",(typeof this.settings.upload_success_handler==="function").toString(),"\n","\t","upload_complete_handler assigned:   ",(typeof this.settings.upload_complete_handler==="function").toString(),"\n","\t","debug_handler assigned:             ",(typeof this.settings.debug_handler==="function").toString(),"\n"].join(""))};SWFUpload.prototype.addSetting=function(B,C,A){if(C==undefined){return(this.settings[B]=A)}else{return(this.settings[B]=C)}};SWFUpload.prototype.getSetting=function(A){if(this.settings[A]!=undefined){return this.settings[A]}return""};SWFUpload.prototype.callFlash=function(functionName,argumentArray){argumentArray=argumentArray||[];var movieElement=this.getMovieElement();var returnValue,returnString;try{returnString=movieElement.CallFunction('<invoke name="'+functionName+'" returntype="javascript">'+__flash__argumentsToXML(argumentArray,0)+"</invoke>");returnValue=eval(returnString)}catch(ex){throw"Call to "+functionName+" failed"}if(returnValue!=undefined&&typeof returnValue.post==="object"){returnValue=this.unescapeFilePostParams(returnValue)}return returnValue};SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile")};SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles")};SWFUpload.prototype.startUpload=function(A){this.callFlash("StartUpload",[A])};SWFUpload.prototype.cancelUpload=function(A,B){if(B!==false){B=true}this.callFlash("CancelUpload",[A,B])};SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload")};SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats")};SWFUpload.prototype.setStats=function(A){this.callFlash("SetStats",[A])};SWFUpload.prototype.getFile=function(A){if(typeof (A)==="number"){return this.callFlash("GetFileByIndex",[A])}else{return this.callFlash("GetFile",[A])}};SWFUpload.prototype.addFileParam=function(A,B,C){return this.callFlash("AddFileParam",[A,B,C])};SWFUpload.prototype.removeFileParam=function(A,B){this.callFlash("RemoveFileParam",[A,B])};SWFUpload.prototype.setUploadURL=function(A){this.settings.upload_url=A.toString();this.callFlash("SetUploadURL",[A])};SWFUpload.prototype.setPostParams=function(A){this.settings.post_params=A;this.callFlash("SetPostParams",[A])};SWFUpload.prototype.addPostParam=function(A,B){this.settings.post_params[A]=B;this.callFlash("SetPostParams",[this.settings.post_params])};SWFUpload.prototype.removePostParam=function(A){delete this.settings.post_params[A];this.callFlash("SetPostParams",[this.settings.post_params])};SWFUpload.prototype.setFileTypes=function(A,B){this.settings.file_types=A;this.settings.file_types_description=B;this.callFlash("SetFileTypes",[A,B])};SWFUpload.prototype.setFileSizeLimit=function(A){this.settings.file_size_limit=A;this.callFlash("SetFileSizeLimit",[A])};SWFUpload.prototype.setFileUploadLimit=function(A){this.settings.file_upload_limit=A;this.callFlash("SetFileUploadLimit",[A])};SWFUpload.prototype.setFileQueueLimit=function(A){this.settings.file_queue_limit=A;this.callFlash("SetFileQueueLimit",[A])};SWFUpload.prototype.setFilePostName=function(A){this.settings.file_post_name=A;this.callFlash("SetFilePostName",[A])};SWFUpload.prototype.setUseQueryString=function(A){this.settings.use_query_string=A;this.callFlash("SetUseQueryString",[A])};SWFUpload.prototype.setRequeueOnError=function(A){this.settings.requeue_on_error=A;this.callFlash("SetRequeueOnError",[A])};SWFUpload.prototype.setHTTPSuccess=function(A){if(typeof A==="string"){A=A.replace(" ","").split(",")}this.settings.http_success=A;this.callFlash("SetHTTPSuccess",[A])};SWFUpload.prototype.setAssumeSuccessTimeout=function(A){this.settings.assume_success_timeout=A;this.callFlash("SetAssumeSuccessTimeout",[A])};SWFUpload.prototype.setDebugEnabled=function(A){this.settings.debug_enabled=A;this.callFlash("SetDebugEnabled",[A])};SWFUpload.prototype.setButtonImageURL=function(A){if(A==undefined){A=""}this.settings.button_image_url=A;this.callFlash("SetButtonImageURL",[A])};SWFUpload.prototype.setButtonDimensions=function(C,A){this.settings.button_width=C;this.settings.button_height=A;var B=this.getMovieElement();if(B!=undefined){B.style.width=C+"px";B.style.height=A+"px"}this.callFlash("SetButtonDimensions",[C,A])};SWFUpload.prototype.setButtonText=function(A){this.settings.button_text=A;this.callFlash("SetButtonText",[A])};SWFUpload.prototype.setButtonTextPadding=function(B,A){this.settings.button_text_top_padding=A;this.settings.button_text_left_padding=B;this.callFlash("SetButtonTextPadding",[B,A])};SWFUpload.prototype.setButtonTextStyle=function(A){this.settings.button_text_style=A;this.callFlash("SetButtonTextStyle",[A])};SWFUpload.prototype.setButtonDisabled=function(A){this.settings.button_disabled=A;this.callFlash("SetButtonDisabled",[A])};SWFUpload.prototype.setButtonAction=function(A){this.settings.button_action=A;this.callFlash("SetButtonAction",[A])};SWFUpload.prototype.setButtonCursor=function(A){this.settings.button_cursor=A;this.callFlash("SetButtonCursor",[A])};SWFUpload.prototype.queueEvent=function(B,C){if(C==undefined){C=[]}else{if(!(C instanceof Array)){C=[C]}}var A=this;if(typeof this.settings[B]==="function"){this.eventQueue.push(function(){this.settings[B].apply(this,C)});setTimeout(function(){A.executeNextEvent()},0)}else{if(this.settings[B]!==null){throw"Event handler "+B+" is unknown or is not a function"}}};SWFUpload.prototype.executeNextEvent=function(){var A=this.eventQueue?this.eventQueue.shift():null;if(typeof (A)==="function"){A.apply(this)}};SWFUpload.prototype.unescapeFilePostParams=function(C){var E=/[$]([0-9a-f]{4})/i;var F={};var D;if(C!=undefined){for(var A in C.post){if(C.post.hasOwnProperty(A)){D=A;var B;while((B=E.exec(D))!==null){D=D.replace(B[0],String.fromCharCode(parseInt("0x"+B[1],16)))}F[D]=C.post[A]}}C.post=F}return C};SWFUpload.prototype.testExternalInterface=function(){try{return this.callFlash("TestExternalInterface")}catch(A){return false}};SWFUpload.prototype.flashReady=function(){var A=this.getMovieElement();if(!A){this.debug("Flash called back ready but the flash movie can't be found.");return }this.cleanUp(A);this.queueEvent("swfupload_loaded_handler")};SWFUpload.prototype.cleanUp=function(A){try{if(this.movieElement&&typeof (A.CallFunction)==="unknown"){this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for(var C in A){try{if(typeof (A[C])==="function"){A[C]=null}}catch(B){}}}}catch(D){}window.__flash__removeCallback=function(E,F){try{if(E){E[F]=null}}catch(G){}}};SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler")};SWFUpload.prototype.fileQueued=function(A){A=this.unescapeFilePostParams(A);this.queueEvent("file_queued_handler",A)};SWFUpload.prototype.fileQueueError=function(A,C,B){A=this.unescapeFilePostParams(A);this.queueEvent("file_queue_error_handler",[A,C,B])};SWFUpload.prototype.fileDialogComplete=function(B,C,A){this.queueEvent("file_dialog_complete_handler",[B,C,A])};SWFUpload.prototype.uploadStart=function(A){A=this.unescapeFilePostParams(A);this.queueEvent("return_upload_start_handler",A)};SWFUpload.prototype.returnUploadStart=function(A){var B;if(typeof this.settings.upload_start_handler==="function"){A=this.unescapeFilePostParams(A);B=this.settings.upload_start_handler.call(this,A)}else{if(this.settings.upload_start_handler!=undefined){throw"upload_start_handler must be a function"}}if(B===undefined){B=true}B=!!B;this.callFlash("ReturnUploadStart",[B])};SWFUpload.prototype.uploadProgress=function(A,C,B){A=this.unescapeFilePostParams(A);this.queueEvent("upload_progress_handler",[A,C,B])};SWFUpload.prototype.uploadError=function(A,C,B){A=this.unescapeFilePostParams(A);this.queueEvent("upload_error_handler",[A,C,B])};SWFUpload.prototype.uploadSuccess=function(B,A,C){B=this.unescapeFilePostParams(B);this.queueEvent("upload_success_handler",[B,A,C])};SWFUpload.prototype.uploadComplete=function(A){A=this.unescapeFilePostParams(A);this.queueEvent("upload_complete_handler",A)};SWFUpload.prototype.debug=function(A){this.queueEvent("debug_handler",A)};SWFUpload.prototype.debugMessage=function(C){if(this.settings.debug){var A,D=[];if(typeof C==="object"&&typeof C.name==="string"&&typeof C.message==="string"){for(var B in C){if(C.hasOwnProperty(B)){D.push(B+": "+C[B])}}A=D.join("\n")||"";D=A.split("\n");A="EXCEPTION: "+D.join("\nEXCEPTION: ");SWFUpload.Console.writeLine(A)}else{SWFUpload.Console.writeLine(C)}}};SWFUpload.Console={};SWFUpload.Console.writeLine=function(D){var B,A;try{B=document.getElementById("SWFUpload_Console");if(!B){A=document.createElement("form");document.getElementsByTagName("body")[0].appendChild(A);B=document.createElement("textarea");B.id="SWFUpload_Console";B.style.fontFamily="monospace";B.setAttribute("wrap","off");B.wrap="off";B.style.overflow="auto";B.style.width="700px";B.style.height="350px";B.style.margin="5px";A.appendChild(B)}B.value+=D+"\n";B.scrollTop=B.scrollHeight-B.clientHeight}catch(C){alert("Exception: "+C.name+" Message: "+C.message)}};SWFUpload.GetSwfVer=function(){var G=-1;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){var F=navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"";var A=navigator.plugins["Shockwave Flash"+F].description;var E=A.split(" ");var C=E[2].split(".");var H=C[0];var B=C[1];var D=E[3];if(D==""){D=E[4]}if(D[0]=="d"){D=D.substring(1)}else{if(D[0]=="r"){D=D.substring(1);if(D.indexOf("d")>0){D=D.substring(0,D.indexOf("d"))}}}var G=H+"."+B+"."+D}}else{if(Prototype.Browser.IE&&(navigator.appVersion.toLowerCase().indexOf("win")!=-1)&&!Prototype.Browser.Opera){G=SWFUpload.ControlVersion()}}return G};SWFUpload.DetectFlashVer=function(F,D,C){versionStr=SWFUpload.GetSwfVer();if(versionStr==-1){return false}else{if(versionStr!=0){if(Prototype.Browser.IE&&(navigator.appVersion.toLowerCase().indexOf("win")!=-1)&&!Prototype.Browser.Opera){tempArray=versionStr.split(" ");tempString=tempArray[1];versionArray=tempString.split(",")}else{versionArray=versionStr.split(".")}var E=versionArray[0];var A=versionArray[1];var B=versionArray[2];if(E>parseFloat(F)){return true}else{if(E==parseFloat(F)){if(A>parseFloat(D)){return true}else{if(A==parseFloat(D)){if(B>=parseFloat(C)){return true}}}}}return false}}};SWFUpload.ControlVersion=function(){var A=-1;var B;var C;try{B=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");A=B.GetVariable("$version")}catch(C){}if(!A){try{B=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");A="WIN 6,0,21,0";B.AllowScriptAccess="always";A=B.GetVariable("$version")}catch(C){}}return A};PBwiki.Components=PBwiki.Components||{};PBwiki.Components.TreeView=Class.create({idKey:"oid",parentIdKey:"parent_id",noParentId:0,rootParentId:0,open:[],setData:function(B,A){this.data=B;if(A){this.open=A}this.computeLookups();this.nodes=this.computeTree(this.rootParentId,[],[])},setOpenNodes:function(A){this.open=A;this.nodes=this.computeTree(this.rootParentId,[],[])},isOpen:function(A){return this.open.indexOf(A)!=-1},expand:function(A){if(this.open.indexOf(A)==-1){this.open.push(A);this.setOpenNodes(this.open)}},collapse:function(A){this.setOpenNodes(this.open.without(A))},openParentNodes:function(C){var A=C,B;while(A&&A!=this.rootParentId){if(!this.isOpen(A)){this.expand(A);B=true}if(!this.indexes[A]){break}A=this.data[this.indexes[A]][this.parentIdKey]}return B},toggle:function(A){return this.isOpen(A)?this.collapse(A):this.expand(A)},computeLookups:function(){this.children={};this.indexes={};this.parents={};for(var A=0;A<this.data.length;A++){if(!this.data[A][this.parentIdKey]){this.data[A][this.parentIdKey]=this.noParentId}this.indexes[this.data[A][this.idKey]]=A;this.parents[this.data[A][this.idKey]]=this.data[A][this.parentIdKey];if(!this.children[this.data[A][this.parentIdKey]]){this.children[this.data[A][this.parentIdKey]]=[]}this.children[this.data[A][this.parentIdKey]].push(this.data[A][this.idKey])}},computeTree:function(C,A,D){if(this.children[C]){var G,E;for(var B=0;B<this.children[C].length;B++){G=this.children[C][B];E=D.clone();E.push(B!=this.children[C].length-1);var F={key:G,index:this.indexes[G],levels:E,parent_id:C};if(this.children[G]){F.hc=true}if(B==this.children[C].length-1){F.last=true}A.push(F);if(this.children[G]&&this.isOpen(G)){A.concat(A,this.computeTree(G,A,E))}}}return A},getData:function(E,A){if(!E){E=0}if(!A){A=this.nodes.length}var B=this.nodes.slice(E,A);var D=[];for(var C=0;C<B.length;C++){D[C+E]=Object.extend(Object.clone(this.data[B[C].index]),Object.clone(B[C]))}return D}});PBwiki.Components.APITreeView=Class.create(PBwiki.Components.TreeView,{apiMethod:"GetObjectsNOM",apiOpts:{},apiKey:"objects",initialize:function(A){this.options=A;this.refresh()},refresh:function(){(new PBwiki.APIRequest(this.apiMethod,this.apiOpts,{onSuccess:this.onLoad.bind(this)}))},onLoad:function(A){this.setData(A[this.apiKey],this.getOpenFromPref());this.onAfterLoad()},onAfterLoad:function(){this.redraw()},getOpenFromPref:function(){var C=PBwiki.UserPrefs.get(this.prefKey);if(!C){return[]}var A=C.toString().split(",");for(var B=0;B<A.length;B++){A[B]=parseInt(A[B],10)}return A},redraw:function(){this.options.elm.update("");delete this.selectedRow;this.getData().each(function(C){try{var A=this.onRenderRow(C);this.options.elm.appendChild(A);if(this.options.selectedObject&&C.oid==this.options.selectedObject.oid){this.selectedRow=A}}catch(B){PBwiki.error(B)}},this)},setOpenNodes:function($super,A){var B=[];A.each(function(D){if(typeof (this.indexes[D])!="undefined"){B.push(D)}},this);var C=B.join(",");PBwiki.UserPrefs.set(this.prefKey,C);$super(B)}});PBwiki.Components.ScrollingAPITreeView=Class.create(PBwiki.Components.APITreeView,{initialize:function($super,A){$super(A)},onAfterLoad:function($super){$super();this.options.elm.observe("scroll",this.onScroll.bind(this))},redraw:function(){this.options.elm.update("");this.loadedRows={};delete this.selectedRow;this.options.elm.setStyle({position:"relative"});var A=new Element("div").setStyle({height:this.nodes.length*this.rowHeight+"px"});this.options.elm.appendChild(A);this.onScroll()},onScroll:function(){var A=this.getVisibleRows(),D;for(var B=A.start;B<A.end;B++){if(this.loadedRows[B]){continue}if(!D){D=this.getData(A.start,A.end)}var E=D[B];var C=this.onRenderRow(E);C.setStyle({position:"absolute",top:B*this.rowHeight+"px"});this.options.elm.appendChild(C);if(this.options.selectedObject&&E.oid==this.options.selectedObject.oid){this.selectedRow=C}this.loadedRows[B]=true}},getVisibleRows:function(){var B=Math.floor(this.options.elm.scrollTop/this.rowHeight);B=Math.max(0,B-5);var A=Math.ceil((this.options.elm.scrollTop+this.options.elm.getHeight())/this.rowHeight);A=Math.min(this.nodes.length,A+5);return{start:B,end:A}}});PBwiki.Components.WorkspaceObjectTreeView=Class.create(PBwiki.Components.ScrollingAPITreeView,{prefKey:PBconst.kWorkspaceTreeOpenNodes,rowHeight:22,apiOpts:{},initialize:function($super,A){this.apiOpts={sortby:"name",recursive:true};if(A.object_types){this.apiOpts.object_types=A.object_types}if(A.workspace){this.apiOpts.wiki=A.workspace}if(typeof (A.includeEmptyFolders)!="undefined"){this.includeEmptyFolders=A.includeEmptyFolders}if(!A.scrollElm){A.scrollElm=A.elm}$super(A)},refresh:function($super){this.options.elm.addClassName("loading");$super()},clearSelectedObject:function(){this.options.selectedObject=null;this.redraw()},onAfterLoad:function($super){this.options.elm.removeClassName("loading");if(this.options.centeredObject){this.openParentNodes(this.options.centeredObject[this.idKey])}$super();var C;if(this.options.centeredObject){var B=this.getData();for(var A=0;A<B.length;A++){if(B[A][this.idKey]==this.options.centeredObject[this.idKey]){C=A*this.rowHeight;break}}}if(C){C-=(this.options.scrollElm.getHeight()/2)-(this.rowHeight/2);this.options.scrollElm.scrollTop=C}this.notify("onLoad")},onRenderRow:function(L,D){var G=new Element("div").addClassName("row");var C=390;C-=21;var I=function(M){this.toggle(L.oid);this.redraw();M.stop()}.bind(this);var A=function(M){M.stop();this.options.selectedObject=L;this.redraw();this.notify("onSelected",L)}.bind(this);if(this.options.show_network_indent){G.appendChild(new Element("div",{"class":"spacer line"}));C-=15}for(var E=0;E<L.levels.length;E++){var H=new Element("div").addClassName("spacer");if(E<L.levels.length-1){if(L.levels[E]){H.addClassName("line")}}else{H.addClassName(L.last?"ln":"tn");if(L.type=="folder"&&L.hc){var K=new Element("div",{"class":"spacer"}).addClassName(this.isOpen(L.oid)?"contract":"expand");K.observe("click",I);H.appendChild(K)}}G.appendChild(H);C-=15}if(this.options.selectedObject&&L.oid==this.options.selectedObject.oid){G.addClassName("active")}if(L.type=="folder"){var B=new Element("a",{"class":"iconbutton folder",href:"#"});C-=20;if(this.options.selectable_folder_objects){B.observe("click",A)}else{B.addClassName("expandable");B.observe("click",I);var F=this.isOpen(L.oid)?"contract_hover":"expand_hover";B.observe("mouseover",function(){if(K){K.addClassName(F)}});B.observe("mouseout",function(){if(K){K.removeClassName(F)}})}B.setStyle({width:C+"px"});B.innerHTML=L.name.escapeHTML();G.appendChild(B)}else{var J=new Element("a",{href:"#","class":"iconbutton ellipses"});C-=20;J.setStyle({width:C+"px"});J.innerHTML=L.name.escapeHTML();if(L.type=="page"){J.addClassName("pageicon")}else{J.addClassName(Util.getFileIcon(L.name));if(this.options.workspace){L.wiki=this.options.workspace}Util.addObjectTooltip(J,L)}J.observe("click",A);G.appendChild(J)}return G}});Object.Event.extend(PBwiki.Components.WorkspaceObjectTreeView);PBwiki.Components.NetworkObjectTreeView=Class.create({initialize:function(A){this.options=A;this.options.elm.addClassName("network");this.load();if(this.options.selectedWorkspace){this.scrollToSelectedWorkspace()}this.toggle(this.options.selectedWorkspace,function(){if(!this.options.workspaceOpts.selectedObject&&this.options.selectedWorkspace){this.scrollToSelectedWorkspace()}}.bind(this))},scrollToSelectedWorkspace:function(){var A=this.treeRows[this.options.selectedWorkspace].cumulativeOffset().top-this.options.elm.cumulativeOffset().top;this.options.elm.scrollTop=A-22},redraw:function(){},load:function(){this.options.elm.innerHTML="";this.treeRows={};this.trees={};this.workspaceRows={};for(var B=0;B<this.options.workspaces.length;B++){var A=this.options.workspaces[B];if(B==this.options.workspaces.length-1){A.last=true}this.options.elm.appendChild(this.onRenderRow(A));this.options.elm.appendChild(this.onRenderTree(A))}},toggle:function(C,B){var A=this.trees[C];var F=this.treeRows[C];var E;if(!A){var D=Object.clone(this.options.workspaceOpts);D.workspace=C;D.elm=this.treeRows[C];D.show_network_indent=true;D.scrollElm=this.options.elm;A=this.trees[C]=new PBwiki.Components.WorkspaceObjectTreeView(D);if(B){A.observe("onLoad",B)}A.observe("onSelected",function(H){H.workspace=C;for(w in this.trees){if(w==C){continue}this.trees[w].clearSelectedObject()}this.notify("onSelected",H)}.bind(this));E=true}else{if(!F.visible()){F.show();if(B){B()}E=true}else{F.hide();if(B){B()}E=false}}var G=this.workspaceRows[C].down("div.expander");G.addClassName(E?"contract":"expand").removeClassName(E?"expand":"contract");return G},onRenderTree:function(A){this.treeRows[A.name]=new Element("div",{"class":"tree"});return this.treeRows[A.name]},onOverRow:function(A){var B=this.workspaceRows[A].down("div.expander");if(B){B.removeClassName("contract_hover").removeClassName("expand_hover");B.addClassName(B.hasClassName("contract")?"contract_hover":"expand_hover")}},onOutRow:function(A){var B=this.workspaceRows[A].down("div.expander");if(B){B.removeClassName("contract_hover").removeClassName("expand_hover")}},onRenderRow:function(A){var B=function(G){G.stop();this.toggle(A.name);this.onOverRow(A.name)}.bind(this);var E=new Element("div").addClassName("workspace");var D=new Element("div").addClassName("spacer");D.addClassName(A.last?"ln":"tn");var F=new Element("div",{"class":"spacer expander"}).addClassName("expand");F.observe("click",B);D.appendChild(F);E.appendChild(D);var C=new Element("a",{href:"#","class":"expandable iconbutton world ellipses"});C.observe("click",B);C.innerHTML=A.title.escapeHTML();C.observe("mouseover",this.onOverRow.bind(this,A.name));C.observe("mouseout",this.onOutRow.bind(this,A.name));E.appendChild(C);this.workspaceRows[A.name]=E;return E}});Object.Event.extend(PBwiki.Components.NetworkObjectTreeView);Page.AjaxEdit={editMode:false,sizeWarned:false,partialLoadEditor:false,initialize:function(){if(!PBwiki.feature("ajaxedit")||PBinfo.CurrentPage.editor_v3){return }if(window.location.search.toString().indexOf("edit=")!=-1){return }if($("edit-tab")&&$("edit-toolbar")&&$("view-tab")&&!$("edit-tab").hasClassName("logintoedit")){Page.AjaxEdit.start.bind(Page.AjaxEdit)()}},start:function(){this.partialLoadEditor=true;this.modeEnabled=true;if(window.location.hash=="#pbedit"){window.location.hash="#view=edit"}this.historyManager=PBwiki.History;this.historyManager.getKey("view").observe("onChange",function(D){if(["page","edit"].indexOf(D)!=-1){this.onViewChanged((D=="edit"))}}.bind(this));if(this.historyManager.getKey("view").getValue()=="edit"){if($("edit-tab").hasClassName("steal")){this.historyManager.setValues({view:"page"})}else{if($("wikicontent")){$("wikicontent").hide()}this.onViewChanged(true)}}if(PBinfo.CurrentPage.saved){document.fire("ui:onCurrentPageSaved",{})}this.frameTimer=setTimeout(this.loadFirstStage.bind(this),(window.location.hash=="#view=edit")?0:1000);document.observe("ui:fckeditor_oncomplete",function(){this.secondStage=true;this.resizeContentPanel()}.bind(this));document.observe("ui:editview",function(){this.onViewChanged(true)}.bind(this));document.observe("ui:fullscreen",this.setFullscreenMode.bind(this,true));document.observe("ui:nofullscreen",this.setFullscreenMode.bind(this,false));document.observe("ui:edit_lock_stolen",this.onEditLockStolen.bind(this));document.observe("live:locked",function(E){if(!this.editMode){return }var D=E.memo;if(!D.page||D.page!=PBwiki.getPageName()){return }if(D.owner!=PBwiki.getUID()){document.fire("ui:edit_lock_stolen",D)}}.bind(this));$("edit-tab").observe("mouseover",this.loadSecondStage.bind(this));$("view-tab").observe("click",this.tabClick.bindAsEventListener(this,false));$("edit-tab").observe("click",this.tabClick.bindAsEventListener(this,true));var A=$("edit-tab").down("a");if(A){A.onclick=null}var C=$("edit-toolbar").down(".button");$("cancelButton").observe("click",this.cancelEdit.bind(this));if(this.ajaxSave){C.observe("click",this.saveContent.bind(this));C.setAttribute("onclick","")}if(PBwiki.feature("ajaxcreate")){var B=$("main-tools").down("a.createpage");if(B&&!B.hasClassName("disabled")){B.observe("click",this.createPage.bind(this))}}Page.EditPage.Tags.initialize();if($("live_edit_toggle")){$("live_edit_toggle").observe("click",this.startLiveEdit.bind(this));document.observe("live:start_live_editing",this.onLiveEditStart.bind(this));document.observe("live:end_live_editing",this.onLiveEditEnd.bind(this));document.observe("live:deny_edit_request",this.onLiveEditDenyRequest.bind(this))}this.historyManager.start()},tabClick:function(B,A){if(B){B.stop();try{B.element().blur()}catch(B){}}this.onViewChanged(A)},onViewChanged:function(A){if(this.editMode==A){return }if(!A&&this.IsDirty()){if(!confirm("You have unsaved changes. Continue and discard those changes?")){this.historyManager.setValues({view:(this.editMode)?"edit":"page"});return }}if(A&&$("edit-tab").hasClassName("steal")){if(!confirm("This page is being edited by "+$("lockinfo").down("a").innerHTML+". Are you sure you wish to steal the lock?")){this.setMode(false);return }}this.setMode(A)},setMode:function(B){if(this.editMode==B){return }this.editMode=B;this.historyManager.setValues({view:(B)?"edit":"page"});try{if(B){this.loadSecondStage();Page.Thingbar.doLoad();var A=[];A.push(["SetPageLock",{page:PBwiki.getPageName(),steal:$("edit-tab").hasClassName("steal")},{onSuccess:function(E){this.handleLockinfo(E.lockinfo)}.bind(this)}]);if($("notification-autosave")){var D=Page.Notifications.findNotification($("notification-autosave"));if(!D){D=$("notification-autosave")}D.remove();A.push(["GetAutosave",{page:PBwiki.getPageName()},{onSuccess:this.handleAutosave.bind(this)}])}else{A.push(["GetPage",{page:PBwiki.getPageName(),raw:true},{onSuccess:this.handleGetPage.bind(this)}])}new PBwiki.MultiAPIRequest(A,{incUsess:true,onAllComplete:function(E){if(E.lastError){document.fire("ui:onNotifyUser",{message:E.lastError});this.setMode(false)}}.bind(this),onFailure:function(E){document.fire("ui:onNotifyUser",{message:E});this.setMode(false)}.bind(this)})}else{new PBwiki.APIRequest("UnlockPage",{page:PBwiki.getPageName()},{})}this.setChromeVisibility(B);this.setModeEvents(B)}catch(C){document.fire("ui:onNotifyUser",{message:"Failed to enter edit mode: "+C.message});return }if(!B&&this.secondStage&&this.IsDirty()){this.setContent(this.initialContent)}},IsDirty:function(){var A=this.getEditor();return((A)?A.IsDirty():false)||Page.EditPage.Tags.IsDirty()},handleGetPage:function(A){if(A.html!=this.initialContent){this.initialContent=A.html;this.setContent(A.html)}},handleAutosave:function(A){if(A.autosave){this.setContent(A.autosave.DATA)}},handleLockinfo:function(B){if(!B.hasLock){var A='<div class="edit-warning"><div class="content">';A+='This page is being edited by <a href="/user/'+B.owner+'">'+B.editname.escapeHTML()+"</a>.";A+='<a class="edit-warning" href="#view=edit">Steal lock</a></div></div>';$("lockinfo").update(A);$("edit-tab").addClassName("steal");this.onViewChanged("view");return }else{$("edit-tab").removeClassName("steal");$("lockinfo").update("")}},setChromeVisibility:function(A){(!A)?$("view-tab").addClassName("active"):$("view-tab").removeClassName("active");(A)?$("edit-tab").addClassName("active"):$("edit-tab").removeClassName("active");(!A)?$("wikicontent").show():$("wikicontent").hide();$("wikiedit").style.display=(A)?"block":"none";if($("comments")){$("comments").style.display=(!A)?"block":"none"}$("page-bottom-toolbar").style.display=(!A)?"block":"none";$("expand-collapse-page").style.display=(!A)?"block":"none";if($("page-footer")&&$("page-footer").down(".content")){$("page-footer").down(".content").style.display=(!A)?"block":"none"}$("edit-toolbar").down(".iconbutton").style.position="relative";if(A){UserPrefs.Manager.saveWidth();UserPrefs.Manager.goFullWidth()}else{UserPrefs.Manager.restoreWidth()}if(A){this.resizeContentPanel()}},setFullscreenMode:function(A){(A)?$("editwikipage").addClassName("fullscreen"):$("editwikipage").removeClassName("fullscreen");$("editwikipage").setStyle({width:""});if($("top-content")){$("top-content").style.display=(A)?"none":"block"}$("editor-column").style.display=(A)?"none":"block";$("show_tags").style.display=(A)?"none":"block";var D=$("content___Frame");if(D&&D.contentWindow){var B=D.contentWindow.document.getElementById("xToolbar");for(var C=0;C<B.childNodes.length;C++){if(B.childNodes[C].nodeName.toUpperCase()=="DIV"){B.childNodes[C].style.display=(A)?"none":"block";break}}}this.isFullscreen=A;this.resizeContentPanel()},setModeEvents:function(A){window.onresize=(A)?this.resizeContentPanel.bind(this):null;window.onbeforeunload=(A)?this.beforeUnload.bind(this):null;if(A){Page.EditPage.AutoSave.start.bind(Page.EditPage.AutoSave)()}else{Page.EditPage.AutoSave.stop.bind(Page.EditPage.AutoSave)()}},cancelEdit:function(A){A.stop();if(this.isFullscreen){document.fire("ui:nofullscreen")}this.setMode(false)},resetDirty:function(){if(this.secondStage){var A=this.getEditor();if(A&&A.ResetIsDirty){A.ResetIsDirty()}}},doDeleteAutosave:function(){new PBwiki.APIRequest("DeleteAutosave",{page:PBwiki.getPageName()},{onSuccess:function(){Page.Notifications.findNotification($("notification-autosave")).remove()}})},setEditorFocus:function(){$("autosave_msg").update($("autosave_msg").innerHTML);var A=this.getEditor();if(A&&this.secondStage){A.Focus()}},setContent:function(C){var A=this.getEditor();try{Page.EditPage.AutoSave.lastHTML=C;A.SetHTML(C,true);A.Focus()}catch(B){}$("content").value=C;this.checkSizeWarning(C.length)},checkSizeWarning:function(B){var A=Math.round(B/1024);var C=PBconst.kPolicyPageSizeWarning/1024;if(A>C&&!this.sizeWarned){document.fire("ui:onNotifyUser",{mode:"warning",message:"Warning: This page is "+A+'KB. We <a target="doc" href="https://usermanual.pbworks.com/Best-Practices#Addingnewpages">recommend splitting pages</a> larger than '+C+"KB up into several smaller pages for easier readability and best performance."});this.sizeWarned=true}},getEditor:function(){if(typeof (FCKeditorAPI)!="undefined"){return FCKeditorAPI.GetInstance("content")}},loadSecondStage:function(){if(this.secondStage||this.secondLoading){return }this.secondLoading=true;this.partialLoadEditor=false;this.loadFirstStage();if(!PBinfo.GetPage.hasPlugins&&$$(".searchhilitepage").length==0){this.editContent=$("wikipage-inner")?$("wikipage-inner").innerHTML:""}var A=$("content___Frame");if(A&&A.contentWindow&&A.contentWindow.SecondStage){A.contentWindow.SecondStage()}},loadFirstStage:function(){if(this.firstStage||this.firstLoading){return }this.firstLoading=true;if($("content")){return }var B=$("wikiedit");var C=(Prototype.Browser.IE)?"ie":"gecko";var A='<iframe id="content___Frame" src="/FCKeditor/build-fck/editor/'+C+"-"+PBinfo.CurrentPage.editorVersion+(PBinfo.CurrentWiki.debug?"/debug":"");A+='" width="100%" height="'+this.getResizeHeight()+'" frameborder="0" scrolling="no"></iframe>';A+='<input type="hidden" id="content___Config" value="ToolbarStartExpanded=true&amp;SkinPath=/FCKeditor/build-fck/editor/skins/silver/" style="display:none" />';var E=new Element("textarea");E.setAttribute("id","content");E.setAttribute("name","content");E.style.display="none";E.value="";var D=this.getContentFromPage();if(D){E.value=this.initialContent=D}$("editframe").innerHTML=A;$("editframe").appendChild(E);if(PBinfo.CurrentWiki.debug){$("content___Frame").contentWindow.onerror=PBwiki.jsDebug}},firstStageLoaded:function(){this.firstStage=true;this.firstLoading=false;document.fire("ui:fckeditor_preloaded")},getResizeHeight:function(){var C=$("content___Frame");var B=(C&&C.cumulativeOffset)?C.cumulativeOffset()[1]:$("editwikipage").cumulativeOffset()[1];if($("page-footer")&&!this.isFullscreen){B+=$("page-footer").getHeight()+parseInt($("page-footer").getStyle("marginBottom"))}B+=$("edit-toolbar-outer").getHeight()+parseInt($("edit-toolbar-outer").getStyle("marginBottom"));var A=document.documentElement.clientHeight-(B+2);A=(A<310?310:A);return A},resizeContentPanel:function(){var A=$("content___Frame");if(!A){return }A.style.height=this.getResizeHeight()+"px";if(A.contentWindow.onresize){A.contentWindow.onresize()}if(this.editMode){this.setEditorFocus()}if(this.isFullscreen){$("editwikipage").setStyle({width:Math.max(document.documentElement.clientWidth,$("main-content").getWidth())+"px"})}},beforeUnload:function(A){A=A||window.event;try{if(this.IsDirty()&&!Page.EditPage.cancel){var C="You have unsaved changes. Continue and discard those changes?";A.returnValue=C;return C}}catch(B){}},startLiveEdit:function(A){A.stop();(new PBwiki.DialogCommands.FindUsers({title:"Invite users to Live View",isLiveEdit:true,isLiveEditor:true,showGroupChats:true,onSelect:function(B){document.fire("live:start_live_editing",B)}.bind(this)}))},onLiveEditStart:function(A){(new PBwiki.APIRequest("SetPageLock",{page:PBwiki.getPageName(),"private":false},{onSuccess:function(B){PBinfo.GetPage.lockinfo=B.lockinfo;Page.EditPage.AutoSave.stop();Page.EditPage.AutoSave.start({draft:{draft_id:B.lockinfo.draft_id,v:0},saveInterval:2});Page.EditPage.AutoSave.lastHTML="";var E=A.memo;var D={wiki:PBinfo.CurrentWiki.name};var C={request_wiki_name:PBinfo.CurrentWiki.name,link:Util.URLRelativeToContext("/"+PBwiki.getPageName()+"#view=liveview",D)};E.each(function(G){C.live_edit_link_for_user=Strophe.getNodeFromJid(G);var H=$J.message({to:G,type:"chat"}).c("body",{unique:PBwiki.Live.randomString()}).c("link-to-page",C).t(PBwiki.getPageName());PBwiki.Live.connection.send(H)});var F=PBwiki.Live.getLiveEditChatForCurrentPage();if(!F){F=new PBwiki.Live.ChatBox(PBwiki.getUID(),true,true);F.show(true)}}}))},onLiveEditDenyRequest:function(F){var D=F.memo;var C=D+"@"+PBwiki.Live.basedomain;var B={wiki:PBinfo.CurrentWiki.name};var A={request_wiki_name:PBinfo.CurrentWiki.name,live_edit_request_deny_for_user:D,link:Util.URLRelativeToContext("/"+PBwiki.getPageName()+"#view=liveview",B)};var E=$J.message({to:C,type:"chat"}).c("body",{unique:PBwiki.Live.randomString()}).c("link-to-page",A).t(PBwiki.getPageName());PBwiki.Live.connection.send(E)},onLiveEditEnd:function(){(new PBwiki.APIRequest("SetPageLock",{page:PBwiki.getPageName(),"private":true},{onSuccess:function(A){PBinfo.GetPage.lockinfo=A.lockinfo;Page.EditPage.AutoSave.stop();Page.EditPage.AutoSave.start()}}))},onEditLockStolen:function(B){var A=B.memo;PBinfo.GetPage.lockinfo=A;alert(((A.editname)?A.editname:"Somebody")+" has stolen your lock on this page.  You will no longer be able to save changes.");Page.EditPage.AutoSave.stop();document.fire("ui:disablesave")},getContentFromPage:function(){if(!$("wikipage-inner")||PBinfo.GetPage.hasPlugins||$$(".searchhilitepage").length>0||$$("table.pbSortable").length>0){return }return $("wikipage-inner").innerHTML},createPage:function(A){A.stop();new PBwiki.DialogCommands.CreateNewPage({noPreloadView:true,onCreate:function(B){window.location.href=PBwiki.getEditURI(B)}})}};Page.Thingbar={pageOpts:{object_types:"page",count:10,offset:0,sortby:"mtime",reverse:true},fileOpts:{object_types:"file",count:10,offset:0,sortby:"mtime",reverse:true},doLoad:function(){if(!$("thingbarLoadIcon")){return true}new MiniTabSwitcher({"linkselectab-pages":"thingbar-pages","linkselectab-images":"thingbar-images"});this.loadPages();$("linkselectab-images").observe("ui:tabswitched",this.filesTab.bind(this));if(!Prototype.Browser.IE){$("linkselectab-images").observe("ui:tabswitched",this.changeTipMessage.bind(this,true));$("linkselectab-pages").observe("ui:tabswitched",this.changeTipMessage.bind(this,false))}},changeTipMessage:function(B){var A=B?"Drag and drop images or files from your desktop to add them to this workspace page.":"To turn text into a link, highlight the text, then click on a page or file from the list above.";$("editor-tip").update("<strong>Tip:&nbsp;</strong> "+A)},showPageLoadIcon:function(){this.pageList.update('<img src="/images/spin_bw.gif" /> Loading '+((!this.pageOpts.count)?"All ":"")+"Pages...")},showFileLoadIcon:function(){this.fileList.update('<img src="/images/spin_bw.gif" /> Loading '+((!this.fileOpts.count)?"All ":"")+"Files...")},loadPages:function(){this.pageList=$("thingbarpages");this.showPageLoadIcon();new PBwiki.APIRequest("GetObjectsNOM",this.pageOpts,{onSuccess:function(A){this.pageList.update("");A.objects.each(function(C){var B=new Element("li").addClassName("tbpage");B.appendChild(new Element("span"));B.appendChild(new Element("a",{unselectable:"on"}).update(C.name.toString().escapeHTML()).observe("mousedown",function(D){D.stop();this.pageLink(Util.dashified_link(C.name.toString()),C.name.toString());return false}.bind(this)));this.pageList.appendChild(B)}.bind(this));if(this.pageOpts.count&&A._total_count>A.objects.length){if(this.allPagesLink){this.allPagesLink.remove()}this.allPagesLink=new Element("a",{href:"javascript:void(0);"}).update("Show all "+A._total_count+" pages").observe("mousedown",function(B){B.stop();delete this.pageOpts.count;delete this.pageOpts.offset;this.loadPages()}.bind(this));this.pageList.parentNode.appendChild(this.allPagesLink)}if(!this.pageOpts.count&&this.allPagesLink){this.allPagesLink.remove()}}.bind(this),priority:PBwiki.Data.LOW_PRIORITY})},filesTab:function(){this.loadFiles();if(!$("file_upload_button")){if(!$("thingbar-upload")){return }$("thingbar-upload").update("");new PBwiki.Components.FileUploadButton({txt:"Upload files",id:"file_upload_button",addTo:$("thingbar-upload"),folder:PBinfo.CurrentPage.folder?PBinfo.CurrentPage.folder:"",onUploaded:function(){new PBwiki.APIRequest("GetTimes",{},{onSuccess:function(){this.loadFiles();this.loadPages()}.bind(this),method:"get"})}.bind(this)});$("file_upload_button").down("span").setStyle({textDecoration:"underline",cursor:"pointer"})}},loadFiles:function(){this.fileList=$("thingbarfiles");delete this.fileOpts.type;this.showFileLoadIcon();new PBwiki.APIRequest("GetObjectsNOM",this.fileOpts,{onSuccess:function(A){this.fileList.update("");A.objects.each(function(C){var B=new Element("li").addClassName("tbfile");var D=Util.iconMap[Util.getFileExtension(C.name.toString())];B.appendChild(new Element("span").addClassName("fileicon").addClassName(D));B.appendChild(new Element("a",{unselectable:"on"}).update(C.name.toString().escapeHTML()).observe("mousedown",function(E){E.stop();this.fileLink(C.name.toString(),Util.isImageFile(C.name.toString()));return false}.bind(this)));this.fileList.appendChild(B);Util.addObjectTooltip(B,C)}.bind(this));if(this.fileOpts.count&&A._total_count>A.objects.length){if(this.allFilesLink){this.allFilesLink.remove()}this.allFilesLink=new Element("a",{href:"javascript:void(0);"}).update("Show all "+A._total_count+" files").observe("mousedown",function(B){B.stop();delete this.fileOpts.count;delete this.fileOpts.offset;this.loadFiles()}.bind(this));this.fileList.parentNode.insertBefore(this.allFilesLink,this.fileList.nextSibling)}else{if(A._total_count==0){this.fileList.update("No recent files")}}if(!this.fileOpts.count&&this.allFilesLink){this.allFilesLink.remove()}}.bind(this),priority:PBwiki.Data.LOW_PRIORITY})},getSelectedText:function(){var A=Page.AjaxEdit.getEditor().Selection.GetSelection();return(A.createRange)?A.createRange().text:A.toString()},pageLink:function(B,D){Util.tracking("editor-linking-tb-page");if(PBinfo.CurrentPage.editor_v3){try{PBwiki.currentEditor.setSelectedLink({href:"/"+B,txt:D,type:"page"})}catch(C){}return }var A=Page.AjaxEdit.getEditor();var E=A.EditorDocument.createElement("a");E.setAttribute("href","/"+B);E.innerHTML=this.getSelectedText()||D.escapeHTML();A.InsertElement(E);A.Focus()},fileLink:function(A,E){Util.tracking("editor-linking-tb-file");if(PBinfo.CurrentPage.editor_v3){try{PBwiki.currentEditor.setSelectedLink({href:"/f/"+encodeURIComponent(A),txt:A,type:"file"})}catch(C){alert(C.message)}return }var B=Page.AjaxEdit.getEditor();E=E&&this.getSelectedText()=="";var D=B.EditorDocument.createElement(E?"img":"a");D.setAttribute((E)?"src":"href","/f/"+encodeURIComponent(A));if(!E){D.innerHTML=this.getSelectedText()||A}B.InsertElement(D)}};Page.InsertLink=Class.create({initialize:function(){document.observe("ui:insertlink",this.insertLink.bind(this))},getEditorSelection:function(){try{var A=Page.AjaxEdit.getEditor();A.Selection.Save();var D=A.Selection.MoveToAncestorNode("A");if(D){return{url:D.getAttribute("href",2),txt:D.innerHTML,newWin:(D.getAttribute("target")=="_blank")}}else{var B=Page.AjaxEdit.getEditor().Selection.GetSelection();return{txt:((B.createRange)?B.createRange().text:B.toString()).strip()}}}catch(C){return{txt:""}}},applyEditorLink:function(A){var F=Page.AjaxEdit.getEditor();F.Selection.Restore();var G=F.Selection.MoveToAncestorNode("A");if(G){G.href=A.href;G.setAttribute("href",A.href);G.setAttribute("target",A.newWin?"_blank":null);G.setAttribute("_fcksavedurl",A.href)}else{var E=this.getEditorSelection();var F=Page.AjaxEdit.getEditor();if(A.type=="file"&&Util.isImageFile(A.txt)){Page.Thingbar.fileLink(A.txt,true);return }var D=F.CreateLink(A.href,true);if(D.length==0){var C=F.InsertElement("a");C.setAttribute("href",A.href);C.innerHTML=E.txt.strip().escapeHTML()||A.txt.escapeHTML();D=[C]}for(var B=0;B<D.length;B++){(A.newWin)?D[B].setAttribute("target","_blank"):D[B].removeAttribute("target")}F.Focus()}},insertLink:function(){if(PBinfo.CurrentPage.editor_v3){return }var A=this.getEditorSelection();A.onSelect=this.applyEditorLink.bind(this);new PBwiki.DialogCommands.InsertLink(A)}});PBwiki.init(function(){var A=$("editor_v3_toggle");if(A){A.observe("click",function(B){B.stop();PBwiki.UserPrefs.set(PBconst.kEditorV3PrefsKey,PBinfo.CurrentPage.editor_v3?false:1);setTimeout(function(){window.location.reload()},1000)})}});PBwiki.init(Page.InsertLink);PBwiki.init(Page.AjaxEdit);Page.NewPage={changeContentSource:function(B){var A=B.element();$$(".content-controller").each(function(D){if(D.getAttribute("ui:sister")){var C=(A==D)?"block":"none";$(D.getAttribute("ui:sister")).setStyle({display:C})}})},checkConvertStatus:function(){var A=$("convert_id").value;new PBwiki.APIRequest("GetImportStatus",{convert_id:A},{onSuccess:function(B){if(B.status=="finished"){window.location="/"+Util.dashified_link(B.page)+"?imported=1"}else{if(B.status=="error"){window.location="/newpage.php?convert_id=error"}else{window.setTimeout(Page.NewPage.checkConvertStatus,2000)}}},onFailure:function(B){window.setTimeout(Page.NewPage.checkConvertStatus,2000)},method:"post"})},fileWasSelected:function(e){var fileName=$("file_data").value.toLowerCase();if(!eval(PBconst.kPolicyConvertSupportedDocumentRegex).test(fileName)){$("file_data").value="";if($("page_name").value==$("page_name").getAttribute("ui:inferred_filename")){$("page_name").value=""}alert("PBworks cannot import that type of file.\n\nSupported document types:\n- Comma-separated values (.csv)\n- Microsoft Word (.doc)\n- OpenDocument Spreadsheet (.ods)\n- OpenDocument Text (.odt)\n- WordPerfect (.wpd)\n- Microsoft Excel (.xls)");return }if($("page_name").value!==""&&$("page_name").value!=$("page_name").getAttribute("ui:inferred_filename")){return }var inferred_filename=Page.NewPage.fileNameToPageName(fileName);$("page_name").value=inferred_filename;$("page_name").setAttribute("ui:inferred_filename",inferred_filename)},fileNameToPageName:function(A){if(A[0]=="."){A=A.substring(1)}if(A.lastIndexOf(".")>=0){A=A.substring(0,A.lastIndexOf("."))}if(A.lastIndexOf("\\")>=0){A=A.substr(A.lastIndexOf("\\")+1)}A=Util.strToPageName(A);return A},initialize:function(){if($("convert_id")){return Page.NewPage.initializeConversionStatus()}else{if($("createpageform")){return Page.NewPage.initializeCreatePageForm()}}},initializeConversionStatus:function(){window.setTimeout(Page.NewPage.checkConvertStatus,1000)},initializeCreatePageForm:function(){if($("tipmoreoptions")){Event.observe("tipmoreoptions","click",Page.NewPage.toggleMoreOptions.bind(this))}Event.observe("page_name","keydown",Page.NewPage.isCharacterValid.bind(this));if($("security")){Event.observe("security","click",Page.NewPage.securityChanged.bind(this))}if($("file_data")){Event.observe("file_data","change",Page.NewPage.fileWasSelected.bind(this))}Event.observe("create-page-form","submit",Page.NewPage.submit.bind(this));if($("createpagemore")){Event.observe("createpagemore","click",Page.NewPage.toggleMoreOptions.bind(this));Page.NewPage.toggleElements=$$($("createpagemore").getAttribute("ui:elements"));Page.NewPage.link=$("createpagemore")}$$(".content-controller").each(function(A){Event.observe(A,"click",Page.NewPage.changeContentSource.bind(A))})},isCharacterValid:function(A){},toggleMoreOptions:function(D){var B=Page.NewPage.link;var C=B.innerHTML;var A=B.getAttribute("ui:alternate");if(A){B.setAttribute("ui:alternate",B.innerHTML);B.innerHTML=A}$(B.parentNode.parentNode).toggleClassName("expanded");B.blur();D.stop();Page.NewPage.toggleElements.invoke("toggle");$("createpageoptions_visible").setAttribute("value",$(B.parentNode.parentNode).hasClassName("expanded")?"true":"false");$("page_name").focus()},securityChanged:function(B){if(!$("page-content-import-security-warning")){return }var A=($("security").value=="default security")?"none":"block";$("security-type").innerHTML=$("security").value;$("page-content-import-security-warning").setStyle({display:A})},submit:function(C){var A=$("page_name").value;if(!A){$("error-text").update("Empty page names are not allowed");Event.stop(C);return }var B;for(B=0;B<PBconst.kInvalidPageCharacters.length;B++){if(A.indexOf(PBconst.kInvalidPageCharacters[B])>=0){$("error-text").update("Page names can't contain any of the following characters: "+PBconst.kInvalidPageCharacters.escapeHTML());Event.stop(C);return }}$$(".form-action-button").each(function(D){D.setAttribute("disabled","disabled")})}};var stIsIE=
/*@cc_on!@*/
false;var _timer=false;sorttable={init:function(){if(arguments.callee.done){return }arguments.callee.done=true;if(_timer){clearInterval(_timer)}if(!document.createElement||!document.getElementsByTagName){return }sorttable.DATE_RE=/^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;forEach(document.getElementsByTagName("table"),function(A){if(A.className.search(/\bpbSortable\b/)!=-1){sorttable.makeSortable(A)}})},makeSortable:function(B){if(B.getElementsByTagName("thead").length==0){the=document.createElement("thead");the.appendChild(B.rows[0]);B.insertBefore(the,B.firstChild)}if(B.tHead==null){B.tHead=B.getElementsByTagName("thead")[0]}if(B.tHead.rows.length!=1){return }sortbottomrows=[];for(var A=0;A<B.rows.length;A++){if(B.rows[A].className.search(/\bsortbottom\b/)!=-1){sortbottomrows[sortbottomrows.length]=B.rows[A]}}if(sortbottomrows){if(B.tFoot==null){tfo=document.createElement("tfoot");B.appendChild(tfo)}for(var A=0;A<sortbottomrows.length;A++){tfo.appendChild(sortbottomrows[A])}delete sortbottomrows}headrow=B.tHead.rows[0].cells;for(var A=0;A<headrow.length;A++){if(!headrow[A].className.match(/\bsorttable_nosort\b/)){mtch=headrow[A].className.match(/\bsorttable_([a-z0-9]+)\b/);if(mtch){override=mtch[1]}if(mtch&&typeof sorttable["sort_"+override]=="function"){headrow[A].sorttable_sortfunction=sorttable["sort_"+override]}else{headrow[A].sorttable_sortfunction=sorttable.guessType(B,A)}headrow[A].sorttable_columnindex=A;headrow[A].sorttable_tbody=B.tBodies[0];dean_addEvent(headrow[A],"click",function(D){if(this.className.search(/\bsorttable_sorted\b/)!=-1){sorttable.reverse(this.sorttable_tbody);this.className=this.className.replace("sorttable_sorted","sorttable_sorted_reverse");this.removeChild(document.getElementById("sorttable_sortfwdind"));sortrevind=document.createElement("span");sortrevind.id="sorttable_sortrevind";sortrevind.setAttribute("style","float: left;");sortrevind.innerHTML=stIsIE?'&nbsp<font face="webdings">5</font>&nbsp;':"&nbsp;&#x25B4;&nbsp;";this.insertBefore(sortrevind,this.firstChild);return }if(this.className.search(/\bsorttable_sorted_reverse\b/)!=-1){sorttable.reverse(this.sorttable_tbody);this.className=this.className.replace("sorttable_sorted_reverse","sorttable_sorted");this.removeChild(document.getElementById("sorttable_sortrevind"));sortfwdind=document.createElement("span");sortfwdind.id="sorttable_sortfwdind";sortfwdind.setAttribute("style","float: left;");sortfwdind.innerHTML=stIsIE?'&nbsp<font face="webdings">6</font>&nbsp;':"&nbsp;&#x25BE;&nbsp;";this.insertBefore(sortfwdind,this.firstChild);return }theadrow=this.parentNode;forEach(theadrow.childNodes,function(E){if(E.nodeType==1){E.className=E.className.replace("sorttable_sorted_reverse","");E.className=E.className.replace("sorttable_sorted","")}});sortfwdind=document.getElementById("sorttable_sortfwdind");if(sortfwdind){sortfwdind.parentNode.removeChild(sortfwdind)}sortrevind=document.getElementById("sorttable_sortrevind");if(sortrevind){sortrevind.parentNode.removeChild(sortrevind)}this.className+=" sorttable_sorted";sortfwdind=document.createElement("span");sortfwdind.id="sorttable_sortfwdind";sortfwdind.setAttribute("style","float: left;");sortfwdind.innerHTML=stIsIE?'&nbsp<font face="webdings">6</font>&nbsp;':"&nbsp;&#x25BE;&nbsp;";this.insertBefore(sortfwdind,this.firstChild);row_array=[];col=this.sorttable_columnindex;rows=this.sorttable_tbody.rows;for(var C=0;C<rows.length;C++){row_array[row_array.length]=[sorttable.getInnerText(rows[C].cells[col]),rows[C]]}row_array.sort(this.sorttable_sortfunction);tb=this.sorttable_tbody;for(var C=0;C<row_array.length;C++){tb.appendChild(row_array[C][1])}delete row_array})}}},guessType:function(C,B){sortfn=sorttable.sort_alpha;for(var A=0;A<C.tBodies[0].rows.length;A++){text=sorttable.getInnerText(C.tBodies[0].rows[A].cells[B]);if(text!=""){if(text.match(/^-?[�$�]?[\d,.]+%?$/)){return sorttable.sort_numeric}possdate=text.match(sorttable.DATE_RE);if(possdate){first=parseInt(possdate[1]);second=parseInt(possdate[2]);if(first>12){return sorttable.sort_ddmm}else{if(second>12){return sorttable.sort_mmdd}else{sortfn=sorttable.sort_ddmm}}}}}return sortfn},getInnerText:function(B){hasInputs=(typeof B.getElementsByTagName=="function")&&B.getElementsByTagName("input").length;if(B.getAttribute("sorttable_customkey")!=null){return B.getAttribute("sorttable_customkey")}else{if(typeof B.textContent!="undefined"&&!hasInputs){return B.textContent.replace(/^\s+|\s+$/g,"")}else{if(typeof B.innerText!="undefined"&&!hasInputs){return B.innerText.replace(/^\s+|\s+$/g,"")}else{if(typeof B.text!="undefined"&&!hasInputs){return B.text.replace(/^\s+|\s+$/g,"")}else{switch(B.nodeType){case 3:if(B.nodeName.toLowerCase()=="input"){return B.value.replace(/^\s+|\s+$/g,"")}case 4:return B.nodeValue.replace(/^\s+|\s+$/g,"");break;case 1:case 11:var C="";for(var A=0;A<B.childNodes.length;A++){C+=sorttable.getInnerText(B.childNodes[A])}return C.replace(/^\s+|\s+$/g,"");break;default:return""}}}}}},reverse:function(A){newrows=[];for(var B=0;B<A.rows.length;B++){newrows[newrows.length]=A.rows[B]}for(var B=newrows.length-1;B>=0;B--){A.appendChild(newrows[B])}delete newrows},sort_numeric:function(B,A){aa=parseFloat(B[0].replace(/[^0-9.-]/g,""));if(isNaN(aa)){aa=0}bb=parseFloat(A[0].replace(/[^0-9.-]/g,""));if(isNaN(bb)){bb=0}return aa-bb},sort_alpha:function(B,A){if(B[0]==A[0]){return 0}if(B[0]<A[0]){return -1}return 1},sort_ddmm:function(B,A){mtch=B[0].match(sorttable.DATE_RE);y=mtch[3];m=mtch[2];d=mtch[1];if(m.length==1){m="0"+m}if(d.length==1){d="0"+d}dt1=y+m+d;mtch=A[0].match(sorttable.DATE_RE);y=mtch[3];m=mtch[2];d=mtch[1];if(m.length==1){m="0"+m}if(d.length==1){d="0"+d}dt2=y+m+d;if(dt1==dt2){return 0}if(dt1<dt2){return -1}return 1},sort_mmdd:function(B,A){mtch=B[0].match(sorttable.DATE_RE);y=mtch[3];d=mtch[2];m=mtch[1];if(m.length==1){m="0"+m}if(d.length==1){d="0"+d}dt1=y+m+d;mtch=A[0].match(sorttable.DATE_RE);y=mtch[3];d=mtch[2];m=mtch[1];if(m.length==1){m="0"+m}if(d.length==1){d="0"+d}dt2=y+m+d;if(dt1==dt2){return 0}if(dt1<dt2){return -1}return 1},shaker_sort:function(F,D){var A=0;var C=F.length-1;var G=true;while(G){G=false;for(var B=A;B<C;++B){if(D(F[B],F[B+1])>0){var E=F[B];F[B]=F[B+1];F[B+1]=E;G=true}}C--;if(!G){break}for(var B=C;B>A;--B){if(D(F[B],F[B-1])<0){var E=F[B];F[B]=F[B-1];F[B-1]=E;G=true}}A++}}};PBwiki.init(sorttable.init);function dean_addEvent(B,D,C){if(B.addEventListener){B.addEventListener(D,C,false)}else{if(!C.$$guid){C.$$guid=dean_addEvent.guid++}if(!B.events){B.events={}}var A=B.events[D];if(!A){A=B.events[D]={};if(B["on"+D]){A[0]=B["on"+D]}}A[C.$$guid]=C;B["on"+D]=handleEvent}}dean_addEvent.guid=1;function removeEvent(A,C,B){if(A.removeEventListener){A.removeEventListener(C,B,false)}else{if(A.events&&A.events[C]){delete A.events[C][B.$$guid]}}}function handleEvent(D){var C=true;D=D||fixEvent(((this.ownerDocument||this.document||this).parentWindow||window).event);var A=this.events[D.type];for(var B in A){this.$$handleEvent=A[B];if(this.$$handleEvent(D)===false){C=false}}return C}function fixEvent(A){A.preventDefault=fixEvent.preventDefault;A.stopPropagation=fixEvent.stopPropagation;return A}fixEvent.preventDefault=function(){this.returnValue=false};fixEvent.stopPropagation=function(){this.cancelBubble=true};if(!Array.forEach){Array.forEach=function(D,C,B){for(var A=0;A<D.length;A++){C.call(B,D[A],A,D)}}}Function.prototype.forEach=function(A,D,C){for(var B in A){if(typeof this.prototype[B]=="undefined"){D.call(C,A[B],B,A)}}};String.forEach=function(A,C,B){Array.forEach(A.split(""),function(E,D){C.call(B,E,D,A)})};var forEach=function(A,D,B){if(A){var C=Object;if(A instanceof Function){C=Function}else{if(A.forEach instanceof Function){A.forEach(D,B);return }else{if(typeof A=="string"){C=String}else{if(typeof A.length=="number"){C=Array}}}}C.forEach(A,D,B)}};SearchHilite=Class.create({initialize:function(){if(/SearchFor\=/.test(window.location.search)){var C=window.location.search.replace(/[a-zA-Z0-9\?\&\=\%\#]+SearchFor\=(\w+)(\&.*)?/,"$1");var A=C.replace(/\%20|\+/g,"|");var B=A.split("|");this.highlight($("wikipage-inner"),B);this.highlight($("comments"),B);var E=$$("span.searchhilitepage");if(E.length>0){var D=new Element("span").update('&nbsp;[ <a href="'+window.location.href.replace(window.location.search,"")+'">remove highlighting</a> ]');E[0].insert({after:D})}}},highlight:function(C,E){for(var B=0;B<E.length;B++){var D=new RegExp(">([^<]*)?("+E[B]+")([^>]*)?<","ig");var A=C.innerHTML;C.innerHTML=A.replace(D,'>$1<span class="searchhilitepage">$2</span>$3<')}}});PBwiki.init(SearchHilite);Page.AjaxSave={initialize:function(){document.observe("ui:fckeditor_oncomplete",Page.AjaxSave.activate.bind(Page.AjaxSave))},activate:function(){this.saveButton=$("edit-toolbar").down(".button");this.saveButton.observe("click",this.saveContent.bind(this));this.saveButton.setAttribute("onclick","");this.tagfield=$("tagfield");this.initialTags=this.tagfield.value;document.observe("ui:disablesave",this.disableSave.bind(this));document.observe("ui:autosaveSuccess",this.autosaveSuccess.bind(this));document.observe("ui:autosaveFailure",this.autosaveFailure.bind(this));document.observe("ui:savepage",this.saveContent.bind(this))},saveContent:function(D){if(D){D.stop()}if(this.saveButton.hasClassName("disabled")){return }this.disableSave();this.setMsg("Saving "+PBwiki.getPageName().toString().escapeHTML()+"...",true);var C=[];var A=window.location.search.toQueryParams()||{};if(A.folder||A.security){var B={page:PBwiki.getPageName()};if(A.folder){B.folder=decodeURIComponent(A.folder.toString().replace(/\+/g," "))}if(A.security){B.security=A.security}B.html=Page.AjaxEdit.getEditor().GetData(true);C.push(["CreatePage",B,{onFailure:this.saveFail.bind(this),onSuccess:this.saveSuccess.bind(this),incUsess:true}])}else{var B={create_if_missing:true};B.page=PBwiki.getPageName();B.html=Page.AjaxEdit.getEditor().GetData(true);C.push(["PutPage",B,{onFailure:this.saveFail.bind(this),onSuccess:this.saveSuccess.bind(this),incUsess:true}])}C.push(["UnlockPage",{page:PBwiki.getPageName()},{onFailure:this.saveFail.bind(this)}]);if(this.initialTags!=this.tagfield.value){C.push(["SetPageTags",{page:PBwiki.getPageName(),tags:this.tagfield.value},{onFailure:this.saveFail.bind(this)}])}new PBwiki.MultiAPIRequest(C,{incUsess:true,onFailure:this.saveFail.bind(this)})},autosaveSuccess:function(){if(this.getMsg()==this.autosaveErrorMsg){this.clearMsg()}},autosaveFailure:function(A){if($("save_msg").style.display!="inline"){this.autosaveErrorMsg=A.memo;this.setMsg(A.memo)}},saveSuccess:function(B){Page.EditPage.cancel=true;this.setMsg("Page Saved Successfully",false,true);var A="/"+(B.page?B.page:PBwiki.getPageName());if(Prototype.Browser.WebKit){A+=((window.location.search.indexOf("?unlock=true")!=-1)?"":"?unlock=true")}window.location=A},saveFail:function(B,A){if(A==403&&$H(PBwiki.getSessCookie()).values()[0]==""){this.setMsg("You have been logged out in another window.  Log back in and try again",false)}else{this.setMsg(B,false)}this.enableSave()},setMsg:function(B,A){var C=$("save_msg");C.style.display="inline";C.innerHTML=B;C.style.background=(A)?"url(/images/spin_bw.gif) no-repeat center left":"none"},clearMsg:function(){$("save_msg").style.display="none"},getMsg:function(){return $("save_msg").innerHTML},disableSave:function(){Page.EditPage.AutoSave.stop();this.saveButton.addClassName("disabled");this.saveButton.onclick=null;this.saveButton.setAttribute("href","javascript:void(0);");$("cancelButton").onclick=null;$("cancelButton").addClassName("disabled");try{this.saveButton.blur()}catch(A){}Page.EditPage.cancel=true},enableSave:function(){Page.EditPage.AutoSave.start();this.saveButton.removeClassName("disabled");$("cancelButton").removeClassName("disabled");Page.EditPage.cancel=false}};PBwiki.init(Page.AjaxSave);Page.AjaxSave={initialize:function(){document.observe("ui:fckeditor_oncomplete",Page.AjaxSave.activate.bind(Page.AjaxSave))},activate:function(){this.saveButton=$("edit-toolbar").down(".button");this.saveButton.observe("click",this.saveContent.bind(this));this.saveButton.setAttribute("onclick","");this.tagfield=$("tagfield");this.initialTags=this.tagfield.value;document.observe("ui:disablesave",this.disableSave.bind(this));document.observe("ui:autosaveSuccess",this.autosaveSuccess.bind(this));document.observe("ui:autosaveFailure",this.autosaveFailure.bind(this));document.observe("ui:savepage",this.saveContent.bind(this))},saveContent:function(D){if(D){D.stop()}if(this.saveButton.hasClassName("disabled")){return }this.disableSave();this.setMsg("Saving "+PBwiki.getPageName().toString().escapeHTML()+"...",true);var C=[];var A=window.location.search.toQueryParams()||{};if(A.folder||A.security){var B={page:PBwiki.getPageName()};if(A.folder){B.folder=decodeURIComponent(A.folder.toString().replace(/\+/g," "))}if(A.security){B.security=A.security}B.html=Page.AjaxEdit.getEditor().GetData(true);C.push(["CreatePage",B,{onFailure:this.saveFail.bind(this),onSuccess:this.saveSuccess.bind(this),incUsess:true}])}else{var B={create_if_missing:true};B.page=PBwiki.getPageName();B.html=Page.AjaxEdit.getEditor().GetData(true);C.push(["PutPage",B,{onFailure:this.saveFail.bind(this),onSuccess:this.saveSuccess.bind(this),incUsess:true}])}C.push(["UnlockPage",{page:PBwiki.getPageName()},{onFailure:this.saveFail.bind(this)}]);if(this.initialTags!=this.tagfield.value){C.push(["SetPageTags",{page:PBwiki.getPageName(),tags:this.tagfield.value},{onFailure:this.saveFail.bind(this)}])}new PBwiki.MultiAPIRequest(C,{incUsess:true,onFailure:this.saveFail.bind(this)})},autosaveSuccess:function(){if(this.getMsg()==this.autosaveErrorMsg){this.clearMsg()}},autosaveFailure:function(A){if($("save_msg").style.display!="inline"){this.autosaveErrorMsg=A.memo;this.setMsg(A.memo)}},saveSuccess:function(B){Page.EditPage.cancel=true;this.setMsg("Page Saved Successfully",false,true);var A="/"+(B.page?B.page:PBwiki.getPageName());if(Prototype.Browser.WebKit){A+=((window.location.search.indexOf("?unlock=true")!=-1)?"":"?unlock=true")}window.location=A},saveFail:function(B,A){if(A==403&&$H(PBwiki.getSessCookie()).values()[0]==""){this.setMsg("You have been logged out in another window.  Log back in and try again",false)}else{this.setMsg(B,false)}this.enableSave()},setMsg:function(B,A){var C=$("save_msg");C.style.display="inline";C.innerHTML=B;C.style.background=(A)?"url(/images/spin_bw.gif) no-repeat center left":"none"},clearMsg:function(){$("save_msg").style.display="none"},getMsg:function(){return $("save_msg").innerHTML},disableSave:function(){Page.EditPage.AutoSave.stop();this.saveButton.addClassName("disabled");this.saveButton.onclick=null;this.saveButton.setAttribute("href","javascript:void(0);");$("cancelButton").onclick=null;$("cancelButton").addClassName("disabled");try{this.saveButton.blur()}catch(A){}Page.EditPage.cancel=true},enableSave:function(){Page.EditPage.AutoSave.start();this.saveButton.removeClassName("disabled");$("cancelButton").removeClassName("disabled");Page.EditPage.cancel=false}};PBwiki.init(Page.AjaxSave);SendALink=Class.create({initialize:function(A){$$("span.sendalink-milestone a").each(function(B){B.observe("click",this.milestoneLinkObserver.bindAsEventListener(this,B))}.bind(this));this.element=$(A);if(!this.element){return }this.link=this.element.down("a");PBwiki.debug(this.link);this.link.observe("click",this.linkObserver.bindAsEventListener(this));if(window.location.hash=="#send-a-link"){window.location.hash="";this.linkObserver(null)}},milestoneLinkObserver:function(D,C){if(D){D.stop()}var F=C.up("div.milestone");var A=F.getAttribute("milestone_id");var B=F.down("span.milestone-title");var E=B.textContent||B.innerText;if(!A){PBwiki.error("milestone_id not found, unable to continue");return }new PBwiki.DialogCommands.SendALink({dimensions:{width:510,height:"auto"},url:Util.URLRelativeToContext("/w/tasks/#milestone"+A,{wiki:PBinfo.CurrentWiki.name}),title:"Project Milestones",description:'the milestone "'+E+'"',destination_type:PBconst.kSendALinkType.Milestone})},linkObserver:function(B){if(B){B.stop()}var A={dimensions:{width:510,height:"auto"}};if(PBinfo.CurrentPage.page){A.page=PBinfo.CurrentPage.page;A.destination_type=PBconst.kSendALinkType.Page;A.objectname=A.page}else{if(PBwiki.ObjectBrowser&&PBwiki.ObjectBrowser.view&&PBwiki.ObjectBrowser.view.name=="ViewFileRevision"){A.url=window.location.toString();A.title=PBwiki.ObjectBrowser.view.options.parameter;A.description='"'+A.title+'" on this workspace';A.destination_type=PBconst.kSendALinkType.File;A.objectname=PBwiki.ObjectBrowser.view.refreshOptions.file}else{if(PBwiki.ObjectBrowser&&PBwiki.ObjectBrowser.view&&PBwiki.ObjectBrowser.view.displayTitle){A.url=Util.URLRelativeToContext("/w/folder/"+encodeURIComponent(PBwiki.ObjectBrowser.view.metadata.name),{wiki:PBinfo.CurrentWiki.name});A.title=PBwiki.ObjectBrowser.view.displayTitle;A.description='"'+A.title+'" on this workspace';A.destination_type=PBconst.kSendALinkType.Folder;A.objectname=PBwiki.ObjectBrowser.view.metadata.name}else{if(PBwiki.Project&&PBwiki.Project.currentView){A.url=window.location.toString();A.title=PBwiki.Project.currentView.getPageTitle();A.objectname=$("project-action").getAttribute("task_id");A.description='the task "'+A.title+'"';A.destination_type=PBconst.kSendALinkType.Task}}}}new PBwiki.DialogCommands.SendALink(A)}});PBwiki.init(SendALink,"sendalink");PBwiki.DialogCommands.SendALink=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"sendalink",title:"Send a link",initialize:function($super,A){if(A.destination_type){this.title="Share this "+A.destination_type}else{this.title="Share this page"}$super(A)},setupDialog:function($super){$super();this.setupInstructions();this.setupUserList();this.setupStar();this.message=$("sendalink_message");Event.observe("sendalink_send","click",this.submit.bind(this))},submit:function(A){A.stop();if(this.userList.empty()){window.alert("Please select people on the workspace to share this page with.");return false}var B={to_uids:this.userList.getUIDs().join(","),destination_type:this.options.destination_type,objectname:this.options.objectname};if(this.options.page){B.page=this.options.page}if(this.options.url){B.url=this.options.url}if(this.options.title){B.title=this.options.title}if(this.allowEmails()){B.to_emails=this.userList.getExtraEmails().join(",");B.new_user_permission=$("sendalink_to_perm-guest").checked?"guest":"user";if($("sendalink-trackuser").checked){B.track_new_users=true}}if(!this.message.value.blank()){B.message=this.message.value.strip()}if(this.userList.contains(PBconst.kSendALinkAllUsersWithAccess)){B.send_to_all_users_with_access=true}new PBwiki.APIRequest("SendALink",B,{method:"post",parameters:B,onSuccess:function(C){document.fire("dialog:close");document.fire("ui:onNotifyUser",{message:"Successfully sent a link to this page.",mode:"success"})}.bind(this),onFailure:function(C){document.fire("dialog:close");document.fire("ui:onNotifyUser",{message:"Failed to send the link. "+C,mode:"error"})}.bind(this)});return true},setupInstructions:function(){if(this.options.description){$("sendalink-workspace-page-title").update(this.options.description.escapeHTML());$("sendalink-network-page-title").update(this.options.description.escapeHTML())}if(this.options.destination_type){$$(".sendalink-destination-type").each(function(A){A.update(this.options.destination_type.escapeHTML())}.bind(this))}$$("a.sendalink-add-all-users").each(function(A){A.observe("click",this.onAddAllUsersClicked.bind(this))}.bind(this));if(PBinfo.GetFeatures.send_a_link_find_users_improvements&&PBinfo.CurrentNetwork){$("sendalink-workspace-instructions").hide();if(this.allowEmails()){$("sendalink-network-instructions").hide();$("sendalink-network-admin-instructions").show()}else{$("sendalink-network-instructions").show();$("sendalink-network-admin-instructions").hide()}$("sendalink-advice-standalone").hide();$("sendalink-advice-network").show();$("sendalink-find-users").observe("click",this.onFindUsersClicked.bind(this))}else{$("sendalink-workspace-instructions").show();$("sendalink-network-instructions").hide();$("sendalink-network-admin-instructions").hide();$("sendalink-advice-standalone").show();$("sendalink-advice-network").hide()}},onAddAllUsersClicked:function(C){var B={name:"All workspace members with access",uid:PBconst.kSendALinkAllUsersWithAccess};var A=new PBwiki.Components.UserAutoComplete.SelectedUser(this.userAutoComplete,B);this.userAutoComplete.selectedUserList.append(A)},onFindUsersClicked:function(A){var B=new PBwiki.FindNetworkUsers.Dialog({callback:this.onUsersSelected.bind(this),exclude_self:false})},onUsersSelected:function(A){$(A).each(function(C){var B=new PBwiki.Components.UserAutoComplete.SelectedUser(this.userAutoComplete,C);this.userAutoComplete.selectedUserList.append(B)}.bind(this))},setupUserList:function(){var A=$("sendalink_to");if(A){if(this.allowEmails()){A.setAttribute("placeholder","Type a name or email address");$("sendalink-to-advice").hide();document.stopObserving("ui:autoCompleteListChange");document.observe("ui:autoCompleteListChange",this.togglePermissionLevel.bind(this));$("sendalink-guest-help-icon").observe("click",function(E){if(E){E.stop()}$("sendalink-guest-help-icon").hide();$("sendalink-guest-help").show()});$("sendalink_to_perm-guest").observe("change",this.togglePermissionLevel.bind(this));$("sendalink_to_perm-user").observe("change",this.togglePermissionLevel.bind(this))}new InputText(A);var D,C;if(this.options.title==="All Pages"||this.options.title==="All Files"||this.options.title==="Unfiled Items"||this.options.destination_type===PBconst.kSendALinkType.Milestone||this.options.destination_type===PBconst.kSendALinkType.Task){D="GetPageUsers";C={page:PBinfo.CurrentWiki.front_page}}else{if(this.options.destination_type===PBconst.kSendALinkType.File){D="GetFileUsers";C={file:this.options.title}}else{if(this.options.destination_type===PBconst.kSendALinkType.Folder){D="GetFolderUsers";C={folder:this.options.title}}else{D="GetPageUsers";C={page:PBinfo.CurrentPage.page}}}}var B={userListContainer:$("sendalink_to_container"),userList:$("sendalink_to_list"),elm:A,apiMethod:D,requestOptions:C,allowEmails:this.allowEmails()};this.userAutoComplete=new PBwiki.Components.UserAutoComplete(B);this.userList=this.userAutoComplete.selectedUserList}},togglePermissionLevel:function(){var A=this.userList.getExtraEmails();if(PBinfo.CheckPermissions.network_perm=="admin"){$$(".sendalink-must-add-as-guests").invoke("hide")}else{$$(".sendalink-must-add-as-guests").invoke("show");$("sendalink-guest-row").select(".radio-label").invoke("hide");$("sendalink_to_perm-guest").checked="checked"}if(A.length==0){$("sendalink-guest-row").hide()}else{if(A.length==1){$$(".sendalink-guest-plural").map(function(B){B.hide()});$$(".sendalink-guest-singular").map(function(B){B.show()});$("sendalink-guest-row").show()}else{$$(".sendalink-guest-singular").map(function(B){B.hide()});$$(".sendalink-guest-plural").map(function(B){B.show()});$("sendalink-guest-row").show()}}if(A.length&&PBwiki.feature("user_tracking")&&(PBinfo.CheckPermissions&&(PBinfo.CheckPermissions.wikiperm=="admin"||PBinfo.CheckPermissions.network_perm=="admin"))&&$("sendalink_to_perm-guest").checked){$("sendalink-star-hr").show();$("sendalink-starred-row").hide();$("sendalink-unstarred-row").hide();$("sendalink-trackuser-row").show()}else{$("sendalink-trackuser-row").hide();this.setupStar()}},allowEmails:function(){var A=(PBinfo.CheckPermissions.network_perm=="admin")||(PBinfo.CheckPermissions.network_perm=="user"&&PBinfo.CheckPermissions.wikiperm=="admin");return PBwiki.feature("getting_started_v3")&&PBinfo&&PBinfo.CheckPermissions&&PBinfo.CheckPermissions.network_perm&&A&&PBinfo.CurrentWiki&&PBinfo.CurrentWiki.network_public&&$$(".security_btn_hidden").length===0&&$$(".security_btn_custom").length===0},setupStar:function(){if(!PBinfo.CurrentPage||!PBinfo.CurrentPage.page){return }$("sendalink-page-name").update("'"+PBinfo.CurrentPage.page+"'");this.starred=PBwiki.UserPrefs.Stars.is_current_page_starred();if(PBinfo.CurrentWiki.granular_notifications){$$(".granular-notifications-message").each(function(A){A.show()})}else{$$(".no-granular-notifications-message").each(function(A){A.show()})}if(this.starred){$("sendalink-star-hr").show();$("sendalink-starred-row").show();$("sendalink-unstarred-row").hide();return }$("sendalink-star-hr").show();$("sendalink-starred-row").hide();$("sendalink-unstarred-row").show();Event.observe("sendalink-star","click",function(A){A.stop();this.toggleStarState();$("sendalink-star").addClassName("working");PBwiki.UserPrefs.Stars.set_object_starred({name:PBinfo.CurrentPage.page,starred:this.starred,onFailure:this.starPageError.bind(this),onSuccess:this.didStarPage.bind(this)});Util.tracking("page-star-sendalink-"+(this.starred?"on":"off"))}.bind(this))},didStarPage:function(A){$("sendalink-star").removeClassName("working")},starPageError:function(A){this.toggleStarState()},toggleStarState:function(B){var A=!this.starred;this.starred=A;if(A){$("sendalink-star").addClassName("starred")}else{$("sendalink-star").removeClassName("starred")}document.fire("ui:hideBubbles")}});PBwiki.init(function(){if(!PBinfo.CurrentWiki||!PBinfo.GetRecentWikis||(!$("network-crumb-all-workspaces-link")&&!$("network-crumb-my-link"))){return }var C=[];$(PBinfo.GetRecentWikis.wikis).each(function(F){var G=F.icon?("icon-"+F.icon):"bullet";C.push({name:F.name,txt:F.title.escapeHTML(),className:"iconbutton "+G,onClick:function(){window.location=F.url}})});var D=$("network-crumb-all-workspaces-link")||$("network-crumb-my-link");var B="Go to workspaces list ("+PBinfo.GetRecentWikis.total_wiki_count+" total)";C.push({name:"all-workspaces",txt:B,className:"iconbutton goback",onClick:function(){window.location=D.href}});var A=new PBMenu({toggle:D,anchor:D.up("li"),items:C});var E=A.options.anchor.getDimensions().width+10;if(A.elm.getDimensions().width<E){A.elm.style.width=E+"px"}if($("network-bar").hasClassName("standalone")){$("network-crumb-all-workspaces-link-pbmenu").addClassName("standalone")}else{$("network-crumb-all-workspaces-link-pbmenu").addClassName("network")}});PBwiki.init(function(){if(!PBinfo.CurrentNetwork||!PBinfo.CurrentNetwork.license||PBinfo.CheckPermissions.network_perm!=="admin"){return }if(PBinfo.CurrentNetwork.license.is_expired){var A=new PBwiki.DialogCommands.LicenseExpired({})}});var videoJSPlayers=new Array();(function(){var A=false,B=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.JRClass=function(){};JRClass.extend=function(G){var E=this.prototype;A=true;var D=new this();A=false;for(var C in G){D[C]=typeof G[C]=="function"&&typeof E[C]=="function"&&B.test(G[C])?(function(H,I){return function(){var K=this._super;this._super=E[H];var J=I.apply(this,arguments);this._super=K;return J}})(C,G[C]):G[C]}function F(){if(!A&&this.init){this.init.apply(this,arguments)}}F.prototype=D;F.constructor=F;F.extend=arguments.callee;return F}})();var VideoJS=JRClass.extend({init:function(B,A){if(typeof B=="string"){this.video=document.getElementById(B)}else{this.video=B}this.video.controls=false;this.options={num:0,controlsBelow:false,controlsHiding:true,defaultVolume:0.85,flashVersion:9,linksHiding:true};if(typeof VideoJS.options=="object"){_V_.merge(this.options,VideoJS.options)}if(typeof A=="object"){_V_.merge(this.options,A)}this.box=this.video.parentNode;this.flashFallback=this.getFlashFallback();this.linksFallback=this.getLinksFallback();if(VideoJS.browserSupportsVideo()||((this.flashFallback||VideoJS.isIE())&&this.flashVersionSupported())){this.hideLinksFallback()}if(VideoJS.browserSupportsVideo()){if(this.canPlaySource()==false){this.replaceWithFlash();return }}else{return }if(VideoJS.isIpad()){this.options.controlsBelow=true;this.options.controlsHiding=false}if(this.options.controlsBelow){_V_.addClass(this.box,"vjs-controls-below")}this.percentLoaded=0;this.buildPoster();this.showPoster();this.buildController();this.showController();this.addListeners()},fixPreloading:function(){if(typeof this.video.hasAttribute=="function"&&this.video.hasAttribute("preload")){this.video.autobuffer=true}},play:function(){this.video.play()},pause:function(){this.video.pause()},buildController:function(){this.controls=_V_.createElement("ul",{className:"vjs-controls"});this.video.parentNode.appendChild(this.controls);this.playControl=_V_.createElement("li",{className:"vjs-play-control vjs-play",innerHTML:"<span></span>"});this.controls.appendChild(this.playControl);this.progressControl=_V_.createElement("li",{className:"vjs-progress-control"});this.controls.appendChild(this.progressControl);this.progressHolder=_V_.createElement("ul",{className:"vjs-progress-holder"});this.progressControl.appendChild(this.progressHolder);this.loadProgress=_V_.createElement("li",{className:"vjs-load-progress"});this.progressHolder.appendChild(this.loadProgress);this.playProgress=_V_.createElement("li",{className:"vjs-play-progress"});this.progressHolder.appendChild(this.playProgress);this.timeControl=_V_.createElement("li",{className:"vjs-time-control"});this.controls.appendChild(this.timeControl);this.currentTimeDisplay=_V_.createElement("span",{className:"vjs-current-time-display",innerHTML:"00:00"});this.timeControl.appendChild(this.currentTimeDisplay);this.timeSeparator=_V_.createElement("span",{innerHTML:" / "});this.timeControl.appendChild(this.timeSeparator);this.durationDisplay=_V_.createElement("span",{className:"vjs-duration-display",innerHTML:"00:00"});this.timeControl.appendChild(this.durationDisplay);this.volumeControl=_V_.createElement("li",{className:"vjs-volume-control",innerHTML:"<ul><li></li><li></li><li></li><li></li><li></li><li></li></ul>"});this.controls.appendChild(this.volumeControl);this.volumeDisplay=this.volumeControl.children[0];this.fullscreenControl=_V_.createElement("li",{className:"vjs-fullscreen-control",innerHTML:"<ul><li></li><li></li><li></li><li></li></ul>"});this.controls.appendChild(this.fullscreenControl)},getLinksFallback:function(){return this.box.getElementsByTagName("P")[0]},hideLinksFallback:function(){if(this.options.linksHiding&&this.linksFallback){this.linksFallback.style.display="none"}},getFlashFallback:function(){if(VideoJS.isIE()){return }var C=this.box.getElementsByClassName("vjs-flash-fallback");for(var B=0,A=C.length;B<A;B++){if(C[B].tagName.toUpperCase()=="OBJECT"){return C[B]}}},replaceWithFlash:function(){if(this.flashFallback){this.box.insertBefore(this.flashFallback,this.video);this.video.style.display="none"}},showController:function(){this.controls.style.display="block";this.positionController()},positionController:function(){if(this.controls.style.display=="none"){return }if(this.playControl.offsetWidth==this.progressControl.offsetWidth&&this.playControl.offsetWidth==this.timeControl.offsetWidth&&this.playControl.offsetWidth==this.volumeControl.offsetWidth){if(!this.positionRetries){this.positionRetries=1}if(this.positionRetries++<100){this.controls.style.display="none";setTimeout(this.showController.context(this),0);return }}if(this.videoIsFullScreen){this.box.style.width=""}else{this.box.style.width=this.video.offsetWidth+"px"}if(this.options.controlsBelow){if(this.videoIsFullScreen){this.box.style.height="";this.video.style.height=(this.box.offsetHeight-this.controls.offsetHeight)+"px"}else{this.video.style.height="";this.box.style.height=this.video.offsetHeight+this.controls.offsetHeight+"px"}this.controls.style.top=this.video.offsetHeight+"px"}else{this.controls.style.top=(this.video.offsetHeight-this.controls.offsetHeight)+"px"}this.sizeProgressBar()},hideController:function(){if(this.options.controlsHiding){this.controls.style.display="none"}},addListeners:function(){this.video.addEventListener("loadeddata",this.onLoadedData.context(this),false);this.video.addEventListener("play",this.onPlay.context(this),false);this.video.addEventListener("pause",this.onPause.context(this),false);this.video.addEventListener("ended",this.onEnded.context(this),false);this.video.addEventListener("volumechange",this.onVolumeChange.context(this),false);this.video.addEventListener("error",this.onError.context(this),false);this.video.addEventListener("progress",this.onProgress.context(this),false);this.watchBuffer=setInterval(this.updateBufferedTotal.context(this),33);this.video.addEventListener("timeupdate",this.onTimeUpdate.context(this),false);this.playControl.addEventListener("click",this.onPlayControlClick.context(this),false);this.video.addEventListener("click",this.onPlayControlClick.context(this),false);if(this.poster){this.poster.addEventListener("click",this.onPlayControlClick.context(this),false)}this.progressHolder.addEventListener("mousedown",this.onProgressHolderMouseDown.context(this),false);this.progressHolder.addEventListener("mouseup",this.onProgressHolderMouseUp.context(this),false);this.setVolume(localStorage.volume||this.options.defaultVolume);this.volumeControl.addEventListener("mousedown",this.onVolumeControlMouseDown.context(this),false);this.volumeControl.addEventListener("mouseup",this.onVolumeControlMouseUp.context(this),false);this.updateVolumeDisplay();this.fullscreenControl.addEventListener("click",this.onFullscreenControlClick.context(this),false);this.video.addEventListener("mousemove",this.onVideoMouseMove.context(this),false);this.video.addEventListener("mouseout",this.onVideoMouseOut.context(this),false);if(this.poster){this.poster.addEventListener("mousemove",this.onVideoMouseMove.context(this),false)}if(this.poster){this.poster.addEventListener("mouseout",this.onVideoMouseOut.context(this),false)}this.controls.addEventListener("mouseout",this.onVideoMouseOut.context(this),false);this.onEscKey=function(A){if(A.keyCode==27){this.fullscreenOff()}}.context(this);this.onWindowResize=function(A){this.positionController()}.context(this);this.fixPreloading();this.subtitlesSource=this.video.getAttribute("data-subtitles");if(this.subtitlesSource!=null){this.loadSubtitles();this.buildSubtitles()}},updatePosterSource:function(){if(!this.video.poster){var A=this.video.getElementsByTagName("img");if(A.length>0){this.video.poster=A[0].src}}},buildPoster:function(){this.updatePosterSource();if(this.video.poster){this.poster=document.createElement("img");this.video.parentNode.appendChild(this.poster);this.poster.src=this.video.poster;this.poster.className="vjs-poster"}else{this.poster=false}},showPoster:function(){if(!this.poster){return }this.poster.style.display="block";this.positionPoster()},positionPoster:function(){if(this.poster==false||this.poster.style.display=="none"){return }this.poster.style.height=this.video.offsetHeight+"px";this.poster.style.width=this.video.offsetWidth+"px"},hidePoster:function(){if(!this.poster){return }this.poster.style.display="none"},canPlaySource:function(){var D=this.video.children;for(var C=0,B=D.length;C<B;C++){if(D[C].tagName.toUpperCase()=="SOURCE"){var A=this.video.canPlayType(D[C].type);if(A=="probably"||A=="maybe"){return true}}}return false},paused:function(){return this.video.paused},currentTime:function(){return this.video.currentTime},durationTime:function(){return this.video.duration},onPlay:function(A){this.playControl.className="vjs-play-control vjs-pause";this.hidePoster();this.trackPlayProgress()},onPause:function(A){this.playControl.className="vjs-play-control vjs-play";this.stopTrackingPlayProgress()},onEnded:function(A){this.pause();this.onPause()},onVolumeChange:function(A){this.updateVolumeDisplay()},onError:function(A){},onLoadedData:function(A){this.showController()},onProgress:function(A){if(A.total>0){this.setLoadProgress(A.loaded/A.total)}},updateBufferedTotal:function(){if(this.video.buffered){if(this.video.buffered.length>=1){this.setLoadProgress(this.video.buffered.end(0)/this.durationTime());if(this.video.buffered.end(0)==this.durationTime()){clearInterval(this.watchBuffer)}}}else{clearInterval(this.watchBuffer)}},setLoadProgress:function(A){if(A>this.percentLoaded){this.percentLoaded=A;this.updateLoadProgress()}},updateLoadProgress:function(){if(this.controls.style.display=="none"){return }this.loadProgress.style.width=(this.percentLoaded*(_V_.getComputedStyleValue(this.progressHolder,"width").replace("px","")))+"px"},onPlayControlClick:function(A){if(this.paused()){this.play()}else{this.pause()}},onProgressHolderMouseDown:function(A){this.stopTrackingPlayProgress();if(this.paused()){this.videoWasPlaying=false}else{this.videoWasPlaying=true;this.pause()}_V_.blockTextSelection();document.onmousemove=function(B){this.setPlayProgressWithEvent(B)}.context(this);document.onmouseup=function(B){_V_.unblockTextSelection();document.onmousemove=null;document.onmouseup=null;if(this.videoWasPlaying){this.video.play();this.trackPlayProgress()}}.context(this)},onProgressHolderMouseUp:function(A){this.setPlayProgressWithEvent(A);if(this.paused()){this.onPause()}else{this.onPlay()}},onVolumeControlMouseDown:function(A){_V_.blockTextSelection();document.onmousemove=function(B){this.setVolumeWithEvent(B)}.context(this);document.onmouseup=function(){_V_.unblockTextSelection();document.onmousemove=null;document.onmouseup=null}.context(this)},onVolumeControlMouseUp:function(A){this.setVolumeWithEvent(A)},onFullscreenControlClick:function(A){if(!this.videoIsFullScreen){this.fullscreenOn()}else{this.fullscreenOff()}},onVideoMouseMove:function(A){this.showController();clearInterval(this.mouseMoveTimeout);this.mouseMoveTimeout=setTimeout(function(){this.hideController()}.context(this),4000)},onVideoMouseOut:function(B){var A=B.relatedTarget;while(A&&A!==this.video&&A!==this.controls){A=A.parentNode}if(A!==this.video&&A!==this.controls){this.hideController()}},sizeProgressBar:function(){this.updatePlayProgress();this.updateLoadProgress()},getControlsPadding:function(){return _V_.findPosX(this.playControl)-_V_.findPosX(this.controls)},getControlBorderAdjustment:function(){var A=parseInt(_V_.getComputedStyleValue(this.playControl,"border-left-width").replace("px",""));var B=parseInt(_V_.getComputedStyleValue(this.playControl,"border-right-width").replace("px",""));return A+B},trackPlayProgress:function(){if(this.playProgressInterval){clearInterval(this.playProgressInterval)}this.playProgressInterval=setInterval(function(){this.updatePlayProgress()}.context(this),33)},stopTrackingPlayProgress:function(){clearInterval(this.playProgressInterval)},updatePlayProgress:function(){if(this.controls.style.display=="none"){return }this.playProgress.style.width=((this.currentTime()/this.durationTime())*(_V_.getComputedStyleValue(this.progressHolder,"width").replace("px","")))+"px";this.updateTimeDisplay()},setPlayProgress:function(A){this.video.currentTime=A*this.durationTime();this.playProgress.style.width=A*(_V_.getComputedStyleValue(this.progressHolder,"width").replace("px",""))+"px";this.updateTimeDisplay();if(this.subtitles!=null){this.currentSubtitlePosition=0}},setPlayProgressWithEvent:function(A){var B=_V_.getRelativePosition(A.pageX,this.progressHolder);this.setPlayProgress(B)},updateTimeDisplay:function(){this.currentTimeDisplay.innerText=_V_.formatTime(this.currentTime());if(this.durationTime()){this.durationDisplay.innerText=_V_.formatTime(this.durationTime())}},setVolume:function(A){this.video.volume=parseFloat(A);localStorage.volume=this.video.volume},setVolumeWithEvent:function(A){var B=_V_.getRelativePosition(A.pageX,this.volumeControl.children[0]);this.setVolume(B)},updateVolumeDisplay:function(){var B=Math.ceil(this.video.volume*6);for(var A=0;A<6;A++){if(A<B){_V_.addClass(this.volumeDisplay.children[A],"vjs-volume-level-on")}else{_V_.removeClass(this.volumeDisplay.children[A],"vjs-volume-level-on")}}},flashVersionSupported:function(){return VideoJS.getFlashVersion()>=this.options.flashVersion},fullscreenOn:function(){if(!this.nativeFullscreenOn()){this.videoIsFullScreen=true;this.docOrigOverflow=document.documentElement.style.overflow;document.addEventListener("keydown",this.onEscKey,false);window.addEventListener("resize",this.onWindowResize,false);document.documentElement.style.overflow="hidden";_V_.addClass(this.box,"vjs-fullscreen");this.positionController();this.positionPoster()}},nativeFullscreenOn:function(){if(typeof this.video.webkitEnterFullScreen=="function"&&false){if(!navigator.userAgent.match("Chrome")){this.video.webkitEnterFullScreen();return true}}},fullscreenOff:function(){this.videoIsFullScreen=false;document.removeEventListener("keydown",this.onEscKey,false);window.removeEventListener("resize",this.onWindowResize,false);document.documentElement.style.overflow=this.docOrigOverflow;_V_.removeClass(this.box,"vjs-fullscreen");this.positionController();this.positionPoster()},loadSubtitles:function(){if(typeof XMLHttpRequest=="undefined"){XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(B){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(B){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(B){}throw new Error("This browser does not support XMLHttpRequest.")}}var A=new XMLHttpRequest();A.open("GET",this.subtitlesSource);A.onreadystatechange=function(){if(A.readyState==4&&A.status==200){this.parseSubtitles(A.responseText)}}.context(this);A.send()},parseSubtitles:function(E){var A=E.replace("\r","").split("\n");this.subtitles=new Array();this.currentSubtitlePosition=0;var C=0;while(C<A.length){var B={};B.id=A[C++];if(B.id==""){break}var D=A[C++].split(" --> ");B.startTime=this.parseSubtitleTime(D[0]);B.endTime=this.parseSubtitleTime(D[1]);var E=new Array();while(A[C].length>0&&A[C]!="\r"){E.push(A[C++])}B.text=E.join("<br/>");this.subtitles.push(B);C++}},parseSubtitleTime:function(A){var C=A.split(":");var B=0;B+=parseInt(C[0])*60*60;B+=parseInt(C[1])*60;var D=C[2].split(",");B+=parseInt(D[0]);B=B+parseInt(D[1])/1000;return B},buildSubtitles:function(){this.subtitlesDiv=_V_.createElement("div",{className:"vjs-subtitles"});this.video.parentNode.appendChild(this.subtitlesDiv)},onTimeUpdate:function(){if(this.subtitles!=null){var A=this.currentSubtitlePosition;while(A<this.subtitles.length&&this.currentTime()>this.subtitles[A].endTime){if(this.subtitles[A].showing){this.subtitles[A].showing=false;this.subtitlesDiv.innerHTML=""}this.currentSubtitlePosition++;A=this.currentSubtitlePosition}if(this.currentSubtitlePosition>=this.subtitles.length){return }if(this.currentTime()>=this.subtitles[A].startTime&&this.currentTime()<=this.subtitles[A].endTime){this.subtitlesDiv.innerHTML=this.subtitles[A].text;this.subtitles[A].showing=true}}}});var _V_={addClass:function(A,B){if(A.className.split(/\s+/).lastIndexOf(B)==-1){A.className=A.className==""?B:A.className+" "+B}},removeClass:function(B,A){if(B.className.indexOf(A)==-1){return }var C=B.className.split(/\s+/);C.splice(C.lastIndexOf(A),1);B.className=C.join(" ")},merge:function(B,A){for(attrname in A){B[attrname]=A[attrname]}return B},createElement:function(B,A){return _V_.merge(document.createElement(B),A)},blockTextSelection:function(){document.body.focus();document.onselectstart=function(){return false}},unblockTextSelection:function(){document.onselectstart=function(){return true}},formatTime:function(A){A=Math.round(A);minutes=Math.floor(A/60);minutes=(minutes>=10)?minutes:"0"+minutes;A=Math.floor(A%60);A=(A>=10)?A:"0"+A;return minutes+":"+A},getRelativePosition:function(B,A){return Math.max(0,Math.min(1,(B-_V_.findPosX(A))/A.offsetWidth))},findPosX:function(A){var B=A.offsetLeft;while(A=A.offsetParent){B+=A.offsetLeft}return B},getComputedStyleValue:function(A,B){if(A.currentStyle){var C=A.currentStyle[B]}else{if(window.getComputedStyle){var C=document.defaultView.getComputedStyle(A,null).getPropertyValue(B)}}return C},bindDOMReady:function(){if(document.readyState==="complete"){return _V_.DOMReady()}if(document.addEventListener){document.addEventListener("DOMContentLoaded",_V_.DOMContentLoaded,false);window.addEventListener("load",_V_.DOMReady,false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",_V_.DOMContentLoaded);window.attachEvent("onload",_V_.DOMReady)}}},DOMContentLoaded:function(){if(document.addEventListener){document.removeEventListener("DOMContentLoaded",_V_.DOMContentLoaded,false);_V_.DOMReady()}else{if(document.attachEvent){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",_V_.DOMContentLoaded);_V_.DOMReady()}}}},DOMReadyList:[],addToDOMReady:function(A){if(_V_.DOMIsReady){A.call(document)}else{_V_.DOMReadyList.push(A)}},DOMIsReady:false,DOMReady:function(){if(_V_.DOMIsReady){return }if(!document.body){return setTimeout(_V_.DOMReady,13)}_V_.DOMIsReady=true;if(_V_.DOMReadyList){for(var A=0;A<_V_.DOMReadyList.length;A++){_V_.DOMReadyList[A].call(document)}_V_.DOMReadyList=null}}};_V_.bindDOMReady();VideoJS.setupAllWhenReady=function(A){VideoJS.options=A;VideoJS.DOMReady(VideoJS.setup)};VideoJS.DOMReady=function(A){_V_.addToDOMReady(A)};VideoJS.setup=function(C,A){var E=false,D=[];if(!C||C=="All"){C=VideoJS.getVideoJSTags()}else{if(typeof C!="object"){C=[C];E=true}}for(var B=0;B<C.length;B++){if(typeof C[B]=="string"){videoElement=document.getElementById(C[B])}else{videoElement=C[B]}D.push(new VideoJS(videoElement,A))}return(E)?D[0]:D};VideoJS.getVideoJSTags=function(){var C=document.getElementsByTagName("video"),A=[];for(var D=0,B=C.length;D<B;D++){videoTag=C[D];if(videoTag.className.indexOf("video-js")!=-1){A.push(videoTag)}}return A};VideoJS.browserSupportsVideo=function(){if(typeof VideoJS.videoSupport!="undefined"){return VideoJS.videoSupport}return VideoJS.videoSupport=!!document.createElement("video").canPlayType};VideoJS.getFlashVersion=function(){if(typeof VideoJS.flashVersion!="undefined"){return VideoJS.flashVersion}var A=0;if(typeof navigator.plugins!="undefined"&&typeof navigator.plugins["Shockwave Flash"]=="object"){desc=navigator.plugins["Shockwave Flash"].description;if(desc&&!(typeof navigator.mimeTypes!="undefined"&&navigator.mimeTypes["application/x-shockwave-flash"]&&!navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)){A=parseInt(desc.match(/^.*\s+([^\s]+)\.[^\s]+\s+[^\s]+$/)[1])}}else{if(typeof window.ActiveXObject!="undefined"){try{var B=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(B){A=parseInt(B.GetVariable("$version").match(/^[^\s]+\s(\d+)/)[1])}}catch(C){}}}return VideoJS.flashVersion=A};VideoJS.isIE=function(){return !+"\v1"};VideoJS.isIpad=function(){return navigator.userAgent.match(/iPad/i)!=null};Function.prototype.context=function(A){var B=this;temp=function(){return B.apply(A,arguments)};return temp};var AudioJS,VideoJS_SWF;PBwiki.init(function(){$$(".pb-av-video").each(function(A){A.setStyle({cursor:"pointer"});A.observe("click",function(G){var H=A.src,C,E,F,D=A.width,B=A.height;H=H.substr(0,H.length-4);if(VideoJS.browserSupportsVideo()&&navigator.userAgent.indexOf("Chrome")<0){C=new Element("div",{"class":"video-js-box"});F=new Element("video",{"class":"video-js",width:D,height:B,autoplay:"autoplay"});C.insert(F);F.insert(new Element("source",{src:H+".mp4",type:"video/mp4"}));F.insert(new Element("source",{src:H+".ogv",type:"video/ogg"}));A.insert({before:C});A.hide();obj=new VideoJS(A.previous().down(),{controlsBelow:true,controlsHiding:false})}else{E="/swf/player_flv_js.swf";obj=new VideoJS_SWF(A,{swf:E,width:D,height:B,src:H})}})});$$(".pb-av-audio").each(function(A){A.setStyle({cursor:"pointer"});A.observe("click",function(E){var F=A.src,B,C,D;F=F.substr(0,F.length-4);if(VideoJS.browserSupportsVideo()){B=new Element("div",{"class":"video-js-box"});D=new Element("audio",{"class":"video-js",autoplay:"autoplay",controls:"controls"});B.insert(D);D.insert(new Element("source",{src:F+".mp3",type:"audio/mp3"}));D.insert(new Element("source",{src:F+".ogg",type:"audio/ogg"}));A.insert({before:B});A.hide();obj=new AudioJS(A.previous().down(),{controlsBelow:true,controlsHiding:false,width:400})}else{D=soundManager.createSound({id:"pb-av-"+F,url:F+".mp3"})}})})});AudioJS=VideoJS.extend({positionController:function(){this.box.style.width=this.options.width+"px";this.box.style.height=this.controls.offsetHeight+"px";this.sizeProgressBar();this.fullscreenControl.hide()}});VideoJS_SWF=VideoJS.extend({init:function(C,B){var A="VideoJS_SWF_"+Math.ceil(Math.random()*100000);window[A]=this;C.insert({before:'<div class="video-js-box"><div style="width:'+B.width+"px; height: "+B.height+'px;"><object width='+B.width+" height="+B.height+' type="application/x-shockwave-flash" data="'+B.swf+'"><param name="movie" value="'+B.swf+'"><param name="flashvars" value="useexternalinterface=1&amp;listener='+A+"&amp;interval=500&amp;width="+B.width+"&amp;height="+B.height+"&amp;autoplay=1&amp;flv="+B.src+'.mp4"></object></div></div>'});C.hide();this.box=C.previous();this.video=this.box.down();this.options={num:0,controlsBelow:true,controlsHiding:false,defaultVolume:0.85,flashVersion:9,linksHiding:true,height:B.height};_V_.addClass(this.box,"vjs-controls-below");this.percentLoaded=0;this.logs=0;this.buildController();this.showController();this.addListeners();this.fullscreenControl.hide()},positionController:function(){this._super();this.controls.style.top=this.options.height+"px"},paused:function(){return(this.isPlaying==="false")},currentTime:function(){if(this.position){return parseInt(this.position,10)/1000}return 0},durationTime:function(){if(this.duration){return parseInt(this.duration,10)/1000}return 1},updatePlayProgress:function(){if(this.controls.style.display=="none"){return }this.playProgress.style.width=(this.currentTime()/this.durationTime())*this.progressHolder.offsetWidth+"px";this.updateTimeDisplay()},updateLoadProgress:function(){if(this.controls.style.display=="none"){return }this.loadProgress.style.width=this.percentLoaded*this.progressHolder.offsetWidth+"px"},setPlayProgress:function(A){this.callMethodOnFlash("setPosition",A*this.durationTime()*1000);this.playProgress.style.width=A*this.progressHolder.offsetWidth+"px";this.updateTimeDisplay();if(this.subtitles!=null){this.currentSubtitlePosition=0}},setVolume:function(A){this.callMethodOnFlash("setVolume",100*parseFloat(A));localStorage.volume=parseFloat(A,10)},updateVolumeDisplay:function(){var B=Math.ceil(parseInt(this.volume,10)*6/100);for(var A=0;A<6;A++){if(A<B){_V_.addClass(this.volumeDisplay.children[A],"vjs-volume-level-on")}else{_V_.removeClass(this.volumeDisplay.children[A],"vjs-volume-level-on")}}},trackPlayProgress:function(){},addListeners:function(){this.video.observe("loadeddata",this.onLoadedData.context(this),false);this.video.observe("play",this.onPlay.context(this),false);this.video.observe("pause",this.onPause.context(this),false);this.video.observe("ended",this.onEnded.context(this),false);this.video.observe("volumechange",this.onVolumeChange.context(this),false);this.video.observe("error",this.onError.context(this),false);this.video.observe("progress",this.onProgress.context(this),false);this.watchBuffer=setInterval(this.updateBufferedTotal.context(this),33);this.video.observe("timeupdate",this.onTimeUpdate.context(this),false);this.playControl.observe("click",this.onPlayControlClick.context(this),false);this.video.observe("click",this.onPlayControlClick.context(this),false);if(this.poster){this.poster.observe("click",this.onPlayControlClick.context(this),false)}this.progressHolder.observe("mousedown",this.onProgressHolderMouseDown.context(this),false);this.progressHolder.observe("mouseup",this.onProgressHolderMouseUp.context(this),false);this.setVolume(localStorage.volume||this.options.defaultVolume);this.volumeControl.observe("mousedown",this.onVolumeControlMouseDown.context(this),false);this.volumeControl.observe("mouseup",this.onVolumeControlMouseUp.context(this),false);this.updateVolumeDisplay();this.fullscreenControl.observe("click",this.onFullscreenControlClick.context(this),false);this.video.observe("mousemove",this.onVideoMouseMove.context(this),false);this.video.observe("mouseout",this.onVideoMouseOut.context(this),false);if(this.poster){this.poster.observe("mousemove",this.onVideoMouseMove.context(this),false)}if(this.poster){this.poster.observe("mouseout",this.onVideoMouseOut.context(this),false)}this.controls.observe("mouseout",this.onVideoMouseOut.context(this),false);this.onEscKey=function(A){if(A.keyCode==27){this.fullscreenOff()}}.context(this);this.onWindowResize=function(A){this.positionController()}.context(this);this.fixPreloading();this.subtitlesSource=this.video.getAttribute("data-subtitles");if(this.subtitlesSource!=null){this.loadSubtitles();this.buildSubtitles()}},fullscreenOn:function(){},play:function(){this.callMethodOnFlash("play")},pause:function(){this.callMethodOnFlash("pause")},callMethodOnFlash:function(C,A){var B=this.box.down("object");if(typeof B.SetVariable!=="undefined"){B.SetVariable("method:"+C,A)}},onInit:function(){},onClick:function(){this.onPlayControlClick.context(this)},onKeyUp:function(){},onFinish:function(){this.onEnded()},onUpdate:function(){this.setLoadProgress(this.bytesPercent/100);if(this.paused()){this.onPause()}else{this.onPlay()}this.updateVolumeDisplay();this.updatePlayProgress()}});PBwiki.DataProviders=PBwiki.DataProviders||{};PBwiki.DataProviders.NOMObjects=Class.create({MAX_DATA_FOR_SINGLE_REQUEST:200,initialize:function(A){if(typeof (A)=="undefined"){this.options={}}else{this.options=A}if(!PBinfo.CurrentWiki){throw"Cannot determine current workspace"}this.total_data_count=(PBinfo.CurrentWiki.pagecount||0)+(PBinfo.CurrentWiki.filecount||0);this.data={};this.requests_in_progress=[];this.last_filter=null;this.pending_callback=null;this.load_entire_dataset=(this.total_data_count<=this.MAX_DATA_FOR_SINGLE_REQUEST)},getData:function(C,E){var D=this.tokenize(C);if(this.hasApplicableData(D)){delete this.last_filter;delete this.pending_callback;var B=this.getApplicableData(D);var A=this.filterData(B,D);E(A,A.length);return true}else{this.last_filter=C;this.pending_callback=E;if(!this.hasRequestInProcess(D)){this.loadDataFor(C)}return false}},tokenize:function(A){if(typeof A=="string"){return A.toLowerCase().split(/\s/).without("")}else{return A.without("")}},hasRequestInProcess:function(C){if(this.requests_in_progress.indexOf("__UNFILTERED__")>-1){return true}if(!this.load_entire_dataset){for(var A=0;A<C.length;A++){var B=C[A].substring(0,2);if(this.requests_in_progress.indexOf(B)>-1){return true}}}return false},hasApplicableData:function(D){if(this.data.__UNFILTERED__){return true}if(!this.load_entire_dataset){for(var A=0;A<D.length;A++){var C=D[A].substring(0,1);var B=D[A].substring(0,2);if(this.data[C]||this.data[B]){return true}}}return false},getApplicableData:function(D){if(!this.load_entire_dataset){for(var A=0;A<D.length;A++){var C=D[A].substring(0,1);var B=D[A].substring(0,2);if(this.data[B]){return this.data[B]}else{if(this.data[C]){return this.data[C]}}}}if(this.data.__UNFILTERED__){return this.data.__UNFILTERED__}return[]},loadDataFor:function(B){var C=this.tokenize(B);var A={sortby:"name",object_types:"page,file,folder"};if(C.length>0&&this.load_entire_dataset){A.filter=C[0].substring(0,2);this.requests_in_progress.push(A.filter)}else{this.requests_in_progress.push("__UNFILTERED__")}new PBwiki.APIRequest("GetObjectsNOM",A,{method:"get",onSuccess:function(D){if(A.filter){this.data[A.filter]=D.objects;this.requests_in_progress=this.requests_in_progress.without(A.filter)}else{this.data.__UNFILTERED__=D.objects;this.requests_in_progress=this.requests_in_progress.without("__UNFILTERED__")}if(!this.last_filter){return }var E=this.tokenize(this.last_filter);if(this.hasApplicableData(E)){this.getData(this.last_filter,this.pending_callback)}}.bind(this),onFailure:function(D){Util.alert(D)}})},filterData:function(B,C){var D=B;for(var A=0;A<C.length;A++){D=D.findAll(function(E){return E.name.toLowerCase().indexOf(C[A])!==-1})}return D}});