var pbBuildTime=1258754823;var c={kPolicyPageSizeWarning:51200,kPolicyValidEmailRegex:"/^([a-zA-Z0-9])+([a-zA-Z0-9\\._+&'-])*@([a-zA-Z0-9-])+\\.([a-zA-Z0-9\\.-]+)+$/",kPolicyValidUIDRegex:"/^([a-f0-9]){40}$/i",kPolicyConvertSupportedDocumentRegex:"/\\.(csv|doc|docx|ods|odt|rtf|txt|wpd|xls|xlsx)$/",kInvalidPageCharacters:".[]?&|/\\+#%",kMaxPageNameLength:100,kInvalidFileCharacters:"%$?\\/|`",kMaxFileNameLength:100,kInvalidFolderCharacters:".!@%&$#+\"'|",kMaxFolderNameLength:127,kMaxWikiNameLength:50,kMinWikiNameLength:4,kMaxPasswordLength:50,kMinPasswordLength:5,kMaxMilestoneLength:100,kMaxActionLength:100,kPolicyValidWikiNameRegex:"/(^[a-zA-Z0-9]$)|(^[a-zA-Z0-9]+[a-zA-Z0-9-]*[a-zA-Z0-9]$)/",kStaticDebugDirectory:"/shared/php/",kPerfmonCookie:"pb_perfmon",kTrackingCookie:"pb_stat",kFoldersDefaultHeight:200,kRecentChangesNumber:7,kRecentChangesMax:12,kShowStarBubblePrefsKey:"prompt_to_star_on_save",kShowSendALinkBubblePrefsKey:"prompt_to_send_a_link",kEditorV3PrefsKey:"editor_v3_active",kScrollAreaBlockSize:50,kCreatePageExpanded:"create_expanded",kSideBarCollapsed:"sidebar_collapsed"};var PBconst=PBconst||c;if(Object.extend){Object.extend(PBconst,c)}var Prototype={Version:"1.6.1",Browser:(function(){var B=navigator.userAgent;var A=Object.prototype.toString.call(window.opera)=="[object Opera]";return{IE:!!window.attachEvent&&!A,Opera:A,WebKit:B.indexOf("AppleWebKit/")>-1,Gecko:B.indexOf("Gecko")>-1&&B.indexOf("KHTML")===-1,MobileSafari:/Apple.*Mobile.*Safari/.test(B)}})(),BrowserFeatures:{XPath:!!document.evaluate,SelectorsAPI:!!document.querySelector,ElementExtensions:(function(){var A=window.Element||window.HTMLElement;return !!(A&&A.prototype)})(),SpecificElementExtensions:(function(){if(typeof window.HTMLDivElement!=="undefined"){return true}var C=document.createElement("div");var B=document.createElement("form");var A=false;if(C.__proto__&&(C.__proto__!==B.__proto__)){A=true}C=B=null;return A})()},ScriptFragment:"<script[^>]*>([\\S\\s]*?)<\/script>",JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){},K:function(A){return A}};if(Prototype.Browser.MobileSafari){Prototype.BrowserFeatures.SpecificElementExtensions=false}var Abstract={};var Try={these:function(){var C;for(var B=0,D=arguments.length;B<D;B++){var A=arguments[B];try{C=A();break}catch(E){}}return C}};var Class=(function(){function A(){}function B(){var G=null,F=$A(arguments);if(Object.isFunction(F[0])){G=F.shift()}function D(){this.initialize.apply(this,arguments)}Object.extend(D,Class.Methods);D.superclass=G;D.subclasses=[];if(G){A.prototype=G.prototype;D.prototype=new A;G.subclasses.push(D)}for(var E=0;E<F.length;E++){D.addMethods(F[E])}if(!D.prototype.initialize){D.prototype.initialize=Prototype.emptyFunction}D.prototype.constructor=D;return D}function C(J){var F=this.superclass&&this.superclass.prototype;var E=Object.keys(J);if(!Object.keys({toString:true}).length){if(J.toString!=Object.prototype.toString){E.push("toString")}if(J.valueOf!=Object.prototype.valueOf){E.push("valueOf")}}for(var D=0,G=E.length;D<G;D++){var I=E[D],H=J[I];if(F&&Object.isFunction(H)&&H.argumentNames().first()=="$super"){var K=H;H=(function(L){return function(){return F[L].apply(this,arguments)}})(I).wrap(K);H.valueOf=K.valueOf.bind(K);H.toString=K.toString.bind(K)}this.prototype[I]=H}return this}return{create:B,Methods:{addMethods:C}}})();(function(){var D=Object.prototype.toString;function I(Q,S){for(var R in S){Q[R]=S[R]}return Q}function L(Q){try{if(E(Q)){return"undefined"}if(Q===null){return"null"}return Q.inspect?Q.inspect():String(Q)}catch(R){if(R instanceof RangeError){return"..."}throw R}}function K(Q){var S=typeof Q;switch(S){case"undefined":case"function":case"unknown":return ;case"boolean":return Q.toString()}if(Q===null){return"null"}if(Q.toJSON){return Q.toJSON()}if(H(Q)){return }var R=[];for(var U in Q){var T=K(Q[U]);if(!E(T)){R.push(U.toJSON()+": "+T)}}return"{"+R.join(", ")+"}"}function C(Q){return $H(Q).toQueryString()}function F(Q){return Q&&Q.toHTML?Q.toHTML():String.interpret(Q)}function O(Q){var R=[];for(var S in Q){R.push(S)}return R}function M(Q){var R=[];for(var S in Q){R.push(Q[S])}return R}function J(Q){return I({},Q)}function H(Q){return !!(Q&&Q.nodeType==1)}function G(Q){return D.call(Q)=="[object Array]"}function P(Q){return Q instanceof Hash}function B(Q){return typeof Q==="function"}function A(Q){return D.call(Q)=="[object String]"}function N(Q){return D.call(Q)=="[object Number]"}function E(Q){return typeof Q==="undefined"}I(Object,{extend:I,inspect:L,toJSON:K,toQueryString:C,toHTML:F,keys:O,values:M,clone:J,isElement:H,isArray:G,isHash:P,isFunction:B,isString:A,isNumber:N,isUndefined:E})})();Object.extend(Function.prototype,(function(){var K=Array.prototype.slice;function D(O,L){var N=O.length,M=L.length;while(M--){O[N+M]=L[M]}return O}function I(M,L){M=K.call(M,0);return D(M,L)}function G(){var L=this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1].replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g,"").replace(/\s+/g,"").split(",");return L.length==1&&!L[0]?[]:L}function H(N){if(arguments.length<2&&Object.isUndefined(arguments[0])){return this}var L=this,M=K.call(arguments,1);return function(){var O=I(M,arguments);return L.apply(N,O)}}function F(N){var L=this,M=K.call(arguments,1);return function(P){var O=D([P||window.event],M);return L.apply(N,O)}}function J(){if(!arguments.length){return this}var L=this,M=K.call(arguments,0);return function(){var N=I(M,arguments);return L.apply(this,N)}}function E(N){var L=this,M=K.call(arguments,1);N=N*1000;return window.setTimeout(function(){return L.apply(L,M)},N)}function A(){var L=D([0.01],arguments);return this.delay.apply(this,L)}function C(M){var L=this;return function(){var N=D([L.bind(this)],arguments);return M.apply(this,N)}}function B(){if(this._methodized){return this._methodized}var L=this;return this._methodized=function(){var M=D([this],arguments);return L.apply(null,M)}}return{argumentNames:G,bind:H,bindAsEventListener:F,curry:J,delay:E,defer:A,wrap:C,methodize:B}})());Date.prototype.toJSON=function(){return'"'+this.getUTCFullYear()+"-"+(this.getUTCMonth()+1).toPaddedString(2)+"-"+this.getUTCDate().toPaddedString(2)+"T"+this.getUTCHours().toPaddedString(2)+":"+this.getUTCMinutes().toPaddedString(2)+":"+this.getUTCSeconds().toPaddedString(2)+'Z"'};RegExp.prototype.match=RegExp.prototype.test;RegExp.escape=function(A){return String(A).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")};var PeriodicalExecuter=Class.create({initialize:function(B,A){this.callback=B;this.frequency=A;this.currentlyExecuting=false;this.registerCallback()},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000)},execute:function(){this.callback(this)},stop:function(){if(!this.timer){return }clearInterval(this.timer);this.timer=null},onTimerEvent:function(){if(!this.currentlyExecuting){try{this.currentlyExecuting=true;this.execute();this.currentlyExecuting=false}catch(A){this.currentlyExecuting=false;throw A}}}});Object.extend(String,{interpret:function(A){return A==null?"":String(A)},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}});Object.extend(String.prototype,(function(){function prepareReplacement(replacement){if(Object.isFunction(replacement)){return replacement}var template=new Template(replacement);return function(match){return template.evaluate(match)}}function gsub(pattern,replacement){var result="",source=this,match;replacement=prepareReplacement(replacement);if(Object.isString(pattern)){pattern=RegExp.escape(pattern)}if(!(pattern.length||pattern.source)){replacement=replacement("");return replacement+source.split("").join(replacement)+replacement}while(source.length>0){if(match=source.match(pattern)){result+=source.slice(0,match.index);result+=String.interpret(replacement(match));source=source.slice(match.index+match[0].length)}else{result+=source,source=""}}return result}function sub(pattern,replacement,count){replacement=prepareReplacement(replacement);count=Object.isUndefined(count)?1:count;return this.gsub(pattern,function(match){if(--count<0){return match[0]}return replacement(match)})}function scan(pattern,iterator){this.gsub(pattern,iterator);return String(this)}function truncate(length,truncation){length=length||30;truncation=Object.isUndefined(truncation)?"...":truncation;return this.length>length?this.slice(0,length-truncation.length)+truncation:String(this)}function strip(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}function stripTags(){return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi,"")}function stripScripts(){if(this.indexOf("<script")==-1){return this}return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"")}function extractScripts(){var matchAll=new RegExp(Prototype.ScriptFragment,"img");var matchOne=new RegExp(Prototype.ScriptFragment,"im");return(this.match(matchAll)||[]).map(function(scriptTag){return(scriptTag.match(matchOne)||["",""])[1]})}function evalScripts(){return this.extractScripts().map(function(script){return eval(script)})}function escapeHTML(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function unescapeHTML(){return this.stripTags().replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function toQueryParams(separator){var match=this.strip().match(/([^?#]*)(#.*)?$/);if(!match){return{}}return match[1].split(separator||"&").inject({},function(hash,pair){if((pair=pair.split("="))[0]){var key=decodeURIComponent(pair.shift());var value=pair.length>1?pair.join("="):pair[0];if(value!=undefined){value=decodeURIComponent(value)}if(key in hash){if(!Object.isArray(hash[key])){hash[key]=[hash[key]]}hash[key].push(value)}else{hash[key]=value}}return hash})}function toArray(){return this.split("")}function succ(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)}function times(count){return count<1?"":new Array(count+1).join(this)}function camelize(){var parts=this.split("-"),len=parts.length;if(len==1){return parts[0]}var camelized=this.charAt(0)=="-"?parts[0].charAt(0).toUpperCase()+parts[0].substring(1):parts[0];for(var i=1;i<len;i++){camelized+=parts[i].charAt(0).toUpperCase()+parts[i].substring(1)}return camelized}function capitalize(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()}function underscore(){return this.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/-/g,"_").toLowerCase()}function dasherize(){return this.replace(/_/g,"-")}function inspect(useDoubleQuotes){var escapedString=this.replace(/[\x00-\x1f\\]/g,function(character){if(character in String.specialChar){return String.specialChar[character]}return"\\u00"+character.charCodeAt().toPaddedString(2,16)});if(useDoubleQuotes){return'"'+escapedString.replace(/"/g,'\\"')+'"'}return"'"+escapedString.replace(/'/g,"\\'")+"'"}function toJSON(){return this.inspect(true)}function unfilterJSON(filter){return this.replace(filter||Prototype.JSONFilter,"$1")}function isJSON(){var str=this;if(str.blank()){return false}str=this.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,"");return(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str)}function evalJSON(sanitize){var json=this.unfilterJSON();try{if(!sanitize||json.isJSON()){return eval("("+json+")")}}catch(e){}throw new SyntaxError("Badly formed JSON string: "+this.inspect())}function include(pattern){return this.indexOf(pattern)>-1}function startsWith(pattern){return this.indexOf(pattern)===0}function endsWith(pattern){var d=this.length-pattern.length;return d>=0&&this.lastIndexOf(pattern)===d}function empty(){return this==""}function blank(){return/^\s*$/.test(this)}function interpolate(object,pattern){return new Template(this,pattern).evaluate(object)}return{gsub:gsub,sub:sub,scan:scan,truncate:truncate,strip:String.prototype.trim?String.prototype.trim:strip,stripTags:stripTags,stripScripts:stripScripts,extractScripts:extractScripts,evalScripts:evalScripts,escapeHTML:escapeHTML,unescapeHTML:unescapeHTML,toQueryParams:toQueryParams,parseQuery:toQueryParams,toArray:toArray,succ:succ,times:times,camelize:camelize,capitalize:capitalize,underscore:underscore,dasherize:dasherize,inspect:inspect,toJSON:toJSON,unfilterJSON:unfilterJSON,isJSON:isJSON,evalJSON:evalJSON,include:include,startsWith:startsWith,endsWith:endsWith,empty:empty,blank:blank,interpolate:interpolate}})());var Template=Class.create({initialize:function(A,B){this.template=A.toString();this.pattern=B||Template.Pattern},evaluate:function(A){if(A&&Object.isFunction(A.toTemplateReplacements)){A=A.toTemplateReplacements()}return this.template.gsub(this.pattern,function(D){if(A==null){return(D[1]+"")}var F=D[1]||"";if(F=="\\"){return D[2]}var B=A,G=D[3];var E=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;D=E.exec(G);if(D==null){return F}while(D!=null){var C=D[1].startsWith("[")?D[2].replace(/\\\\]/g,"]"):D[1];B=B[C];if(null==B||""==D[3]){break}G=G.substring("["==D[3]?D[1].length:D[0].length);D=E.exec(G)}return F+String.interpret(B)})}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={};var Enumerable=(function(){function C(Y,X){var W=0;try{this._each(function(a){Y.call(X,a,W++)})}catch(Z){if(Z!=$break){throw Z}}return this}function R(Z,Y,X){var W=-Z,a=[],b=this.toArray();if(Z<1){return b}while((W+=Z)<b.length){a.push(b.slice(W,W+Z))}return a.collect(Y,X)}function B(Y,X){Y=Y||Prototype.K;var W=true;this.each(function(a,Z){W=W&&!!Y.call(X,a,Z);if(!W){throw $break}});return W}function I(Y,X){Y=Y||Prototype.K;var W=false;this.each(function(a,Z){if(W=!!Y.call(X,a,Z)){throw $break}});return W}function J(Y,X){Y=Y||Prototype.K;var W=[];this.each(function(a,Z){W.push(Y.call(X,a,Z))});return W}function T(Y,X){var W;this.each(function(a,Z){if(Y.call(X,a,Z)){W=a;throw $break}});return W}function H(Y,X){var W=[];this.each(function(a,Z){if(Y.call(X,a,Z)){W.push(a)}});return W}function G(Z,Y,X){Y=Y||Prototype.K;var W=[];if(Object.isString(Z)){Z=new RegExp(RegExp.escape(Z))}this.each(function(b,a){if(Z.match(b)){W.push(Y.call(X,b,a))}});return W}function A(W){if(Object.isFunction(this.indexOf)){if(this.indexOf(W)!=-1){return true}}var X=false;this.each(function(Y){if(Y==W){X=true;throw $break}});return X}function Q(X,W){W=Object.isUndefined(W)?null:W;return this.eachSlice(X,function(Y){while(Y.length<X){Y.push(W)}return Y})}function L(W,Y,X){this.each(function(a,Z){W=Y.call(X,W,a,Z)});return W}function V(X){var W=$A(arguments).slice(1);return this.map(function(Y){return Y[X].apply(Y,W)})}function P(Y,X){Y=Y||Prototype.K;var W;this.each(function(a,Z){a=Y.call(X,a,Z);if(W==null||a>=W){W=a}});return W}function N(Y,X){Y=Y||Prototype.K;var W;this.each(function(a,Z){a=Y.call(X,a,Z);if(W==null||a<W){W=a}});return W}function E(Z,X){Z=Z||Prototype.K;var Y=[],W=[];this.each(function(b,a){(Z.call(X,b,a)?Y:W).push(b)});return[Y,W]}function F(X){var W=[];this.each(function(Y){W.push(Y[X])});return W}function D(Y,X){var W=[];this.each(function(a,Z){if(!Y.call(X,a,Z)){W.push(a)}});return W}function M(X,W){return this.map(function(Z,Y){return{value:Z,criteria:X.call(W,Z,Y)}}).sort(function(f,e){var Z=f.criteria,Y=e.criteria;return Z<Y?-1:Z>Y?1:0}).pluck("value")}function O(){return this.map()}function S(){var X=Prototype.K,W=$A(arguments);if(Object.isFunction(W.last())){X=W.pop()}var Y=[this].concat(W).map($A);return this.map(function(a,Z){return X(Y.pluck(Z))})}function K(){return this.toArray().length}function U(){return"#<Enumerable:"+this.toArray().inspect()+">"}return{each:C,eachSlice:R,all:B,every:B,any:I,some:I,collect:J,map:J,detect:T,findAll:H,select:H,filter:H,grep:G,include:A,member:A,inGroupsOf:Q,inject:L,invoke:V,max:P,min:N,partition:E,pluck:F,reject:D,sortBy:M,toArray:O,entries:O,zip:S,size:K,inspect:U,find:T}})();function $A(C){if(!C){return[]}if("toArray" in Object(C)){return C.toArray()}var B=C.length||0,A=new Array(B);while(B--){A[B]=C[B]}return A}function $w(A){if(!Object.isString(A)){return[]}A=A.strip();return A?A.split(/\s+/):[]}Array.from=$A;(function(){var S=Array.prototype,M=S.slice,O=S.forEach;function B(W){for(var V=0,X=this.length;V<X;V++){W(this[V])}}if(!O){O=B}function L(){this.length=0;return this}function D(){return this[0]}function G(){return this[this.length-1]}function I(){return this.select(function(V){return V!=null})}function U(){return this.inject([],function(W,V){if(Object.isArray(V)){return W.concat(V.flatten())}W.push(V);return W})}function H(){var V=M.call(arguments,0);return this.select(function(W){return !V.include(W)})}function F(V){return(V!==false?this:this.toArray())._reverse()}function K(V){return this.inject([],function(Y,X,W){if(0==W||(V?Y.last()!=X:!Y.include(X))){Y.push(X)}return Y})}function P(V){return this.uniq().findAll(function(W){return V.detect(function(X){return W===X})})}function Q(){return M.call(this,0)}function J(){return this.length}function T(){return"["+this.map(Object.inspect).join(", ")+"]"}function R(){var V=[];this.each(function(W){var X=Object.toJSON(W);if(!Object.isUndefined(X)){V.push(X)}});return"["+V.join(", ")+"]"}function A(X,V){V||(V=0);var W=this.length;if(V<0){V=W+V}for(;V<W;V++){if(this[V]===X){return V}}return -1}function N(W,V){V=isNaN(V)?this.length:(V<0?this.length+V:V)+1;var X=this.slice(0,V).reverse().indexOf(W);return(X<0)?X:V-X-1}function C(){var a=M.call(this,0),Y;for(var W=0,X=arguments.length;W<X;W++){Y=arguments[W];if(Object.isArray(Y)&&!("callee" in Y)){for(var V=0,Z=Y.length;V<Z;V++){a.push(Y[V])}}else{a.push(Y)}}return a}Object.extend(S,Enumerable);if(!S._reverse){S._reverse=S.reverse}Object.extend(S,{_each:O,clear:L,first:D,last:G,compact:I,flatten:U,without:H,reverse:F,uniq:K,intersect:P,clone:Q,toArray:Q,size:J,inspect:T,toJSON:R});var E=(function(){return[].concat(arguments)[0][0]!==1})(1,2);if(E){S.concat=C}if(!S.indexOf){S.indexOf=A}if(!S.lastIndexOf){S.lastIndexOf=N}})();function $H(A){return new Hash(A)}var Hash=Class.create(Enumerable,(function(){function E(Q){this._object=Object.isHash(Q)?Q.toObject():Object.clone(Q)}function F(R){for(var Q in this._object){var S=this._object[Q],T=[Q,S];T.key=Q;T.value=S;R(T)}}function K(Q,R){return this._object[Q]=R}function C(Q){if(this._object[Q]!==Object.prototype[Q]){return this._object[Q]}}function N(Q){var R=this._object[Q];delete this._object[Q];return R}function P(){return Object.clone(this._object)}function O(){return this.pluck("key")}function M(){return this.pluck("value")}function G(R){var Q=this.detect(function(S){return S.value===R});return Q&&Q.key}function I(Q){return this.clone().update(Q)}function D(Q){return new Hash(Q).inject(this,function(R,S){R.set(S.key,S.value);return R})}function B(Q,R){if(Object.isUndefined(R)){return Q}return Q+"="+encodeURIComponent(String.interpret(R))}function A(){return this.inject([],function(S,T){var R=encodeURIComponent(T.key),Q=T.value;if(Q&&typeof Q=="object"){if(Object.isArray(Q)){return S.concat(Q.map(B.curry(R)))}}else{S.push(B(R,Q))}return S}).join("&")}function L(){return"#<Hash:{"+this.map(function(Q){return Q.map(Object.inspect).join(": ")}).join(", ")+"}>"}function J(){return Object.toJSON(this.toObject())}function H(){return new Hash(this)}return{initialize:E,_each:F,set:K,get:C,unset:N,toObject:P,toTemplateReplacements:P,keys:O,values:M,index:G,merge:I,update:D,toQueryString:A,inspect:L,toJSON:J,clone:H}})());Hash.from=$H;Object.extend(Number.prototype,(function(){function D(){return this.toPaddedString(2,16)}function E(){return this+1}function A(K,J){$R(0,this,true).each(K,J);return this}function B(L,K){var J=this.toString(K||10);return"0".times(L-J.length)+J}function F(){return isFinite(this)?this.toString():"null"}function I(){return Math.abs(this)}function H(){return Math.round(this)}function G(){return Math.ceil(this)}function C(){return Math.floor(this)}return{toColorPart:D,succ:E,times:A,toPaddedString:B,toJSON:F,abs:I,round:H,ceil:G,floor:C}})());function $R(C,A,B){return new ObjectRange(C,A,B)}var ObjectRange=Class.create(Enumerable,(function(){function B(F,D,E){this.start=F;this.end=D;this.exclusive=E}function C(D){var E=this.start;while(this.include(E)){D(E);E=E.succ()}}function A(D){if(D<this.start){return false}if(this.exclusive){return D<this.end}return D<=this.end}return{initialize:B,_each:C,include:A}})());var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})||false},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(A){this.responders._each(A)},register:function(A){if(!this.include(A)){this.responders.push(A)}},unregister:function(A){this.responders=this.responders.without(A)},dispatch:function(D,B,C,A){this.each(function(E){if(Object.isFunction(E[D])){try{E[D].apply(E,[B,C,A])}catch(F){}}})}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++},onComplete:function(){Ajax.activeRequestCount--}});Ajax.Base=Class.create({initialize:function(A){this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:"",evalJSON:true,evalJS:true};Object.extend(this.options,A||{});this.options.method=this.options.method.toLowerCase();if(Object.isString(this.options.parameters)){this.options.parameters=this.options.parameters.toQueryParams()}else{if(Object.isHash(this.options.parameters)){this.options.parameters=this.options.parameters.toObject()}}}});Ajax.Request=Class.create(Ajax.Base,{_complete:false,initialize:function($super,B,A){$super(A);this.transport=Ajax.getTransport();this.request(B)},request:function(B){this.url=B;this.method=this.options.method;var D=Object.clone(this.options.parameters);if(!["get","post"].include(this.method)){D._method=this.method;this.method="post"}this.parameters=D;if(D=Object.toQueryString(D)){if(this.method=="get"){this.url+=(this.url.include("?")?"&":"?")+D}else{if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){D+="&_="}}}try{var A=new Ajax.Response(this);if(this.options.onCreate){this.options.onCreate(A)}Ajax.Responders.dispatch("onCreate",this,A);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous){this.respondToReadyState.bind(this).defer(1)}this.transport.onreadystatechange=this.onStateChange.bind(this);this.setRequestHeaders();this.body=this.method=="post"?(this.options.postBody||D):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType){this.onStateChange()}}catch(C){this.dispatchException(C)}},onStateChange:function(){var A=this.transport.readyState;if(A>1&&!((A==4)&&this._complete)){this.respondToReadyState(this.transport.readyState)}},setRequestHeaders:function(){var E={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,Accept:"text/javascript, text/html, application/xml, text/xml, */*"};if(this.method=="post"){E["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:"");if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){E.Connection="close"}}if(typeof this.options.requestHeaders=="object"){var C=this.options.requestHeaders;if(Object.isFunction(C.push)){for(var B=0,D=C.length;B<D;B+=2){E[C[B]]=C[B+1]}}else{$H(C).each(function(F){E[F.key]=F.value})}}for(var A in E){this.transport.setRequestHeader(A,E[A])}},success:function(){var A=this.getStatus();return !A||(A>=200&&A<300)},getStatus:function(){try{return this.transport.status||0}catch(A){return 0}},respondToReadyState:function(A){var C=Ajax.Request.Events[A],B=new Ajax.Response(this);if(C=="Complete"){try{this._complete=true;(this.options["on"+B.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(B,B.headerJSON)}catch(D){this.dispatchException(D)}var E=B.getHeader("Content-type");if(this.options.evalJS=="force"||(this.options.evalJS&&this.isSameOrigin()&&E&&E.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))){this.evalResponse()}}try{(this.options["on"+C]||Prototype.emptyFunction)(B,B.headerJSON);Ajax.Responders.dispatch("on"+C,this,B,B.headerJSON)}catch(D){this.dispatchException(D)}if(C=="Complete"){this.transport.onreadystatechange=Prototype.emptyFunction}},isSameOrigin:function(){var A=this.url.match(/^\s*https?:\/\/[^\/]*/);return !A||(A[0]=="#{protocol}//#{domain}#{port}".interpolate({protocol:location.protocol,domain:document.domain,port:location.port?":"+location.port:""}))},getHeader:function(A){try{return this.transport.getResponseHeader(A)||null}catch(B){return null}},evalResponse:function(){try{return eval((this.transport.responseText||"").unfilterJSON())}catch(e){this.dispatchException(e)}},dispatchException:function(A){(this.options.onException||Prototype.emptyFunction)(this,A);Ajax.Responders.dispatch("onException",this,A)}});Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];Ajax.Response=Class.create({initialize:function(C){this.request=C;var D=this.transport=C.transport,A=this.readyState=D.readyState;if((A>2&&!Prototype.Browser.IE)||A==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=String.interpret(D.responseText);this.headerJSON=this._getHeaderJSON()}if(A==4){var B=D.responseXML;this.responseXML=Object.isUndefined(B)?null:B;this.responseJSON=this._getResponseJSON()}},status:0,statusText:"",getStatus:Ajax.Request.prototype.getStatus,getStatusText:function(){try{return this.transport.statusText||""}catch(A){return""}},getHeader:Ajax.Request.prototype.getHeader,getAllHeaders:function(){try{return this.getAllResponseHeaders()}catch(A){return null}},getResponseHeader:function(A){return this.transport.getResponseHeader(A)},getAllResponseHeaders:function(){return this.transport.getAllResponseHeaders()},_getHeaderJSON:function(){var A=this.getHeader("X-JSON");if(!A){return null}A=decodeURIComponent(escape(A));try{return A.evalJSON(this.request.options.sanitizeJSON||!this.request.isSameOrigin())}catch(B){this.request.dispatchException(B)}},_getResponseJSON:function(){var A=this.request.options;if(!A.evalJSON||(A.evalJSON!="force"&&!(this.getHeader("Content-type")||"").include("application/json"))||this.responseText.blank()){return null}try{return this.responseText.evalJSON(A.sanitizeJSON||!this.request.isSameOrigin())}catch(B){this.request.dispatchException(B)}}});Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,A,C,B){this.container={success:(A.success||A),failure:(A.failure||(A.success?null:A))};B=Object.clone(B);var D=B.onComplete;B.onComplete=(function(E,F){this.updateContent(E.responseText);if(Object.isFunction(D)){D(E,F)}}).bind(this);$super(C,B)},updateContent:function(D){var C=this.container[this.success()?"success":"failure"],A=this.options;if(!A.evalScripts){D=D.stripScripts()}if(C=$(C)){if(A.insertion){if(Object.isString(A.insertion)){var B={};B[A.insertion]=D;C.insert(B)}else{A.insertion(C,D)}}else{C.update(D)}}}});Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,A,C,B){$super(B);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=A;this.url=C;this.start()},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent()},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments)},updateComplete:function(A){if(this.options.decay){this.decay=(A.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=A.responseText}this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}});function $(B){if(arguments.length>1){for(var A=0,D=[],C=arguments.length;A<C;A++){D.push($(arguments[A]))}return D}if(Object.isString(B)){B=document.getElementById(B)}return Element.extend(B)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(F,A){var C=[];var E=document.evaluate(F,$(A)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var B=0,D=E.snapshotLength;B<D;B++){C.push(Element.extend(E.snapshotItem(B)))}return C}}if(!window.Node){var Node={}}if(!Node.ELEMENT_NODE){Object.extend(Node,{ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12})}(function(C){var B=(function(){var F=document.createElement("form");var E=document.createElement("input");var D=document.documentElement;E.setAttribute("name","test");F.appendChild(E);D.appendChild(F);var G=F.elements?(typeof F.elements.test=="undefined"):null;D.removeChild(F);F=E=null;return G})();var A=C.Element;C.Element=function(F,E){E=E||{};F=F.toLowerCase();var D=Element.cache;if(B&&E.name){F="<"+F+' name="'+E.name+'">';delete E.name;return Element.writeAttribute(document.createElement(F),E)}if(!D[F]){D[F]=Element.extend(document.createElement(F))}return Element.writeAttribute(D[F].cloneNode(false),E)};Object.extend(C.Element,A||{});if(A){C.Element.prototype=A.prototype}})(this);Element.cache={};Element.idCounter=1;Element.Methods={visible:function(A){return $(A).style.display!="none"},toggle:function(A){A=$(A);Element[Element.visible(A)?"hide":"show"](A);return A},hide:function(A){A=$(A);A.style.display="none";return A},show:function(A){A=$(A);A.style.display="";return A},remove:function(A){A=$(A);A.parentNode.removeChild(A);return A},update:(function(){var B=(function(){var E=document.createElement("select"),F=true;E.innerHTML='<option value="test">test</option>';if(E.options&&E.options[0]){F=E.options[0].nodeName.toUpperCase()!=="OPTION"}E=null;return F})();var A=(function(){try{var E=document.createElement("table");if(E&&E.tBodies){E.innerHTML="<tbody><tr><td>test</td></tr></tbody>";var G=typeof E.tBodies[0]=="undefined";E=null;return G}}catch(F){return true}})();var D=(function(){var E=document.createElement("script"),G=false;try{E.appendChild(document.createTextNode(""));G=!E.firstChild||E.firstChild&&E.firstChild.nodeType!==3}catch(F){G=true}E=null;return G})();function C(F,G){F=$(F);if(G&&G.toElement){G=G.toElement()}if(Object.isElement(G)){return F.update().insert(G)}G=Object.toHTML(G);var E=F.tagName.toUpperCase();if(E==="SCRIPT"&&D){F.text=G;return F}if(B||A){if(E in Element._insertionTranslations.tags){while(F.firstChild){F.removeChild(F.firstChild)}Element._getContentFromAnonymousElement(E,G.stripScripts()).each(function(H){F.appendChild(H)})}else{F.innerHTML=G.stripScripts()}}else{F.innerHTML=G.stripScripts()}G.evalScripts.bind(G).defer();return F}return C})(),replace:function(B,C){B=$(B);if(C&&C.toElement){C=C.toElement()}else{if(!Object.isElement(C)){C=Object.toHTML(C);var A=B.ownerDocument.createRange();A.selectNode(B);C.evalScripts.bind(C).defer();C=A.createContextualFragment(C.stripScripts())}}B.parentNode.replaceChild(C,B);return B},insert:function(C,E){C=$(C);if(Object.isString(E)||Object.isNumber(E)||Object.isElement(E)||(E&&(E.toElement||E.toHTML))){E={bottom:E}}var D,F,B,G;for(var A in E){D=E[A];A=A.toLowerCase();F=Element._insertionTranslations[A];if(D&&D.toElement){D=D.toElement()}if(Object.isElement(D)){F(C,D);continue}D=Object.toHTML(D);B=((A=="before"||A=="after")?C.parentNode:C).tagName.toUpperCase();G=Element._getContentFromAnonymousElement(B,D.stripScripts());if(A=="top"||A=="after"){G.reverse()}G.each(F.curry(C));D.evalScripts.bind(D).defer()}return C},wrap:function(B,C,A){B=$(B);if(Object.isElement(C)){$(C).writeAttribute(A||{})}else{if(Object.isString(C)){C=new Element(C,A)}else{C=new Element("div",C)}}if(B.parentNode){B.parentNode.replaceChild(C,B)}C.appendChild(B);return C},inspect:function(B){B=$(B);var A="<"+B.tagName.toLowerCase();$H({id:"id",className:"class"}).each(function(F){var E=F.first(),C=F.last();var D=(B[E]||"").toString();if(D){A+=" "+C+"="+D.inspect(true)}});return A+">"},recursivelyCollect:function(A,C){A=$(A);var B=[];while(A=A[C]){if(A.nodeType==1){B.push(Element.extend(A))}}return B},ancestors:function(A){return Element.recursivelyCollect(A,"parentNode")},descendants:function(A){return Element.select(A,"*")},firstDescendant:function(A){A=$(A).firstChild;while(A&&A.nodeType!=1){A=A.nextSibling}return $(A)},immediateDescendants:function(A){if(!(A=$(A).firstChild)){return[]}while(A&&A.nodeType!=1){A=A.nextSibling}if(A){return[A].concat($(A).nextSiblings())}return[]},previousSiblings:function(A){return Element.recursivelyCollect(A,"previousSibling")},nextSiblings:function(A){return Element.recursivelyCollect(A,"nextSibling")},siblings:function(A){A=$(A);return Element.previousSiblings(A).reverse().concat(Element.nextSiblings(A))},match:function(B,A){if(Object.isString(A)){A=new Selector(A)}return A.match($(B))},up:function(B,D,A){B=$(B);if(arguments.length==1){return $(B.parentNode)}var C=Element.ancestors(B);return Object.isNumber(D)?C[D]:Selector.findElement(C,D,A)},down:function(B,C,A){B=$(B);if(arguments.length==1){return Element.firstDescendant(B)}return Object.isNumber(C)?Element.descendants(B)[C]:Element.select(B,C)[A||0]},previous:function(B,D,A){B=$(B);if(arguments.length==1){return $(Selector.handlers.previousElementSibling(B))}var C=Element.previousSiblings(B);return Object.isNumber(D)?C[D]:Selector.findElement(C,D,A)},next:function(C,D,B){C=$(C);if(arguments.length==1){return $(Selector.handlers.nextElementSibling(C))}var A=Element.nextSiblings(C);return Object.isNumber(D)?A[D]:Selector.findElement(A,D,B)},select:function(B){var A=Array.prototype.slice.call(arguments,1);return Selector.findChildElements(B,A)},adjacent:function(B){var A=Array.prototype.slice.call(arguments,1);return Selector.findChildElements(B.parentNode,A).without(B)},identify:function(A){A=$(A);var B=Element.readAttribute(A,"id");if(B){return B}do{B="anonymous_element_"+Element.idCounter++}while($(B));Element.writeAttribute(A,"id",B);return B},readAttribute:function(C,A){C=$(C);if(Prototype.Browser.IE){var B=Element._attributeTranslations.read;if(B.values[A]){return B.values[A](C,A)}if(B.names[A]){A=B.names[A]}if(A.include(":")){return(!C.attributes||!C.attributes[A])?null:C.attributes[A].value}}return C.getAttribute(A)},writeAttribute:function(E,C,F){E=$(E);var B={},D=Element._attributeTranslations.write;if(typeof C=="object"){B=C}else{B[C]=Object.isUndefined(F)?true:F}for(var A in B){C=D.names[A]||A;F=B[A];if(D.values[A]){C=D.values[A](E,F)}if(F===false||F===null){E.removeAttribute(C)}else{if(F===true){E.setAttribute(C,C)}else{E.setAttribute(C,F)}}}return E},getHeight:function(A){return Element.getDimensions(A).height},getWidth:function(A){return Element.getDimensions(A).width},classNames:function(A){return new Element.ClassNames(A)},hasClassName:function(A,B){if(!(A=$(A))){return }var C=A.className;return(C.length>0&&(C==B||new RegExp("(^|\\s)"+B+"(\\s|$)").test(C)))},addClassName:function(A,B){if(!(A=$(A))){return }if(!Element.hasClassName(A,B)){A.className+=(A.className?" ":"")+B}return A},removeClassName:function(A,B){if(!(A=$(A))){return }A.className=A.className.replace(new RegExp("(^|\\s+)"+B+"(\\s+|$)")," ").strip();return A},toggleClassName:function(A,B){if(!(A=$(A))){return }return Element[Element.hasClassName(A,B)?"removeClassName":"addClassName"](A,B)},cleanWhitespace:function(B){B=$(B);var C=B.firstChild;while(C){var A=C.nextSibling;if(C.nodeType==3&&!/\S/.test(C.nodeValue)){B.removeChild(C)}C=A}return B},empty:function(A){return $(A).innerHTML.blank()},descendantOf:function(B,A){B=$(B),A=$(A);if(B.compareDocumentPosition){return(B.compareDocumentPosition(A)&8)===8}if(A.contains){return A.contains(B)&&A!==B}while(B=B.parentNode){if(B==A){return true}}return false},scrollTo:function(A){A=$(A);var B=Element.cumulativeOffset(A);window.scrollTo(B[0],B[1]);return A},getStyle:function(B,C){B=$(B);C=C=="float"?"cssFloat":C.camelize();var D=B.style[C];if(!D||D=="auto"){var A=document.defaultView.getComputedStyle(B,null);D=A?A[C]:null}if(C=="opacity"){return D?parseFloat(D):1}return D=="auto"?null:D},getOpacity:function(A){return $(A).getStyle("opacity")},setStyle:function(B,C){B=$(B);var E=B.style,A;if(Object.isString(C)){B.style.cssText+=";"+C;return C.include("opacity")?B.setOpacity(C.match(/opacity:\s*(\d?\.?\d*)/)[1]):B}for(var D in C){if(D=="opacity"){B.setOpacity(C[D])}else{E[(D=="float"||D=="cssFloat")?(Object.isUndefined(E.styleFloat)?"cssFloat":"styleFloat"):D]=C[D]}}return B},setOpacity:function(A,B){A=$(A);A.style.opacity=(B==1||B==="")?"":(B<0.00001)?0:B;return A},getDimensions:function(C){C=$(C);var G=Element.getStyle(C,"display");if(G!="none"&&G!=null){return{width:C.offsetWidth,height:C.offsetHeight}}var B=C.style;var F=B.visibility;var D=B.position;var A=B.display;B.visibility="hidden";if(D!="fixed"){B.position="absolute"}B.display="block";var H=C.clientWidth;var E=C.clientHeight;B.display=A;B.position=D;B.visibility=F;return{width:H,height:E}},makePositioned:function(A){A=$(A);var B=Element.getStyle(A,"position");if(B=="static"||!B){A._madePositioned=true;A.style.position="relative";if(Prototype.Browser.Opera){A.style.top=0;A.style.left=0}}return A},undoPositioned:function(A){A=$(A);if(A._madePositioned){A._madePositioned=undefined;A.style.position=A.style.top=A.style.left=A.style.bottom=A.style.right=""}return A},makeClipping:function(A){A=$(A);if(A._overflow){return A}A._overflow=Element.getStyle(A,"overflow")||"auto";if(A._overflow!=="hidden"){A.style.overflow="hidden"}return A},undoClipping:function(A){A=$(A);if(!A._overflow){return A}A.style.overflow=A._overflow=="auto"?"":A._overflow;A._overflow=null;return A},cumulativeOffset:function(B){var A=0,C=0;do{A+=B.offsetTop||0;C+=B.offsetLeft||0;B=B.offsetParent}while(B);return Element._returnOffset(C,A)},positionedOffset:function(B){var A=0,D=0;do{A+=B.offsetTop||0;D+=B.offsetLeft||0;B=B.offsetParent;if(B){if(B.tagName.toUpperCase()=="BODY"){break}var C=Element.getStyle(B,"position");if(C!=="static"){break}}}while(B);return Element._returnOffset(D,A)},absolutize:function(B){B=$(B);if(Element.getStyle(B,"position")=="absolute"){return B}var D=Element.positionedOffset(B);var F=D[1];var E=D[0];var C=B.clientWidth;var A=B.clientHeight;B._originalLeft=E-parseFloat(B.style.left||0);B._originalTop=F-parseFloat(B.style.top||0);B._originalWidth=B.style.width;B._originalHeight=B.style.height;B.style.position="absolute";B.style.top=F+"px";B.style.left=E+"px";B.style.width=C+"px";B.style.height=A+"px";return B},relativize:function(A){A=$(A);if(Element.getStyle(A,"position")=="relative"){return A}A.style.position="relative";var C=parseFloat(A.style.top||0)-(A._originalTop||0);var B=parseFloat(A.style.left||0)-(A._originalLeft||0);A.style.top=C+"px";A.style.left=B+"px";A.style.height=A._originalHeight;A.style.width=A._originalWidth;return A},cumulativeScrollOffset:function(B){var A=0,C=0;do{A+=B.scrollTop||0;C+=B.scrollLeft||0;B=B.parentNode}while(B);return Element._returnOffset(C,A)},getOffsetParent:function(A){if(A.offsetParent){return $(A.offsetParent)}if(A==document.body){return $(A)}while((A=A.parentNode)&&A!=document.body){if(Element.getStyle(A,"position")!="static"){return $(A)}}return $(document.body)},viewportOffset:function(D){var A=0,C=0;var B=D;do{A+=B.offsetTop||0;C+=B.offsetLeft||0;if(B.offsetParent==document.body&&Element.getStyle(B,"position")=="absolute"){break}}while(B=B.offsetParent);B=D;do{if(!Prototype.Browser.Opera||(B.tagName&&(B.tagName.toUpperCase()=="BODY"))){A-=B.scrollTop||0;C-=B.scrollLeft||0}}while(B=B.parentNode);return Element._returnOffset(C,A)},clonePosition:function(B,D){var A=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});D=$(D);var E=Element.viewportOffset(D);B=$(B);var F=[0,0];var C=null;if(Element.getStyle(B,"position")=="absolute"){C=Element.getOffsetParent(B);F=Element.viewportOffset(C)}if(C==document.body){F[0]-=document.body.offsetLeft;F[1]-=document.body.offsetTop}if(A.setLeft){B.style.left=(E[0]-F[0]+A.offsetLeft)+"px"}if(A.setTop){B.style.top=(E[1]-F[1]+A.offsetTop)+"px"}if(A.setWidth){B.style.width=D.offsetWidth+"px"}if(A.setHeight){B.style.height=D.offsetHeight+"px"}return B}};Object.extend(Element.Methods,{getElementsBySelector:Element.Methods.select,childElements:Element.Methods.immediateDescendants});Element._attributeTranslations={write:{names:{className:"class",htmlFor:"for"},values:{}}};if(Prototype.Browser.Opera){Element.Methods.getStyle=Element.Methods.getStyle.wrap(function(D,B,C){switch(C){case"left":case"top":case"right":case"bottom":if(D(B,"position")==="static"){return null}case"height":case"width":if(!Element.visible(B)){return null}var E=parseInt(D(B,C),10);if(E!==B["offset"+C.capitalize()]){return E+"px"}var A;if(C==="height"){A=["border-top-width","padding-top","padding-bottom","border-bottom-width"]}else{A=["border-left-width","padding-left","padding-right","border-right-width"]}return A.inject(E,function(F,G){var H=D(B,G);return H===null?F:F-parseInt(H,10)})+"px";default:return D(B,C)}});Element.Methods.readAttribute=Element.Methods.readAttribute.wrap(function(C,A,B){if(B==="title"){return A.title}return C(A,B)})}else{if(Prototype.Browser.IE){Element.Methods.getOffsetParent=Element.Methods.getOffsetParent.wrap(function(C,B){B=$(B);try{B.offsetParent}catch(E){return $(document.body)}var A=B.getStyle("position");if(A!=="static"){return C(B)}B.setStyle({position:"relative"});var D=C(B);B.setStyle({position:A});return D});$w("positionedOffset viewportOffset").each(function(A){Element.Methods[A]=Element.Methods[A].wrap(function(E,C){C=$(C);try{C.offsetParent}catch(G){return Element._returnOffset(0,0)}var B=C.getStyle("position");if(B!=="static"){return E(C)}var D=C.getOffsetParent();if(D&&D.getStyle("position")==="fixed"){D.setStyle({zoom:1})}C.setStyle({position:"relative"});var F=E(C);C.setStyle({position:B});return F})});Element.Methods.cumulativeOffset=Element.Methods.cumulativeOffset.wrap(function(B,A){try{A.offsetParent}catch(C){return Element._returnOffset(0,0)}return B(A)});Element.Methods.getStyle=function(A,B){A=$(A);B=(B=="float"||B=="cssFloat")?"styleFloat":B.camelize();var C=A.style[B];if(!C&&A.currentStyle){C=A.currentStyle[B]}if(B=="opacity"){if(C=(A.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){if(C[1]){return parseFloat(C[1])/100}}return 1}if(C=="auto"){if((B=="width"||B=="height")&&(A.getStyle("display")!="none")){return A["offset"+B.capitalize()]+"px"}return null}return C};Element.Methods.setOpacity=function(B,E){function F(G){return G.replace(/alpha\([^\)]*\)/gi,"")}B=$(B);var A=B.currentStyle;if((A&&!A.hasLayout)||(!A&&B.style.zoom=="normal")){B.style.zoom=1}var D=B.getStyle("filter"),C=B.style;if(E==1||E===""){(D=F(D))?C.filter=D:C.removeAttribute("filter");return B}else{if(E<0.00001){E=0}}C.filter=F(D)+"alpha(opacity="+(E*100)+")";return B};Element._attributeTranslations=(function(){var B="className";var A="for";var C=document.createElement("div");C.setAttribute(B,"x");if(C.className!=="x"){C.setAttribute("class","x");if(C.className==="x"){B="class"}}C=null;C=document.createElement("label");C.setAttribute(A,"x");if(C.htmlFor!=="x"){C.setAttribute("htmlFor","x");if(C.htmlFor==="x"){A="htmlFor"}}C=null;return{read:{names:{"class":B,className:B,"for":A,htmlFor:A},values:{_getAttr:function(D,E){return D.getAttribute(E)},_getAttr2:function(D,E){return D.getAttribute(E,2)},_getAttrNode:function(D,F){var E=D.getAttributeNode(F);return E?E.value:""},_getEv:(function(){var D=document.createElement("div");D.onclick=Prototype.emptyFunction;var F=D.getAttribute("onclick");var E;if(String(F).indexOf("{")>-1){E=function(G,H){H=G.getAttribute(H);if(!H){return null}H=H.toString();H=H.split("{")[1];H=H.split("}")[0];return H.strip()}}else{if(F===""){E=function(G,H){H=G.getAttribute(H);if(!H){return null}return H.strip()}}}D=null;return E})(),_flag:function(D,E){return $(D).hasAttribute(E)?E:null},style:function(D){return D.style.cssText.toLowerCase()},title:function(D){return D.title}}}}})();Element._attributeTranslations.write={names:Object.extend({cellpadding:"cellPadding",cellspacing:"cellSpacing"},Element._attributeTranslations.read.names),values:{checked:function(A,B){A.checked=!!B},style:function(A,B){A.style.cssText=B?B:""}}};Element._attributeTranslations.has={};$w("colSpan rowSpan vAlign dateTime accessKey tabIndex encType maxLength readOnly longDesc frameBorder").each(function(A){Element._attributeTranslations.write.names[A.toLowerCase()]=A;Element._attributeTranslations.has[A.toLowerCase()]=A});(function(A){Object.extend(A,{href:A._getAttr2,src:A._getAttr2,type:A._getAttr,action:A._getAttrNode,disabled:A._flag,checked:A._flag,readonly:A._flag,multiple:A._flag,onload:A._getEv,onunload:A._getEv,onclick:A._getEv,ondblclick:A._getEv,onmousedown:A._getEv,onmouseup:A._getEv,onmouseover:A._getEv,onmousemove:A._getEv,onmouseout:A._getEv,onfocus:A._getEv,onblur:A._getEv,onkeypress:A._getEv,onkeydown:A._getEv,onkeyup:A._getEv,onsubmit:A._getEv,onreset:A._getEv,onselect:A._getEv,onchange:A._getEv})})(Element._attributeTranslations.read.values);if(Prototype.BrowserFeatures.ElementExtensions){(function(){function A(E){var B=E.getElementsByTagName("*"),D=[];for(var C=0,F;F=B[C];C++){if(F.tagName!=="!"){D.push(F)}}return D}Element.Methods.down=function(C,D,B){C=$(C);if(arguments.length==1){return C.firstDescendant()}return Object.isNumber(D)?A(C)[D]:Element.select(C,D)[B||0]}})()}}else{if(Prototype.Browser.Gecko&&/rv:1\.8\.0/.test(navigator.userAgent)){Element.Methods.setOpacity=function(A,B){A=$(A);A.style.opacity=(B==1)?0.999999:(B==="")?"":(B<0.00001)?0:B;return A}}else{if(Prototype.Browser.WebKit){Element.Methods.setOpacity=function(A,B){A=$(A);A.style.opacity=(B==1||B==="")?"":(B<0.00001)?0:B;if(B==1){if(A.tagName.toUpperCase()=="IMG"&&A.width){A.width++;A.width--}else{try{var D=document.createTextNode(" ");A.appendChild(D);A.removeChild(D)}catch(C){}}}return A};Element.Methods.cumulativeOffset=function(B){var A=0,C=0;do{A+=B.offsetTop||0;C+=B.offsetLeft||0;if(B.offsetParent==document.body){if(Element.getStyle(B,"position")=="absolute"){break}}B=B.offsetParent}while(B);return Element._returnOffset(C,A)}}}}}if("outerHTML" in document.documentElement){Element.Methods.replace=function(C,E){C=$(C);if(E&&E.toElement){E=E.toElement()}if(Object.isElement(E)){C.parentNode.replaceChild(E,C);return C}E=Object.toHTML(E);var D=C.parentNode,B=D.tagName.toUpperCase();if(Element._insertionTranslations.tags[B]){var F=C.next();var A=Element._getContentFromAnonymousElement(B,E.stripScripts());D.removeChild(C);if(F){A.each(function(G){D.insertBefore(G,F)})}else{A.each(function(G){D.appendChild(G)})}}else{C.outerHTML=E.stripScripts()}E.evalScripts.bind(E).defer();return C}}Element._returnOffset=function(B,C){var A=[B,C];A.left=B;A.top=C;return A};Element._getContentFromAnonymousElement=function(C,B){var D=new Element("div"),A=Element._insertionTranslations.tags[C];if(A){D.innerHTML=A[0]+B+A[1];A[2].times(function(){D=D.firstChild})}else{D.innerHTML=B}return $A(D.childNodes)};Element._insertionTranslations={before:function(A,B){A.parentNode.insertBefore(B,A)},top:function(A,B){A.insertBefore(B,A.firstChild)},bottom:function(A,B){A.appendChild(B)},after:function(A,B){A.parentNode.insertBefore(B,A.nextSibling)},tags:{TABLE:["<table>","</table>",1],TBODY:["<table><tbody>","</tbody></table>",2],TR:["<table><tbody><tr>","</tr></tbody></table>",3],TD:["<table><tbody><tr><td>","</td></tr></tbody></table>",4],SELECT:["<select>","</select>",1]}};(function(){var A=Element._insertionTranslations.tags;Object.extend(A,{THEAD:A.TBODY,TFOOT:A.TBODY,TH:A.TD})})();Element.Methods.Simulated={hasAttribute:function(A,C){C=Element._attributeTranslations.has[C]||C;var B=$(A).getAttributeNode(C);return !!(B&&B.specified)}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);(function(A){if(!Prototype.BrowserFeatures.ElementExtensions&&A.__proto__){window.HTMLElement={};window.HTMLElement.prototype=A.__proto__;Prototype.BrowserFeatures.ElementExtensions=true}A=null})(document.createElement("div"));Element.extend=(function(){function C(G){if(typeof window.Element!="undefined"){var I=window.Element.prototype;if(I){var K="_"+(Math.random()+"").slice(2);var H=document.createElement(G);I[K]="x";var J=(H[K]!=="x");delete I[K];H=null;return J}}return false}function B(H,G){for(var J in G){var I=G[J];if(Object.isFunction(I)&&!(J in H)){H[J]=I.methodize()}}}var D=C("object");if(Prototype.BrowserFeatures.SpecificElementExtensions){if(D){return function(H){if(H&&typeof H._extendedByPrototype=="undefined"){var G=H.tagName;if(G&&(/^(?:object|applet|embed)$/i.test(G))){B(H,Element.Methods);B(H,Element.Methods.Simulated);B(H,Element.Methods.ByTag[G.toUpperCase()])}}return H}}return Prototype.K}var A={},E=Element.Methods.ByTag;var F=Object.extend(function(I){if(!I||typeof I._extendedByPrototype!="undefined"||I.nodeType!=1||I==window){return I}var G=Object.clone(A),H=I.tagName.toUpperCase();if(E[H]){Object.extend(G,E[H])}B(I,G);I._extendedByPrototype=Prototype.emptyFunction;return I},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(A,Element.Methods);Object.extend(A,Element.Methods.Simulated)}}});F.refresh();return F})();Element.hasAttribute=function(A,B){if(A.hasAttribute){return A.hasAttribute(B)}return Element.Methods.Simulated.hasAttribute(A,B)};Element.addMethods=function(C){var J=Prototype.BrowserFeatures,D=Element.Methods.ByTag;if(!C){Object.extend(Form,Form.Methods);Object.extend(Form.Element,Form.Element.Methods);Object.extend(Element.Methods.ByTag,{FORM:Object.clone(Form.Methods),INPUT:Object.clone(Form.Element.Methods),SELECT:Object.clone(Form.Element.Methods),TEXTAREA:Object.clone(Form.Element.Methods)})}if(arguments.length==2){var B=C;C=arguments[1]}if(!B){Object.extend(Element.Methods,C||{})}else{if(Object.isArray(B)){B.each(H)}else{H(B)}}function H(F){F=F.toUpperCase();if(!Element.Methods.ByTag[F]){Element.Methods.ByTag[F]={}}Object.extend(Element.Methods.ByTag[F],C)}function A(M,L,F){F=F||false;for(var O in M){var N=M[O];if(!Object.isFunction(N)){continue}if(!F||!(O in L)){L[O]=N.methodize()}}}function E(N){var F;var M={OPTGROUP:"OptGroup",TEXTAREA:"TextArea",P:"Paragraph",FIELDSET:"FieldSet",UL:"UList",OL:"OList",DL:"DList",DIR:"Directory",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading",Q:"Quote",INS:"Mod",DEL:"Mod",A:"Anchor",IMG:"Image",CAPTION:"TableCaption",COL:"TableCol",COLGROUP:"TableCol",THEAD:"TableSection",TFOOT:"TableSection",TBODY:"TableSection",TR:"TableRow",TH:"TableCell",TD:"TableCell",FRAMESET:"FrameSet",IFRAME:"IFrame"};if(M[N]){F="HTML"+M[N]+"Element"}if(window[F]){return window[F]}F="HTML"+N+"Element";if(window[F]){return window[F]}F="HTML"+N.capitalize()+"Element";if(window[F]){return window[F]}var L=document.createElement(N);var O=L.__proto__||L.constructor.prototype;L=null;return O}var I=window.HTMLElement?HTMLElement.prototype:Element.prototype;if(J.ElementExtensions){A(Element.Methods,I);A(Element.Methods.Simulated,I,true)}if(J.SpecificElementExtensions){for(var K in Element.Methods.ByTag){var G=E(K);if(Object.isUndefined(G)){continue}A(D[K],G.prototype)}}Object.extend(Element,Element.Methods);delete Element.ByTag;if(Element.extend.refresh){Element.extend.refresh()}Element.cache={}};document.viewport={getDimensions:function(){return{width:this.getWidth(),height:this.getHeight()}},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop)}};(function(C){var H=Prototype.Browser,F=document,D,E={};function A(){if(H.WebKit&&!F.evaluate){return document}if(H.Opera&&window.parseFloat(window.opera.version())<9.5){return document.body}return document.documentElement}function G(B){if(!D){D=A()}E[B]="client"+B;C["get"+B]=function(){return D[E[B]]};return C["get"+B]()}C.getWidth=G.curry("Width");C.getHeight=G.curry("Height")})(document.viewport);Element.Storage={UID:1};Element.addMethods({getStorage:function(B){if(!(B=$(B))){return }var A;if(B===window){A=0}else{if(typeof B._prototypeUID==="undefined"){B._prototypeUID=[Element.Storage.UID++]}A=B._prototypeUID[0]}if(!Element.Storage[A]){Element.Storage[A]=$H()}return Element.Storage[A]},store:function(B,A,C){if(!(B=$(B))){return }if(arguments.length===2){Element.getStorage(B).update(A)}else{Element.getStorage(B).set(A,C)}return B},retrieve:function(C,B,A){if(!(C=$(C))){return }var E=Element.getStorage(C),D=E.get(B);if(Object.isUndefined(D)){E.set(B,A);D=A}return D},clone:function(C,A){if(!(C=$(C))){return }var E=C.cloneNode(A);E._prototypeUID=void 0;if(A){var D=Element.select(E,"*"),B=D.length;while(B--){D[B]._prototypeUID=void 0}}return Element.extend(E)}});var Selector=Class.create({initialize:function(A){this.expression=A.strip();if(this.shouldUseSelectorsAPI()){this.mode="selectorsAPI"}else{if(this.shouldUseXPath()){this.mode="xpath";this.compileXPathMatcher()}else{this.mode="normal";this.compileMatcher()}}},shouldUseXPath:(function(){var A=(function(){var E=false;if(document.evaluate&&window.XPathResult){var D=document.createElement("div");D.innerHTML="<ul><li></li></ul><div><ul><li></li></ul></div>";var C=".//*[local-name()='ul' or local-name()='UL']//*[local-name()='li' or local-name()='LI']";var B=document.evaluate(C,D,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);E=(B.snapshotLength!==2);D=null}return E})();return function(){if(!Prototype.BrowserFeatures.XPath){return false}var B=this.expression;if(Prototype.Browser.WebKit&&(B.include("-of-type")||B.include(":empty"))){return false}if((/(\[[\w-]*?:|:checked)/).test(B)){return false}if(A){return false}return true}})(),shouldUseSelectorsAPI:function(){if(!Prototype.BrowserFeatures.SelectorsAPI){return false}if(Selector.CASE_INSENSITIVE_CLASS_NAMES){return false}if(!Selector._div){Selector._div=new Element("div")}try{Selector._div.querySelector(this.expression)}catch(A){return false}return true},compileMatcher:function(){var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m,len=ps.length,name;if(Selector._cache[e]){this.matcher=Selector._cache[e];return }this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i=0;i<len;i++){p=ps[i].re;name=ps[i].name;if(m=e.match(p)){this.matcher.push(Object.isFunction(c[name])?c[name](m):new Template(c[name]).evaluate(m));e=e.replace(m[0],"");break}}}this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join("\n"));Selector._cache[this.expression]=this.matcher},compileXPathMatcher:function(){var G=this.expression,H=Selector.patterns,C=Selector.xpath,F,B,A=H.length,D;if(Selector._cache[G]){this.xpath=Selector._cache[G];return }this.matcher=[".//*"];while(G&&F!=G&&(/\S/).test(G)){F=G;for(var E=0;E<A;E++){D=H[E].name;if(B=G.match(H[E].re)){this.matcher.push(Object.isFunction(C[D])?C[D](B):new Template(C[D]).evaluate(B));G=G.replace(B[0],"");break}}}this.xpath=this.matcher.join("");Selector._cache[this.expression]=this.xpath},findElements:function(A){A=A||document;var C=this.expression,B;switch(this.mode){case"selectorsAPI":if(A!==document){var D=A.id,E=$(A).identify();E=E.replace(/([\.:])/g,"\\$1");C="#"+E+" "+C}B=$A(A.querySelectorAll(C)).map(Element.extend);A.id=D;return B;case"xpath":return document._getElementsByXPath(this.xpath,A);default:return this.matcher(A)}},match:function(I){this.tokens=[];var M=this.expression,A=Selector.patterns,E=Selector.assertions;var B,D,F,L=A.length,C;while(M&&B!==M&&(/\S/).test(M)){B=M;for(var H=0;H<L;H++){D=A[H].re;C=A[H].name;if(F=M.match(D)){if(E[C]){this.tokens.push([C,Object.clone(F)]);M=M.replace(F[0],"")}else{return this.findElements(document).include(I)}}}}var K=true,C,J;for(var H=0,G;G=this.tokens[H];H++){C=G[0],J=G[1];if(!Selector.assertions[C](I,J)){K=false;break}}return K},toString:function(){return this.expression},inspect:function(){return"#<Selector:"+this.expression.inspect()+">"}});if(Prototype.BrowserFeatures.SelectorsAPI&&document.compatMode==="BackCompat"){Selector.CASE_INSENSITIVE_CLASS_NAMES=(function(){var C=document.createElement("div"),A=document.createElement("span");C.id="prototype_test_id";A.className="Test";C.appendChild(A);var B=(C.querySelector("#prototype_test_id .test")!==null);C=A=null;return B})()}Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:"/following-sibling::*",tagName:function(A){if(A[1]=="*"){return""}return"[local-name()='"+A[1].toLowerCase()+"' or local-name()='"+A[1].toUpperCase()+"']"},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:function(A){A[1]=A[1].toLowerCase();return new Template("[@#{1}]").evaluate(A)},attr:function(A){A[1]=A[1].toLowerCase();A[3]=A[5]||A[6];return new Template(Selector.xpath.operators[A[2]]).evaluate(A)},pseudo:function(A){var B=Selector.xpath.pseudos[A[1]];if(!B){return""}if(Object.isFunction(B)){return B(A)}return new Template(Selector.xpath.pseudos[A[1]]).evaluate(A)},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]",empty:"[count(*) = 0 and (count(text()) = 0)]",checked:"[@checked]",disabled:"[(@disabled) and (@type!='hidden')]",enabled:"[not(@disabled) and (@type!='hidden')]",not:function(E){var H=E[6],C=Selector.patterns,I=Selector.xpath,A,J,G=C.length,B;var D=[];while(H&&A!=H&&(/\S/).test(H)){A=H;for(var F=0;F<G;F++){B=C[F].name;if(E=H.match(C[F].re)){J=Object.isFunction(I[B])?I[B](E):new Template(I[B]).evaluate(E);D.push("("+J.substring(1,J.length-1)+")");H=H.replace(E[0],"");break}}}return"[not("+D.join(" and ")+")]"},"nth-child":function(A){return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",A)},"nth-last-child":function(A){return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",A)},"nth-of-type":function(A){return Selector.xpath.pseudos.nth("position() ",A)},"nth-last-of-type":function(A){return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",A)},"first-of-type":function(A){A[6]="1";return Selector.xpath.pseudos["nth-of-type"](A)},"last-of-type":function(A){A[6]="1";return Selector.xpath.pseudos["nth-last-of-type"](A)},"only-of-type":function(A){var B=Selector.xpath.pseudos;return B["first-of-type"](A)+B["last-of-type"](A)},nth:function(E,C){var F,G=C[6],B;if(G=="even"){G="2n+0"}if(G=="odd"){G="2n+1"}if(F=G.match(/^(\d+)$/)){return"["+E+"= "+F[1]+"]"}if(F=G.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(F[1]=="-"){F[1]=-1}var D=F[1]?Number(F[1]):1;var A=F[2]?Number(F[2]):0;B="[((#{fragment} - #{b}) mod #{a} = 0) and ((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(B).evaluate({fragment:E,a:D,b:A})}}}},criteria:{tagName:'n = h.tagName(n, r, "#{1}", c);      c = false;',className:'n = h.className(n, r, "#{1}", c);    c = false;',id:'n = h.id(n, r, "#{1}", c);           c = false;',attrPresence:'n = h.attrPresence(n, r, "#{1}", c); c = false;',attr:function(A){A[3]=(A[5]||A[6]);return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(A)},pseudo:function(A){if(A[6]){A[6]=A[6].replace(/"/g,'\\"')}return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(A)},descendant:'c = "descendant";',child:'c = "child";',adjacent:'c = "adjacent";',laterSibling:'c = "laterSibling";'},patterns:[{name:"laterSibling",re:/^\s*~\s*/},{name:"child",re:/^\s*>\s*/},{name:"adjacent",re:/^\s*\+\s*/},{name:"descendant",re:/^\s/},{name:"tagName",re:/^\s*(\*|[\w\-]+)(\b|$)?/},{name:"id",re:/^#([\w\-\*]+)(\b|$)/},{name:"className",re:/^\.([\w\-\*]+)(\b|$)/},{name:"pseudo",re:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/},{name:"attrPresence",re:/^\[((?:[\w-]+:)?[\w-]+)\]/},{name:"attr",re:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/}],assertions:{tagName:function(A,B){return B[1].toUpperCase()==A.tagName.toUpperCase()},className:function(A,B){return Element.hasClassName(A,B[1])},id:function(A,B){return A.id===B[1]},attrPresence:function(A,B){return Element.hasAttribute(A,B[1])},attr:function(B,C){var A=Element.readAttribute(B,C[1]);return A&&Selector.operators[C[2]](A,C[5]||C[6])}},handlers:{concat:function(B,A){for(var C=0,D;D=A[C];C++){B.push(D)}return B},mark:function(A){var D=Prototype.emptyFunction;for(var B=0,C;C=A[B];B++){C._countedByPrototype=D}return A},unmark:(function(){var A=(function(){var B=document.createElement("div"),E=false,D="_countedByPrototype",C="x";B[D]=C;E=(B.getAttribute(D)===C);B=null;return E})();return A?function(B){for(var C=0,D;D=B[C];C++){D.removeAttribute("_countedByPrototype")}return B}:function(B){for(var C=0,D;D=B[C];C++){D._countedByPrototype=void 0}return B}})(),index:function(A,D,G){A._countedByPrototype=Prototype.emptyFunction;if(D){for(var B=A.childNodes,E=B.length-1,C=1;E>=0;E--){var F=B[E];if(F.nodeType==1&&(!G||F._countedByPrototype)){F.nodeIndex=C++}}}else{for(var E=0,C=1,B=A.childNodes;F=B[E];E++){if(F.nodeType==1&&(!G||F._countedByPrototype)){F.nodeIndex=C++}}}},unique:function(B){if(B.length==0){return B}var D=[],E;for(var C=0,A=B.length;C<A;C++){if(typeof (E=B[C])._countedByPrototype=="undefined"){E._countedByPrototype=Prototype.emptyFunction;D.push(Element.extend(E))}}return Selector.handlers.unmark(D)},descendant:function(A){var D=Selector.handlers;for(var C=0,B=[],E;E=A[C];C++){D.concat(B,E.getElementsByTagName("*"))}return B},child:function(A){var E=Selector.handlers;for(var D=0,C=[],F;F=A[D];D++){for(var B=0,G;G=F.childNodes[B];B++){if(G.nodeType==1&&G.tagName!="!"){C.push(G)}}}return C},adjacent:function(A){for(var C=0,B=[],E;E=A[C];C++){var D=this.nextElementSibling(E);if(D){B.push(D)}}return B},laterSibling:function(A){var D=Selector.handlers;for(var C=0,B=[],E;E=A[C];C++){D.concat(B,Element.nextSiblings(E))}return B},nextElementSibling:function(A){while(A=A.nextSibling){if(A.nodeType==1){return A}}return null},previousElementSibling:function(A){while(A=A.previousSibling){if(A.nodeType==1){return A}}return null},tagName:function(A,H,C,B){var I=C.toUpperCase();var E=[],G=Selector.handlers;if(A){if(B){if(B=="descendant"){for(var F=0,D;D=A[F];F++){G.concat(E,D.getElementsByTagName(C))}return E}else{A=this[B](A)}if(C=="*"){return A}}for(var F=0,D;D=A[F];F++){if(D.tagName.toUpperCase()===I){E.push(D)}}return E}else{return H.getElementsByTagName(C)}},id:function(A,I,B,C){var H=$(B),G=Selector.handlers;if(I==document){if(!H){return[]}if(!A){return[H]}}else{if(!I.sourceIndex||I.sourceIndex<1){var A=I.getElementsByTagName("*");for(var E=0,D;D=A[E];E++){if(D.id===B){return[D]}}}}if(A){if(C){if(C=="child"){for(var F=0,D;D=A[F];F++){if(H.parentNode==D){return[H]}}}else{if(C=="descendant"){for(var F=0,D;D=A[F];F++){if(Element.descendantOf(H,D)){return[H]}}}else{if(C=="adjacent"){for(var F=0,D;D=A[F];F++){if(Selector.handlers.previousElementSibling(H)==D){return[H]}}}else{A=G[C](A)}}}}for(var F=0,D;D=A[F];F++){if(D==H){return[H]}}return[]}return(H&&Element.descendantOf(H,I))?[H]:[]},className:function(B,A,C,D){if(B&&D){B=this[D](B)}return Selector.handlers.byClassName(B,A,C)},byClassName:function(C,B,F){if(!C){C=Selector.handlers.descendant([B])}var H=" "+F+" ";for(var E=0,D=[],G,A;G=C[E];E++){A=G.className;if(A.length==0){continue}if(A==F||(" "+A+" ").include(H)){D.push(G)}}return D},attrPresence:function(C,B,A,G){if(!C){C=B.getElementsByTagName("*")}if(C&&G){C=this[G](C)}var E=[];for(var D=0,F;F=C[D];D++){if(Element.hasAttribute(F,A)){E.push(F)}}return E},attr:function(A,I,H,J,C,B){if(!A){A=I.getElementsByTagName("*")}if(A&&B){A=this[B](A)}var K=Selector.operators[C],F=[];for(var E=0,D;D=A[E];E++){var G=Element.readAttribute(D,H);if(G===null){continue}if(K(G,J)){F.push(D)}}return F},pseudo:function(B,C,E,A,D){if(B&&D){B=this[D](B)}if(!B){B=A.getElementsByTagName("*")}return Selector.pseudos[C](B,E,A)}},pseudos:{"first-child":function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(Selector.handlers.previousElementSibling(E)){continue}C.push(E)}return C},"last-child":function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(Selector.handlers.nextElementSibling(E)){continue}C.push(E)}return C},"only-child":function(B,G,A){var E=Selector.handlers;for(var D=0,C=[],F;F=B[D];D++){if(!E.previousElementSibling(F)&&!E.nextElementSibling(F)){C.push(F)}}return C},"nth-child":function(B,C,A){return Selector.pseudos.nth(B,C,A)},"nth-last-child":function(B,C,A){return Selector.pseudos.nth(B,C,A,true)},"nth-of-type":function(B,C,A){return Selector.pseudos.nth(B,C,A,false,true)},"nth-last-of-type":function(B,C,A){return Selector.pseudos.nth(B,C,A,true,true)},"first-of-type":function(B,C,A){return Selector.pseudos.nth(B,"1",A,false,true)},"last-of-type":function(B,C,A){return Selector.pseudos.nth(B,"1",A,true,true)},"only-of-type":function(B,D,A){var C=Selector.pseudos;return C["last-of-type"](C["first-of-type"](B,D,A),D,A)},getIndices:function(B,A,C){if(B==0){return A>0?[A]:[]}return $R(1,C).inject([],function(D,E){if(0==(E-A)%B&&(E-A)/B>=0){D.push(E)}return D})},nth:function(A,L,N,K,C){if(A.length==0){return[]}if(L=="even"){L="2n+0"}if(L=="odd"){L="2n+1"}var J=Selector.handlers,I=[],B=[],E;J.mark(A);for(var H=0,D;D=A[H];H++){if(!D.parentNode._countedByPrototype){J.index(D.parentNode,K,C);B.push(D.parentNode)}}if(L.match(/^\d+$/)){L=Number(L);for(var H=0,D;D=A[H];H++){if(D.nodeIndex==L){I.push(D)}}}else{if(E=L.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(E[1]=="-"){E[1]=-1}var O=E[1]?Number(E[1]):1;var M=E[2]?Number(E[2]):0;var P=Selector.pseudos.getIndices(O,M,A.length);for(var H=0,D,F=P.length;D=A[H];H++){for(var G=0;G<F;G++){if(D.nodeIndex==P[G]){I.push(D)}}}}}J.unmark(A);J.unmark(B);return I},empty:function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(E.tagName=="!"||E.firstChild){continue}C.push(E)}return C},not:function(A,D,I){var G=Selector.handlers,J,C;var H=new Selector(D).findElements(I);G.mark(H);for(var F=0,E=[],B;B=A[F];F++){if(!B._countedByPrototype){E.push(B)}}G.unmark(H);return E},enabled:function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(!E.disabled&&(!E.type||E.type!=="hidden")){C.push(E)}}return C},disabled:function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(E.disabled){C.push(E)}}return C},checked:function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(E.checked){C.push(E)}}return C}},operators:{"=":function(B,A){return B==A},"!=":function(B,A){return B!=A},"^=":function(B,A){return B==A||B&&B.startsWith(A)},"$=":function(B,A){return B==A||B&&B.endsWith(A)},"*=":function(B,A){return B==A||B&&B.include(A)},"~=":function(B,A){return(" "+B+" ").include(" "+A+" ")},"|=":function(B,A){return("-"+(B||"").toUpperCase()+"-").include("-"+(A||"").toUpperCase()+"-")}},split:function(B){var A=[];B.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(C){A.push(C[1].strip())});return A},matchElements:function(F,G){var E=$$(G),D=Selector.handlers;D.mark(E);for(var C=0,B=[],A;A=F[C];C++){if(A._countedByPrototype){B.push(A)}}D.unmark(E);return B},findElement:function(B,C,A){if(Object.isNumber(C)){A=C;C=false}return Selector.matchElements(B,C||"*")[A||0]},findChildElements:function(E,G){G=Selector.split(G.join(","));var D=[],F=Selector.handlers;for(var C=0,B=G.length,A;C<B;C++){A=new Selector(G[C].strip());F.concat(D,A.findElements(E))}return(B>1)?F.unique(D):D}});if(Prototype.Browser.IE){Object.extend(Selector.handlers,{concat:function(B,A){for(var C=0,D;D=A[C];C++){if(D.tagName!=="!"){B.push(D)}}return B}})}function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(A){A=$(A);A.reset();return A},serializeElements:function(G,B){if(typeof B!="object"){B={hash:!!B}}else{if(Object.isUndefined(B.hash)){B.hash=true}}var C,F,A=false,E=B.submit;var D=G.inject({},function(H,I){if(!I.disabled&&I.name){C=I.name;F=$(I).getValue();if(F!=null&&I.type!="file"&&(I.type!="submit"||(!A&&E!==false&&(!E||C==E)&&(A=true)))){if(C in H){if(!Object.isArray(H[C])){H[C]=[H[C]]}H[C].push(F)}else{H[C]=F}}}return H});return B.hash?D:Object.toQueryString(D)}};Form.Methods={serialize:function(B,A){return Form.serializeElements(Form.getElements(B),A)},getElements:function(E){var F=$(E).getElementsByTagName("*"),D,A=[],C=Form.Element.Serializers;for(var B=0;D=F[B];B++){A.push(D)}return A.inject([],function(G,H){if(C[H.tagName.toLowerCase()]){G.push(Element.extend(H))}return G})},getInputs:function(G,C,D){G=$(G);var A=G.getElementsByTagName("input");if(!C&&!D){return $A(A).map(Element.extend)}for(var E=0,H=[],F=A.length;E<F;E++){var B=A[E];if((C&&B.type!=C)||(D&&B.name!=D)){continue}H.push(Element.extend(B))}return H},disable:function(A){A=$(A);Form.getElements(A).invoke("disable");return A},enable:function(A){A=$(A);Form.getElements(A).invoke("enable");return A},findFirstElement:function(B){var C=$(B).getElements().findAll(function(D){return"hidden"!=D.type&&!D.disabled});var A=C.findAll(function(D){return D.hasAttribute("tabIndex")&&D.tabIndex>=0}).sortBy(function(D){return D.tabIndex}).first();return A?A:C.find(function(D){return/^(?:input|select|textarea)$/i.test(D.tagName)})},focusFirstElement:function(A){A=$(A);A.findFirstElement().activate();return A},request:function(B,A){B=$(B),A=Object.clone(A||{});var D=A.parameters,C=B.readAttribute("action")||"";if(C.blank()){C=window.location.href}A.parameters=B.serialize(true);if(D){if(Object.isString(D)){D=D.toQueryParams()}Object.extend(A.parameters,D)}if(B.hasAttribute("method")&&!A.method){A.method=B.method}return new Ajax.Request(C,A)}};Form.Element={focus:function(A){$(A).focus();return A},select:function(A){$(A).select();return A}};Form.Element.Methods={serialize:function(A){A=$(A);if(!A.disabled&&A.name){var B=A.getValue();if(B!=undefined){var C={};C[A.name]=B;return Object.toQueryString(C)}}return""},getValue:function(A){A=$(A);var B=A.tagName.toLowerCase();return Form.Element.Serializers[B](A)},setValue:function(A,B){A=$(A);var C=A.tagName.toLowerCase();Form.Element.Serializers[C](A,B);return A},clear:function(A){$(A).value="";return A},present:function(A){return $(A).value!=""},activate:function(A){A=$(A);try{A.focus();if(A.select&&(A.tagName.toLowerCase()!="input"||!(/^(?:button|reset|submit)$/i.test(A.type)))){A.select()}}catch(B){}return A},disable:function(A){A=$(A);A.disabled=true;return A},enable:function(A){A=$(A);A.disabled=false;return A}};var Field=Form.Element;var $F=Form.Element.Methods.getValue;Form.Element.Serializers={input:function(A,B){switch(A.type.toLowerCase()){case"checkbox":case"radio":return Form.Element.Serializers.inputSelector(A,B);default:return Form.Element.Serializers.textarea(A,B)}},inputSelector:function(A,B){if(Object.isUndefined(B)){return A.checked?A.value:null}else{A.checked=!!B}},textarea:function(A,B){if(Object.isUndefined(B)){return A.value}else{A.value=B}},select:function(C,F){if(Object.isUndefined(F)){return this[C.type=="select-one"?"selectOne":"selectMany"](C)}else{var B,D,G=!Object.isArray(F);for(var A=0,E=C.length;A<E;A++){B=C.options[A];D=this.optionValue(B);if(G){if(D==F){B.selected=true;return }}else{B.selected=F.include(D)}}}},selectOne:function(B){var A=B.selectedIndex;return A>=0?this.optionValue(B.options[A]):null},selectMany:function(D){var A,E=D.length;if(!E){return null}for(var C=0,A=[];C<E;C++){var B=D.options[C];if(B.selected){A.push(this.optionValue(B))}}return A},optionValue:function(A){return Element.extend(A).hasAttribute("value")?A.value:A.text}};Abstract.TimedObserver=Class.create(PeriodicalExecuter,{initialize:function($super,A,B,C){$super(C,B);this.element=$(A);this.lastValue=this.getValue()},execute:function(){var A=this.getValue();if(Object.isString(this.lastValue)&&Object.isString(A)?this.lastValue!=A:String(this.lastValue)!=String(A)){this.callback(this.element,A);this.lastValue=A}}});Form.Element.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.serialize(this.element)}});Abstract.EventObserver=Class.create({initialize:function(A,B){this.element=$(A);this.callback=B;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=="form"){this.registerFormCallbacks()}else{this.registerCallback(this.element)}},onElementEvent:function(){var A=this.getValue();if(this.lastValue!=A){this.callback(this.element,A);this.lastValue=A}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback,this)},registerCallback:function(A){if(A.type){switch(A.type.toLowerCase()){case"checkbox":case"radio":Event.observe(A,"click",this.onElementEvent.bind(this));break;default:Event.observe(A,"change",this.onElementEvent.bind(this));break}}}});Form.Element.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.serialize(this.element)}});(function(){var V={KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,cache:{}};var E=document.documentElement;var W="onmouseenter" in E&&"onmouseleave" in E;var O;if(Prototype.Browser.IE){var H={0:1,1:4,2:2};O=function(Y,X){return Y.button===H[X]}}else{if(Prototype.Browser.WebKit){O=function(Y,X){switch(X){case 0:return Y.which==1&&!Y.metaKey;case 1:return Y.which==1&&Y.metaKey;default:return false}}}else{O=function(Y,X){return Y.which?(Y.which===X+1):(Y.button===X)}}}function R(X){return O(X,0)}function Q(X){return O(X,1)}function K(X){return O(X,2)}function C(Z){Z=V.extend(Z);var Y=Z.target,X=Z.type,a=Z.currentTarget;if(a&&a.tagName){if(X==="load"||X==="error"||(X==="click"&&a.tagName.toLowerCase()==="input"&&a.type==="radio")){Y=a}}if(Y.nodeType==Node.TEXT_NODE){Y=Y.parentNode}return Element.extend(Y)}function M(Y,a){var X=V.element(Y);if(!a){return X}var Z=[X].concat(X.ancestors());return Selector.findElement(Z,a,0)}function P(X){return{x:B(X),y:A(X)}}function B(Z){var Y=document.documentElement,X=document.body||{scrollLeft:0};return Z.pageX||(Z.clientX+(Y.scrollLeft||X.scrollLeft)-(Y.clientLeft||0))}function A(Z){var Y=document.documentElement,X=document.body||{scrollTop:0};return Z.pageY||(Z.clientY+(Y.scrollTop||X.scrollTop)-(Y.clientTop||0))}function N(X){V.extend(X);X.preventDefault();X.stopPropagation();X.stopped=true}V.Methods={isLeftClick:R,isMiddleClick:Q,isRightClick:K,element:C,findElement:M,pointer:P,pointerX:B,pointerY:A,stop:N};var T=Object.keys(V.Methods).inject({},function(X,Y){X[Y]=V.Methods[Y].methodize();return X});if(Prototype.Browser.IE){function G(Y){var X;switch(Y.type){case"mouseover":X=Y.fromElement;break;case"mouseout":X=Y.toElement;break;default:return null}return Element.extend(X)}Object.extend(T,{stopPropagation:function(){this.cancelBubble=true},preventDefault:function(){this.returnValue=false},inspect:function(){return"[object Event]"}});V.extend=function(Y,X){if(!Y){return false}if(Y._extendedByPrototype){return Y}Y._extendedByPrototype=Prototype.emptyFunction;var Z=V.pointer(Y);Object.extend(Y,{target:Y.srcElement||X,relatedTarget:G(Y),pageX:Z.x,pageY:Z.y});return Object.extend(Y,T)}}else{V.prototype=window.Event.prototype||document.createEvent("HTMLEvents").__proto__;Object.extend(V.prototype,T);V.extend=Prototype.K}function L(b,a,e){var Z=Element.retrieve(b,"prototype_event_registry");if(Object.isUndefined(Z)){D.push(b);Z=Element.retrieve(b,"prototype_event_registry",$H())}var X=Z.get(a);if(Object.isUndefined(X)){X=[];Z.set(a,X)}if(X.pluck("handler").include(e)){return false}var Y;if(a.include(":")){Y=function(f){if(Object.isUndefined(f.eventName)){return false}if(f.eventName!==a){return false}V.extend(f,b);e.call(b,f)}}else{if(!W&&(a==="mouseenter"||a==="mouseleave")){if(a==="mouseenter"||a==="mouseleave"){Y=function(g){V.extend(g,b);var f=g.relatedTarget;while(f&&f!==b){try{f=f.parentNode}catch(h){f=b}}if(f===b){return }e.call(b,g)}}}else{Y=function(f){V.extend(f,b);e.call(b,f)}}}Y.handler=e;X.push(Y);return Y}function F(){for(var X=0,Y=D.length;X<Y;X++){V.stopObserving(D[X]);D[X]=null}}var D=[];if(Prototype.Browser.IE){window.attachEvent("onunload",F)}if(Prototype.Browser.WebKit){window.addEventListener("unload",Prototype.emptyFunction,false)}var J=Prototype.K;if(!W){J=function(Y){var X={mouseenter:"mouseover",mouseleave:"mouseout"};return Y in X?X[Y]:Y}}function S(a,Z,b){a=$(a);var Y=L(a,Z,b);if(!Y){return a}if(Z.include(":")){if(a.addEventListener){a.addEventListener("dataavailable",Y,false)}else{a.attachEvent("ondataavailable",Y);a.attachEvent("onfilterchange",Y)}}else{var X=J(Z);if(a.addEventListener){a.addEventListener(X,Y,false)}else{a.attachEvent("on"+X,Y)}}return a}function I(e,a,f){e=$(e);var Z=Element.retrieve(e,"prototype_event_registry");if(Object.isUndefined(Z)){return e}if(a&&!f){var b=Z.get(a);if(Object.isUndefined(b)){return e}b.each(function(g){Element.stopObserving(e,a,g.handler)});return e}else{if(!a){Z.each(function(j){var g=j.key,h=j.value;h.each(function(k){Element.stopObserving(e,g,k.handler)})});return e}}var b=Z.get(a);if(!b){return }var Y=b.find(function(g){return g.handler===f});if(!Y){return e}var X=J(a);if(a.include(":")){if(e.removeEventListener){e.removeEventListener("dataavailable",Y,false)}else{e.detachEvent("ondataavailable",Y);e.detachEvent("onfilterchange",Y)}}else{if(e.removeEventListener){e.removeEventListener(X,Y,false)}else{e.detachEvent("on"+X,Y)}}Z.set(a,b.without(Y));return e}function U(a,Z,Y,X){a=$(a);if(Object.isUndefined(X)){X=true}if(a==document&&document.createEvent&&!a.dispatchEvent){a=document.documentElement}var b;if(document.createEvent){b=document.createEvent("HTMLEvents");b.initEvent("dataavailable",true,true)}else{b=document.createEventObject();b.eventType=X?"ondataavailable":"onfilterchange"}b.eventName=Z;b.memo=Y||{};if(document.createEvent){a.dispatchEvent(b)}else{a.fireEvent(b.eventType,b)}return V.extend(b)}Object.extend(V,V.Methods);Object.extend(V,{fire:U,observe:S,stopObserving:I});Element.addMethods({fire:U,observe:S,stopObserving:I});Object.extend(document,{fire:U.methodize(),observe:S.methodize(),stopObserving:I.methodize(),loaded:false});if(window.Event){Object.extend(window.Event,V)}else{window.Event=V}})();(function(){var D;function A(){if(document.loaded){return }if(D){window.clearTimeout(D)}document.loaded=true;document.fire("dom:loaded")}function C(){if(document.readyState==="complete"){document.stopObserving("readystatechange",C);A()}}function B(){try{document.documentElement.doScroll("left")}catch(E){D=B.defer();return }A()}if(document.addEventListener){document.addEventListener("DOMContentLoaded",A,false)}else{document.observe("readystatechange",C);if(window==top){D=B.defer()}}Event.observe(window,"load",A)})();Element.addMethods();Hash.toQueryString=Object.toQueryString;var Toggle={display:Element.toggle};Element.Methods.childOf=Element.Methods.descendantOf;var Insertion={Before:function(A,B){return Element.insert(A,{before:B})},Top:function(A,B){return Element.insert(A,{top:B})},Bottom:function(A,B){return Element.insert(A,{bottom:B})},After:function(A,B){return Element.insert(A,{after:B})}};var $continue=new Error('"throw $continue" is deprecated, use "return" instead');var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},within:function(B,A,C){if(this.includeScrollOffsets){return this.withinIncludingScrolloffsets(B,A,C)}this.xcomp=A;this.ycomp=C;this.offset=Element.cumulativeOffset(B);return(C>=this.offset[1]&&C<this.offset[1]+B.offsetHeight&&A>=this.offset[0]&&A<this.offset[0]+B.offsetWidth)},withinIncludingScrolloffsets:function(B,A,D){var C=Element.cumulativeScrollOffset(B);this.xcomp=A+C[0]-this.deltaX;this.ycomp=D+C[1]-this.deltaY;this.offset=Element.cumulativeOffset(B);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+B.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+B.offsetWidth)},overlap:function(B,A){if(!B){return 0}if(B=="vertical"){return((this.offset[1]+A.offsetHeight)-this.ycomp)/A.offsetHeight}if(B=="horizontal"){return((this.offset[0]+A.offsetWidth)-this.xcomp)/A.offsetWidth}},cumulativeOffset:Element.Methods.cumulativeOffset,positionedOffset:Element.Methods.positionedOffset,absolutize:function(A){Position.prepare();return Element.absolutize(A)},relativize:function(A){Position.prepare();return Element.relativize(A)},realOffset:Element.Methods.cumulativeScrollOffset,offsetParent:Element.Methods.getOffsetParent,page:Element.Methods.viewportOffset,clone:function(B,C,A){A=A||{};return Element.clonePosition(C,B,A)}};if(!document.getElementsByClassName){document.getElementsByClassName=function(B){function A(C){return C.blank()?null:"[contains(concat(' ', @class, ' '), ' "+C+" ')]"}B.getElementsByClassName=Prototype.BrowserFeatures.XPath?function(C,E){E=E.toString().strip();var D=/\s/.test(E)?$w(E).map(A).join(""):A(E);return D?document._getElementsByXPath(".//*"+D,C):[]}:function(E,F){F=F.toString().strip();var G=[],H=(/\s/.test(F)?$w(F):null);if(!H&&!F){return G}var C=$(E).getElementsByTagName("*");F=" "+F+" ";for(var D=0,J,I;J=C[D];D++){if(J.className&&(I=" "+J.className+" ")&&(I.include(F)||(H&&H.all(function(K){return !K.toString().blank()&&I.include(" "+K+" ")})))){G.push(Element.extend(J))}}return G};return function(D,C){return $(C||document.body).getElementsByClassName(D)}}(Element.Methods)}Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(A){this.element=$(A)},_each:function(A){this.element.className.split(/\s+/).select(function(B){return B.length>0})._each(A)},set:function(A){this.element.className=A},add:function(A){if(this.include(A)){return }this.set($A(this).concat(A).join(" "))},remove:function(A){if(!this.include(A)){return }this.set($A(this).without(A).join(" "))},toString:function(){return $A(this).join(" ")}};Object.extend(Element.ClassNames.prototype,Enumerable);Object.Event={extend:function(A){A._objectEventSetup=function(B){this._observers=this._observers||{};this._observers[B]=this._observers[B]||[]};A.observe=function(D,B){if(typeof (D)=="string"&&typeof (B)!="undefined"){this._objectEventSetup(D);if(!this._observers[D].include(B)){this._observers[D].push(B)}}else{for(var C in D){this.observe(C,D[C])}}};A.stopObserving=function(C,B){this._objectEventSetup(C);if(C&&B){this._observers[C]=this._observers[C].without(B)}else{if(C){this._observers[C]=[]}else{this._observers={}}}};A.observeOnce=function(D,C){var B=function(){C.apply(this,arguments);this.stopObserving(D,B)}.bind(this);this._objectEventSetup(D);this._observers[D].push(B)};A.notify=function(F){this._objectEventSetup(F);var D=[];var B=$A(arguments).slice(1);try{for(var C=0;C<this._observers[F].length;++C){D.push(this._observers[F][C].apply(this._observers[F][C],B)||null)}}catch(E){if(E==$break){return false}else{throw E}}return D};if(A.prototype){A.prototype._objectEventSetup=A._objectEventSetup;A.prototype.observe=A.observe;A.prototype.stopObserving=A.stopObserving;A.prototype.observeOnce=A.observeOnce;A.prototype.notify=function(F){if(A.notify){var B=$A(arguments).slice(1);B.unshift(this);B.unshift(F);A.notify.apply(A,B)}this._objectEventSetup(F);var B=$A(arguments).slice(1);var D=[];try{if(this.options&&this.options[F]&&typeof (this.options[F])=="function"){D.push(this.options[F].apply(this,B)||null)}for(var C=0;C<this._observers[F].length;++C){D.push(this._observers[F][C].apply(this._observers[F][C],B)||null)}}catch(E){if(E==$break){return false}else{throw E}}return D}}}};Object.extend(Event,{wheel:function(A){var B=0;if(!A){A=window.event}if(A.wheelDelta){B=A.wheelDelta/120;if(window.opera){B=-B}}else{if(A.detail){B=-A.detail/3}}return Math.round(B)}});PBMenu=Class.create({initialize:function(A){var B={items:[]};Object.extend(B,A);this.options=B;this.items=new Array();this.create();this.enable();if(this.options.items){this.addItems(this.options.items)}this.onClickOpen=this.show.bind(this);this.onClickClose=this.off.bind(this);this.options.toggle.observe("click",this.onClickOpen)},toggle:function(A){if(A){A.stop();this.options.toggle.blur()}if(this.isOpen){this.hide()}else{this.show()}},create:function(){this.elm=new Element("div",{"class":"pbMenu"});this.listElm=new Element("ul");this.elm.appendChild(this.listElm);this.elm.appendChild(new Element("img",{src:"/layout/common/images/shadow.png",width:"100%"}));document.body.appendChild(this.elm)},disable:function(){this.isEnabled=false;this.elm.addClassName("disabled")},enable:function(){this.isEnabled=true;this.elm.removeClassName("disabled")},show:function(A){A.stop();A.element().blur();if(A.element().disabled){return }this.options.toggle.addClassName("active");if(this.isOpen||!this.isEnabled){return }var B=this.options.toggle.cumulativeOffset();if(Prototype.Browser.WebKit){B.left+=10;B.top+=40}B.top+=this.options.toggle.getHeight()-1;this.elm.setStyle({top:B.top+"px",left:(B.left-1)+"px",display:"block"});this.isOpen=true;this.notify("onOpen");this.options.toggle.stopObserving("click",this.onClickOpen).observe("click",this.onClickClose);document.observe("click",this.onClickClose)},off:function(A){A.stop();A.element().blur();this.hide()},hide:function(){this.timer=null;this.isOpen=false;this.elm.setStyle({display:"none"});this.notify("onClose");this.options.toggle.stopObserving("click",this.onClickClose).observe("click",this.onClickOpen).removeClassName("active");document.stopObserving("click",this.onClickClose)},addItems:function(A){A.each(function(B){this.add(new PBMenu.Item(this,B))}.bind(this))},add:function(A){this.items.push(A);this.listElm.appendChild(A.elm)},getItem:function(B){for(var A=0;A<this.items.length;A++){if(this.items[A].options.name==B){return this.items[A]}}},removeAll:function(){this.items.each(function(A){this.remove(A)}.bind(this))},remove:function(A){A.remove();this.items=this.items.without(A)}});Object.Event.extend(PBMenu);PBMenu.Item=Class.create({initialize:function(B,A){this.options=A;this.menu=B;this.elm=new Element("li").update(A.txt).observe("click",this.activate.bind(this)).addClassName(A.className);if(this.options.className){this.elm.className=this.options.className}(this.options.disabled)?this.disable():this.enable()},disable:function(){this.isDisabled=true;this.elm.addClassName("disabled")},enable:function(){this.isDisabled=false;this.elm.removeClassName("disabled")},activate:function(A){if(A){A.stop()}if(!this.isDisabled){this.menu.hide();this.notify("onClick")}},remove:function(){this.elm.parentNode.removeChild(this.elm)}});Object.Event.extend(PBMenu.Item);Util={findEmails:function(D,A){var G=new Array();var F=D.split(/[,;\s]+|,/);for(var C=0;C<F.length;C++){var B=F[C].replace(/^\s+|\s+$/g,"");if(B==""){continue}var E=Util.is_valid_email(B);if(E!==true){A(E);return new Array()}else{G.push(B)}}return G},parseQueryString:function(B){var A={};$A(B.split("&")).each(function(D){var C=D.split("=");A[C[0]]=C[1]});return A},getURLParameter:function(D){var C=document.location.href;if(!C){return null}if(!C.indexOf("?")){return null}var A=C.substring(C.indexOf("?")+1);var B=Util.parseQueryString(A);if(B[D]&&!B[D].empty()){return B[D]}else{return null}},onFCKcomplete:function(A){document.fire("ui:fckeditor_oncomplete",{editorInstance:A})},strHasInvalidCharacters:function(C,B){for(var A=0;A<B.length;A++){if(C.indexOf(B.charAt(A))!==-1){return true}}return false},strToPageName:function(A){for(var B=0;B<PBconst.kInvalidPageCharacters.length;B++){A=A.replace(PBconst.kInvalidPageCharacters.charAt(B),"")}A=A.replace(/\./,"");return A},is_valid_page_name:function(A){if(A=="FrontPage"){return"Cannot create a page called 'FrontPage'"}if(A.strip().length==0){return"Empty page names are not allowed"}if(A.length>PBconst.kMaxPageNameLength){return"That name is too long (page names must be "+PBconst.kMaxPageNameLength+" characters or less)"}if(Util.strHasInvalidCharacters(A,PBconst.kInvalidPageCharacters)){return"Page names can't contain any of the following characters: "+PBconst.kInvalidPageCharacters}return true},is_valid_folder_name:function(A){if(A.length>PBconst.kMaxFolderNameLength){return"Folder names must be less then "+PBconst.kMaxFolderNameLength+" characters"}if(A.strip().length==0){return"Empty folder names are not allowed"}if(Util.strHasInvalidCharacters(A,PBconst.kInvalidFolderCharacters)){return"Folder names can't contain any of the following characters: "+PBconst.kInvalidFolderCharacters}return true},is_valid_file_name:function(A){if(A.length>PBconst.kMaxFileNameLength){return"File names must be less then "+PBconst.kMaxFileNameLength+" characters"}if(A.strip().length==0){return"Empty file names are not allowed"}if(Util.strHasInvalidCharacters(A,PBconst.kInvalidFileCharacters)){return"File names can't contain any of the following characters: "+PBconst.kInvalidFileCharacters}return true},is_valid_milestone_name:function(A){if(!A||A.strip().length==0){return"Empty milestone names are not allowed"}if(A.length>PBconst.kMaxMilestoneLength){return"Milestone names must be less then "+PBconst.kMaxMilestoneLength+" characters"}return true},is_valid_action_name:function(A){if(!A||A.strip().length==0){return"Empty action names are not allowed"}if(A.length>PBconst.kMaxActionLength){return"Action names must be less then "+PBconst.kMaxActionLength+" characters"}return true},is_valid_email:function(v){if(!eval(PBconst.kPolicyValidEmailRegex).test(v)){return"The address "+v+" isn't a proper email address."}return true},is_valid_domain_object_name:function(o,obj_type){o=o.strip();if(o.length<PBconst.kMinWikiNameLength){return obj_type+" names must be at least "+PBconst.kMinWikiNameLength+" characters."}if(o.length>PBconst.kMaxWikiNameLength){return obj_type+" names must be no more than "+PBconst.kMaxWikiNameLength+" characters."}if(!eval(PBconst.kPolicyValidWikiNameRegex).test(o)){return obj_type+" names can only have letters and numbers in them"}return true},is_valid_network_name:function(A){return Util.is_valid_domain_object_name(A,"Network")},is_valid_wiki_name:function(A){return Util.is_valid_domain_object_name(A,"Workspace")},is_valid_uid:function(u){return !!eval(PBconst.kPolicyValidUIDRegex).test(u)},dashified_link:function(A){if(A.indexOf("-")==-1){A=A.replace(/ /g,"-")}A=encodeURIComponent(A);A=A.replace(/%20/g,"+");return A},undashified_link:function(A){var B=A.indexOf("+")==-1;A=decodeURIComponent(A);A=A.replace(/\+/g," ");if(B&&A.indexOf("-")!=-1){A=A.replace(/-/g," ")}return A},getFolderLink:function(A){return(A=="")?"/browse/#view=ViewUnfiled":"/browse/#view=ViewFolder&param="+encodeURIComponent(A)},getFileExtension:function(A){if(!A||typeof (A)!="string"){return }var B=A.lastIndexOf(".");if(B==-1){return }return A.substr(B+1).toLowerCase()},getFileIcon:function(A){return Util.iconMap[Util.getFileExtension(A.toString())]||"fileicon"},iconMap:{pdf:"ob_item_pdf",doc:"ob_item_doc",odt:"ob_item_doc",rtf:"ob_item_doc",docx:"ob_item_doc",xls:"ob_item_xls",ods:"ob_item_xls",xlsx:"ob_item_xls",ppt:"ob_item_ppt",odp:"ob_item_ppt",pptx:"ob_item_ppt",zip:"ob_item_zip",rar:"ob_item_zip",jpg:"ob_item_jpg",gif:"ob_item_jpg",png:"ob_item_jpg",psd:"ob_item_jpg",bmp:"ob_item_jpg",jpeg:"ob_item_jpg",txt:"ob_item_txt",css:"ob_item_txt",mp3:"ob_item_audio",htm:"ob_item_html",html:"ob_item_html"},addObjectTooltip:function(F,E){if(E.type!=="page"&&Util.isPreviewable(E.name)){var B="/f/"+E.mtime+"-180p/"+encodeURIComponent(E.name);var D="img-"+encodeURIComponent(E.name);var A='<span id="'+D+'"><img src="/images/loadingSmaller.gif"></span>';var C="document.getElementById('"+D+"').style.display='none';";new Tooltip(F,{txt:'<div style="width: 180px;"><img src="'+B+'" alt="Loading preview image..." width="180" onload="'+C+'" />'+A+"</div>"})}},isPreviewable:function(A){return["png","gif","jpg","jpeg","psd","pdf","ps","bmp"].indexOf(Util.getFileExtension(A))!=-1},isImageFile:function(A){return["png","gif","jpg","jpeg"].indexOf(Util.getFileExtension(A))!=-1},getAuthorNameFromObject:function(A){return A.user?A.user.name:(A.name||A.username||A.user_name||A.user_email||A.email||A.uid)},authorLinkFromObject:function(D,C){if(!D){return }var B=D.user?D.user.uid:(D.uid||D.user_id);var A=this.getAuthorNameFromObject(D);C=(C?C:"");if(PBinfo.CurrentNetwork){D.userClass+=" usercard_trigger"}if(B){var E=A?A.toString().escapeHTML():"";return C+'<a href="/user/'+B+'"'+((D.userClass)?' class="'+D.userClass+'"':"")+"ui:uid="+B+">"+E+"</a>"}else{return(A?C+A:"")}},URLRelativeToContext:function(A,B){var C=PBinfo.CurrentPage.host||window.location.host.substr(window.location.host.indexOf(".")+1);var D="";if(B.wiki||B.network){D=window.location.protocol+"//"+(B.wiki||B.network)+"."+C}else{D=window.location.protocol+"//"+C}if(A.charAt(0)!="/"){A="/"+A}return D+A},time_chunks:{yr:31536000,mo:2592000,wk:604800,day:86400,hr:3600,min:60},time_chunks_long:{year:31536000,month:2592000,week:604800,day:86400,hour:3600,minute:60},time_ago:function(C,F){var B=0,D=0,E="",A;if(C<0){C=0}A=(F?Util.time_chunks:Util.time_chunks_long);for(itm in A){if((D=Math.floor(C/A[itm]))!=0){B++;if(B>1){E+=", "}E+=(D==1)?"1 "+itm:D+" "+itm+"s";C-=A[itm]*D}if(B==1){break}}if(B==0){return"0 "+itm+"s"}return E},trackingPrefix:"",trackingSuffix:"",tracking:function(C,A){C=Util.trackingPrefix+C+Util.trackingSuffix;if(A&&Util.trackingList.indexOf(C)!=-1){return }PBwiki.info("tracking "+C);if(C.length>50){return false}var B=Cookie.get(PBconst.kTrackingCookie);B=(B)?B.evalJSON():[];B.push(C);if(B.length>10){B=[];Cookie.set(PBconst.kTrackingCookie,Object.toJSON(B));(new PBwiki.APIRequest("TrackingInit",{verb_list:B.join(",")}))}else{Cookie.set(PBconst.kTrackingCookie,Object.toJSON(B))}if(A){Util.trackingList.push(C)}},trackingList:[],executeUnlessEsc:function(B){esc_pressed=false;var A=function(){esc_pressed=true};document.observe("keypress:esc",A);setTimeout(function(){document.stopObserving("keypress:esc",A)},10);setTimeout(function(){if(!esc_pressed){B()}},10)}};window.FCKeditor_OnComplete=Util.onFCKcomplete;
/*@cc_on
Util.IE6 = ( @_jscript_version == '5.6' );
@*/
Object.extend(Date.prototype,{strftime:function(G){var B=this.getDay(),F=this.getMonth();var A=this.getHours(),D=this.getMinutes(),C=this.getDate();function E(H){return H.toPaddedString(2)}return G.gsub(/\%([aAbBcdeHIimMpSwyY])/,function(H){switch(H[1]){case"a":return $w("Sun Mon Tue Wed Thu Fri Sat")[B];break;case"A":return $w("Sunday Monday Tuesday Wednesday Thursday Friday Saturday")[B];break;case"b":return $w("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")[F];break;case"B":return $w("January February March April May June July August September October November December")[F];break;case"c":return this.toString();break;case"d":return E(this.getDate());break;case"H":return E(A);break;case"I":var I=((A+12)%12);return(I==0?12:E(I));break;case"i":var I=((A+12)%12);return(I==0?12:I);break;case"m":return E(F+1);break;case"M":return E(D);break;case"p":return A>=12?"PM":"AM";break;case"S":return E(this.getSeconds());break;case"w":return B;break;case"y":return E(this.getFullYear()%100);break;case"Y":return this.getFullYear().toString();break;case"e":return C;break;case"m":return F+1;break;case"M":return E(D);break}}.bind(this))}});Object.extend(String.prototype,{escapeTruncate:function(A){if(!A){A=40}if(this.length<A){return this.escapeHTML()}var B=Math.floor(A/2);return this.substr(0,B).escapeHTML()+"&hellip;"+this.substr(this.length-B).escapeHTML()}});MiniTabSwitcher=Class.create({linkPanelHash:null,initialize:function(A){this.linkPanelHash=new Hash();$H(A).each(function(C){if($(C.key)){var B=$(C.key);this.linkPanelHash.set(C.key,$(C.value));B.onmousedown=function(){return false};B.observe("click",this.handleTabOnclick.bindAsEventListener(this)).setAttribute("unselectable","on");if(B.hasClassName("active")){this.switchTab(B)}}}.bind(this))},handleTabOnclick:function(B){B.stop();var A=B.element();PBwiki.info(this.linkPanelHash);this.switchTab(A)},switchTab:function(A){this.linkPanelHash.each(function(B){$(B.key).removeClassName("active");B.value.hide()});A.addClassName("active");this.linkPanelHash.get(A.id).show();A.fire("ui:tabswitched")}});var Cookie={set:function(C,E,B,F){var A="";if(B){var G=new Date();G.setTime(G.getTime()+(86400000*parseFloat(B)));A="; expires="+G.toGMTString()}var D="";if(F){D="; domain="+F}return(document.cookie=escape(C)+"="+escape(E||"")+A+D+"; path=/")},get:function(A){var B=document.cookie.split(";").find(function(C){if(C.strip().indexOf(A+"=")==0){return true}});return(B)?unescape(B.split("=")[1]):""}};PBwiki={is_dev:function(){var A=(window.location.hostname.endsWith("pbworks.us")||window.location.search.indexOf("?debug=")==0);this.is_dev=function(){return A};return A},installFirebugLiteForIE:function(){if(this.is_dev()&&Prototype.Browser.IE&&false){document.write('<script src="/layout/js/firebug/firebug.js"><\/script>')}},getQueryParams:function(){this.queryParams=Util.parseQueryString(window.location.search.substr(1));this.loglevel=this.queryParams.loglevel},setLogLevel:function(){var A=PBwiki.queryParams.loglevel;PBwiki.logLevel=(PBwiki.loglevels.indexOf(A)>-1?PBwiki.loglevels.indexOf(A):PBwiki.loglevels.indexOf("info"))},canLog:function(A){return(PBwiki.logLevel<=PBwiki.loglevels.indexOf(A))},_initialize:function(){window.onerror=PBwiki.error;this.getQueryParams();PBwiki.setLogLevel();for(var A=0;A<this.initFunctions.length;A++){try{this.initFunctions[A]()}catch(B){PBwiki.error("error: "+B.message+" "+B.fileName+" line "+B.lineNumber)}}document.fire("pbwiki:init");PBwiki.debug("PBwiki : init complete")},loglevels:["debug","info","warn"],addInitFunction:function(B,A){this.initFunctions.push(function(){B.apply(null,A)})},initFunctions:[function(){if(window.loadFirebugConsole){window.loadFirebugConsole()}if(window.console&&PBwiki.is_dev()){PBwiki.loglevels.each(function(A){PBwiki[A]=(PBwiki.canLog(A)?function(B){console[A](B)}:Prototype.emptyFunction)})}else{PBwiki.loglevels.each(function(A){PBwiki[A]=Prototype.emptyFunction})}}],init:function(){var A=Array.prototype.shift.call(arguments);if(A.initialize){this.addInitFunction(A.initialize,arguments)}else{if(A.prototype){this.addInitFunction(function(B){(new A(B))},arguments)}else{if(Object.isFunction(A)){this.addInitFunction(A,arguments)}}}},getPageName:function(){return PBinfo.CurrentPage.page},getEditURI:function(B,A){if(PBwiki.feature("ajaxedit")){return"/"+Util.dashified_link(B.toString())+((A)?"?referer="+encodeURIComponent(window.location):"")+"#view=edit"}else{return"/"+encodeURIComponent(B.toString())+"?edit=1"+((A)?"&referer="+encodeURIComponent(window.location):"")}},getSessCookie:function(){var C=PBinfo.CurrentPage.sessCookie;var B={};var A=Cookie.get(C);if(A){B[C]=A}return B},getUID:function(){var A=PBinfo.CheckPermissions.uid;return(!A||A=="public-browser-proxy-id")?null:A},feature:function(A){if(typeof (PBinfo)=="undefined"||!PBinfo.GetFeatures){return false}return(PBinfo.GetFeatures[A])?true:false},error:function(A){PBwiki.warn(A);PBwiki.jsDebug(A)},jsDebug:function(A,C,B){if(PBinfo.CurrentWiki&&PBinfo.CurrentWiki.debug&&!PBwiki.jsDebugSent){(new Ajax.Request("/jsdebug.php?"+Object.toQueryString({msg:A,url:C,line:B,file:document.location.href})));PBwiki.jsDebugSent=true}return false},getCache:function(A){return PBinfo[A]},getTimestamp:function(){return Math.floor(new Date().getTime()/1000)},confirmDeletePage:function(){if(confirm("This will irretrievably delete this page and its revisions. Click OK to confirm this action.")){(new PBwiki.APIRequest("DeletePage",{page:PBwiki.getPageName()},{onSuccess:function(A){Page.EditPage.cancel=true;if(A.revcount==0){window.location.href="/browse/"}else{window.location.reload()}},onFailure:function(A){alert(A)},waitCursor:true,method:"post"}))}}};PBwiki.installFirebugLiteForIE();$(document).observe("dom:loaded",PBwiki._initialize.bind(PBwiki));PBwiki.UINotification=Class.create({initialize:function(){document.observe("ui:onNotifyUser",this.handleUserNotification.bind(this))},handleUserNotification:function(A){if(A.memo.mode&&A.memo.mode=="success"){this.displaySuccess(A.memo.message)}else{this.displayError(A.memo.message)}},showMessage:function(B){var A;if($$("h1.wikititle").length>0){A=$$("h1.wikititle")[0].nextSibling}else{if($$("h1.wikilogo").length>0){A=$$("h1.wikilogo")[0].nextSibling}}if(A){$("main-content").insertBefore(B,A)}},displayError:function(A){if(!this.errMsg){this.errMsg=new Element("div",{"class":"yellow-note"});this.showMessage(this.errMsg)}this.errMsg.update(A).show();if(this.errTimeout){window.clearTimeout(this.errTimeout);this.errTimeout=null}this.errTimeout=this.errMsg.hide.bind(this.errMsg).delay(10)},displaySuccess:function(A){PBwiki.info("displaySuccess");if(!this.successMsg){this.successContainer=new Element("ul",{"class":"page-notices ipm"});this.successMsg=new Element("li",{"class":"notification page-tick successmsg"});this.successContainer.appendChild(this.successMsg);this.showMessage(this.successContainer)}this.successMsg.update(A).show();this.successContainer.show();if(this.successTimeout){window.clearTimeout(this.successTimeout);this.successTimeout=null}this.successTimeout=this.successContainer.hide.bind(this.successContainer).delay(10)}});var UIException=Class.create({element:null,message:"",parent:null,initialize:function(C,A,B){this.element=A;this.message=C;this.parent=B},toString:function(){var A=this.message+(this.element?"("+this.element+")":"");if(this.parent){A+=" > "+this.parent.toString()}return A}});PBwiki.init(function(){var B=navigator.userAgent.indexOf("Windows NT 6.0")!=-1;var C=Prototype.Browser.WebKit;var A=navigator.userAgent.indexOf("Mac")!=-1;if(!(B||C||A)){$(document.body).addClassName("nn")}});PBwiki.init(PBwiki.UINotification);PBHistory=Class.create({initialize:function(A){var B={checkTime:100};Object.extend(B,A);this.options=B;this.keyList={};for(itm in this.options.items){this.keyList[itm]=new PBHistory.Key(this.options.items[itm])}},start:function(){this.timer=setInterval(this.check.bind(this),this.options.checkTime);return this},stop:function(){if(this.timer){this.timer.stop();this.timer=null}},getItems:function(){var B=location.hash;if(B.charAt(0)=="#"&&B.indexOf("=")!=-1){var A=B.substr(1).toQueryParams();for(itm in A){A[itm]=decodeURIComponent(A[itm])}return A}else{return{}}},setItems:function(B){for(itm in B){B[itm]=encodeURIComponent(B[itm])}var A=Object.toQueryString(B);if(A.length===0&&window.scrollY!==0){A="n"}if(A!=location.hash){location.hash=A}},check:function(){var A=this.getItems();for(itm in this.keyList){this.getKey(itm).check(A[itm])}},getKey:function(B){if(!this.keyList[B]){var A=this.getItems();this.keyList[B]=new PBHistory.Key({item:B});this.keyList[B].lastVal=A[B]}return this.keyList[B]},removeKey:function(B){var A=this.getItems();if(A[B]){delete A[B];this.setItems(A)}},setValues:function(B){var A=this.getItems();var C=false;for(itm in B){if(A[itm]&&(B[itm]==undefined||B[itm]==null)){delete A[itm];this.getKey(itm).lastVal=null;continue}if(A[itm]==B[itm]){continue}C=true;this.getKey(itm).lastVal=B[itm];A[itm]=B[itm]}if(C){this.setItems(A)}},getValue:function(B){var A=this.getItems();return A[B]}});Object.Event.extend(PBHistory);PBHistory.Key=Class.create({initialize:function(A){this.options=A||{}},check:function(A){if(A!=this.lastVal){this.lastVal=A;this.notify("onChange",A,this.options.item)}},getValue:function(){return this.lastVal}});Object.Event.extend(PBHistory.Key);PBwiki.init(function(){PBwiki.History=new PBHistory()});PBwiki.ResourceLoader={timer:{},scripts:[],load:function(B,F){B=PBwiki.ResourceLoader.getStaticURI(B);var E=null;var C=null;try{if($A(PBwiki.ResourceLoader.scripts).indexOf(B)==-1){PBwiki.ResourceLoader.scripts.push(B);var A=document.createElement("script");A.src=B;A.type="text/javascript";$$("head")[0].appendChild(A);if(F){A.onreadystatechange=function(){if(A.readyState=="loaded"||A.readyState=="complete"){F()}};A.onload=function(){F();return };if((Prototype.Browser.WebKit&&!navigator.userAgent.match(/Version\/3/))||Prototype.Browser.Opera){LazyLoader.timer[B]=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(PBwiki.ResourceLoader.timer[B]);F()}},10)}}}else{if(F){F()}}}catch(D){}},getStaticURI:function(B){var A=Util.getFileExtension(B);var C=B.split("/");if((C[1]=="shared"||C[1]=="swf")&&["js","css","swf"].indexOf(A)!=-1&&B.indexOf(".php")==-1){var D=window.location.host.substr(window.location.host.indexOf(".")+1);return window.location.protocol+"//vs1."+D+B.replace("."+A,"-v"+pbBuildTime+"."+A)}return B},applyCSS:function(C){var B=null;if(Prototype.Browser.IE){B=document.createStyleSheet();B.cssText=C}else{B=new Element("style",{type:"text/css"});var A=($$("head")[0]||$$("body")[0]);A.insertBefore(B,A.firstChild);B[(Prototype.Browser.WebKit)?"innerText":"innerHTML"]=C}}};PBButton=Class.create({initialize:function(A){var B={};Object.extend(B,A);this.options=B;this.create();this.enable();this.elm.observe("click",this.clicked.bindAsEventListener(this));return this},clicked:function(){if(this.isEnabled){this.notify("onClick")}},create:function(){this.elm=new Element("a",{id:this.options.id}).addClassName("button");this.span=new Element("span").update(this.options.txt);if(this.options.icon){this.span.addClassName(this.options.icon).addClassName("iconbutton")}if(this.options.className){this.span.className=this.options.className}this.elm.appendChild(this.span);if(this.options.addTo){this.addTo(this.options.addTo)}},disable:function(){this.isEnabled=false;this.elm.addClassName("disabled")},enable:function(){this.isEnabled=true;this.elm.removeClassName("disabled")},addTo:function(A){A.appendChild(this.elm)}});Object.Event.extend(PBButton);PBwiki.Components=PBwiki.Components||{};PBwiki.Components.Button=PBButton;PBwiki.Components.FolderSecurityButton=Class.create(PBwiki.Components.Button,{create:function($super){$super();PBwiki.info(this);this.elm.addClassName("folder_sec");if(this.options.has_custom_perms){this.span.appendChild(new Element("sub").update("&nbsp;"))}}});PBwiki.Components.FileUploadButton=Class.create(PBwiki.Components.Button,{create:function($super){$super();this.placeholder=new Element("div",{id:this.options.id+"_placeholder"});this.elm.insertBefore(this.placeholder,this.elm.firstChild);if(!PBinfo.CurrentPage.noFlashUploader&&(SWFUpload.DetectFlashVer(10,0,0)||(SWFUpload.DetectFlashVer(9,0,0)&&navigator.appVersion.indexOf("Mac")==-1))){this.createSwf()}this.obj=this.elm.down("object");if(this.obj){this.obj.setStyle({position:"absolute",zIndex:1000});if(Prototype.Browser.Gecko){this.obj.observe("mousedown",function(A){A.stop()})}}},setUploadFolder:function(A){this.options.folder=A;if(this.flashLoaded){this.swf.setUploadURL(this.getUploadUrl());this.swf.addPostParam("folder",this.options.folder)}},getUploadUrl:function(){var A={op:"PutFile",verbose:"true",_type:"xml"};Object.extend(A,PBwiki.getSessCookie());if(this.options.folder){A.folder=this.options.folder}return window.location.protocol+"//"+window.location.host+"/api_v2/?"+Object.toQueryString(A)},getLegacyUploadUrl:function(){var A={op:"PutFile",verbose:"true",_type:"iframe",callback:"top.PBwiki.APIRequest.DelegateFrameRequest"};Object.extend(A,PBwiki.getSessCookie());if(this.options.folder){A.folder=this.options.folder}return"/api_v2/?"+Object.toQueryString(A)},clicked:function(A){A.stop();if(this.isEnabled){setTimeout(this.openLegacyUpload.bind(this),100)}},disable:function(){if(this.obj){Element.hide(this.obj)}this.isEnabled=false;this.elm.addClassName("disabled")},enable:function(){if(this.obj){Element.show(this.obj)}this.isEnabled=true;this.elm.removeClassName("disabled")},openLegacyUpload:function(){if(this.isEnabled&&!this.flashLoaded){if(this.isRateLimited()){new PBwiki.DialogCommands.RateLimited({})}else{new PBwiki.DialogCommands.LegacyUploader({uploadUrl:this.getLegacyUploadUrl(),onUploaded:this.uploadFinshed.bind(this),folder:this.folder})}}},filesSelected:function(A){if(!this.flashLoaded){return false}if(A>10){return }try{this.obj.blur()}catch(B){}if(A==0){this.notify("onUploaded",0,"No files selected")}else{if(this.isRateLimited()){new PBwiki.DialogCommands.RateLimited({})}else{this.flashUploader=new PBwiki.DialogCommands.FlashUploader({swf:this.swf,onUploaded:this.uploadFinshed.bind(this)})}}},flashLoad:function(){this.flashLoaded=true;this.setUploadFolder(this.options.folder)},isRateLimited:function(){var A=PBwiki.getCache("GetStorageInfo");return A&&(A.ratelimited||((A.total>0)&&(A.used>A.total)))},uploadFinshed:function(A,B){this.notify("onUploaded",A,B)},fileQueueError:function(A){this.notify("onUploaded",0,"PBworks supports uploading 10 files at a time, please select fewer files and try again.")},createSwf:function(){var A={upload_url:this.getUploadUrl(),file_size_limit:"1073741824",file_types:"*.*",file_types_description:"All Files",file_upload_limit:"10",file_queue_limit:"10",button_width:this.elm.getWidth(),button_height:this.elm.getHeight(),button_placeholder_id:this.options.id+"_placeholder",button_window_mode:SWFUpload.WINDOW_MODE.TRANSPARENT,button_text_top_padding:4,button_text_left_padding:8,file_dialog_start_handler:this.flashLoad.bind(this),file_dialog_complete_handler:this.filesSelected.bind(this),file_queue_error_handler:this.fileQueueError.bind(this),debug_handler:this.debug.bind(this),flash_url:PBwiki.ResourceLoader.getStaticURI("/swf/swfupload.swf"),prevent_swf_caching:false,custom_settings:{progressTarget:"fsUploadProgress1"},debug:true};this.swf=new SWFUpload(A)},debug:function(A){PBwiki.info(A)}});PBwiki.Components.IEButtonFix=function(){if(/MSIE/.test(navigator.userAgent)&&$$("div.button-bar").length>0){if(PBwiki.resize_timer){window.clearTimeout(PBwiki.resize_timer)}PBwiki.resize_timer=window.setTimeout(function(){var C=$$("div.button-bar");for(var A=0;A<C.length;A++){var B=C[A];B.style.display="none";B.style.display="block"}},50)}};PBwiki.init(function(){if(/MSIE/.test(navigator.userAgent)&&$$("div.button-bar").length>0){Event.observe(window,"resize",PBwiki.Components.IEButtonFix)}});var Tooltip=Class.create();Tooltip.setup=function(){document.observe("mousemove",function(A){this.xCord=Event.pointerX(A);this.yCord=Event.pointerY(A)}.bind(Tooltip))};var Tooltips={addLinkTooltips:function(A){A.select("a.preview").each(function(B){var C=B.getAttribute("href");if(!C||C.indexOf("/f/")==-1||!Util.isPreviewable(C)||!B.getAttribute("time")||B.hasTooltip){return }var D="/f/"+B.getAttribute("time")+"-180p/"+encodeURIComponent(C.substr(C.lastIndexOf("/")+1));if(B.getAttribute("wiki")){D=Util.URLRelativeToContext(D,{wiki:B.getAttribute("wiki")})}new Tooltip(B,{txt:'<div style="width: 180px;"><img src="'+D+'" alt="Loading preview image..." width="180" /></div>'});B.hasTooltip=true})}};Tooltip.prototype={initialize:function(B,A){this.el=$(B);this.initialized=false;this.setOptions(A);this.showEvent=this.show.bindAsEventListener(this);this.hideEvent=this.hide.bindAsEventListener(this);this.updateEvent=this.update.bindAsEventListener(this);Event.observe(this.el,"mouseover",this.showEvent);Event.observe(this.el,"mouseout",this.hideEvent);this.content=this.options.txt;this.el.title="";this.el.descendants().each(function(C){if(Element.readAttribute(C,"alt")){C.alt=""}});Tooltip.setup()},setOptions:function(A){this.options={backgroundColor:"#fff",borderColor:"#ccc",textColor:"",textShadowColor:"",maxWidth:450,align:"left",delay:200,mouseFollow:true,opacity:0.95,appearDuration:0,hideDuration:0};Object.extend(this.options,A||{})},show:function(A){this.xCord=Event.pointerX(A);this.yCord=Event.pointerY(A);if(!this.initialized){this.timeout=window.setTimeout(this.appear.bind(this),this.options.delay)}},hide:function(A){if(this.initialized){if(this.appearingFX){this.appearingFX.cancel()}if(this.options.mouseFollow){Event.stopObserving(this.el,"mousemove",this.updateEvent)}if(typeof (Effect)!="undefined"){new Effect.Fade(this.tooltip,{duration:this.options.hideDuration,afterFinish:function(){Element.remove(this.tooltip)}.bind(this)})}else{this.tooltip.remove()}}this._clearTimeout(this.timeout);this.initialized=false},update:function(A){this.xCord=Event.pointerX(A);this.yCord=Event.pointerY(A);this.setup()},updateCoords:function(){this.xCord=Tooltip.xCord;this.yCord=Tooltip.yCord},checkNode:function(){if(!this.el){this.hide()}else{if(this.initialized){setTimeout(this.checkNode.bind(this),1000)}}},appear:function(){this.tooltip=new Element("div",{className:"tooltip",style:"display: none;"});var A=new Element("div",{className:"xtop"});A.appendChild(new Element("div",{className:"xb2",style:"background-color:"+this.options.backgroundColor+"; border-color:"+this.options.borderColor+";"}));A.appendChild(new Element("div",{className:"xb3",style:"background-color:"+this.options.backgroundColor+"; border-color:"+this.options.borderColor+";"}));A.appendChild(new Element("div",{className:"xb4",style:"background-color:"+this.options.backgroundColor+"; border-color:"+this.options.borderColor+";"}));var B=new Element("div",{className:"xboxcontent",style:"background-color:"+this.options.backgroundColor+"; border-color:"+this.options.borderColor+((this.options.textColor!="")?"; color:"+this.options.textColor:"")+((this.options.textShadowColor!="")?"; text-shadow:2px 2px 0"+this.options.textShadowColor+";":"")});var C=new Element("div",{className:"xbottom"});C.appendChild(new Element("div",{className:"xb4",style:"background-color:"+this.options.backgroundColor+"; border-color:"+this.options.borderColor+";"}));C.appendChild(new Element("div",{className:"xb3",style:"background-color:"+this.options.backgroundColor+"; border-color:"+this.options.borderColor+";"}));C.appendChild(new Element("div",{className:"xb2",style:"background-color:"+this.options.backgroundColor+"; border-color:"+this.options.borderColor+";"}));C.appendChild(new Element("div",{className:"xb1",style:"background-color:"+this.options.borderColor+";"}));this.tooltip.appendChild(A);this.tooltip.appendChild(B);this.tooltip.appendChild(C);this.tooltip.childNodes[1].innerHTML=this.content;document.body.insertBefore(this.tooltip,document.body.childNodes[0]);Element.extend(this.tooltip);this.options.width=this.tooltip.getWidth();this.tooltip.style.width=this.options.width+"px";this.setup();if(this.options.mouseFollow){Event.observe(this.el,"mousemove",this.updateEvent)}this.initialized=true;this.updateCoords();this.setup();if(typeof (Effect)!="undefined"){this.appearingFX=new Effect.Appear(this.tooltip,{duration:this.options.appearDuration,to:this.options.opacity})}else{this.tooltip.show()}this.checkNode()},setup:function(){if(this.options.width>this.options.maxWidth){this.options.width=this.options.maxWidth;this.tooltip.style.width=this.options.width+"px"}if(this.xCord+this.options.width>=Element.getWidth(document.body)){this.options.align="right";this.xCord=this.xCord-this.options.width+20}this.tooltip.style.left=this.xCord-7+"px";this.tooltip.style.top=this.yCord+22+"px"},_clearTimeout:function(A){clearTimeout(A);clearInterval(A);return null}};PBMenu=Class.create({initialize:function(A){var B={items:[]};Object.extend(B,A);this.options=B;this.items=new Array();this.create();this.enable();if(this.options.items){this.addItems(this.options.items)}this.onClickOpen=this.show.bind(this);this.onClickClose=this.off.bind(this);this.options.toggle.observe("click",this.onClickOpen)},toggle:function(A){if(A){A.stop();this.options.toggle.blur()}if(this.isOpen){this.hide()}else{this.show()}},create:function(){this.elm=new Element("div",{"class":"pbMenu"});this.listElm=new Element("ul");this.elm.appendChild(this.listElm);this.elm.appendChild(new Element("img",{src:"/layout/common/images/shadow.png",width:"100%"}));document.body.appendChild(this.elm)},disable:function(){this.isEnabled=false;this.elm.addClassName("disabled")},enable:function(){this.isEnabled=true;this.elm.removeClassName("disabled")},show:function(A){A.stop();A.element().blur();if(A.element().disabled){return }this.options.toggle.addClassName("active");if(this.isOpen||!this.isEnabled){return }var B=this.options.toggle.cumulativeOffset();if(Prototype.Browser.WebKit){B.left+=10;B.top+=40}B.top+=this.options.toggle.getHeight()-1;this.elm.setStyle({top:B.top+"px",left:(B.left-1)+"px",display:"block"});this.isOpen=true;this.notify("onOpen");this.options.toggle.stopObserving("click",this.onClickOpen).observe("click",this.onClickClose);document.observe("click",this.onClickClose)},off:function(A){A.stop();A.element().blur();this.hide()},hide:function(){this.timer=null;this.isOpen=false;this.elm.setStyle({display:"none"});this.notify("onClose");this.options.toggle.stopObserving("click",this.onClickClose).observe("click",this.onClickOpen).removeClassName("active");document.stopObserving("click",this.onClickClose)},addItems:function(A){A.each(function(B){this.add(new PBMenu.Item(this,B))}.bind(this))},add:function(A){this.items.push(A);this.listElm.appendChild(A.elm)},getItem:function(B){for(var A=0;A<this.items.length;A++){if(this.items[A].options.name==B){return this.items[A]}}},removeAll:function(){this.items.each(function(A){this.remove(A)}.bind(this))},remove:function(A){A.remove();this.items=this.items.without(A)}});Object.Event.extend(PBMenu);PBMenu.Item=Class.create({initialize:function(B,A){this.options=A;this.menu=B;this.elm=new Element("li").update(A.txt).observe("click",this.activate.bind(this)).addClassName(A.className);if(this.options.className){this.elm.className=this.options.className}(this.options.disabled)?this.disable():this.enable()},disable:function(){this.isDisabled=true;this.elm.addClassName("disabled")},enable:function(){this.isDisabled=false;this.elm.removeClassName("disabled")},activate:function(A){if(A){A.stop()}if(!this.isDisabled){this.menu.hide();this.notify("onClick")}},remove:function(){this.elm.parentNode.removeChild(this.elm)}});Object.Event.extend(PBMenu.Item);PBwiki.UserPrefs={set:function(B,A,D){var C={key:B};if(D){C.wikiname=D}new PBwiki.APIRequest("SetUserPref",C,{method:"post",parameters:{value:(typeof (A)=="object")?Object.toJSON(A):A}});if(PBinfo.GetUserPrefs){PBinfo.GetUserPrefs[B]=(typeof (A)=="object")?Object.clone(A):A}},get:function(A){if(!PBinfo.GetUserPrefs){return }return PBinfo.GetUserPrefs[A]},group_add:function(C,B,A){new PBwiki.APIRequest("GroupAddPref",{group:C},{onSuccess:A,method:"post",parameters:{value:B}})}};PBwiki.UserPrefs.Stars={get_starred_objects:function(A){if(PBinfo.GetUserPrefs&&PBinfo.GetUserPrefs.starred){A(PBinfo.GetUserPrefs.starred)}else{A([])}},is_current_page_starred:function(){return PBinfo.CurrentPage.starred},set_object_starred:function(A){new PBwiki.APIRequest("SetObjectStarred",{name:A.name,starred:A.starred},A);if(PBinfo.GetUserPrefs){if(!A.starred){PBinfo.GetUserPrefs.starred=PBinfo.GetUserPrefs.starred.without(A.name)}else{PBinfo.GetUserPrefs.starred.push(A.name)}}if(PBinfo.CurrentPage.page==A.name){PBinfo.CurrentPage.starred=A.starred}document.fire("data:objectStarred",A)}};var UserPrefs={};UserPrefs.Manager={initialize:function(){var A=$("expand-collapse-page-link");if(!A){return }if(PBwiki.UserPrefs.get(PBconst.kSideBarCollapsed)){this.setCollapsed(true)}A.observe("click",function(B){try{B.stop();B.element().blur()}catch(B){}try{this.setCollapsed(!this.isCollapsed());if(PBwiki.getUID()){PBwiki.UserPrefs.set(PBconst.kSideBarCollapsed,this.isCollapsed())}}catch(B){alert(B.message)}}.bind(this))},isCollapsed:function(){return(document.body.className.indexOf("fullwidth")!=-1)},setCollapsed:function(A){(A)?$(document.body).addClassName("fullwidth"):$(document.body).removeClassName("fullwidth");if(!$("top-content")){return }$(document.body).appendChild($("top-content").addClassName("abs"))},goFullWidth:function(){this.setCollapsed(true)},saveWidth:function(){this.savedWidth=this.isCollapsed();PBwiki.info("SAVE WIDTH = "+this.savedWidth)},restoreWidth:function(){PBwiki.info("RESTORE WIDTH = "+this.savedWidth);this.setCollapsed(this.savedWidth)}};PBwiki.init(UserPrefs.Manager.initialize.bind(UserPrefs.Manager));PBwiki.APIRequest=Class.create({initialize:function(A,B,D){this.m=A;this.args=B;this.options={_type:"jsontext",method:"post",incUsess:true,evalJS:false};Object.extend(this.options,D);if(this.options.incUsess){Object.extend(this.args,PBwiki.getSessCookie())}if(this.options.cacheability&&PBinfo.GetTimes){this.options.method="get";var E={};this.options.cacheability.each(function(F){if(PBinfo.GetTimes[F]){E[F]=PBinfo.GetTimes[F]}});Object.extend(B,E);B._bt=pbBuildTime}var C=PBwiki.APIRequest.callPreOp(A,this.args,this.options,this);if(C){return this.dispatchSuccess(C)}this.apiUrl=this.buildUri(A,this.args);this.reqOpts=Object.clone(this.options);Object.extend(this.reqOpts,{onSuccess:this.apiResponse.bind(this),onFailure:this.dispatchError.bind(this,"Sorry, your request has failed to reach the PBworks servers. Please reconnect and try again.",509),on504:this.dispatchError.bind(this,"Sorry, PBworks is experiencing slowness serving your request, Please try again or email support if the problem persists.",504),onException:this.dispatchError.bind(this,"Your internet connection is disconnected. Please reconnect and try again.",510)});this.doRequest()},unicodeConvert:function(B){var A={0:"",1:"000",2:"00",3:"0",4:""};return B.replace(/[\u0080-\uFFFF]/g,function(D){var E=D[0]||D;var C=Math.floor(E.charCodeAt()/16).toString(16)+(E.charCodeAt()%16).toString(16);return"\\u"+A[C.length].concat(C)})},doRequest:function(){this.setWaitCursor(true);this.apiRequest=new Ajax.Request(this.apiUrl,this.reqOpts)},setWaitCursor:function(B){if(this.options.waitCursor&&this.waitCursor!=B){try{this.waitCursor=B;(B)?$(document.body).addClassName("wait"):$(document.body).removeClassName("wait")}catch(A){}}},buildUri:function(A,B){B.op=A;return"/api_v2/?"+Object.toQueryString(B)},abortRequest:function(){this.setWaitCursor(false);try{this.apiRequest.transport.abort()}catch(A){}this.isAborted=true},dispatchError:function(B,A){this.setWaitCursor(false);if(this.options.onFailure){this.options.onFailure(B,A)}},apiResponse:function(A){var B=this.parseResponse(A.responseText);this.dispatchSuccess(B)},dispatchSuccess:function(B){this.setWaitCursor(false);if(B){this.handleResponse(this.m,B,this.args);try{if(this.options.onSuccess){this.options.onSuccess(B)}}catch(A){PBwiki.error(A);this.dispatchError((PBwiki.is_dev()?"Dev JS Exception: ":"Sorry, we encountered an error. ")+A.message,500)}}},parseResponse:function(A){var D=A.split("\n");if(D.length>2&&A.indexOf("/*-secure-")!=-1){if(this.options.raw){return D[1]}try{var C=(typeof (JSON)!="undefined")?JSON.parse(D[1]):D[1].evalJSON(true)}catch(B){this.dispatchError(this.getParseErrorMsg(A),511)}if(C.error_status){return this.dispatchError(C.error_string,C.error_status)}else{if(C.success===false){return this.dispatchError("Sorry, we encountered an error.",512)}}return C}else{this.dispatchError(this.getParseErrorMsg(A),511)}},getParseErrorMsg:function(A){if(PBwiki.is_dev()){var B=new RegExp("Dev-only error notice</h2><hr><h3>(.*?)</div>").exec(A.replace(/\n/g,""));if(B){return B[1].replace(/(<([^>]+)>)/ig," ").replace(/  /g," ")}else{return"Dev PHP Output: "+A.substr(0,150)}}else{return"Sorry, we encountered an error while processing your request. Please try again or email support if the problem persists. ("+this.m+" 511)"}},handleResponse:function(A,D,B){var C=PBwiki.APIRequest.lastClientTime=PBwiki.getTimestamp();if(this.options.raw){return }D._args=Object.clone(B);D._args.op=A;D._client_time=C;PBinfo[A]=D;if(D._perm_cache_times&&PBinfo.GetTimes){Object.extend(PBinfo.GetTimes,D._perm_cache_times||{});if(PBinfo[A]._args){Object.extend(PBinfo[A]._args,D._perm_cache_times||{})}PBinfo.GetTimes._client_time=C;if(!this.options.times){PBwiki.APIRequest.callPostOp("GetTimes",PBinfo.GetTimes)}}PBwiki.APIRequest.callPostOp(A,D)}});PBwiki.APIRequest.postOpCallbacks=new Array();PBwiki.APIRequest.observePostOp=function(B,A){if(!this.postOpCallbacks[B]){this.postOpCallbacks[B]=new Array()}this.postOpCallbacks[B].push(A)};PBwiki.APIRequest.callPostOp=function(B,A){if(!PBwiki.APIRequest.postOpCallbacks[B]){return }PBwiki.APIRequest.postOpCallbacks[B].each(function(C){C(A)})};PBwiki.APIRequest.preOpCallbacks=[];PBwiki.APIRequest.observePreOp=function(B,A){if(!this.preOpCallbacks[B]){this.preOpCallbacks[B]=new Array()}this.preOpCallbacks[B].push(A)};PBwiki.APIRequest.callPreOp=function(E,A,D,C){preOps=PBwiki.APIRequest.preOpCallbacks["*"].concat(PBwiki.APIRequest.preOpCallbacks[E]||[]);if(!preOps||preOps.length==0){return }var B=false;preOps.each(function(F){B=F(E,A,D,C);if(B){throw $break}});return B};PBwiki.APIRequest.DelegateFrameRequest=function(A){document.fire("frame:"+A.op,A)};PBwiki.MultiAPIRequest=Class.create(PBwiki.APIRequest,{initialize:function(D,C){this.reqOptions=new Array();this.options={times:true};Object.extend(this.options,C);var A={};if(this.options.incUsess){Object.extend(A,PBwiki.getSessCookie())}if(this.options.times){D.push(["GetTimes",{},{onSuccess:function(E){PBinfo.GetTimes=E},counted:false}])}for(var B=0;B<D.length;B++){if(D[B].length==3){this.reqOptions[B]=D[B].pop()}}this.r=D;this.apiUrl=this.buildUri("Multi",A);this.reqOpts=Object.clone(this.options);this.reqOpts=Object.extend(this.reqOpts,{method:"post",parameters:{calls:this.unicodeConvert(Object.toJSON(D))},onSuccess:this.onMulti.bind(this),onFailure:this.dispatchError.bind(this,"Sorry, your request has failed to reach the PBworks servers. Please reconnect and try again.",509),on504:this.dispatchError.bind(this,"Sorry, PBworks is experiencing slowness serving your requests, Please try again or email support if the problem persists.",504),onException:function(E,F){this.dispatchError.bind(this,F.message,510)}.bind(this)});this.setWaitCursor(true);this.apiRequest=new Ajax.Request(this.apiUrl,this.reqOpts)},onMulti:function(E){this.setWaitCursor(false);var H=false;var F=0;var D=0;var G=this.parseResponse(E.responseText);if(!G){return }var A=G.response;if(A&&A.length==this.reqOptions.length){for(var C=0;C<A.length;C++){H=!A[C].error_status&&A[C].success!==false;this.handleResponse(this.r[C][0],G.response[C],this.r[C][1]);if(this.reqOptions[C].counted!==false){D++;if(H){F++}}if(!H){if(A[C].error_string){this.lastError=A[C].error_string}else{this.lastError=this.r[C][0]+" failed unexpectedly."}}if(H&&this.reqOptions[C].onSuccess){if(this.reqOptions[C].onSuccess){this.reqOptions[C].onSuccess(A[C])}}else{if(!H&&this.reqOptions[C].onFailure){if(this.reqOptions[C].onFailure){this.reqOptions[C].onFailure(this.lastError,A[C].error_status)}}}}}if(this.options.onAllComplete){var B={responses:G.response,successful:F,total:D,lastError:(this.lastError||"")};this.options.onAllComplete(B)}}});PBwiki.Data={enabledLayers:["LocalCache","DOMObjectListNonVerbose"],initialize:function(){PBwiki.Data.Instances=[];PBwiki.Data.enabledLayers.each(function(A){PBwiki.Data.Instances.push(new PBwiki.Data.Layers[A])});PBwiki.info(PBwiki.Data.Instances)},check:function(A,B,D,C){var E=false;if(!PBwiki.Data.Instances){return }PBwiki.Data.Instances.each(function(F){E=F.check(A,B,D,C);if(E){throw $break}});return E},getInstance:function(B){var A=PBwiki.Data.enabledLayers.indexOf(B);return(A!=-1)?PBwiki.Data.Instances[A]:{hasData:function(){return false}}}};PBwiki.Data.HIGH_PRIORITY=1;PBwiki.Data.MED_PRIORITY=2;PBwiki.Data.LOW_PRIORITY=3;PBwiki.Data.NO_CACHE=4;PBwiki.APIRequest.observePreOp("*",PBwiki.Data.check);PBwiki.init(PBwiki.Data);PBwiki.Data.Layers={};PBwiki.Data.Layers.DOMStorageCache=Class.create({data:{},hasData:function(){if(!this.hasDOMStorage()&&!this.data){return }return !!this.getData(this.storageKey+"-times")},storeData:function(A,C){if(!this.hasDOMStorage()){return }if(window.location.protocol=="https:"){A+="-s"}this.data[A]=C;try{if(typeof (localStorage)!="undefined"){localStorage.setItem(A,C)}}catch(B){}try{if(typeof (globalStorage)!="undefined"){globalStorage[window.location.host].setItem(A,C)}}catch(B){}},checkKey:"PBStorageTest",checkStorage:function(){if(!this.hasDOMStorage()){return false}var A=Math.round(Math.random()*1000);this.storeData(this.checkKey,A);if(this.getData(this.checkKey)==A){try{localStorage.removeItem(this.checkKey)}catch(B){}try{globalStorage[window.location.host].removeItem(this.checkKey)}catch(B){}return true}},getData:function(A){if(!this.hasDOMStorage()){return }if(this.data[A]){return this.data[A]}if(window.location.protocol=="https:"){A+="-s"}try{if(typeof (localStorage)!="undefined"){return localStorage.getItem(A)}}catch(B){}try{if(typeof (globalStorage)!="undefined"){return globalStorage[location.host].getItem(A).value}}catch(B){}return false},hasDOMStorage:function(){return typeof (localStorage)!="undefined"||typeof (globalStorage)!="undefined"},check:function(A,B,D,C){if(!this.hasData()){return false}if(this.methods.indexOf(A)==-1){return false}if(!this.checkTimes()){return false}PBwiki.info("TIMES PASSED");return true},filter:function(A,D,I,B,J){A=A.objects;var H=A.length;if(D!="GetObjects"){I.type=(D=="GetPages")?"page":"file"}if(I.type||D!="GetObjects"||I.filter||typeof (I.folder)!="undefined"){var C=[];for(var G=0;G<A.length;G++){if(I.type&&A[G].type!=I.type){continue}if(I.filter&&A[G].name.toLowerCase().indexOf(I.filter.toLowerCase())===-1){continue}if(typeof (I.folder)!="undefined"&&I.folder!=A[G].folder&&!(I.folder==""&&!A[G].folder)){continue}C.push(A[G])}A=C;H=C.length}if(I.anchor){for(var G=0;G<A.length;G++){if(I.anchor==A[G].name){var F=G;var E=Math.floor(G/I.count);I.offset=E*I.count;break}}if(!F){I.offset=0}}if(I.sortby&&I.sortby!="name"){A=A.sort(function(L,K){return(L[I.sortby]<K[I.sortby])?-1:(L[I.sortby]>K[I.sortby])});delete this.list}if(I.reverse){A=A.reverse();delete this.list}if(I.count||I.offset){A=A.slice(I.offset,I.offset+I.count)}var C={_total_count:H,_args:I,_used_dom_storage:true};if(F){C._anchor=F;C._block=E}if(D=="GetObjects"){C.objects=A}else{if(D=="GetPages"){C.pages=A}else{if(D=="GetFiles"){C.files=A}}}return C},checkTimes:function(){var B=true;var A=this.getData(this.storageKey+"-times");if(!A){return }A=A.evalJSON();if(!A._perm_cache_times){return }this.cacheTimes.each(function(C){if(A._perm_cache_times[C]!=PBinfo.GetTimes[C]){B=false;throw $break}});if(A._uid!=PBwiki.getUID()){return }return B}});PBwiki.Data.Layers.DOMObjectListNonVerbose=Class.create(PBwiki.Data.Layers.DOMStorageCache,{fetchMethod:"GetObjects",methods:["GetObjects","GetPages","GetFiles"],cacheTimes:["page_list_time","filetime","permtime","foldertime"],storageKey:"objListNonVerbose_v2",check:function($super,A,B,D,C){if(B.verbose==false||B.detail!="partial"||D.priority==PBwiki.Data.NO_CACHE){return }var E=false;if($super(A,B,D,C)){if(!this.list){this.list=this.getData(this.storageKey).evalJSON()}E=this.filter(this.list,A,B,D,C)}if(!E){this.checkFetch(A,B,D)}return E},checkFetch:function(A,C,E){if(this.isFetching){return }var D=E.priority||PBwiki.Data.MED_PRIORITY;var B=PBinfo.CurrentWiki.pagecount+PBinfo.CurrentWiki.filecount>1000;if(!this.hasDOMStorage()){if(!D==PBwiki.Data.HIGH_PRIORITY&&!B){return }}if(D==PBwiki.Data.LOW_PRIORITY||B&&D<PBwiki.Data.HIGH_PRIORITY){return }if(!this.checkStorage()){return }if(this.timeout){clearTimeout(this.timeout)}this.timeout=setTimeout(this.doRequest.bind(this),300)},doRequest:function(){if(this.isFetching){return }PBwiki.info("DO DATA REQUEST!");this.isFetching=true;new PBwiki.APIRequest(this.fetchMethod,{verbose:true,detail:"partial",sortby:"name"},{onSuccess:function(A){this.storeData(this.storageKey,A);this.storeData(this.storageKey+"-times",Object.toJSON({_perm_cache_times:Object.clone(PBinfo.GetTimes),_uid:PBwiki.getUID()}));PBwiki.info("STORE DATA REQUEST");document.fire("data:nonVerboseListLoaded");this.isFetching=false}.bind(this),method:"get",priority:PBwiki.Data.NO_CACHE,cacheability:this.cacheTimes,raw:true})}});PBwiki.Data.Layers.DOMObjectListVerbose=Class.create(PBwiki.Data.Layers.DOMStorageCache,{methods:["GetObjects","GetPages","GetFiles"],cacheTimes:["pagetime","filetime","permtime","foldertime"],storageKey:"objListVerbose",check:function($super,A,B,D,C){if(B.verbose===false||B.detail=="partial"||B.priority==PBwiki.Data.NO_CACHE){return }var E=$super(A,B,D,C);if(E){E=this.filter(E,A,B,D,C)}if(!E&&this.methods.indexOf(A)!=-1){this.checkFetch()}return E},checkFetch:function(){PBwiki.info("VERBOSE CHECK FETCH");if(this.isFetching){return }if(!this.hasDOMStorage()){return }if(this.timeout){clearTimeout(this.timeout)}this.timeout=setTimeout(function(){this.doRequest()}.bind(this),500)},doRequest:function(){if(this.isFetching){return }PBwiki.info("DO VERBOSE REQUEST!");this.isFetching=true;new PBwiki.APIRequest("GetObjects",{},{method:"get",onSuccess:function(A){A._perm_cache_times=Object.clone(PBinfo.GetTimes);A._uid=PBwiki.getUID();PBwiki.info("GET VERBOSE OBJECT LIST");this.storeData(A);this.isFetching=false}.bind(this),method:"get",cacheability:this.cacheTimes,priority:PBwiki.Data.NO_CACHE})}});PBwiki.Data.Layers.LocalCache=Class.create({check:function(F,D,E){if(E.cacheability&&PBinfo.GetTimes){var C=E.key||F;if(!PBinfo[C]){return }var A=Object.clone(D);var B=$H(Object.clone(PBinfo[C]._args));E.cacheability.each(function(G){A[G]=parseInt(PBinfo.GetTimes[G])});A.op=F;A=$H(A);if(Object.toJSON(A.keys().sort())!=Object.toJSON(B.keys().sort())){PBwiki.info("local cache key mismatch");PBwiki.info(Object.toJSON(A.keys().sort()));PBwiki.info(Object.toJSON(B.keys().sort()));return false}PBwiki.info("local cache keys match");if(Object.toJSON(A.values().sort())!=Object.toJSON(B.values().sort())){PBwiki.info("local cache values mismatch");PBwiki.info(Object.toJSON(A.values().sort()));PBwiki.info(Object.toJSON(B.values().sort()));return false}return PBinfo[C]}return false}});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){alert(B.message+" "+B.lineNumber)}},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;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 }else{if(E._total_count!=this.options.count){this.options.count=E._total_count}}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)},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.totalHeight=A*this.options.height;this.container.setStyle({position:"relative",height:this.totalHeight+"px"});this.doScrollLoading=PBwiki.Data.getInstance("DOMObjectListNonVerbose").hasData();this.notify("onLoaded");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")},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.info(Sortable.sequence("sidebarModules"));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)}};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};$(document.body).setStyle({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;$(document.body).setStyle({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(A,C){if(!A||A==""){return PBinfo.GetFolders["unfiled_"+C+"count"]}var B=PBinfo.GetFolders.folders.find(function(D){return D.name==A});return(B)?B[C+"count"]:0},getModuleHeight:function(){return(this.options.ysize||PBconst.kFoldersDefaultHeight)},refresh:function(){if(this.view){this.view.refresh()}else{if(PBinfo.CurrentPage.folder){new PBwiki.APIRequest("GetFolders",{verbose:true},{incUsess:true,cacheability:["foldertime","filetime","page_list_time","permtime"],onSuccess:function(){this.selectView("PageView",{slide:false,folder:PBinfo.CurrentPage.folder});this.setupNavigatorResize()}.bind(this)});return }else{this.selectView("FolderView",{slide:false})}}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(B){this.heading=new Element("div",{"class":"heading"});var A=(B.length>28)?B.toString().substring(0,28).escapeHTML()+"&hellip;":B.toString().escapeHTML();this.folderTitle=new Element("a",{"class":(B=="")?"iconbutton unfiled":"iconbutton folder",href:Util.getFolderLink(B)}).update(A||"Unfiled Items");this.backButton=new Element("span",{"class":"folder_back"}).observe("click",this.mb.selectView.bind(this.mb,"FolderView",{folder:false,slide:true,reverse:true}));this.heading.appendChild(this.backButton);this.heading.appendChild(this.folderTitle);this.newContent.insertBefore(this.heading,this.newContent.firstChild)},createTabs:function(D,B){this.tabs=new Element("div",{"class":"tabs"});var C=new Element("a").addClassName("filter_link").update("Pages").observe("click",this.selectTab.bindAsEventListener(this,"PageView",{slide:true}));var A=new Element("a").addClassName("filter_link").update((this.mb.getFolderObjectCount(this.param.folder,"file")==0)?"No Files":"Files").observe("click",this.selectTab.bindAsEventListener(this,"FileView",{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(D,B){if(this.type=="folder"){D.observe("click",this.folderLink.bind(this,B));D.appendChild(new Element("a",{href:"javascript:void(0);","class":"iconbutton folder"}).update(B.name.toString().escapeHTML()))}else{if(this.type=="page"){var C=new Element("a",{href:"/"+Util.dashified_link(B.name.toString())}).update(B.name.toString().escapeHTML());D.appendChild(C);if(PBinfo.CurrentPage.page==B.name){C.setStyle({fontWeight:"bold"})}if(this.starredPages&&this.starredPages.indexOf(B.name)!==-1){D.addClassName("starred")}}else{if(this.type=="file"){var A=Util.iconMap[Util.getFileExtension(B.name.toString())];D.appendChild(new Element("a",{href:encodeURI("/f/"+B.name)}).addClassName("iconbutton").addClassName(A).update(B.name.toString().escapeHTML()));Util.addObjectTooltip(D,B)}}}return D},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.requestOpts,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(B,A){B.stop();this.mb.selectView.bind(this.mb,A,{folder:this.param.folder,slide:false})()},getRequestOpts:function(){return this.requestOpts}});PBwiki.SideBar.FoldersItem.FolderView=Class.create(PBwiki.SideBar.FoldersItem.ObjectView,{apiMethod:"GetFolders",requestOpts:{verbose:true},cacheTimes:["foldertime","filetime","page_list_time","permtime"],type:"folder",folderLink:function(A){this.mb.selectView.bind(this.mb,"PageView",{folder:A.name,count:A.count,slide:true})()},starredLink:function(){this.mb.selectView.bind(this.mb,"StarredView",{slide:true})()},refresh:function($super){$super();this.loadingMsg=new Element("div",{"class":"loading"}).update("Loading&hellip;");this.newList.appendChild(this.loadingMsg);new PBwiki.APIRequest(this.apiMethod,this.getRequestOpts(),{onSuccess:this.update.bind(this),cacheability:this.cacheTimes});return this},update:function($super,B){this.loadingMsg.remove();if(PBwiki.getUID()){var C=new Element("div",{"class":"mbfolder"}).observe("click",this.starredLink.bind(this,{name:""}));C.appendChild(new Element("a",{href:"javascript:void(0);","class":"iconbutton starred"}).update("Starred Pages"));this.newList.appendChild(C)}B.folders.each(function(D){var E=new Element("div",{"class":"mbfolder"});this.renderObjectRow(E,D);this.newList.appendChild(E)},this);var A=new Element("div",{"class":"mbfolder"}).observe("click",this.folderLink.bind(this,{name:"",count:B.unfiled_count}));A.appendChild(new Element("a",{href:"javascript:void(0);","class":"iconbutton unfiled"}).update("Unfiled Items"));this.newList.appendChild(A);this.newList.childElements().each(function(D,E){if(E%2==1){D.addClassName("alternate")}});if(PBwiki.getUID()){this.tabs=new Element("div",{"class":"tabs"}).update('<a href="/browse/#view=ViewAllPages" class="folder_properties"><span></span>edit folders</a>');this.setHeight();this.newContent.appendChild(this.tabs)}else{this.setHeight()}this.onLoaded()}});PBwiki.SideBar.FoldersItem.PageView=Class.create(PBwiki.SideBar.FoldersItem.ObjectView,{apiMethod:"GetPages",requestOpts:{verbose:true,detail:"partial",sortby:"name"},cacheTimes:["page_list_time","foldertime","permtime"],type:"page",refresh:function($super,A){$super();this.createFolderHeading(this.param.folder);PBwiki.UserPrefs.Stars.get_starred_objects(function(B){this.starredPages=B}.bind(this));this.newContent.appendChild(this.newList);this.createTabs("pages");this.setupScrollableArea();this.setHeight();return this},getObjectCount:function(){return this.mb.getFolderObjectCount(this.param.folder,"page")},getRequestOpts:function(){this.requestOpts.folder=this.param.folder;return this.requestOpts}});PBwiki.SideBar.FoldersItem.FileView=Class.create(PBwiki.SideBar.FoldersItem.ObjectView,{apiMethod:"GetFiles",requestOpts:{verbose:true,detail:"partial",sortby:"name"},cacheTimes:["filetime","foldertime","permtime"],type:"file",refresh:function($super,A){$super();this.createFolderHeading(this.param.folder);this.createTabs("files");this.setupScrollableArea();this.setHeight();return this},getObjectCount:function(){return this.mb.getFolderObjectCount(this.param.folder,"file")},getRequestOpts:function(){return Object.extend(this.requestOpts,{folder:this.param.folder})}});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"}).observe("click",this.mb.selectView.bind(this.mb,"FolderView",{folder:false,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.incrementNewRecentActivityCount()}},incrementNewRecentActivityCount:function(){this.setNewRecentActivityCount(this.getNewRecentActivityCount()+1)},setNewRecentActivityCount:function(A){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)}},getNewRecentActivityCount:function(){var A=$("new-recent-activity-count");var B=A.innerText?A.innerText:A.textContent;B=Number(B);if(isNaN(B)){B=0}return B},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(E){$("new-recent-activity").hide();$("new-recent-activity-count").update("0");var A="";var D=new Template(this.row);var C=new Template(this.rowUserUpdate);var B=0;this.changes=E.changes;E.changes.each(function(G){try{if(G.type=="userupdate"){G.icon="pageicon";G.updateMessage=G.data.escapeHTML();G.userClass="user";G.userLink=Util.authorLinkFromObject(G);A+=C.evaluate(G)}else{G.icon=this.changeOpIcons[G.op_word]||"pageicon";if(G.type=="folder"){G.icon="foldericon"}G.escapedName=G.title.toString().escapeHTML();G.userClass="user";G.userLink=Util.authorLinkFromObject(G);A+=D.evaluate(G)}}catch(F){PBwiki.error(F)}B++;if(B==this.getNumberChanges()){throw $break}}.bind(this));if(E.changes.length==0){this.showNoChanges()}else{this.content.update(new Template(this.template).evaluate({changeItems:A}))}Tooltips.addLinkTooltips(this.content);this.currentChanges=this.content.down("ul");this.content.setStyle({height:""});this.currentHeight=this.content.getHeight()-(parseInt(this.content.getStyle("paddingTop"))*2)-this.content.down("a").getHeight();this.clearModuleResize();this.setupModuleResize({onStart:function(){this.currentChanges.setStyle({position:"relative",overflow:"hidden",marginBottom:"5px"})}.bind(this),onSize:function(F){this.currentChanges.setStyle({height:(this.currentHeight+F)+"px"})}.bind(this),onFinish:function(F){this.options.numChanges=Math.round((this.currentHeight+F)/52);if(this.options.numChanges>PBconst.kRecentChangesMax){this.options.numChanges=PBconst.kRecentChangesMax}this.content.setStyle({height:(this.options.numChanges*52)+this.content.down("a").getHeight()+"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("");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("ui: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)}});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||500;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")}}}},map:{},initialize:function(){this.addShortCut("¿",this.functions.searchfocus);this.addShortCut("e",this.functions.edit)},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;PBwiki.info("initializing EditPage code");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(){PBwiki.info("autosave trigger");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){PBwiki.info("NO CHANGES TO SAVE");this.refresh();return }if(this.useDrafts){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};PBwiki.info("SEND DELTA");PBwiki.info(Object.toJSON(E))}else{PBwiki.info("SEND RAW HTML");PBwiki.info(D);E.parameters={html:D}}this.apiRequest=new PBwiki.APIRequest(F,C,E)},draftFailure:function(B,A){if(A===600){PBwiki.info("DELTA FAILURE");PBwiki.info(B);this.saveToDraft(Page.EditPage.getEditor().GetHTML(),true);return }else{PBwiki.info("DRAFT FAILURE");PBwiki.info(B)}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;PBwiki.info("DRAFT SAVED");PBwiki.info(Object.toJSON(B.draft))}if(!B.lockinfo.hasLock){alert(((B.lockinfo.editname)?B.lockinfo.editname:"Somebody")+" has stolen your lock on this page.  You will no longer be able to save changes.");this.stop()}else{PBwiki.info("has lock");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("%i:%M%p");B+=" ("+((A==0)?"less than a ":A);B+=" minute"+((A>1)?"s":"")+" ago)";$("autosave_msg").innerHTML=B;PBwiki.info(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)}},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)},initStar:function(){if(!$("pb-page-star")){return }this.starred=$("pb-page-star").hasClassName("starred");Event.observe("pb-page-star","click",function(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)})}.bind(this));document.observe("data:objectStarred",function(A){if(A.memo){this.starred=A.memo.starred;this.updateVisualState()}}.bind(this))},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"}))})});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)}.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)},update:function(){$("page-history-ago").update(Util.time_ago(PBwiki.getTimestamp()-PBinfo.GetPage.mtime-PBwiki.timeOffset)+" ago")}});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);SecurityInteraction={cellTemplates:["#{username}",'<input type="hidden" name="uid[]" value="#{uid}"/><select name="role[]"><option value="read">Reader</option><option value="write">Writer</option><option value="edit">Editor</option></select>','<a class="iconbutton deleteicon" href="#" onclick="SecurityInteraction.removeRow(this); return false;">&nbsp;</a>'],addUser:function(A){if(A){A.role=A.role||"read";A.username=A.username.toString().escapeHTML();window.obj=A;var B=SecurityInteraction.table.tBodies.item(0).insertRow(-1);SecurityInteraction.cellTemplates.each(function(C){B.insertCell(-1).innerHTML=C.interpolate(A)});$A(B.getElementsByTagName("select")[0].options).find(function(C){return C.value==A.role}).selected=true;SecurityInteraction.updateRows()}else{}},addUserEvent:function(D){var A=SecurityInteraction.userSelector;var B={uid:A.getValue(),username:A.options[A.selectedIndex].text,role:"read"};var C=SecurityInteraction.table.getElementsBySelector("input[value="+B.uid+"]");if(C.size()!=0){if(!C[0].next("select").value||C[0].next("select").value=="remove"){C[0].up("tr").remove()}else{alert(B.username+" is already in the table");return }}SecurityInteraction.addUser(B)},addTheseUsers:function(A){A.each(SecurityInteraction.addUser)},removeRow:function(C){SecurityInteraction.table.tBodies.item(1).appendChild(C.parentNode.parentNode);var B=$(C.parentNode.parentNode);var A=B.getElementsBySelector("select")[0];A.innerHTML='<option value="remove" selected="selected">remove</option>';SecurityInteraction.updateRows()},updateRows:function(){var A=$A(SecurityInteraction.table.tBodies.item(0).rows);A.each(function(C,B){C.className=(B%2?"even":"odd")})},hideCustomSecurity:function(){SecurityInteraction.customTable.style.display="none"},showCustomSecurity:function(){SecurityInteraction.customTable.style.display=""}};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){PBwiki.info("PBwiki.Settings.Security: error settings up radio buttons and labels: "+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))},linkOnclick:function(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.each(function(B){this.selector.options[this.selector.options.length]=new Option(B.name,B.name);if(B.name==PBinfo.CurrentPage.folder){this.selector.selectedIndex=this.selector.options.length-1}},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")}},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("ui: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("ui: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)}});var InputText=Class.create({initialize:function(B){this.element=$(B);try{this.placeholder=this.element.getAttribute("ui:placeholder");if(this.placeholder){this.placeholder=this.placeholder.strip()}if(this.placeholder&&!this.placeholder.empty()){this.element.observe("focus",this.onFocus.bind(this));this.element.observe("blur",this.onBlur.bind(this));this.element.observe("keypress",function(C){if(C.keyCode==Event.KEY_ESC){this.element.blur()}}.bind(this))}if(this.element.value.empty()||this.element.value==this.placeholder){this.setElementToEmptyStyle()}this.element.observe("ui:clearfield",this.onBlur.bind(this))}catch(A){throw new UIException("InputText: error "+A.getMessage(),this.element,A)}},setElementToEmptyStyle:function(){this.placeholder=this.element.getAttribute("ui:placeholder");if(this.placeholder){this.placeholder=this.placeholder.strip();this.element.setStyle({color:"#999"});this.element.value=this.placeholder}else{this.element.value=""}this.isEmpty=true},onFocus:function(A){this.element.setStyle({color:"#000"});if(this.isEmpty){this.element.value=""}},onBlur:function(){if(this.element.value.empty()||this.placeholder==this.element.value){this.setElementToEmptyStyle()}else{this.isEmpty=false}}});InputText.initialize=function(){InputText.selector=".inputtext";try{$$(InputText.selector).each(function(B){new InputText(B)})}catch(A){PBwiki.warn(A)}};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()})}};EllipsesManager={selector:".ellipses",initialize:function(){if(Prototype.Browser.Gecko||Util.IE6){EllipsesManager.redrawLines();Event.observe(window,"resize",EllipsesManager.redrawLines)}},redrawLines:function(){var A=$$(EllipsesManager.selector);function B(){A.each(EllipsesManager.singleLine)}B()},singleLine:function(A){var E=A.getAttribute("ui:text")||A.innerHTML;A.setAttribute("ui:text",E);A.innerHTML=E;var D={initialText:E,maxwidth:A.clientWidth,scrollWidth:A.scrollWidth,element:A};if(Util.IE6){D.maxwidth=A.offsetWidth}A.title=D.initialText;if(D.scrollWidth>D.maxwidth){var C=D.initialText.length;D.estimatedLength=Math.floor(C*0.95*(D.maxwidth/D.scrollWidth));var B=D.initialText.substr(0,D.estimatedLength)+"&hellip;";A.innerHTML=B;D.scrollWidth=A.scrollWidth;if(D.scrollWidth>D.maxwidth){EllipsesManager.parseBackward(D)}else{EllipsesManager.parseForward(D)}}},parseForward:function(D){var C=D.initialText.length;for(var A=D.estimatedLength+1;A<C;A++){var B=D.initialText.substr(0,A)+"&hellip;";D.element.innerHTML=B;if(D.element.scrollWidth>D.maxwidth){if(D.initialText[A-2]==" "){A--}D.element.innerHTML=D.initialText.substr(0,A-1)+"&hellip;";return }}},parseBackward:function(D){var C=D.initialText.length;for(var A=D.estimatedLength-1;A>0;A--){var B=D.initialText.substr(0,A)+"&hellip;";D.element.innerHTML=B;if(D.element.scrollWidth<=D.maxwidth){if(D.initialText[A-1]==" "){A--}D.element.innerHTML=D.initialText.substr(0,A)+"&hellip;";return }}}};PBwiki.init(EllipsesManager);PBwiki.init(InputText);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 A=FCKeditorAPI.GetInstance("content");A.InsertHtml('<img src="'+B+'" />');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));PBwiki.Components=PBwiki.Components||{};PBwiki.Components.Bubble=Class.create({initialize:function(A){this.options=A||{};if(this.showUserPref&&!PBwiki.UserPrefs.get(this.showUserPref)){return }if(this.bubbleID&&$(this.bubbleID)){return }this.options.className="bubble"+(this.options.className?" "+this.options.className:"");if(!this.hideFunction){this.hideFunction=this.hide}this.hideFunctionBound=this.hideFunction.bindAsEventListener(this);this.setUp()},getCoordinates:function(){return this.anchor.cumulativeOffset()},setUp:function(){this.show()},create:function(){if(this.anchorToID){this.anchor=$(this.anchorToID)}this.bubble=new Element("div",{"class":this.options.className,id:this.bubbleID});this.bubble.update('<div class="'+(this.arrowDirection=="left"?"bubble-arrow":"bubble-arrow-right")+'"></div>    <a class="close" href="#"></a>    <table cellspacing="0"><tr class="header"><td class="left"></td><td class="right"></td></tr><tr class="content"><td class="left"></td><td class="right">      <div class="inner-content">'+this.getContent()+"</div>    </td></tr></table>");document.body.appendChild(this.bubble);this.bubble.getElementsBySelector("a.close")[0].observe("click",this.hideFunctionBound);if(this.hideCheckbox){$(this.hideCheckbox).observe("change",function(A){A.stop();this.hide();PBwiki.UserPrefs.set(this.showUserPref,false,"my")}.bind(this))}},getContent:function(){},hide:function(A){if(!this.bubble){return }document.stopObserving("click",this.hideFunction);document.stopObserving("ui:hideBubbles",this.hideFunction);this.hideFunction=false;window.setTimeout(function(){this.bubble.hide()}.bind(this),250)},reposition:function(){var A=this.getCoordinates();if(this.arrowDirection=="right"){A.left-=this.bubble.getWidth()+10}else{A.left+=this.anchor.getWidth()}A.top-=(this.bubble.getHeight()/2)-(this.anchor.getHeight()/2);this.bubble.setStyle({top:A.top+"px",left:A.left+"px"})},show:function(A){this.create();document.observe("click",this.hideFunctionBound);document.observe("ui:hideBubbles",this.hideFunctionBound);this.bubble.show();this.reposition();PBwiki.Components.Bubble.showingBubble=true}});PBwiki.Components.StarBubble=Class.create(PBwiki.Components.Bubble,{showUserPref:PBconst.kShowStarBubblePrefsKey,arrowDirection:"left",hideCheckbox:"dont_prompt_to_save_pages",anchorToID:"pb-page-star",setUp:function(){document.observe("ui:onCurrentPageSaved",function(A){if(!PBwiki.Components.Bubble.showingBubble){this.show()}}.bind(this))},getContent:function(){return'<div class="top">          Click the star to mark this page as starred        </div>        <p>You can choose to only receive email notifications of pages<br />        that are starred. <a href="/user/'+PBinfo.CheckPermissions.uid+'#preferences">Change your preferences here</a>.</p>        <label for="dont_prompt_to_save_pages"><input type="checkbox" id="dont_prompt_to_save_pages" /> Don\'t show this message again</label>'}});PBwiki.Components.SendALinkBubble=Class.create(PBwiki.Components.Bubble,{showUserPref:PBconst.kShowSendALinkBubblePrefsKey,arrowDirection:"right",hideCheckbox:"dont_prompt_send_a_link",anchorToID:"sendalink",bubbleID:"send-a-link-bubble",setUp:function(){document.observe("ui:onCurrentPageSaved",function(){if(!PBwiki.Components.Bubble.showingBubble){this.show()}}.bind(this))},getContent:function(){return'<div class="top">        Let others know about this page        </div>        <p>Send a link to other users to let them know about<br/>your changes or to get feedback.</p>        <label for="dont_prompt_send_a_link"><input type="checkbox" id="dont_prompt_send_a_link" /> Don\'t show this tip again.</label>'}});PBwiki.Components.ImportFeedbackBubble=Class.create(PBwiki.Components.Bubble,{arrowDirection:"left",anchorToID:"import-feedback-no",bubbleID:"import-feedback-bubble",getContent:function(){var A=Prototype.Browser.IE?90:100;return'<div class="top">          Tell us what\'s wrong:        </div>        <form action="/report.php" target="import-feedback-frame" method="POST">          <input type="hidden" name="convert_id" value="'+this.options.convertID+'" />          <textarea id="import-feedback-text" name="import-feedback" style="width: '+A+'%;"></textarea>          <input type="submit" id="import-feedback-submit" value="Send feedback" />        </form>        <iframe id="import-feedback-frame" name="import-feedback-frame" style="display:none;"></iframe>'},create:function($super){$super();$("import-feedback-submit").observe("click",function(A){this.hide();$("import-feedback").update('<div class="content">Thanks for your feedback.</div>')}.bind(this),true)},show:function($super){$super();$("import-feedback-text").focus()}});PBwiki.Components.UserCard=Class.create(PBwiki.Components.Bubble,{arrowDirection:"left",bubbleID:"user_card_1",getContent:function(){return this.loadingHtml},getUserCardContent:function(){var A=new Template(this.html);this.apiResponse.mailto="mailto:"+encodeURIComponent(this.apiResponse.email);this.apiResponse.domain=(PBinfo.CurrentNetwork?PBinfo.CurrentNetwork.url:"/");if(!this.apiResponse.role){this.bubble.addClassName("norole")}["name","company","title","phone_mobile","phone_work"].each(function(C){if(this.apiResponse[C]){this.apiResponse[C]=this.apiResponse[C].escapeHTML()}}.bind(this));this.apiResponse.im_links="";["im_aim","im_icq","im_msn","im_skype","im_yim"].each(function(D,C){if(this.apiResponse[D]){if(C==3){this.apiResponse.im_links+='</p><p class="row clearfix" style="margin-top: 2px">'}this.apiResponse.im_links+=PBwiki.Components.IMIconGenerator.getIconLink(this.apiResponse[D],D,this.apiResponse.uid)}}.bind(this));if(this.apiResponse.im_links.length==0){this.apiResponse.im_links="<em>No IM clients</em>"}if(this.apiResponse.phone_work){this.apiResponse.phone=this.apiResponse.phone_work+" <strong>WORK</strong>"}else{if(this.apiResponse.phone_mobile){this.apiResponse.phone=this.apiResponse.phone_mobile+" <strong>MOBILE</strong>"}else{this.apiResponse.phone="<em>No phone number</em>"}}if(!this.apiResponse.title||this.apiResponse.title.length<1){this.apiResponse.title="<em>No title</em>"}if(!this.apiResponse.image||this.apiResponse.image.length<1){this.apiResponse.image="/uimg/bread.png"}this.apiResponse.followClass=(this.isFollowing?"unfollowuser":"followuser");this.apiResponse.followText=(this.isFollowing?"Unfollow":"Follow user");this.apiResponse.isthisyouclass=(this.isSelf?"thisisyou":"");if(PBinfo.CheckPermissions.isGuest){this.bubble.addClassName("isguest")}try{this.apiResponse.status={data:this.statusUpdate.data.escapeHTML(),timestamp:Util.time_ago(PBwiki.getTimestamp()-this.statusUpdate.time)+" ago"}}catch(B){this.bubble.addClassName("nostatus")}return A.evaluate(this.apiResponse)},setupStatusReply:function(){var C=this.bubble.down("a.reply");var B=this.bubble.down("a.cancel");var A=(function(D){D.stop();this.bubble.toggleClassName("showstatusreply");this.bubble.down("textarea").focus()}).bind(this);C.observe("click",A);B.observe("click",A)},confirmCloseBubble:function(){return(this.bubble.hasClassName("showstatusreply")&&this.bubble.down("textarea").value.strip().length>0&&!confirm("Are you sure you wish to cancel your reply?"))},hideFunction:function(B){var A=B.findElement("a");if(!this.bubble||(A&&!A.hasClassName("close"))){return }B.stop();this.hideBubble()},hideBubble:function(){document.stopObserving("click",this.hideFunctionBound);document.stopObserving("ui:hideBubbles",this.hideFunctionBound);if(this.options.uid!=PBinfo.CheckPermissions.uid){this.bubble.stopObserving("usercard:togglefollow",this.toggleFollowingBound)}if(this.changedFollowed){document.fire("ui:refreshactivity")}this.bubble.innerHTML="";this.bubble.remove()},getCoordinates:function(){return{left:this.options.event.pageX,top:this.options.event.pageY}},reposition:function(){var A=this.getCoordinates();var C=document.body.cumulativeScrollOffset().top;A.top-=this.bubble.getHeight()/2;A.top=Math.min(C+document.body.clientHeight-this.bubble.getHeight(),A.top);A.top=Math.max(0,A.top);var B=Math.min(document.documentElement.clientWidth-430,A.left);if(B<A.left){A.left-=this.bubble.getWidth()}A.left=Math.max(0,A.left);this.bubble.setStyle({top:A.top+"px",left:A.left+"px"})},setUp:function(){this.show();var A=new Array();A.push(["GetUserInfo",{uid:this.options.uid},{onSuccess:function(C){this.apiResponse=C}.bind(this)}],["GetLastUpdate",{uid:this.options.uid},{onSuccess:function(C){this.statusUpdate=C.update}.bind(this)}]);if(this.options.uid!=PBinfo.CheckPermissions.uid){A.push(["GetFollowedUsers",{},{onSuccess:function(C){this.isFollowing=C.users.include(this.options.uid)}.bind(this)}])}else{this.isSelf=true}var B=new PBwiki.MultiAPIRequest(A,{onAllComplete:this.showUserCard.bind(this)})},toggleFollowing:function(D){D.stop();this.toggleFollowBtn=D.element();this.toggleFollowBtn.blur();if(this.toggleFollowBtn.down().hasClassName("success")){return }var A=this.toggleFollowBtn.down().hasClassName("followuser");var C=this.followPrefix=(A?"F":"Unf");var E=C+"ollowUser";var B=new PBwiki.APIRequest(E,{user_id:this.options.uid},{onSuccess:function(){var F=(this.toggleFollowBtn.down().hasClassName("followuser")?"unfollowuser":"followuser");this.toggleFollowBtn.innerHTML="<span class='iconbutton "+F+" success'><strong>"+this.followPrefix+"ollowed!</strong></span>";this.toggleFollowBtn.addClassName("disabled");this.changedFollowed=true;(function(){this.toggleFollowBtn.down().removeClassName("success").down().innerHTML=(this.followPrefix=="F"?"Unfollow":"Follow user");this.toggleFollowBtn.removeClassName("disabled")}.bind(this)).delay(3)}.bind(this)})},showUserCard:function(){if(this.options.uid!=PBinfo.CheckPermissions.uid){this.toggleFollowingBound=this.toggleFollowing.bind(this);this.bubble.observe("usercard:togglefollow",this.toggleFollowingBound)}this.bubble.removeClassName("usercard-loading");this.bubble.down(".loading").parentNode.innerHTML=this.getUserCardContent();this.reposition();this.setupStatusReply()},loadingHtml:'<div class="loading"><div>LOADING</div></div>',html:'<div class="profile-summary clearfix outerpad">        <div class="button-bar secondarypagetoolbar #{isthisyouclass}">          <a href="#" class="button" id="__usercard_toggle_follow" onclick="this.fire(\'usercard:togglefollow\'); return false;"><span class="iconbutton #{followClass}"><strong>#{followText}</strong></span></a>        </div>              <div class="pic"><a href="#{domain}n/user-profile?uid=#{uid}"><img height="48" width="48" alt="" src="#{image}"/></a></div>        <h3 class="#{isthisyouclass}">#{name} <span class="you"> </span></h3><h4>#{title}</h4>      </div>            <div class="profile-status">        <p>#{status.data}<span>#{status.timestamp}<span class="replyspan" style="display:none">&ndash; <a href="" class="reply">reply</a></span></span></p>        <div class="status-reply">          <textarea class="text"></textarea>          <div class="button-row"><input type="button" value="Post your reply" class="button primarybutton"/> <span>or <a href="" class="cancel">back to profile</a></span></div>        </div>      </div>            <div class="profile-info clearfix">        <div class="cell">          <h5>EMAIL</h5>          <p class="row"><a href="#{mailto}" class="email">#{email}</a></p>          <p class="row">&nbsp;</p>          <h5>PHONE</h5>          <p class="row phone">#{phone}</p>        </div>        <div class="cell right">          <h5>IM PRESENCE</h5>          <p class="row clearfix">#{im_links}</p>          <p class="row">&nbsp;</p>          <h5 class="role">WORKSPACE ROLE</h5>          <p class="row role">#{role} &ndash; <a class="activity" href="">activity on workspace</a></p>        </div>      </div>      <div class="profile-link button-bar clearfix secondarypagetoolbar">        <a href="#{domain}n/user-profile?uid=#{uid}" class="button"><span><strong>View profile</strong></span></a>    </div>'});PBwiki.Components.IMIconGenerator={templateStrings:{im_aim:'<a href="aim:goim?screenname=#{username}" class="presence aim" title="Chat with #{username} on AIM"><img src="#{domain}n/im-presence?screenname=#{username}&client=#{client}" alt="" hspace="3" vspace="3" height="16" width="16"/></a>',im_msn:'<a href="msnim:chat?contact=#{username}" class="presence msn" title="Chat with #{username} on MSN Messenger"><img src="#{domain}n/im-presence?screenname=#{username}&client=#{client}" alt="" hspace="2" vspace="2" height="16" width="16"/></a>',im_yim:'<a href="ymsgr:sendim?ion_on" class="presence yim" title="Chat with #{username} on Yahoo Messenger"><img src="#{domain}n/im-presence?screenname=#{username}&client=#{client}"  alt="" hspace="5" vspace="5" height="12" width="12"/></a>',im_skype:'<a href="skype:#{username}?call" class="presence skype" title="Chat with #{username} on Skype"><img src="#{domain}n/im-presence?screenname=#{username}&client=#{client}" width="16" height="16" alt="" hspace="3" vspace="3"/></a>',im_icq:'<a href="http://people.icq.com/#{username}" class="presence icq" title="Chat with #{username} on ICQ"><img src="#{domain}n/im-presence?screenname=#{username}&client=#{client}" width="13" height="13" alt="" hspace="4" vspace="4"/></a>'},templateObjects:{},getIconLink:function(A,C,B){var E=(PBinfo.CurrentNetwork?PBinfo.CurrentNetwork.url:"/");var D=PBwiki.Components.IMIconGenerator;if(D.templateStrings[C]){if(!D.templateObjects[C]){D.templateObjects[C]=new Template(D.templateStrings[C])}return D.templateObjects[C].evaluate({username:A,domain:E,uid:B,client:C})}return""}};PBwiki.Components.UserCard.intercept=function(C){var B=C.findElement("a");if(B&&B.hasClassName("usercard_trigger")){C.stop();var A=B.getAttribute("ui:uid");new PBwiki.Components.UserCard({className:"usercard usercard-loading",event:C,uid:A})}};PBwiki.init(PBwiki.Components.StarBubble);PBwiki.init(PBwiki.Components.SendALinkBubble);PBwiki.init(function(){document.observe("click",PBwiki.Components.UserCard.intercept)});PBwiki=PBwiki||parent.PBwiki;PBwiki.Components=PBwiki.Components||{};PBwiki.Components.Dialog=Class.create({close:function(){this.onUnload();this.onClosed();this.remove();if(this.window_event_handler){Event.stopObserving(window,"scroll",this.window_event_handler);Event.stopObserving(window,"resize",this.window_event_handler)}},IE6:
/*@cc_on @_jscript_version < 5.7 || @*/
false,displayIframe:function(A){this.resize(A.dimensions);this.renderMode=A.contentSource;this.originalSize=A.dimensions},display:function(A){document.body.appendChild(this);this.resize(A.dimensions);this.renderMode=A.contentSource;this.originalSize=A.dimensions},resize:function(C){var A={};A.width=(parseInt(C.width)?C.width+"px":"400px");A.height=(parseInt(C.height)?C.height+"px":"auto");var B=this.select(".modal_content").first();B.setStyle(A);this.setContainerSize(C)},setContainerSize:function(C){var B=(this.IE6?"absolute":"fixed");var A=(typeof C.height=="string"?"auto":(C.height+41)+"px");this.setStyle({width:(C.width+18)+"px",height:A,display:"block",position:B});this.recenter();this.redisplay();this.setStyle({visibility:"visible"});this.window_event_handler=this.redisplay.bind(this);Event.observe(window,"scroll",this.window_event_handler);Event.observe(window,"resize",this.window_event_handler)},redisplay:function(){PBwiki.DialogFactory.background.style.height=document.body.clientHeight;PBwiki.DialogFactory.background.style.width=document.documentElement.clientWidth;if(this.timeOut){clearTimeout(this.timeOut)}this.timeOut=setTimeout(this.recenter.bind(this),50)},setTitle:function(A){this.getElementsByTagName("h3")[0].innerHTML=A.escapeHTML()},recenter:function(){var G=document.documentElement.clientHeight;var F=document.documentElement.scrollTop||window.scrollY||0;var A=this.getDimensions()?this.getDimensions().height:0;var E=A/-2;var D=document.viewport.getHeight()/4+E;if(D<0){E-=D}this.style.marginTop=E.toString()+"px";var C=0;if((G*2/3)<A){C=Math.max(-E,0)+5}else{C=Math.max(-E,0)+F+Math.max(5,G/8)}var B={position:"absolute",top:C.toString()+"px",left:(document.documentElement.clientWidth/2).toString()+"px",marginLeft:(this.getDimensions().width/-2).toString()+"px"};this.setStyle(B)},onUnload:function(){if(this.contentSourceElement){target=this.select(".modal_content").first();this.select("form").invoke("reset");$A(target.childNodes).each(function(A){this.contentSourceElement.appendChild(A)}.bind(this))}}});PBwiki.DialogFactory={activeDialog:null,cache:{},background:new Element("div",{"class":"modalbg"}),defaultDimensions:{width:400,height:"auto"},trapEsc:true,resize:function(A){if(this.activeDialog){this.activeDialog.resize(Object.extend(PBwiki.DialogFactory.defaultDimensions,A))}},close:function(A){if(this.activeDialog){this.activeDialog.close(A);if(this.activeDialog.closeable==true){document.stopObserving("keydown",PBwiki.DialogFactory.trapKeyEsc)}this.activeDialog=null;document.fire("dialog:closed")}if(typeof (Effect)!="undefined"){Effect.Fade(PBwiki.DialogFactory.background,{duration:0.1})}else{PBwiki.DialogFactory.background.hide()}},setTitle:function(A){if(PBwiki.DialogFactory.activeDialog){PBwiki.DialogFactory.activeDialog.setTitle(A)}},recenter:function(){if(PBwiki.DialogFactory.activeDialog){PBwiki.DialogFactory.activeDialog.recenter()}},showBackground:function(){if(PBwiki.DialogFactory.background.parentNode!=document.body){PBwiki.DialogFactory.background.innerHTML='<!--[if lte IE 6.5]><iframe src="/layout/common/templates/dialog/blank.html" class="iefix"></iframe><![endif]-->';document.body.appendChild(PBwiki.DialogFactory.background)}if(!document.evaluate){PBwiki.DialogFactory.background.style.height=document.body.clientHeight;PBwiki.DialogFactory.background.style.width=document.documentElement.clientWidth}PBwiki.DialogFactory.background.setStyle({display:"block"});PBwiki.DialogFactory.background.setOpacity(0.3)},open:function(B,D,C,A){C=Object.extend({renderAs:"div",contentSource:"ajax",expireCache:true,dimensions:PBwiki.DialogFactory.defaultDimensions,closeable:true,onClosed:Prototype.emptyFunction,onOpened:Prototype.emptyFunction},C);D=D||"No Title";if(C.renderAs=="iframe"){C.contentSource=C.renderAs}else{if(C.renderAs=="div"&&!C.contentSource){C.contentSource="ajax"}}A=Object.extend({evalScripts:true,parameters:"",method:"post"},A);if(this.activeDialog){C.contentSource=this.activeDialog.renderMode;C.dimensions=this.activeDialog.originalSize}this[("open-"+C.contentSource.toLowerCase()).camelize()](B,D,C,A);if(C.closeable==true){document.observe("keydown",PBwiki.DialogFactory.trapKeyEsc)}},trapKeyEsc:function(A){if(A.keyCode==Event.KEY_ESC){if(PBwiki.DialogFactory.trapEsc){document.fire("dialog:close")}else{document.fire("keypress:esc")}}},openPage:function(C,G,F,A){var E;var D=this.activeDialog;var B=F.dimensions.width;C=$(C);if(!D){D=new Element("div",{className:"modal"});D.appendChild(new Element("div",{className:"modal_title"}));D.firstChild.innerHTML="<h3>"+G.escapeHTML()+"</h3>";D.firstChild.innerHTML+=(F.closeable?'<a href="javascript:void(0);" onclick="PBwiki.DialogFactory.close(); return false;"></a>':"");E=new Element("div",{className:"modal_content"});D.appendChild(E);Object.extend(D,PBwiki.Components.Dialog.prototype);D.contentSourceElement=C;D.onClosed=F.onClosed;D.closeable=F.closeable;this.activeDialog=D}else{D.onUnload();E=D.getElementsByClassName("modal_content")[0]}this.showBackground();$A(C.childNodes).each(function(H){E.appendChild(H)});D.display(F)},openAjax:function(C,G,F,A){var E;var D=this.activeDialog;var B=F.dimensions.width;if(!D){D=new Element("div",{className:"modal"});D.appendChild(new Element("div",{className:"modal_title"}));D.firstChild.innerHTML="<h3>"+G.escapeHTML()+"</h3>";D.firstChild.innerHTML+=(F.closeable?'<a href="javascript:void(0);" onclick="PBwiki.DialogFactory.close(); return false;"></a>':"");E=new Element("div",{className:"modal_content"});D.appendChild(E);Object.extend(D,PBwiki.Components.Dialog.prototype);D.onClosed=F.onClosed;this.activeDialog=D}else{E=D.getElementsByClassName("modal_content")[0]}this.showBackground();if(F.templateSrc){E.innerHTML=F.templateSrc;D.display(F);F.onOpened()}else{this.ajax=new Ajax.Updater(E,C,{onComplete:function(I){if(F.templateObject){var H=new Template(E.innerHTML);H.innerHTML=H.evaluate(F.templateObject)}D.display(F);F.onOpened()},method:"get"})}},openIframe:function(A,G,C,B){var E;var H;var F;var I=this.activeDialog;if(typeof B.parameters=="object"){B.parameters=$H(B.parameters)}if(!I){I=new Element("div",{className:"modal"});I.appendChild(new Element("div",{className:"modal_title"}));I.firstChild.innerHTML="<h3>"+G.escapeHTML()+"</h3>";I.firstChild.innerHTML+=(C.closeable?'<a href="javascript:void(0);" onclick="PBwiki.DialogFactory.close(); return false;"></a>':"");var D=new Element("div",{className:"modal_content"});E=new Element("iframe",{scrolling:"no",frameborder:"no",style:"width: 100%",allowTransparency:true,name:"__modal_iframe_target"});D.appendChild(E);I.style.display=Prototype.Browser.WebKit?"":"none";I.appendChild(D);Object.extend(I,PBwiki.Components.Dialog.prototype);I.onClosed=C.onClosed;this.activeDialog=I}else{E=this.activeDialog.childNodes[1].firstChild}switch(B.method){case"post":if(typeof B.parameters=="object"&&B.parameters.keys().length>0){H=this.buildIframeForm(A,B.parameters);F="javascript:void(0);";break}case"get":default:F=A+(typeof B.parameters=="object"?"?"+B.parameters.toQueryString():B.parameters)}document.body.appendChild(I);this.showBackground();E.src=F;Event.observe(E,"load",function(){I.displayIframe(C)});if(H){H.target="__modal_iframe_target";document.body.appendChild(H);H.id="_f1";H.submit();post.remove()}},buildIframeForm:function(B,C){var A=new Element("form",{action:B,method:"post"});$H(C).each(function(D){A.appendChild(new Element("input",{name:D.key,value:D.value}))});return A},cancelLoading:function(){this.ajax.transport.abort();this.activeDialog.remove();delete this.activeDialog;PBwiki.DialogFactory.background.hide()},initialize:function(){document.observe("dialog:close",PBwiki.DialogFactory.close.bind(PBwiki.DialogFactory))}};PBwiki.init(PBwiki.DialogFactory);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.DialogCommands={};PBwiki.DialogCommands.TemplateDialog=Class.create({dialogPath:"/layout/common/templates/dialog/",dialogOptions:{},initialize:function(A){this.options=A;this.dialogOptions={contentSource:"ajax",dimensions:Object.extend({width:400,height:"auto"},A.dimensions),onOpened:this.setupDialog.bind(this),onClosed:this.options.onClosed||Prototype.emptyFunction,templateSrc:this.templateSrc,templateObject:this.getTemplateObject()};if(A.closeable===false){this.dialogOptions.closeable=A.closeable}var B;if(this.templateName){if(this.templateName.startsWith("/")){B=this.templateName}else{B=this.dialogPath+this.templateName+".html"}}PBwiki.DialogFactory.open(B,this.title,this.dialogOptions)},setupDialog:function(){this.active=PBwiki.DialogFactory.activeDialog;this.dialog=this.active.down(".modal_content")},findInputs:function(){this.inputs={};var A=this.dialog.down("form");A.select("input").concat(A.select("select")).concat(A.select("textarea")).each(function(B){var C=B.getAttribute("name");if(C){this.inputs[C]=B}},this)},inputs:{},getInputs:function(){var A={};for(itm in this.inputs){if(this.inputs[itm].value&&this.inputs[itm].value!=this.inputs[itm].getAttribute("ui:placeholder")){A[itm]=this.inputs[itm].value.strip()}}return A},getTemplateObject:function(){return false},setTitle:function(A){this.active.down("div.modal_title h3").update(A)},setWaitMsg:function(A){this.dialog.down("form").update('<p style="margin: 70px; background: transparent url(/images/spin_bw.gif) no-repeat scroll left center; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; padding-left: 20px;">'+A+"</p>")}});PBwiki.DialogCommands.APIDialog=Class.create(PBwiki.DialogCommands.TemplateDialog,{setupDialog:function($super){$super();this.saveButton=this.dialog.down("input.primarybutton");this.cancelLink=this.dialog.down("a.cancel");if(this.cancelLink){this.cancelLink.observe("click",function(A){A.stop();document.fire("dialog:close")})}this.apiForm=this.dialog.down("form");this.apiForm.observe("submit",this.Execute.bind(this));this.saveButton.observe("click",this.Execute.bind(this));this.addInputTexts();this.findInputs()},addInputTexts:function(){this.apiForm.select(InputText.selector).each(function(A){new InputText(A)})},validate:function(A){return true},Execute:function(C){C.stop();var A=this.getInputs();PBwiki.info(A);var B=this.validate(A);if(B!==true){this.setError(B);return }this.saveButton.writeAttribute({disabled:true});this.doRequest(A)},doRequest:function(A){var B={};if(this.postable){this.postable.each(function(C){B[C]=A[C];delete A[C]})}new PBwiki.APIRequest(this.apiMethod,A,{onSuccess:function(C){if(!this.onSuccess(C)){this.saveButton.writeAttribute({disabled:false})}}.bind(this),onFailure:function(C){this.saveButton.writeAttribute({disabled:false});this.onFailure(C)}.bind(this),waitCursor:true,method:"post",parameters:B})},onSuccess:function(A){},onFailure:function(A){this.setError(A)},setError:function(A){var B=this.apiForm.down("span.err").update(A).show()},loadUsersList:function(A,C,B,D){new PBwiki.APIRequest("GetUsersInfos",C||{},{cacheability:["permtime"],onSuccess:function(H){var J=H.uids;var E=A;var G="";for(var F=0;F<J.length;F++){if(J[F].uid==PBwiki.getUID()){G=Util.getAuthorNameFromObject(J[F]).escapeHTML()}}E.appendChild(new Element("option",{value:PBwiki.getUID()}).update("You ("+G+")"));if(D){E=new Element("optgroup",{label:"Users"});A.appendChild(E)}if(PBwiki.getUID()==B){A.selectedIndex=A.length-1}for(var F=0;F<J.length;F++){var I=new Element("option",{value:J[F].uid}).update(Util.getAuthorNameFromObject(J[F]).escapeHTML());if(J[F].uid==B){I.selected=true}E.appendChild(I)}}.bind(this),onFailure:function(E){this.setError(E)}.bind(this)})}});PBwiki.DialogCommands.InsertLink=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"insertlink",title:"Insert Link",sections:["page","file","folder","url","email"],initialize:function($super,A){Object.extend(A,{dimensions:{width:400}});$super(A)},setupDialog:function($super){$super();this.okButton=this.dialog.down("input.newpagesubmit");this.okButton.observe("click",this.Execute.bindAsEventListener(this));this.dialog.down("form").observe("submit",this.Execute.bindAsEventListener(this));if(this.options.sections){this.sections=this.options.sections}this.insertType=$("insertlink_type");var A=0;while(A<this.insertType.options.length){if(this.sections.indexOf(this.insertType.options[A].value)==-1){this.insertType.remove(A)}A++}this.insertType.observe("change",function(){this.selectSection(this.insertType.options[this.insertType.selectedIndex].value)}.bind(this));this.pageName=$("insertlink_pagename");this.emailInput=$("insertlink_email");this.urlInput=$("insertlink_url");this.selectSection(this.sections[0]);if(this.options.url){this.loadFromLink(this.options.url)}else{this.loadFromText(this.options.txt)}this.targetBox=$("insertlink_target");if(this.options.newWin){this.targetBox.checked=true}this.pageList=$("insertlink_pagelist");this.pageList.observe("change",this.pageSelect.bind(this));this.pageSelect();this.loadPageList();this.folderList=$("insertlink_folderlist");this.loadFolderList();this.fileList=$("insertlink_filelist");if(this.fileList){this.loadFileList()}},Execute:function(A){A.stop();try{this.notify("onSelect",this.getLink());document.fire("dialog:close")}catch(A){alert(A.message)}},getLink:function(){switch(this.currentSection){case"page":var E=this.getCurrentPage();if(!E){throw {message:"Please specify a page for your link."}}if(/https?:\/\//.test(E)){return{txt:E,href:E,type:"page"}}var B=Util.is_valid_page_name(E);if(B!==true&&E!="FrontPage"){throw {message:B}}return{txt:E,href:"/"+Util.dashified_link(E.toString()),type:"page"};case"file":var E=this.getCurrentFile();if(!E){throw {message:"Please select a file for your link."}}return{txt:E,href:"/f/"+encodeURIComponent(E),type:"file"};case"folder":var C=this.getCurrentFolder();if(!C){throw {message:"Please specify a folder for your link."}}return{txt:C,href:"/folder.php?folder="+C,type:"folder"};case"url":var A=this.urlInput.value;if(!A){throw {message:"Please specify a url of your link."}}if(!/(http|mailto|https|news|ftp|file):/.test(A)){A="http://"+A}return{txt:A,href:A,newWin:this.targetBox.checked,type:"url"};case"email":var D=this.emailInput.value;var B=Util.is_valid_email(D);if(B!==true){throw {message:B}}return{txt:D,href:"mailto:"+D,type:"mailto"}}},loadFromLink:function(A){if(A.indexOf("/folder.php?folder=")===0&&this.sections.indexOf("folder")!=-1){this.defaultFolder=A.replace("/folder.php?folder=","").replace(/\+/g," ");this.selectSection("folder")}else{if(A.substr(0,7)=="mailto:"&&this.sections.indexOf("email")!=-1){this.emailInput.value=A.replace("mailto:","");this.selectSection("email")}else{if(A.substr(0,3)=="/f/"&&this.sections.indexOf("file")!=-1){this.defaultFile=decodeURIComponent(A.substr(3)).replace(/\+/g," ");this.selectSection("file")}else{if(A.charAt(0)=="/"){this.defaultPage=this.pageName.value=Util.undashified_link(A.substr(1));this.selectSection("page")}else{this.urlInput.value=A;this.selectSection("url")}}}}},loadFromText:function(A){if(Util.is_valid_email(A)===true&&this.sections.indexOf("email")!=-1){this.emailInput.value=A;this.selectSection("email")}else{if(/^(https?|file|ftp):/.test(A)&&this.sections.indexOf("url")!=-1){this.urlInput.value=A;this.selectSection("url")}else{this.defaultPage=this.pageName.value=Util.strToPageName(A);this.defaultFile=A}}},selectSection:function(A){this.currentSection=A;this.insertType.value=A;this.sections.each(function(C){var D=$("insertlink_"+C+"_section");if(C==A){D.show();try{D.down("input").focus()}catch(B){}}else{D.hide()}})},pageSelect:function(){var B=this.pageList.options[this.pageList.selectedIndex].value;var C=(B=="__PBWIKI_NEW_PAGE__");$("insertlink_pagename_row").style.display=C?"block":"none";if(C){try{this.pageName.focus()}catch(A){}}},getCurrentPage:function(){var A=this.pageList.options[this.pageList.selectedIndex].value;return(A=="__PBWIKI_NEW_PAGE__")?this.pageName.value:A},getCurrentFile:function(){return this.fileList.options[this.fileList.selectedIndex].value},getCurrentFolder:function(){return this.folderList.options[this.folderList.selectedIndex].value},loadPageList:function(){new PBwiki.APIRequest("GetPages",{verbose:true,detail:"partial"},{cacheability:["page_list_time","foldertime","permtime"],onSuccess:function(A){A.pages.each(function(B){this.pageList.options[this.pageList.length]=new Option(B.name,B.name);if(this.defaultPage==B.name||(!this.defaultPage&&B.name==this.options.txt)){this.pageList.selectedIndex=this.pageList.length-1;this.selectSection("page")}}.bind(this));this.pageSelect()}.bind(this)})},loadFileList:function(){new PBwiki.APIRequest("GetFiles",{verbose:true,detail:"partial"},{cacheability:["filetime","foldertime","permtime"],onSuccess:function(A){A.files.each(function(B){this.fileList.options[this.fileList.length]=new Option(B.name,B.name);if(this.defaultFile==B.name||(!this.defaultFile&&B.name==this.options.txt)){this.fileList.selectedIndex=this.fileList.length-1;this.selectSection("file")}}.bind(this))}.bind(this)})},loadFolderList:function(){new PBwiki.APIRequest("GetFolders",{verbose:true},{cacheability:["foldertime"],onSuccess:function(A){A.folders.each(function(B){this.folderList.options[this.folderList.length]=new Option(B.name,B.name);if(this.defaultFolder==B.name||(!this.defaultFolder&&B.name==this.options.txt)){this.folderList.selectedIndex=this.folderList.length-1;this.selectSection("folder")}}.bind(this))}.bind(this)})}});Object.Event.extend(PBwiki.DialogCommands.InsertLink);PBwiki.DialogCommands.CreateNewPage=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"newpage",title:"Create a new page",initialize:function($super,A){Object.extend(A,{dimensions:{width:700}});$super(A)},setupDialog:function($super){$super();this.saveButton=this.dialog.down("input.newpagesubmit");this.saveButton.observe("click",this.Execute.bindAsEventListener(this));this.dialog.down("form").observe("submit",this.Execute.bindAsEventListener(this));if(!PBwiki.feature("file_import")){$("page-import").remove()}else{$("file_data").observe("change",Page.NewPage.fileWasSelected)}if(PBwiki.feature("email_import")){var A="inbox@"+document.domain;$("workspace_email").writeAttribute("href","mailto:"+A.escapeHTML());$("workspace_email").update(A)}else{$("email_import").remove()}this.moreOptions=$("createpagemore");this.moreOptions.observe("click",function(){PBwiki.UserPrefs.set(PBconst.kCreatePageExpanded,this.toggle())}.bind(this));if(PBwiki.UserPrefs.get(PBconst.kCreatePageExpanded)){this.toggle()}this.addFolderList();this.addTemplatesList();this.setupSecuritySelect();this.dialog.down("input.page_name").focus();this.sections.each(function(B){B=$("page-content-"+B);if(B){B.observe("click",this.updateSection.bind(this))}}.bind(this))},toggle:function(){var A=$("createpageoptionspanel").style.display=="none";this.moreOptions.update(A?"fewer options":"more options");$("createpageoptionspanel").style.display=A?"block":"none";(A)?this.moreOptions.up("p").addClassName("expanded"):this.moreOptions.up("p").removeClassName("expanded");return A},sections:["blank","import","template"],currentSection:function(){return this.sections.find(function(A){return $("page-content-"+A)&&$("page-content-"+A).checked})},updateSection:function(){var A=this.currentSection();this.sections.each(function(B){var C=$("page-content-"+B+"-details");if(C){C.style.display=(B==A)?"block":"none"}});this.saveButton.value=(A=="import")?"Import File":"Create page"},addFolderList:function(){this.folderSelect=this.dialog.down("select.newpagefolders");var A=PBwiki.getCache("GetFolders");if(!A){new PBwiki.APIRequest("GetFolders",{verbose:true},{onSuccess:this.updateFolderList.bind(this),method:"get"})}else{this.updateFolderList(A)}},updateFolderList:function(A){A.folders.each(function(C){var B=new Element("option",{value:C.name}).update(C.name.escapeHTML());if(this.options.folder==C.name){B.selected=true}this.folderSelect.appendChild(B)}.bind(this))},addTemplatesList:function(){this.templateList=this.dialog.down("#page-content-template-details select");var A=PBwiki.getCache("GetTemplates");if(A){this.updateTemplateList(A)}else{new PBwiki.APIRequest("GetTemplates",{},{onSuccess:this.updateTemplateList.bind(this),method:"get"})}},updateTemplateList:function(A){if(!A.templates||A.templates.length==0){$("page-template").hide();return }A.templates.each(function(B){var C=" "+B.replace("wiki.","");this.templateList.options[this.templateList.length]=new Option(C,B)}.bind(this))},setupSecuritySelect:function(){var A=this.dialog.down("select.newpagesecurity");if(!PBwiki.feature("page_security")||PBinfo.CheckPermissions.wikiperm!="admin"){this.dialog.down("div.newpagesecurityrow").hide()}else{A.appendChild(new Element("option",{value:"locked"}).update("locked"));if(!PBwiki.feature("public_only")){A.appendChild(new Element("option",{value:"hidden"}).update("hidden"))}}},Execute:function(A){if(A){A.stop()}if(this.currentSection()=="import"){this.importFile()}else{this.createPage()}},getImportUrl:function(){var A={op:"ImportFile",_type:"iframe",callback:"top.PBwiki.APIRequest.DelegateFrameRequest",page:this.dialog.down("input.page_name").value.strip()};Object.extend(A,PBwiki.getSessCookie());var B=this.dialog.down("select.newpagesecurity");var D=(B)?B.options[B.selectedIndex].value:"";var C=this.folderSelect.options[this.folderSelect.selectedIndex].value;if(D!="default"){A.security=D}if(C){A.folder=C}return"/api_v2/?"+Object.toQueryString(A)},importFile:function(){if(!this.checkPageName()){return }this.fileFrame=$("file_import_frame");if(this.fileFrame){this.fileFrame.remove()}this.fileFrame=new Element("iframe",{name:"file_import_frame",id:"file_import_frame",src:(Prototype.Browser.IE)?"/layout/common/templates/blank.html":"about:blank"}).setStyle({display:"none"});this.dialog.appendChild(this.fileFrame);this.fileFrame=$("file_import_frame");document.observe("frame:ImportFile",this.importFileResult.bind(this));this.dialog.down("form").writeAttribute("action",this.getImportUrl()).submit();this.saveButton.writeAttribute({disabled:true})},importFileResult:function(D){var C=D.memo;document.stopObserving("frame:ImportFile");if(C.convert_id){$("createpageform").update('<p style="background: left center no-repeat url(/images/spin_bw.gif); padding-left: 20px; margin: 100px;">Please wait while your document is imported...</p>');this.importFileStatusCheck(C.convert_id)}else{var B=C.error_message;if(B){var A=this.dialog.down("span.newpageerror");A.innerHTML=B.escapeHTML();A.show();setTimeout(function(){A.hide()},5000)}else{document.fire("dialog:close");document.fire("objectbrowser:onNotifyUser",{message:"PBworks was not able to import the selected document",mode:"error"})}}},importFileStatusCheck:function(A){new PBwiki.APIRequest("GetImportStatus",{convert_id:A},{onSuccess:function(B){if(B.status=="finished"){new PBwiki.APIRequest("GetTimes",{},{onSuccess:function(){document.fire("dialog:close");this.notify("onCreate",B.page)}.bind(this)})}else{if(B.status=="error"){document.fire("dialog:close");document.fire("objectbrowser:onNotifyUser",{message:"PBworks was not able to import the selected document",mode:"error"})}else{if(this.dialog){setTimeout(this.importFileStatusCheck.bind(this,A),2000)}}}}.bind(this),onFailure:function(){if(this.dialog){setTimeout(this.importFileStatusCheck.bind(this,A),2000)}}.bind(this),method:"post"})},checkPageName:function(){var A=this.dialog.down("input.page_name").value.strip();var C=Util.is_valid_page_name(A);if(C!==true){var B=this.dialog.down("span.newpageerror");B.innerHTML=C;setTimeout(function(){B.hide()},5000)}return(C===true)},createPage:function(){var J=this.dialog.down("select.newpagesecurity");var G=(J)?J.options[J.selectedIndex].value:"";var B=this.folderSelect.options[this.folderSelect.selectedIndex].value;var I=$("page-content-template-name");var H=I&&I.options.length>0?I.options[I.selectedIndex].value:false;var F=this.dialog.down("input.page_name").value.strip();if(!this.checkPageName()){return }var C={page:F};if(G!="default"){C.security=G}if(B){C.folder=B}if(this.currentSection()=="template"&&H){C.template=H}var A=new Array();A.push(["CreatePage",C,{}]);if(!this.options.noPreloadView&&PBwiki.ObjectBrowser){A.push(["GetFolders",{verbose:true},{cacheability:["foldertime"],counted:false}]);var E=PBwiki.ObjectBrowser.view;var D=Object.clone(E.refreshOptions);D.sortby="mtime";D.reverse=true;A.push([E.apiMethod,D,{counted:false}])}this.saveButton.writeAttribute({disabled:true});new PBwiki.MultiAPIRequest(A,{incUsess:true,onAllComplete:function(L){if(L.successful==1){document.fire("dialog:close");this.notify("onCreate",F)}else{var K=this.dialog.down("span.newpageerror");K.update(L.lastError).show();setTimeout(function(){K.hide()},5000);this.saveButton.writeAttribute({disabled:false})}}.bind(this),waitCursor:true})}});Object.Event.extend(PBwiki.DialogCommands.CreateNewPage);PBwiki.DialogCommands.FolderSelector=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"choosefolder",title:"Choose a Folder",initialize:function($super,A){Object.extend(A,{dimensions:{width:260}});$super(A)},setupDialog:function($super){$super();this.folderList=this.dialog.down(".dialog_folder_selector");if(this.options.buttonTitle){$("dialog_folder_move_btn").value=this.options.buttonTitle}var A=PBwiki.getCache("GetFolders");if(!A){new PBwiki.APIRequest("GetFolders",{},{onSuccess:this.setupFolderList.bind(this),method:"get"})}else{this.setupFolderList(A)}$("dialog_folder_move_btn").observe("click",this.submitMoveCommand.bind(this))},setupFolderList:function(B){if(this.options.folder){var A=new Element("a",{href:"",className:"iconbutton unfiled"}).observe("click",this.selectFolder.bindAsEventListener(this,"")).update("Remove from '"+this.options.folder.escapeHTML()+"'").wrap("li");this.folderList.appendChild(A)}B.folders.each(function(D){if(D.name==this.options.folder||!D.perms.w){return }var C=new Element("a",{href:"",className:"iconbutton folder"}).observe("click",this.selectFolder.bindAsEventListener(this,D.name)).update(D.name.escapeHTML()).wrap("li");this.folderList.appendChild(C)}.bind(this))},submitMoveCommand:function(A){if(this.selectedFolder||this.selectedFolder==""){document.fire("dialog:close");this.notify("onSelect",this.selectedFolder)}},selectFolder:function(C,B){C.stop();C.element().blur();var A=C.element().up();A.adjacent("li").invoke("removeClassName","active");A.addClassName("active");this.selectedFolder=B}});Object.Event.extend(PBwiki.DialogCommands.FolderSelector);PBwiki.DialogCommands.FolderSecurity=Class.create(PBwiki.DialogCommands.TemplateDialog,{cellTemplates:["#{name}",'<input type="hidden" class="securityuids" name="uid[]" value="#{uid}"/><select class="roleselect" name="role[]"><option value="read">Reader</option><option value="write">Writer</option><option value="edit">Editor</option></select>','<a class="securitydeletelink iconbutton deleteicon" href="#">&nbsp;</a>'],templateName:"foldersecurity",removedRows:{},initialize:function($super,A){this.title="Folder Security for "+A.folder.escapeHTML();Object.extend(A,{dimensions:{width:700}});$super(A)},setupDialog:function($super){$super();var A=new Array();A.push(["GetUsersInfos",{sortby:"name"},{onSuccess:this.loadUserList.bind(this),onFailure:function(B){document.fire("dialog:close");document.fire("objectbrowser:onNotifyUser",{message:"Failed to load folder security user list. "+B,mode:"error"})}}]);A.push(["GetFolderSecurity",{folder:this.options.folder},{onSuccess:this.loadSecurityState.bind(this),onFailure:function(B){document.fire("dialog:close");document.fire("objectbrowser:onNotifyUser",{message:"Failed to load folder security. "+B,mode:"error"})}}]);this.active.hide();new PBwiki.MultiAPIRequest(A,{incUsess:true});$("securityadduserbutton").observe("click",this.addUser.bind(this));$("foldersecuritysubmit").observe("click",this.saveSecurity.bindAsEventListener(this))},addUser:function(){var D=$("foldersecurityusers");if(D.selectedIndex==-1){return }var C=D.options[D.selectedIndex];var A=this.dialog.select("input.securityuids").find(function(E){return(E.value==C.value)});if(A){alert("User '"+C.text+"' is already in the custom security list");return }var B={uid:C.value,name:C.text};this.addSecurityRow(B)},loadUserList:function(D){var F=D.uids;var C=$("foldersecurityusers");var A=PBwiki.getCache("CheckPermissions");for(var B=0;B<F.length;B++){if(F[B].id==A.uid||F[B].perm=="admin"||F[B].perm=="deny"){continue}var E=new Element("option",{value:F[B].uid}).update(Util.getAuthorNameFromObject(F[B]).escapeHTML());C.appendChild(E)}},saveSecurity:function(C){if(C){C.stop()}var B=new Array();if(this.hasCustomSecurity){var A=$("securitytable").select("input.securityuids");if(A){var B=A.collect(function(E){var D=E.next().options[E.next().selectedIndex].value;return["SetFolderUserPermission",{folder:this.options.folder,uid:E.value,perm:D},{}]}.bind(this))}$H(this.removedRows).each(function(D){B.push(["SetFolderUserPermission",{folder:this.options.folder,uid:D[0],perm:"deny"},{}])}.bind(this))}B.unshift(["SetFolderHasCustomSecurity",{folder:this.options.folder,enabled:this.hasCustomSecurity},{}]);B.unshift(["SetFolderPublic",{folder:this.options.folder,"public":$("foldersecuritypublished").checked},{}]);B.push(["GetFolders",{verbose:true},{cacheability:["foldertime","permtime"],counted:false}]);new PBwiki.MultiAPIRequest(B,{incUsess:true,onAllComplete:function(D){this.notify("onSecurityChange",this.hasCustomSecurity);document.fire("dialog:close")}.bind(this)})},addSecurityRow:function(A){if(this.removedRows[A.uid]){delete this.removedRows[A.uid]}var B=$($("foldersecurityusersettings").insertRow(-1));this.cellTemplates.each(function(C){A.name=Util.getAuthorNameFromObject(A).escapeHTML();B.insertCell(-1).innerHTML=C.interpolate(A);var D=B.down("select.roleselect");if(D){for(var F=0;F<D.options.length;F++){if(D.options[F].value==A.perm){D.options[F].selected=true}}}var E=B.down("a.securitydeletelink");if(E){E.observe("click",function(G){if(G){G.stop()}this.removeSecurityRow(B)}.bindAsEventListener(this))}}.bind(this))},removeSecurityRow:function(A){this.removedRows[A.down("input.securityuids").value]=true;A.parentNode.removeChild(A)},loadSecurityState:function(C){try{this.hasCustomSecurity=!!C.perms;this.isPublished=C["public"];if(this.hasCustomSecurity){$("customsecurityradio").checked=true;for(var A=0;A<C.perms.length;A++){this.addSecurityRow(C.perms[A])}}else{$("defaultsecurityradio").checked=true}this.setVisibleSecurity();this.setPublicSecurity();$("customsecurityradio").observe("click",this.securityUserToggle.bind(this,true));$("defaultsecurityradio").observe("click",this.securityUserToggle.bind(this,false))}catch(B){alert(B.message)}this.active.show()},securityUserToggle:function(A){this.hasCustomSecurity=A;this.setVisibleSecurity()},setVisibleSecurity:function(){$("customsecurity").setStyle({display:((this.hasCustomSecurity)?"block":"none")});$("custom_security_button").setStyle({display:((this.hasCustomSecurity)?"inline-block":"none")})},setPublicSecurity:function(){this.dialog.down("div.foldersecurityprivate").setStyle({display:(!PBinfo.CurrentWiki.isPublic)?"block":"none"});$("foldersecuritypublished").checked=this.isPublished}});Object.Event.extend(PBwiki.DialogCommands.FolderSecurity);PBwiki.DialogCommands.FlashUploader=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"uploadfiles",title:"Upload Files",initialize:function($super,A){Object.extend(A,{dimensions:{width:400}});this.swfUpload=A.swf;$super(A)},setupDialog:function($super){try{$super();this.cancelButton=this.dialog.down("input.cancelupload");this.cancelButton.observe("click",this.cancelQueue.bind(this));if(PBinfo.GetStorageInfo&&PBinfo.GetStorageInfo.ratelimit_percent>=75){this.dialog.down("div.ratelimitwarning").show()}var D={file_queue_error_handler:this.fileQueueError.bind(this),upload_start_handler:this.uploadStart.bind(this),upload_progress_handler:this.uploadProgress.bind(this),upload_error_handler:this.uploadError.bind(this),upload_success_handler:this.uploadSuccess.bind(this),upload_complete_handler:this.uploadComplete.bind(this),file_queued_handler:this.fileQueued.bind(this),debug_handler:this.debugHandler.bind(this)};Object.extend(this.swfUpload.settings,D);var C=this.swfUpload.getStats();for(var B=0;B<C.files_queued;B++){var A=this.swfUpload.getFile(B);if(A.filestatus!=SWFUpload.FILE_STATUS.COMPLETE){this.fileQueued(A)}}this.swfUpload.startUpload()}catch(E){alert(E.message)}},cancelQueue:function(){var B=this.swfUpload.getStats();for(var A=0;A<B.files_queued;A++){this.swfUpload.cancelUpload()}},fileQueued:function(C){try{var A=new FileProgress(C,this.swfUpload.customSettings.progressTarget);A.SetStatus("Pending...");A.ToggleCancel(true,this.swfUpload)}catch(B){this.debug(B)}},fileQueueError:function(E,A,D){try{if(A===SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED){document.fire("dialog:close");return }var B=new FileProgress(E,this.swfUpload.customSettings.progressTarget);B.SetError();B.ToggleCancel(false);switch(A){case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:B.SetStatus("File is too big.");this.debug("Error Code: File too big, File name: "+E.name+", File size: "+E.size+", Message: "+D);break;case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:B.SetStatus("Cannot upload Zero Byte files.");this.debug("Error Code: Zero byte file, File name: "+E.name+", File size: "+E.size+", Message: "+D);break;case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:B.SetStatus("Invalid File Type.");this.debug("Error Code: Invalid File Type, File name: "+E.name+", File size: "+E.size+", Message: "+D);break;case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:alert("You have selected too many files.  "+(D>1?"You may only add "+D+" more files":"You cannot add any more files."));break;default:if(E!==null){B.SetStatus("Unhandled Error")}this.debug("Error Code: "+A+", File name: "+E.name+", File size: "+E.size+", Message: "+D);break}}catch(C){this.debug(C)}},fileDialogComplete:function(B){this.active.show();try{if(this.swfUpload.getStats().files_queued>0){this.cancelButton.disabled=false}else{this.uploadAllComplete()}this.swfUpload.startUpload()}catch(A){this.debug(A)}},uploadStart:function(C){try{var A=new FileProgress(C,this.swfUpload.customSettings.progressTarget);A.SetStatus("Uploading...");A.ToggleCancel(true,this.swfUpload)}catch(B){}return true},uploadProgress:function(F,E,D){try{var C=Math.ceil((E/D)*100);var A=new FileProgress(F,this.swfUpload.customSettings.progressTarget);A.SetProgress(C);A.SetStatus("Uploading...")}catch(B){this.debug(B)}},uploadSuccess:function(D,C){try{var A=new FileProgress(D,this.swfUpload.customSettings.progressTarget);A.SetComplete();A.SetStatus("Complete.");A.ToggleCancel(false)}catch(B){this.debug(B)}},uploadComplete:function(B){try{if(this.swfUpload.getStats().files_queued===0){this.cancelButton.disabled=true;if(this.swfUpload.getStats().files_queued===0){this.uploadAllComplete()}}else{setTimeout(function(){this.swfUpload.startUpload()}.bind(this),1000)}}catch(A){this.debug(A)}},uploadAllComplete:function(){$("fsUploadProgress1").update("");document.fire("dialog:close");this.notify("onUploaded",this.swfUpload.getStats().successful_uploads,this.lastErrorMsg);this.swfUpload.setStats({successful_uploads:0})},uploadError:function(D,A,C){var B=new FileProgress(D,this.swfUpload.customSettings.progressTarget);B.SetError();B.ToggleCancel(false);switch(A){case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:B.SetStatus("Upload Error: "+C);this.debug("Error Code: HTTP Error, File name: "+D.name+", Message: "+C);break;case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:B.SetStatus("Configuration Error");this.debug("Error Code: No backend file, File name: "+D.name+", Message: "+C);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:B.SetStatus("Upload Failed.");this.debug("Error Code: Upload Failed, File name: "+D.name+", File size: "+D.size+", Message: "+C);break;case SWFUpload.UPLOAD_ERROR.IO_ERROR:B.SetStatus("Server (IO) Error");this.debug("Error Code: IO Error, File name: "+D.name+", Message: "+C);break;case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:B.SetStatus("Security Error");this.debug("Error Code: Security Error, File name: "+D.name+", Message: "+C);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:B.SetStatus("Upload limit exceeded.");this.debug("Error Code: Upload Limit Exceeded, File name: "+D.name+", File size: "+D.size+", Message: "+C);break;case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:B.SetStatus("File not found.");this.debug("Error Code: The file was not found, File name: "+D.name+", File size: "+D.size+", Message: "+C);break;case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:B.SetStatus("Failed Validation.  Upload skipped.");this.debug("Error Code: File Validation Failed, File name: "+D.name+", File size: "+D.size+", Message: "+C);break;case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:if(this.swfUpload.getStats().files_queued===0){this.cancelButton.disabled=true}B.SetStatus("Cancelled");B.SetCancelled();break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:B.SetStatus("Stopped");break;default:B.SetStatus("Unhandled Error: "+A);this.debug("Error Code: "+A+", File name: "+D.name+", File size: "+D.size+", Message: "+C);break}},debug:function(A){PBwiki.info(A)},debugHandler:function(D){var F=(typeof (D)==="object"&&typeof (D.name)==="string"&&typeof (D.message)==="string");if(F||D.indexOf("Exception: Error:")!=-1){this.setupLegacy();this.active.show()}if(this.swfUpload.settings&&this.swfUpload.settings.debug){var A,E=[];if(F){for(var B in D){if(D.hasOwnProperty(B)){E.push(B+": "+D[B])}}A=E.join("\n")||"";E=A.split("\n");A="EXCEPTION: "+E.join("\nEXCEPTION: ");PBwiki.info(A)}else{var C=D.match(/<error_string>(.*?)<\/error_string>/);if(C){this.lastErrorMsg=C[1]}PBwiki.info(D)}}}});Object.Event.extend(PBwiki.DialogCommands.FlashUploader);PBwiki.DialogCommands.LegacyUploader=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"legacyupload",title:"Upload a File",setupDialog:function($super){$super();this.legacyUpload=this.dialog.down("div.formupload");this.legacyForm=this.legacyUpload.down("form");this.legacyInput=this.legacyUpload.down("input.dialog_formupload_filename");this.legacyFrame=this.legacyUpload.down("iframe.dialog_formupload_frame");if(this.options.uploadUrl){this.legacyForm.setAttribute("action",this.options.uploadUrl)}this.legacyInput.observe("change",function(){try{document.observe("frame:PutFile",this.legacyUploadResult.bind(this));this.legacyForm.submit();this.legacyUpload.down("div.dialog_formupload_status").update("Uploading...");this.legacyUploadCheck()}catch(A){}}.bind(this))},legacyUploadResult:function(A){document.stopObserving("frame:PutFile");if(A.error_message){document.fire("objectbrowser:onNotifyUser",{message:"Upload failed: "+A.error_message.escapeHTML(),mode:"error"});document.fire("dialog:close")}else{setTimeout(function(){document.fire("dialog:close");this.notify("onUploaded",1)}.bind(this),1000)}}});Object.Event.extend(PBwiki.DialogCommands.LegacyUploader);function FileProgress(D,B){this.file_progress_id=D.id;this.opacity=100;this.height=0;this.fileProgressWrapper=document.getElementById(this.file_progress_id);if(!this.fileProgressWrapper){this.fileProgressWrapper=document.createElement("div");this.fileProgressWrapper.className="progressWrapper";this.fileProgressWrapper.id=this.file_progress_id;this.fileProgressElement=document.createElement("div");this.fileProgressElement.className="progressContainer";var F=document.createElement("a");F.className="progressCancel";F.href="#";F.style.visibility="hidden";F.appendChild(document.createTextNode(" "));var A=document.createElement("div");A.className="progressName";A.appendChild(document.createTextNode(D.name));var E=document.createElement("div");E.className="progressBarInProgress";var C=document.createElement("div");C.className="progressBarStatus";C.innerHTML="&nbsp;";this.fileProgressElement.appendChild(F);this.fileProgressElement.appendChild(A);this.fileProgressElement.appendChild(C);this.fileProgressElement.appendChild(E);this.fileProgressWrapper.appendChild(this.fileProgressElement);document.getElementById(B).appendChild(this.fileProgressWrapper)}else{this.fileProgressElement=this.fileProgressWrapper.firstChild}this.height=this.fileProgressWrapper.offsetHeight}FileProgress.prototype.SetProgress=function(A){this.fileProgressElement.className="progressContainer green";this.fileProgressElement.childNodes[3].className="progressBarInProgress";this.fileProgressElement.childNodes[3].style.width=A+"%"};FileProgress.prototype.SetComplete=function(){this.fileProgressElement.className="progressContainer blue";this.fileProgressElement.childNodes[3].className="progressBarComplete";this.fileProgressElement.childNodes[3].style.width="";var A=this;setTimeout(function(){A.Disappear()},3000)};FileProgress.prototype.SetError=function(){this.fileProgressElement.className="progressContainer red";this.fileProgressElement.childNodes[3].className="progressBarError";this.fileProgressElement.childNodes[3].style.width="";var A=this;setTimeout(function(){A.Disappear()},5000)};FileProgress.prototype.SetCancelled=function(){this.fileProgressElement.className="progressContainer";this.fileProgressElement.childNodes[3].className="progressBarError";this.fileProgressElement.childNodes[3].style.width="";var A=this;setTimeout(function(){A.Disappear()},2000)};FileProgress.prototype.SetStatus=function(A){this.fileProgressElement.childNodes[2].innerHTML=A};FileProgress.prototype.ToggleCancel=function(A,B){this.fileProgressElement.childNodes[0].style.visibility=A?"visible":"hidden";if(B){var C=this.file_progress_id;this.fileProgressElement.childNodes[0].onclick=function(){B.cancelUpload(C);return false}}};FileProgress.prototype.Disappear=function(){try{Effect.Fade(this.fileProgressWrapper,{duration:1})}catch(A){}};PBwiki.DialogCommands.RateLimited=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"ratelimited",title:"Sorry, uploading is currently disabled",setupDialog:function($super){$super();var A=PBwiki.getCache("GetStorageInfo");$("ratelimit").hide();$("ratelimit_storage").hide();$("ratelimit_quota").innerHTML=A.total_readable;(A.ratelimited)?$("ratelimit").show():$("ratelimit_storage").show();if(!PBinfo.CheckPermissions||PBinfo.CheckPermissions.wikiperm!="admin"){$("ratelimit_upgrade").hide()}}});PBwiki.DialogCommands.SecureStorage=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"securestorage",title:"Secure Storage"});PBwiki.DialogCommands.SecureCommunication=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"securecommunication",title:"Secure Communication"});PBwiki.DialogCommands.JoinWorkspace=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"joinworkspace",title:"Join",dialogOptions:{closeable:false},initialize:function($super,A){if(PBinfo.CurrentWiki.archived){this.templateName="joinarchivedworkspace";this.title=PBinfo.CurrentWiki.title+" is archived"}else{this.title="Join "+PBinfo.CurrentWiki.title}Object.extend(A,{closeable:false,dimensions:{width:582}});this.cancelLink=false;$super(A)},setupDialog:function($super){$super();$("join-preview").observe("click",function(E){E.stop();PBwiki.UserPrefs.set("show_join_dialog",false,PBinfo.CurrentWiki.name);document.fire("dialog:close")});$("join-perm").innerHTML=PBinfo.CurrentWiki.join_perm+"&nbsp;";$("about-desc").innerHTML=PBinfo.CurrentWiki.description?PBinfo.CurrentWiki.description:"<em>No description</em>";$("about-stats-files").innerHTML=PBinfo.CurrentWiki.file_count;$("about-stats-pages").innerHTML=PBinfo.CurrentWiki.page_count;$("about-stats-users").innerHTML=PBinfo.CurrentWiki.user_count;if(PBinfo.CurrentWiki.admins.length>0){for(var B=0;B<2;B++){var D="admin"+(B+1);var C="";var A="";if(!PBinfo.CurrentWiki.admins[B]){$(D).down(".pictureframe").hide();$$("#join-workspace .separator").each(function(E){E.hide()});continue}if(PBinfo.CurrentWiki.admins[B].name){C=PBinfo.CurrentWiki.admins[B].name}else{C="<em>No name set</em>"}A=PBinfo.CurrentWiki.admins[B].email;if(PBinfo.CurrentWiki.admins[B].image.match("uimg/bread.png")){PBinfo.CurrentWiki.admins[B].image='<img class="profile-img" alt="profile picture" src="/layout/common/images/userpicture-default42.gif">'}$(D).down(".primary").innerHTML=C;$(D).down(".secondary").innerHTML=A;$(D).down("img").replace(PBinfo.CurrentWiki.admins[B].image);$("skip_message").value="true";$("page_name").value=PBinfo.CurrentPage.page}}if(PBinfo.CurrentWiki.admins.length==0){$("admins").hide();$("admin-other").innerHTML="<em>No administrators</em>"}else{if(PBinfo.CurrentWiki.admins.length<=1){$("admin2").hide()}else{if(PBinfo.CurrentWiki.admins.length<=2){$("admin-other").hide()}else{if(PBinfo.CurrentWiki.admins.length==3){$("admin-other").innerHTML='<div class="separator">&nbsp;</div>&hellip;and one other'}else{$("admin-other").innerHTML='<div class="separator">&nbsp;</div>&hellip;and '+(PBinfo.CurrentWiki.admins.length-2)+" others"}}}}}});PBwiki.DialogCommands.DeleteFolder=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"folderdelete",title:"Delete Folder",setupDialog:function($super){$super();this.objectList=this.dialog.down("ul");var C=[];var B=this.options.objects.length;this.options.objects.each(function(E){if(E.name=="FrontPage"||E.name=="SideBar"){B--;C.push(E.name)}else{var D=new Element("li");D.appendChild(new Element("span",{"class":"iconbutton "+((E.type=="page")?"pageicon":Util.getFileIcon(E.name))}).update(E.name.toString().escapeHTML()));this.objectList.appendChild(D)}},this);if(B>0){var A="Removing this folder will also permanently delete "+B+" item"+((B>1)?"s":"")+":";this.dialog.down("div.yellow-note").update(A)}else{var A="You are about to permanently delete this folder.";this.dialog.down("div.yellow-note").update(A)}if(C.length>0){var A="Your "+C.join(" and ")+" will not be deleted.";this.objectList.insert({after:new Element("p").update(A)})}$("folder-delete-button").observe("click",function(){document.fire("dialog:close");this.notify("onConfirmation")}.bind(this))}});Object.Event.extend(PBwiki.DialogCommands.DeleteFolder);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(){PBwiki.info("Loaded second stage complete");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));$("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))}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){PBwiki.info("Restored autosave data");if(A.autosave){this.setContent(A.autosave.DATA)}},handleLockinfo:function(B){if(!B.hasLock){PBwiki.info("Lost the lock on this page");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{PBwiki.info("Gained the lock on this page");$("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 }PBwiki.info("Load second stage");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){PBwiki.info("Partially loaded, loading second stage now");A.contentWindow.SecondStage()}},loadFirstStage:function(){if(this.firstStage||this.firstLoading){return }this.firstLoading=true;if($("content")){return }PBwiki.info("Load first stage");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,chatBox:PBwiki.Live.getLiveEditChatForCurrentPage(),onSelect:function(B){(new PBwiki.APIRequest("SetPageLock",{page:PBwiki.getPageName(),"private":false},{asynchronous:false,onSuccess:function(C){Page.EditPage.AutoSave.stop();Page.EditPage.AutoSave.start({draft:{draft_id:C.lockinfo.draft_id,v:0},saveInterval:2});Page.EditPage.AutoSave.lastHTML=""}}))}}))},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:{verbose:true,detail:"partial",count:10,offset:0,sortby:"mtime",reverse:true},fileOpts:{verbose:true,detail:"partial",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))},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("GetPages",this.pageOpts,{cacheability:["pagetime","foldertime","permtime"],onSuccess:function(A){this.pageList.update("");A.pages.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.pages.length){this.pageList.parentNode.appendChild(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)))}}.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()}.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("GetFiles",this.fileOpts,{cacheability:["filetime","foldertime","permtime"],onSuccess:function(A){this.fileList.update("");A.files.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.files.length){this.fileList.appendChild(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)))}else{if(A._total_count==0){this.fileList.update("No recent files")}}}.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){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){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(){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;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")){alet("User has already entered a page name; don't infer one based on filename\n\ncurrent name = "+$("page_name").value+"\ninferred name = "+$("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(){Event.observe("createpagemore","click",Page.NewPage.toggleMoreOptions.bind(this));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));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)}};var Droppables={drops:[],remove:function(A){this.drops=this.drops.reject(function(B){return B.element==$(A)})},removeAll:function(){this.drops=new Array()},add:function(B){B=$(B);var A=Object.extend({greedy:true,hoverclass:null,tree:false},arguments[1]||{});if(A.containment){A._containers=[];var C=A.containment;if(Object.isArray(C)){C.each(function(D){A._containers.push($(D))})}else{A._containers.push($(C))}}if(A.accept){A.accept=[A.accept].flatten()}A.element=B;this.drops.push(A)},findDeepestChild:function(A){deepest=A[0];for(i=1;i<A.length;++i){if(Element.isParent(A[i].element,deepest.element)){deepest=A[i]}}return deepest},isContained:function(B,A){var C;if(A.tree){C=B.treeNode}else{C=B.parentNode}return A._containers.detect(function(D){return C==D})},isAffected:function(A,C,B){return((B.element!=C)&&((!B._containers)||this.isContained(C,B))&&((!B.accept)||(Element.classNames(C).detect(function(D){return B.accept.include(D)})))&&Position.within(B.element,A[0],A[1]-((Prototype.Browser.WebKit)?40:0)))},deactivate:function(A){if(A.hoverclass){Element.removeClassName(A.element,A.hoverclass)}this.last_active=null},activate:function(A){if(A.hoverclass){Element.addClassName(A.element,A.hoverclass)}this.last_active=A},show:function(A,C){if(!this.drops.length){return }var B,D=[];this.drops.each(function(E){if(Droppables.isAffected(A,C,E)){D.push(E)}});if(D.length>0){B=Droppables.findDeepestChild(D)}if(this.last_active&&this.last_active!=B){this.deactivate(this.last_active)}if(B){Position.within(B.element,A[0],A[1]);if(B.onHover){B.onHover(C,B.element,Position.overlap(B.overlap,B.element))}if(B!=this.last_active){Droppables.activate(B)}}},fire:function(B,A){if(!this.last_active){return }Position.prepare();if(this.isAffected([Event.pointerX(B),Event.pointerY(B)],A,this.last_active)){if(this.last_active.onDrop){this.last_active.onDrop(A,this.last_active.element,B);return true}}},reset:function(){if(this.last_active){this.deactivate(this.last_active)}}};var Draggables={drags:[],observers:[],register:function(A){if(this.drags.length==0){this.eventMouseUp=this.endDrag.bindAsEventListener(this);this.eventMouseMove=this.updateDrag.bindAsEventListener(this);this.eventKeypress=this.keyPress.bindAsEventListener(this);Event.observe(document,"mouseup",this.eventMouseUp);Event.observe(document,"mousemove",this.eventMouseMove);Event.observe(document,"keypress",this.eventKeypress)}this.drags.push(A)},unregister:function(A){this.drags=this.drags.reject(function(B){return B==A});if(this.drags.length==0){Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);Event.stopObserving(document,"keypress",this.eventKeypress)}},activate:function(A){if(A.options.delay){this._timeout=setTimeout(function(){Draggables._timeout=null;window.focus();Draggables.activeDraggable=A}.bind(this),A.options.delay)}else{try{window.focus()}catch(B){}this.activeDraggable=A}},deactivate:function(){this.activeDraggable=null},updateDrag:function(A){if(!this.activeDraggable){return }var B=[Event.pointerX(A),Event.pointerY(A)];if(this._lastPointer&&(this._lastPointer.inspect()==B.inspect())){return }this._lastPointer=B;this.activeDraggable.updateDrag(A,B)},endDrag:function(A){if(this._timeout){clearTimeout(this._timeout);this._timeout=null}if(!this.activeDraggable){return }this._lastPointer=null;this.activeDraggable.endDrag(A);this.activeDraggable=null},keyPress:function(A){if(this.activeDraggable){this.activeDraggable.keyPress(A)}},addObserver:function(A){this.observers.push(A);this._cacheObserverCallbacks()},removeObserver:function(A){this.observers=this.observers.reject(function(B){return B.element==A});this._cacheObserverCallbacks()},notify:function(B,A,C){if(this[B+"Count"]>0){this.observers.each(function(D){if(D[B]){D[B](B,A,C)}})}if(A.options[B]){A.options[B](A,C)}},_cacheObserverCallbacks:function(){["onStart","onEnd","onDrag"].each(function(A){Draggables[A+"Count"]=Draggables.observers.select(function(B){return B[A]}).length})}};var Draggable=Class.create({initialize:function(B){var C={handle:false,reverteffect:function(F,E,D){F.style.top=F.style.left=""},endeffect:function(E){var D=Object.isNumber(E._opacity)?E._opacity:1;E.setOpacity(1);Draggable._dragging[E]=false},zindex:1000,revert:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,snap:false,delay:0};if(!arguments[1]||Object.isUndefined(arguments[1].endeffect)){Object.extend(C,{starteffect:function(D){D._opacity=Element.getOpacity(D);Draggable._dragging[D]=true;D.setOpacity(0.9)}})}var A=Object.extend(C,arguments[1]||{});this.element=$(B);if(A.handle&&Object.isString(A.handle)){this.handle=this.element.down("."+A.handle,0)}if(!this.handle){this.handle=$(A.handle)}if(!this.handle){this.handle=this.element}if(A.scroll&&!A.scroll.scrollTo&&!A.scroll.outerHTML){A.scroll=$(A.scroll);this._isScrollChild=Element.childOf(this.element,A.scroll)}if(!A.proxy){Element.makePositioned(this.element)}this.options=A;this.dragging=false;this.eventMouseDown=this.initDrag.bindAsEventListener(this);Event.observe(this.handle,"mousedown",this.eventMouseDown);Draggables.register(this)},destroy:function(){Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);Draggables.unregister(this)},currentDelta:function(){return([parseInt(Element.getStyle(this.element,"left")||"0"),parseInt(Element.getStyle(this.element,"top")||"0")])},initDrag:function(A){if(!Object.isUndefined(Draggable._dragging[this.element])&&Draggable._dragging[this.element]){return }if(Event.isLeftClick(A)){var C=Event.element(A);if((tag_name=C.tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){return }var B=[Event.pointerX(A),Event.pointerY(A)];var D=Position.cumulativeOffset(this.element);this.offset=[0,1].map(function(E){return(B[E]-D[E])});Draggables.activate(this);Event.stop(A)}},startDrag:function(C){this.dragging=true;if(!this.delta&&!this.options.proxy){this.delta=this.currentDelta()}if(this.options.zindex){this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);this.element.style.zIndex=this.options.zindex}if(this.options.ghosting){this._clone=this.element.cloneNode(true);this.element._originallyAbsolute=(this.element.getStyle("position")=="absolute");if(!this.element._originallyAbsolute){Position.absolutize(this.element)}this.element.parentNode.insertBefore(this._clone,this.element)}if(this.options.proxy){this.oldElement=this.element;var B=new Element("div",{id:"proxy"}).setStyle({top:Event.pointerX(C)+"px",left:Event.pointerY(C)+"px",position:"absolute"}).addClassName("objectdragproxy");B=this.options.proxy(B,this.oldElement);document.body.appendChild(B);this.element=B}if(this.options.scroll){if(this.options.scroll==window){var A=this._getWindowScroll(this.options.scroll);this.originalScrollLeft=A.left;this.originalScrollTop=A.top}else{this.originalScrollLeft=this.options.scroll.scrollLeft;this.originalScrollTop=this.options.scroll.scrollTop}}Draggables.notify("onStart",this,C);if(this.options.starteffect){this.options.starteffect(this.element)}},updateDrag:function(event,pointer){if(!this.dragging){this.startDrag(event)}if(!this.options.quiet){Position.prepare();Droppables.show(pointer,this.element)}Draggables.notify("onDrag",this,event);this.draw(pointer);if(this.options.change){this.options.change(this)}if(this.options.scroll){this.stopScrolling();var p;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){p=[left,top,left+width,top+height]}}else{p=Position.page(this.options.scroll);p[0]+=this.options.scroll.scrollLeft+Position.deltaX;p[1]+=this.options.scroll.scrollTop+Position.deltaY;p.push(p[0]+this.options.scroll.offsetWidth);p.push(p[1]+this.options.scroll.offsetHeight)}var speed=[0,0];if(pointer[0]<(p[0]+this.options.scrollSensitivity)){speed[0]=pointer[0]-(p[0]+this.options.scrollSensitivity)}if(pointer[1]<(p[1]+this.options.scrollSensitivity)){speed[1]=pointer[1]-(p[1]+this.options.scrollSensitivity)}if(pointer[0]>(p[2]-this.options.scrollSensitivity)){speed[0]=pointer[0]-(p[2]-this.options.scrollSensitivity)}if(pointer[1]>(p[3]-this.options.scrollSensitivity)){speed[1]=pointer[1]-(p[3]-this.options.scrollSensitivity)}this.startScrolling(speed)}if(Prototype.Browser.WebKit){window.scrollBy(0,0)}Event.stop(event)},finishDrag:function(B,E){this.dragging=false;if(this.options.quiet){Position.prepare();var D=[Event.pointerX(B),Event.pointerY(B)];Droppables.show(D,this.element)}if(this.options.ghosting){if(!this.element._originallyAbsolute){Position.relativize(this.element)}else{delete this.element._originallyAbsolute}Element.remove(this._clone);this._clone=null}if(this.options.proxy){this.element.remove();this.element=this.oldElement}var F=false;if(E){F=Droppables.fire(B,this.element);if(!F){F=false}}if(F&&this.options.onDropped){this.options.onDropped(this.element)}Draggables.notify("onEnd",this,B);var A=this.options.revert;if(A&&Object.isFunction(A)){A=A(this.element)}if(!this.options.proxy){var C=this.currentDelta()}if(A&&this.options.reverteffect){if(F==0||A!="failure"){this.options.reverteffect(this.element,C[1]-this.delta[1],C[0]-this.delta[0])}}else{this.delta=C}if(this.options.zindex){this.element.style.zIndex=this.originalZ}if(this.options.endeffect){this.options.endeffect(this.element)}Draggables.deactivate(this);Droppables.reset()},keyPress:function(A){if(A.keyCode!=Event.KEY_ESC){return }this.finishDrag(A,false);Event.stop(A)},endDrag:function(A){if(!this.dragging){return }this.stopScrolling();this.finishDrag(A,true);Event.stop(A)},draw:function(A){if(!this.options.proxy){var F=Position.cumulativeOffset(this.element);var E=this.currentDelta();F[0]-=E[0];F[1]-=E[1]}if(this.options.ghosting){var C=Position.realOffset(this.element);F[0]+=C[0]-Position.deltaX;F[1]+=C[1]-Position.deltaY}if(this.options.scroll&&(this.options.scroll!=window&&this._isScrollChild)){F[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;F[1]-=this.options.scroll.scrollTop-this.originalScrollTop}if(!this.options.proxy){var D=[0,1].map(function(G){return(A[G]-F[G]-this.offset[G])}.bind(this))}else{var D=[A[0]+20,A[1]]}if(this.options.snap){if(Object.isFunction(this.options.snap)){D=this.options.snap(D[0],D[1],this)}else{if(Object.isArray(this.options.snap)){D=D.map(function(G,H){return(G/this.options.snap[H]).round()*this.options.snap[H]}.bind(this))}else{D=D.map(function(G){return(G/this.options.snap).round()*this.options.snap}.bind(this))}}}var B=this.element.style;if((!this.options.constraint)||(this.options.constraint=="horizontal")){B.left=D[0]+"px"}if((!this.options.constraint)||(this.options.constraint=="vertical")){B.top=D[1]+"px"}if(B.visibility=="hidden"){B.visibility=""}},stopScrolling:function(){if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;Draggables._lastScrollPointer=null}},startScrolling:function(A){if(!(A[0]||A[1])){return }this.scrollSpeed=[A[0]*this.options.scrollSpeed,A[1]*this.options.scrollSpeed];this.lastScrolled=new Date();this.scrollInterval=setInterval(this.scroll.bind(this),10)},scroll:function(){var current=new Date();var delta=current-this.lastScrolled;this.lastScrolled=current;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){if(this.scrollSpeed[0]||this.scrollSpeed[1]){var d=delta/1000;this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1])}}}else{this.options.scroll.scrollLeft+=this.scrollSpeed[0]*delta/1000;this.options.scroll.scrollTop+=this.scrollSpeed[1]*delta/1000}Position.prepare();Droppables.show(Draggables._lastPointer,this.element);Draggables.notify("onDrag",this);if(this._isScrollChild){Draggables._lastScrollPointer=Draggables._lastScrollPointer||$A(Draggables._lastPointer);Draggables._lastScrollPointer[0]+=this.scrollSpeed[0]*delta/1000;Draggables._lastScrollPointer[1]+=this.scrollSpeed[1]*delta/1000;if(Draggables._lastScrollPointer[0]<0){Draggables._lastScrollPointer[0]=0}if(Draggables._lastScrollPointer[1]<0){Draggables._lastScrollPointer[1]=0}this.draw(Draggables._lastScrollPointer)}if(this.options.change){this.options.change(this)}},_getWindowScroll:function(w){var T,L,W,H;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft}else{if(w.document.body){T=body.scrollTop;L=body.scrollLeft}}if(w.innerWidth){W=w.innerWidth;H=w.innerHeight}else{if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight}else{W=body.offsetWidth;H=body.offsetHeight}}}return{top:T,left:L,width:W,height:H}}});Draggable._dragging={};var SortableObserver=Class.create({initialize:function(B,A){this.element=$(B);this.observer=A;this.lastValue=Sortable.serialize(this.element)},onStart:function(){this.lastValue=Sortable.serialize(this.element)},onEnd:function(){Sortable.unmark();if(this.lastValue!=Sortable.serialize(this.element)){this.observer(this.element)}}});var Sortable={SERIALIZE_RULE:/^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,sortables:{},_findRootElement:function(A){while(A.tagName.toUpperCase()!="BODY"){if(A.id&&Sortable.sortables[A.id]){return A}A=A.parentNode}},options:function(A){A=Sortable._findRootElement($(A));if(!A){return }return Sortable.sortables[A.id]},destroy:function(A){var B=Sortable.options(A);if(B){Draggables.removeObserver(B.element);B.droppables.each(function(C){Droppables.remove(C)});B.draggables.invoke("destroy");delete Sortable.sortables[B.element.id]}},create:function(C){C=$(C);var B=Object.extend({element:C,tag:"li",dropOnEmpty:false,tree:false,treeTag:"ul",overlap:"vertical",constraint:"vertical",containment:C,handle:false,only:false,delay:0,hoverclass:null,ghosting:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,format:this.SERIALIZE_RULE,elements:false,handles:false,onChange:Prototype.emptyFunction,onUpdate:Prototype.emptyFunction},arguments[1]||{});this.destroy(C);var A={revert:true,quiet:B.quiet,scroll:B.scroll,scrollSpeed:B.scrollSpeed,scrollSensitivity:B.scrollSensitivity,delay:B.delay,ghosting:B.ghosting,constraint:B.constraint,handle:B.handle};if(B.starteffect){A.starteffect=B.starteffect}if(B.reverteffect){A.reverteffect=B.reverteffect}else{if(B.ghosting){A.reverteffect=function(F){F.style.top=0;F.style.left=0}}}if(B.endeffect){A.endeffect=B.endeffect}if(B.zindex){A.zindex=B.zindex}var D={overlap:B.overlap,containment:B.containment,tree:B.tree,hoverclass:B.hoverclass,onHover:Sortable.onHover};var E={onHover:Sortable.onEmptyHover,overlap:B.overlap,containment:B.containment,hoverclass:B.hoverclass};Element.cleanWhitespace(C);B.draggables=[];B.droppables=[];if(B.dropOnEmpty||B.tree){Droppables.add(C,E);B.droppables.push(C)}(B.elements||this.findElements(C,B)||[]).each(function(H,F){var G=B.handles?$(B.handles[F]):(B.handle?$(H).select("."+B.handle)[0]:H);B.draggables.push(new Draggable(H,Object.extend(A,{handle:G})));Droppables.add(H,D);if(B.tree){H.treeNode=C}B.droppables.push(H)});if(B.tree){(Sortable.findTreeElements(C,B)||[]).each(function(F){Droppables.add(F,E);F.treeNode=C;B.droppables.push(F)})}this.sortables[C.id]=B;Draggables.addObserver(new SortableObserver(C,B.onUpdate))},findElements:function(B,A){return Element.findChildren(B,A.only,A.tree?true:false,A.tag)},findTreeElements:function(B,A){return Element.findChildren(B,A.only,A.tree?true:false,A.treeTag)},onHover:function(E,D,A){if(Element.isParent(D,E)){return }if(A>0.33&&A<0.66&&Sortable.options(D).tree){return }else{if(A>0.5){Sortable.mark(D,"before");if(D.previousSibling!=E){var B=E.parentNode;E.style.visibility="hidden";D.parentNode.insertBefore(E,D);if(D.parentNode!=B){Sortable.options(B).onChange(E)}Sortable.options(D.parentNode).onChange(E)}}else{Sortable.mark(D,"after");var C=D.nextSibling||null;if(C!=E){var B=E.parentNode;E.style.visibility="hidden";D.parentNode.insertBefore(E,C);if(D.parentNode!=B){Sortable.options(B).onChange(E)}Sortable.options(D.parentNode).onChange(E)}}}},onEmptyHover:function(E,G,H){var I=E.parentNode;var A=Sortable.options(G);if(!Element.isParent(G,E)){var F;var C=Sortable.findElements(G,{tag:A.tag,only:A.only});var B=null;if(C){var D=Element.offsetSize(G,A.overlap)*(1-H);for(F=0;F<C.length;F+=1){if(D-Element.offsetSize(C[F],A.overlap)>=0){D-=Element.offsetSize(C[F],A.overlap)}else{if(D-(Element.offsetSize(C[F],A.overlap)/2)>=0){B=F+1<C.length?C[F+1]:null;break}else{B=C[F];break}}}}G.insertBefore(E,B);Sortable.options(I).onChange(E);A.onChange(E)}},unmark:function(){if(Sortable._marker){Sortable._marker.hide()}},mark:function(B,A){var D=Sortable.options(B.parentNode);if(D&&!D.ghosting){return }if(!Sortable._marker){Sortable._marker=($("dropmarker")||Element.extend(document.createElement("DIV"))).hide().addClassName("dropmarker").setStyle({position:"absolute"});document.getElementsByTagName("body").item(0).appendChild(Sortable._marker)}var C=Position.cumulativeOffset(B);Sortable._marker.setStyle({left:C[0]+"px",top:C[1]+"px"});if(A=="after"){if(D.overlap=="horizontal"){Sortable._marker.setStyle({left:(C[0]+B.clientWidth)+"px"})}else{Sortable._marker.setStyle({top:(C[1]+B.clientHeight)+"px"})}}Sortable._marker.show()},_tree:function(E,B,F){var D=Sortable.findElements(E,B)||[];for(var C=0;C<D.length;++C){var A=D[C].id.match(B.format);if(!A){continue}var G={id:encodeURIComponent(A?A[1]:null),element:E,parent:F,children:[],position:F.children.length,container:$(D[C]).down(B.treeTag)};if(G.container){this._tree(G.container,B,G)}F.children.push(G)}return F},tree:function(D){D=$(D);var C=this.options(D);var B=Object.extend({tag:C.tag,treeTag:C.treeTag,only:C.only,name:D.id,format:C.format},arguments[1]||{});var A={id:null,parent:null,children:[],container:D,position:0};return Sortable._tree(D,B,A)},_constructIndex:function(B){var A="";do{if(B.id){A="["+B.position+"]"+A}}while((B=B.parent)!=null);return A},sequence:function(B){B=$(B);var A=Object.extend(this.options(B),arguments[1]||{});return $(this.findElements(B,A)||[]).map(function(C){return C.id.match(A.format)?C.id.match(A.format)[1]:""})},setSequence:function(B,C){B=$(B);var A=Object.extend(this.options(B),arguments[2]||{});var D={};this.findElements(B,A).each(function(E){if(E.id.match(A.format)){D[E.id.match(A.format)[1]]=[E,E.parentNode]}E.parentNode.removeChild(E)});C.each(function(E){var F=D[E];if(F){F[1].appendChild(F[0]);delete D[E]}})},serialize:function(C){C=$(C);var B=Object.extend(Sortable.options(C),arguments[1]||{});var A=encodeURIComponent((arguments[1]&&arguments[1].name)?arguments[1].name:C.id);if(B.tree){return Sortable.tree(C,arguments[1]).children.map(function(D){return[A+Sortable._constructIndex(D)+"[id]="+encodeURIComponent(D.id)].concat(D.children.map(arguments.callee))}).flatten().join("&")}else{return Sortable.sequence(C,arguments[1]).map(function(D){return A+"[]="+encodeURIComponent(D)}).join("&")}}};Element.isParent=function(B,A){if(!B.parentNode||B==A){return false}if(B.parentNode==A){return true}return Element.isParent(B.parentNode,A)};Element.findChildren=function(D,B,A,C){if(!D.hasChildNodes()){return null}C=C.toUpperCase();if(B){B=[B].flatten()}var E=[];$A(D.childNodes).each(function(G){if(G.tagName&&G.tagName.toUpperCase()==C&&(!B||(Element.classNames(G).detect(function(H){return B.include(H)})))){E.push(G)}if(A){var F=Element.findChildren(G,B,A,C);if(F){E.push(F)}}});return(E.length>0?E.flatten():[])};Element.offsetSize=function(A,B){return A["offset"+((B=="vertical"||B=="height")?"Height":"Width")]};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:autosaveSuccess",this.autosaveSuccess.bind(this));document.observe("ui:autosaveFailure",this.autosaveFailure.bind(this));document.observe("ui:savepage",this.saveContent.bind(this))},saveContent:function(E){if(E){E.stop()}if(this.saveButton.hasClassName("disabled")){return }this.disableSave();this.setMsg("Saving "+PBwiki.getPageName().toString().escapeHTML()+"...",true);var D=[];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}D.push(["CreatePage",B,{onFailure:this.saveFail.bind(this),onSuccess:this.saveSuccess.bind(this),incUsess:true}])}var B={create_if_missing:true};B.page=PBwiki.getPageName();B.html=Page.AjaxEdit.getEditor().GetData(true);if(PBinfo.live_enabled){var C=/<span[^>]* class="pb_live_changes"[^>]*>(.*?)<\/span>/g;while(C.test(B.html)){B.html=B.html.replace(C,"$1")}}D.push(["PutPage",B,{onFailure:this.saveFail.bind(this),onSuccess:this.saveSuccess.bind(this),incUsess:true}]);D.push(["UnlockPage",{page:PBwiki.getPageName()},{onFailure:this.saveFail.bind(this)}]);if(this.initialTags!=this.tagfield.value){D.push(["SetPageTags",{page:PBwiki.getPageName(),tags:this.tagfield.value},{onFailure:this.saveFail.bind(this)}])}new PBwiki.MultiAPIRequest(D,{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);PBwiki.AutoComplete=function(){if($("input-search")){new PBwiki.Components.SearchAutoComplete({elm:$("input-search")})}};PBwiki.Components=PBwiki.Components||{};PBwiki.Components.AutoComplete=Class.create({initialize:function(B){this.KEY_ENTER=13;this.KEY_COMMA=188;this.options=B;this.elm=this.options.elm;this.container=new Element("div",{"class":"accontainer"});this.elm.insert({after:this.container});this.hide();this.acout=new Element("div",{id:"acout"});this.container.appendChild(this.acout);this.content=new Element("div",{"class":"content"});this.acout.appendChild(this.content);this.header=new Element("div",{"class":"header"});this.content.appendChild(this.header);this.ul=new Element("ul",{"class":"ul"});this.content.appendChild(this.ul);this.footer=new Element("div",{"class":"footer"});this.content.appendChild(this.footer);this.elm.observe("focus",this.addKeyListener.bind(this));this.elm.observe("blur",this.removeKeyListener.bind(this));this.elm.observe("blur",this.hide.bind(this));var A=this.elm.up("form");if(A){A.observe("submit",this.onSearch.bind(this))}this.ignoreBlur=false},keyDown:function(H){if(this.elm.value==""){this.hide();return }var G=H.keyCode||H.charCode;if(G==this.KEY_ENTER){this.onSearch(H)}if(G==this.KEY_COMMA&&this.onComma){this.onComma(H)}if(G==Event.KEY_DOWN||G==Event.KEY_UP||G==Event.KEY_TAB){var F=this.ul.down("li.active");if(F){F.removeClassName("active")}if(G==Event.KEY_UP){var A=(F)?F.previous():this.ul.lastChild;if(!A){A=this.ul.lastChild}}else{if(G==Event.KEY_DOWN||G==Event.KEY_TAB){var A=(F)?F.next():this.ul.down();if(!A){A=this.ul.down()}}}if(A){A.addClassName("active");if(this.maxHeight){var C=this.container.scrollTop;var E=C+this.container.clientHeight;var B=A.offsetTop;var D=A.offsetTop+A.clientHeight;if(E<D){this.container.scrollTop=D-this.container.clientHeight}else{if(C>B){this.container.scrollTop=B}}}}}else{this.keyPressed=this.drawAfterKeypress(this.elm.value);if(this.refreshTimer){clearTimeout(this.refreshTimer)}if(this.keyPressed){this.refreshTimer=setTimeout(this.doRefresh.bind(this),this.getRefreshTimeout())}}},doRefresh:function(){if(this.isLoading){return }this.isLoading=true;this.refreshTimer=null;this.drawLoading();var A=this.getFilterForAPICall();if(A){Object.extend(this.requestOptions,{filter:A})}this.filter=this.elm.value;this.request=new PBwiki.APIRequest(this.apiMethod,this.requestOptions,{onSuccess:function(B){this.isLoading=false;this.draw(this.elm.value,B)}.bind(this),onFailure:function(B){this.isLoading=false}.bind(this),method:"get",priority:PBwiki.Data.HIGH_PRIORITY,cacheability:this.apiCacheability})},drawLoading:function(){if(!this.shouldDisplayLoadingMessage()){return }var A=new Element("li").update("Loading...");this.ul.update("");this.ul.appendChild(A);this.show();this.footer.hide();if(this.content.clientHeight){this.container.style.height=this.content.clientHeight.toString()+"px"}else{if(this.content.scrollHeight){this.container.style.height=this.content.scrollHeight.toString()+"px"}}},addKeyListener:function(){if(!this.listener){this.listener=this.keyDown.bindAsEventListener(this);$(document).observe("keyup",this.listener)}var A=this.elm.getAttribute("ui:placeholder");if(this.elm.value===A){this.elm.clear();this.elm.focus()}},removeKeyListener:function(A){if(A&&A.type=="blur"&&this.ignoreBlur){return }if(this.listener){$(document).stopObserving("keyup",this.listener);this.listener=null}},show:function(){this.container.show();PBwiki.DialogFactory.trapEsc=false},hide:function(A){if(A&&A.type=="blur"&&this.ignoreBlur){return }this.container.hide();window.setTimeout(function(){PBwiki.DialogFactory.trapEsc=true},10)}});PBwiki.Components.SearchAutoComplete=Class.create(PBwiki.Components.AutoComplete,{apiMethod:"GetObjects",apiCacheability:["filetime","foldertime","page_list_time","permtime"],requestOptions:{sortby:"name",count:10,offset:0,verbose:true,detail:"partial"},onSearch:function(B){var A=this.ul.down("li.active");if(this.listener&&A){B.stop();window.location.href=A.down("a").getAttribute("href")}},draw:function(A,B){this.request=null;this.ul.update("");(B.objects.length==0)?this.ul.hide():this.ul.show();B.objects.each(function(G){var C=new Element("li",{"class":(G.type=="page")?"tbpage":"tbfile"});var F=Util.iconMap[Util.getFileExtension(G.name.toString())];var E=(G.type=="page")?"/"+Util.dashified_link(G.name.toString()):"/f/"+encodeURIComponent(G.name);C.observe("mousedown",function(H){H.stop();window.location=E});Util.addObjectTooltip(C,G);var D=new Element("a",{href:E});C.appendChild(D);D.appendChild(new Element("span").addClassName("fileicon").addClassName(F));D.appendChild(new Element("div").setStyle({overflow:"hidden"}).update(G.name.toString().escapeHTML()));this.ul.appendChild(C)}.bind(this));if(B._total_count>10){this.footer.update("... and "+B._total_count+" more");this.footer.show()}else{this.footer.hide()}if(A!=this.elm.value&&!this.refreshTimer){this.refreshTimer=setTimeout(this.doRefresh.bind(this),10)}this.lastTxt=A;this.show()},drawAfterKeypress:function(A){this.header.update("");var C="/FindPage?SearchFor="+encodeURIComponent(this.elm.value);var B=new Element("a",{href:C}).update("or look in page content for: "+this.elm.value.escapeHTML()).observe("mousedown",function(D){D.stop();window.location=C});this.header.appendChild(B);this.header.show();return true},getFilterForAPICall:function(){return this.elm.value},getRefreshTimeout:function(){this.hasData=PBwiki.Data.getInstance("DOMObjectListNonVerbose").hasData();return(this.hasData)?10:200},shouldDisplayLoadingMessage:function(){return false}});PBwiki.Components.UserAutoComplete=Class.create(PBwiki.Components.AutoComplete,{apiCacheability:["permtime"],dataLoaded:false,maxHeight:200,ignoreUids:[],initialize:function(A){PBwiki.Components.AutoComplete.prototype.initialize.call(this,A);if(navigator&&navigator.userAgent.indexOf("Firefox/2")>-1){this.container.style.position="relative"}if(A.ignoreUids){this.ignoreUids=A.ignoreUids}this.apiMethod=A.apiMethod;this.requestOptions=A.requestOptions;this.serverSideFiltering=(PBinfo.CurrentWiki&&PBinfo.CurrentWiki.usercount>100);this.selectedUserList=new PBwiki.Components.UserAutoComplete.SelectedUserList(this,A.userList);this.userListContainer=A.userListContainer;this.elm.observe("blur",this.addSelectedUser.bind(this));this.container.observe("mousedown",this.mouseDown.bind(this))},mouseDown:function(A){this.ignoreBlur=true;window.setTimeout(function(){this.ignoreBlur=false;this.elm.focus()}.bind(this),10);return },onSearch:function(C){C.stop();var B=this.ul.down("li.active");if(B){var A={uid:B.getAttribute("user:uid"),name:B.getAttribute("user:name"),email:B.getAttribute("user:email"),is_classroom_account:B.getAttribute("user:is_classroom_account")};this.click(A)}},addSelectedUser:function(D){if(D&&D.type=="blur"&&this.ignoreBlur){return }var C=this.ul.down("li.active");if(C){var A={uid:C.getAttribute("user:uid"),name:C.getAttribute("user:name"),email:C.getAttribute("user:email"),is_classroom_account:C.getAttribute("user:is_classroom_account")};var B=new PBwiki.Components.UserAutoComplete.SelectedUser(this,A);Util.executeUnlessEsc(function(E){this.selectedUserList.append(E)}.bind(this,B));this.hide();C.removeClassName("active")}this.elm.value=""},draw:function(A,C){this.request=null;if(!this.serverSideFiltering){this.dataLoaded=true}if(A.blank()){PBwiki.info("text is now blank, ignoring.");this.lastTxt="";this.hide();return }this.header.hide();this.ul.update("");var B=this.filterUsers(C.users,A);var B=this.setNames(B);B.sort(this.compareUsers.bind(this));B.each(this.userToElement.bind(this));selectedElm=this.ul.down("li");if(selectedElm){selectedElm.addClassName("active")}this.footer.hide();(B.length==0)?this.hide():this.show();this.container.scrollTop=0;this.resizePopover();this.lastTxt=A;if(A!=this.elm.value&&!this.refreshTimer){this.refreshTimer=setTimeout(this.doRefresh.bind(this),10)}},setNames:function(B){for(var A=0;A<B.length;A++){if(B[A].name.empty()&&!B[A].email.empty()){B[A].name=B[A].email}}return B},compareUsers:function(B,A){B=this.userToString(B).toLowerCase();A=this.userToString(A).toLowerCase();if(B==A){return 0}else{if(B<A){return -1}else{return 1}}},filterUsers:function(C,A){var B=A.toLowerCase().split(/\s+/);if(this.options.filter){C=C.filter(this.options.filter)}return C.filter(function(I){if(this.selectedUserList.contains(I.uid)){return false}if(this.ignoreUids.indexOf(I.uid)!=-1){return false}if(I.is_classroom_account){return false}var D=(I.name||"").toLowerCase();var K=(I.email||"").toLowerCase();var L=this.tokenize(D).concat(this.tokenize(K));for(var J=0;J<B.length;J++){var E=B[J];if(E.length==0){continue}var F=false;for(var H=0;H<L.length;H++){var G=L[H];if(G.startsWith(E)){F=true;break}}if(!F){return false}}return true}.bind(this))},tokenize:function(A){return A.split(/[^A-Za-z0-9]/).without("")},userToString:function(A){var B=A.name.toString();if(A.email&&!A.email.empty()&&A.email!=A.name){B+=" <"+A.email+">"}return B},userToElement:function(C){var A=new Element("li");A.setAttribute("user:uid",C.uid||"");A.setAttribute("user:name",C.name||"");A.setAttribute("user:email",C.email||"");A.setAttribute("user:is_classroom_account",C.is_classroom_account||false);A.observe("mousedown",function(E){E.stop();this.click(C)}.bind(this));var B=new Element("a",{href:"#"});A.appendChild(B);var D=new Element("span").addClassName("iconbutton").addClassName("usericon");D.appendChild(document.createTextNode(this.userToString(C)));B.appendChild(D);this.ul.appendChild(A)},click:function(A){var B=new PBwiki.Components.UserAutoComplete.SelectedUser(this,A);this.selectedUserList.append(B);this.hide();this.ul.update("");this.elm.value="";this.setFocus()},onComma:function(C){C.stop();var B=this.ul.down("li.active");if(B){var A={uid:B.getAttribute("user:uid"),name:B.getAttribute("user:name"),email:B.getAttribute("user:email"),is_classroom_account:B.getAttribute("user:is_classroom_account")};this.click(A)}else{this.elm.value=""}},setFocus:function(){setTimeout(function(){this.elm.focus()}.bind(this),10)},resizePopover:function(){var A;if(this.container.clientHeight){A=this.header.clientHeight+this.ul.clientHeight+this.footer.clientHeight}if(this.container.scrollHeight){A=this.header.scrollHeight+this.ul.scrollHeight+this.footer.scrollHeight}this.container.style.overflowX="hidden";this.container.style.overflowY=(A>this.maxHeight)?"scroll":"hidden";A=Math.min(A,this.maxHeight).toString()+"px";this.container.style.height=A;this.container.style.maxHeight=A},resizeTextField:function(){var E=0;var C=this.textFieldMinWidth();var F=this.userListContainer.getWidth()-15;var D=F-E;this.elm.style.width=C.toString()+"px";var A=this.elm.offsetLeft-this.userListContainer.offsetLeft;var B;if(A+C>D){B=D}else{B=D-A}this.elm.style.width=B.toString()+"px"},textFieldMinWidth:function(){var D=10;var B=4;if(this.elm.value.blank()){return D}var A=new Element("span");A.setStyle({position:"absolute",top:0,left:0,whiteSpace:"nowrap",visibility:"hidden"});A.appendChild(document.createTextNode(this.elm.value));document.body.appendChild(A);var C=A.offsetWidth;document.body.removeChild(A);return Math.max(D,C+B)},drawAfterKeypress:function(A){if(this.elm.value.blank()){PBwiki.info("Input is empty, ignoring.");this.hide();return false}else{if(this.ul.childNodes==0){this.hide()}}this.resizeTextField();this.setFocus();return true},getFilterForAPICall:function(){return this.serverSideFiltering?this.elm.value:null},getRefreshTimeout:function(){return this.serverSideFiltering?200:10},shouldDisplayLoadingMessage:function(){if(this.serverSideFiltering){return true}else{return !this.dataLoaded}}});PBwiki.Components.UserAutoComplete.SelectedUserList=Class.create();Object.extend(PBwiki.Components.UserAutoComplete.SelectedUserList.prototype,Enumerable);Object.extend(PBwiki.Components.UserAutoComplete.SelectedUserList.prototype,{initialize:function(A,B){this.map=new Object();this.arr=new Array();this.autoComplete=A;this.elm=B;this.placeholderText=this.autoComplete.elm.attributes["ui:placeholder"].value},clear:function(){while(user=this.arr.pop()){delete this.map[user.uid]}this.draw()},empty:function(){return(this.arr.length===0)},_toString:function(){var A="";for(var C=0;C<this.arr.length;C++){var B=this.arr[C];A+=B.uid+","}A=A.substring(0,A.length-1);return A},contains:function(A){return !!this.map[A]},append:function(B){if(this.map[B.uid]){this.remove(B.uid)}var A=new PBwiki.Components.UserAutoComplete.SelectedUser(this,B);this.map[B.uid]=A;this.arr.push(A);this.draw()},remove:function(A){if(this.map[A]){this.arr=this.arr.without(this.map[A]);delete this.map[A];this.draw()}},draw:function(){this.elm.update("");for(var A=0;A<this.arr.length;A++){this.elm.appendChild(this.arr[A].toElement());this.elm.appendChild(document.createTextNode(" "))}this.autoComplete.resizeTextField();this.updatePlaceholder()},updatePlaceholder:function(){if(this.arr.length>0){this.autoComplete.elm.attributes["ui:placeholder"].value=""}else{this.autoComplete.elm.attributes["ui:placeholder"].value=this.placeholderText}},_each:function(A){this.arr.each(A)}});PBwiki.Components.UserAutoComplete.SelectedUser=Class.create({initialize:function(A,B){this.userList=A;this.uid=B.uid||"";this.name=B.name||"";this.email=B.email||"";this.is_classroom_account=B.is_classroom_account||false},toElement:function(){var B=new Element("span").addClassName("iconbutton").addClassName("usericon").addClassName("acuser");B.id="user-"+this.uid.toString();B.appendChild(document.createTextNode(this.name.toString()+" "));var A=new Element("a").update("&nbsp;");A.href="";A.observe("click",this.clickRemove.bind(this));B.appendChild(A);return B},clickRemove:function(A){A.stop();this.userList.remove(this.uid);this.userList.autoComplete.setFocus()}});PBwiki.init(PBwiki.AutoComplete);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:autosaveSuccess",this.autosaveSuccess.bind(this));document.observe("ui:autosaveFailure",this.autosaveFailure.bind(this));document.observe("ui:savepage",this.saveContent.bind(this))},saveContent:function(E){if(E){E.stop()}if(this.saveButton.hasClassName("disabled")){return }this.disableSave();this.setMsg("Saving "+PBwiki.getPageName().toString().escapeHTML()+"...",true);var D=[];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}D.push(["CreatePage",B,{onFailure:this.saveFail.bind(this),onSuccess:this.saveSuccess.bind(this),incUsess:true}])}var B={create_if_missing:true};B.page=PBwiki.getPageName();B.html=Page.AjaxEdit.getEditor().GetData(true);if(PBinfo.live_enabled){var C=/<span[^>]* class="pb_live_changes"[^>]*>(.*?)<\/span>/g;while(C.test(B.html)){B.html=B.html.replace(C,"$1")}}D.push(["PutPage",B,{onFailure:this.saveFail.bind(this),onSuccess:this.saveSuccess.bind(this),incUsess:true}]);D.push(["UnlockPage",{page:PBwiki.getPageName()},{onFailure:this.saveFail.bind(this)}]);if(this.initialTags!=this.tagfield.value){D.push(["SetPageTags",{page:PBwiki.getPageName(),tags:this.tagfield.value},{onFailure:this.saveFail.bind(this)}])}new PBwiki.MultiAPIRequest(D,{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){this.element=$(A);if(!this.element){return }this.link=this.element.down("a");PBwiki.debug(this.link);this.link.observe("click",this.linkOnclick.bind(this));if(window.location.hash=="#send-a-link"){window.location.hash="";this.linkOnclick(null)}},linkOnclick:function(A){new PBwiki.DialogCommands.SendALink({dimensions:{width:510,height:"auto"}});if(A){A.stop()}}});PBwiki.init(SendALink,"sendalink");PBwiki.DialogCommands.SendALink=Class.create(PBwiki.DialogCommands.TemplateDialog,{templateName:"sendalink",title:"Send a link",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={page:PBinfo.CurrentPage.page,to_uids:this.userList._toString()};if(!this.message.value.blank()){B.message=this.message.value.strip()}new PBwiki.APIRequest("SendALink",{},{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. "+err,mode:"error"})}.bind(this)});return true},setupInstructions:function(){if(PBinfo.CurrentNetwork){$("sendalink-workspace-instructions").hide();$("sendalink-network-instructions").show()}else{$("sendalink-workspace-instructions").show();$("sendalink-network-instructions").hide()}},setupUserList:function(){var A=$("sendalink_to");if(A){new InputText(A);this.userAutoComplete=new PBwiki.Components.UserAutoComplete({userListContainer:$("sendalink_to_container"),userList:$("sendalink_to_list"),elm:A,apiMethod:"GetPageUsers",requestOptions:{page:PBinfo.CurrentPage.page}});this.userList=this.userAutoComplete.selectedUserList}},setupStar:function(){if(!PBinfo.GetFeatures.stars){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)})}.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(!$("network-bar")){return }if($$("a.search-btn").length===0){return }if(!$("toolbar-search-left")||!$("toolbar-search-right")){return }var A=$$("a.search-btn")[0];A.observe("click",function(B){B.stop();$("toolbar-search").style.display="inline";$("user-bar").style.display="none";$("toolbar_q").focus()});$("toolbar-search-left").observe("click",function(B){B.stop();$("toolbar-search").style.display="none";$("user-bar").style.display="inline"});$("toolbar-search-right").observe("click",function(B){B.stop()})});PBwiki.PerfMon={initialize:function(){if(typeof PBperf!="undefined"){Event.observe(document,"pbwiki:init",this.initHandler.bindAsEventListener(this));Event.observe(window,"load",this.loadHandler.bindAsEventListener(this));Event.observe(window,"beforeunload",this.unloadHandler.bindAsEventListener(this));this.load_complete=false;this.init_complete=false}},initHandler:function(B){if(typeof PBperf=="undefined"){Cookie.set(PBconst.kPerfmonCookie,"",0);Cookie.set("pb_unload_time","",0)}else{this.notes=PBperf;var A=Cookie.get("pb_unload_time");if(A.length>0){this.notes.ts_c_req_st=A;Cookie.set("pb_unload_time","",0)}this.init_complete=true;this.addTimestamp("ts_c_init_fin")}},loadHandler:function(A){this.load_complete=true;this.addTimestamp("ts_c_load_fin")},addTimestamp:function(A){if(typeof PBperf!="undefined"){if(this.init_complete){this.notes[A]=new Date().getTime().toString();if(this.load_complete){Cookie.set(PBconst.kPerfmonCookie,Object.toJSON(this.notes),(1/24))}}}},unloadHandler:function(A){Cookie.set("pb_unload_time",new Date().getTime().toString(),(1/1440))}};PBwiki.init(function(){PBwiki.PerfMon.initialize()});PBwiki.Views={validViews:{page:true,loading:true},initialize:function(){if(PBinfo.CurrentPage&&PBinfo.CurrentPage.editor_v3){if(PBinfo.CurrentPage.noStatics){this.validViews.edit=this.validViews.newpage=PBconst.kStaticDebugDirectory+"debug.php?manifest=editor.js&rand"+Math.random()}else{this.validViews.edit=this.validViews.newpage="/shared/statics/editor.js"}}this.initialView=this.getDefaultView();if(!this.initialView){return }this.historyManager=PBwiki.History;this.historyManager.getKey("view").observe("onChange",this.checkView.bind(this));this.historyManager.start();var A=this.getHistoryKey();if(this.isValidView(A)){this.initialView=A}this.selectView(this.initialView);document.observe("ui:changeview",function(C){if(Object.isString(C.memo)){this.selectView(C.memo)}else{var B=C.memo.view;delete C.memo.view;this.selectView(B,C.memo)}}.bind(this));if($("view-tab")&&PBinfo.CurrentPage&&PBinfo.CurrentPage.editor_v3){$("view-tab").observe("click",this.tabClick.bindAsEventListener(this,"page"));$("edit-tab").observe("click",this.tabClick.bindAsEventListener(this,"edit"))}},getDefaultView:function(){if(this.defaultView){return this.defaultView}var A=false;for(var B=0;B<this.findDefaultViewChecks.length;B++){A=this.findDefaultViewChecks[B]();if(A){break}}this.defaultView=A;return A},findDefaultViewChecks:[function(){if(PBinfo.CurrentPage&&PBinfo.CurrentPage.editor_v3&&$("view-tab")&&$("edit-tab")&&$("edit-toolbar")&&!$("wikicontent")){return"newpage"}},function(){if($("view-tab")&&$("wikicontent")){return"page"}}],tabClick:function(C,B){if(C){C.stop();try{C.element().blur()}catch(A){}}PBwiki.info("TAB CLICK = "+B);this.selectView(B)},checkView:function(B){var A=B||this.getHistoryKey();if(!this.isValidView(A)||A==this.currentView){return }this.selectView(A,this.historyManager.getItems())},selectView:function(A,B){if(this.currentView==A||!this.isValidView(A)){return false}if(PBwiki.Views[A]){if(!this.switchView(A,B)){return false}return true}else{PBwiki.info("LOADING "+A);if(!this.switchView("loading",{view:A})){return false}this.loadView(A,function(){PBwiki.info("LOADED "+A);this.switchView(A,B)}.bind(this))}},loadView:function(B,A){if(PBwiki.Views[B]){A()}else{PBwiki.ResourceLoader.load(this.validViews[B],A)}},isValidView:function(A){return !!this.validViews[A]},setHistoryKey:function(A){if(!this.historyManager||A=="loading"){return false}var B=this.getHistoryKey();if(!B&&A==this.getDefaultView()){return false}if(B==A){return false}this.historyManager.setItems({view:A})},getHistoryKey:function(){var A;if(this.historyManager){A=this.historyManager.getKey("view").getValue()}if(!(PBinfo.CurrentPage&&PBinfo.CurrentPage.editor_v3)&&A=="edit"){return"page"}return A},switchView:function(A,B){PBwiki.info("SWITCH VIEW = "+A);if(this.view){var C=this.view.destroy();if(!C){return false}}delete this.view;delete PBwiki.currentView;this.view=PBwiki.currentView=new PBwiki.Views[A](B);this.currentView=A;this.setHistoryKey(A);return true}};PBwiki.Views.base=Class.create({chromeVisibility:false,setChromeVisibility:function(A){if(A==(!$("wikicontent")||$("wikicontent").style.display=="none")){return }if($("wikicontent")){($("wikiedit").style.display=(A)?"block":"none");((!A)?$("wikicontent").show():$("wikicontent").hide());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";$("page-footer").setStyle({marginBottom:(A)?"4px":"9px"});if(A){UserPrefs.Manager.saveWidth();UserPrefs.Manager.goFullWidth()}else{UserPrefs.Manager.restoreWidth()}if(A){this.resizeChromeHeight()}else{$("page-col-2").setStyle({height:""})}if(!Prototype.Browser.IE){document.documentElement.style.overflowY=(A)?"auto":"scroll"}},setLockInfo:function(A){if(!A||A.page!=PBwiki.getPageName()){return }var B;if(A.owner==PBwiki.getUID()){B="";liveView=false}else{if(A["private"]&&!$("read-only")){B='<div class="edit-warning"><div class="content">';B+='This page is being edited by <a owner="'+A.owner+'" href="/user/'+A.owner+'">'+A.editname.escapeHTML()+"</a>. ";B+='<a class="edit-warning" href="#view=edit">Steal lock</a></div></div>';liveView=false}else{if(!A["private"]){B=this.getPublicLockInfoHTML(A)}}}$("lockinfo").update(B);if($("read-only")){(B)?$("read-only").hide():$("read-only").show()}if($("edit-tab")&&A.owner!=PBwiki.getUID()){$("edit-tab").addClassName("steal")}if(PBinfo.GetPage){PBinfo.GetPage.lockinfo=A}},removeLockInfo:function(){$("lockinfo").update("");if($("edit-tab")){$("edit-tab").removeClassName("steal")}if($("read-only")){$("read-only").show()}PBinfo.GetPage.lockinfo=false},getPublicLockInfoHTML:function(A){lContent='<div class="edit-warning"><div class="content">';lContent+='This page is being edited by <a owner="'+A.owner+'" href="/user/'+A.owner+'">'+A.editname.escapeHTML()+"</a> &nbsp;";lContent+='<strong><a id="live_edit_view" class="edit-warning" draft_id="'+A.draft_id+'" href="#view=liveview">see the changes live</a></strong>';lContent+="</div></div>";return lContent},resizeChromeHeight:function(){$("page-col-2").setStyle({height:this.getChromeHeight()+"px"});if(Prototype.Browser.IE){$("saveButton").setStyle({display:"none"});$("saveButton").setStyle({display:"block"})}},getChromeHeight:function(){return document.documentElement.clientHeight-this.getControlHeight()},getControlHeight:function(){var A=$("page-col-2").cumulativeOffset()[1];A+=$("page-footer").getHeight()+parseInt($("page-footer").getStyle("marginBottom"),10);if($("notifications")&&$("notifications").style.display!="none"){A-=$("notifications").getHeight()}return A},getEditHeight:function(){return Math.max(310,this.getChromeHeight()-$("edit-toolbar-outer").getHeight()-45)},setEditLoading:function(A){if(A){$("editframe").show().addClassName("loading").setStyle({height:this.getEditHeight()+"px"})}else{$("editframe").removeClassName("loading")}},setActiveTab:function(A){((A=="view")?$("view-tab").addClassName("active"):$("view-tab").removeClassName("active"));((A=="edit")?$("edit-tab").addClassName("active"):$("edit-tab").removeClassName("active"))}});PBwiki.Views.page=Class.create(PBwiki.Views.base,{initialize:function(){if($("edit-tab")&&(PBinfo.CurrentPage&&PBinfo.CurrentPage.editor_v3)){this.setActiveTab("view");this.setChromeVisibility(false)}this.lockInfoHandler=this.onLockInfo.bindAsEventListener(this);this.unlockHandler=this.onUnlock.bindAsEventListener(this);this.saveHandler=this.onPageSave.bindAsEventListener(this);document.observe("live:locked",this.lockInfoHandler);document.observe("live:unlocked",this.unlockHandler);document.observe("live:mod",this.saveHandler);this.wikipage=$("wikipage-inner");if(PBinfo.GetPage&&PBinfo.GetPage.lockinfo){this.setLockInfo(this.getLockInfo())}},onLockInfo:function(B){var A=B.memo;if(!A.page||A.page!=PBwiki.getPageName()){return }this.setLockInfo(A);if(PBwiki.Views.currentView=="liveview"&&A["private"]){document.fire("ui:changeview","page")}},onUnlock:function(B){PBwiki.info("GOT UNLOCKED");PBwiki.info(B);var A=B.memo;if(!A.page||A.page!=PBwiki.getPageName()){return }if(A&&A.owner!=PBwiki.getUID()){document.fire("ui:onNotifyUser",{mode:"success",message:"<strong>"+(A.editname||A.editemail).escapeHTML()+"</strong> stopped editing this page"})}this.removeLockInfo()},onPageSave:function(A){if(A.memo.title!=PBwiki.getPageName()||A.memo.user.uid==PBwiki.getUID()){return }document.fire("ui:onNotifyUser",{mode:"success",message:"<strong>"+Util.getAuthorNameFromObject(A.memo.user)+"</strong> saved the page"})},setPageContent:function(A){this.wikipage.innerHTML=A},getPageContent:function(){return this.wikipage.innerHTML},getLockInfo:function(){if(PBinfo.GetPage.lockinfo){return PBinfo.GetPage.lockinfo}else{var A=this.lockInfoFromPage();PBinfo.GetPage.lockinfo=A;return A}},lockInfoFromPage:function(){if(!$("lockinfo")){return false}var A=$("lockinfo").down("a");if(!A){return false}return{editname:A.innerHTML.unescapeHTML(),draft_id:$("live_edit_view")?$("live_edit_view").getAttribute("draft_id"):"",owner:A.getAttribute("owner"),page:PBwiki.getPageName()}},reload:function(){var A=new PBwiki.APIRequest("GetPage",{page:PBwiki.getPageName()},{onSuccess:function(B){this.setPageContent(B.html)}.bind(this)})},destroy:function(){document.stopObserving("live:locked",this.lockInfoHandler);document.stopObserving("live:unlocked",this.unlockHandler);document.stopObserving("live:mod",this.saveHandler);return true}});PBwiki.Views.loading=Class.create(PBwiki.Views.base,{initialize:function(A){if(A.view=="edit"||A.view=="newpage"){this.setActiveTab("edit");if($("notification-autosave")){Page.Notifications.findNotification($("notification-autosave")).remove()}this.setChromeVisibility(true);this.setEditLoading(true);this.resizeChromeHeight()}},destroy:function(){return true}});PBwiki.init(PBwiki.Views.initialize.bind(PBwiki.Views));PBwiki.Dashboard={};PBwiki.Profile={};PBwiki.ActivityStream=Class.create({apiMethod:"GetNetworkChanges",apiOpts:{},apiCacheability:["pagetime","filetime","permtime","foldertime","commenttime","userupdatetime","milestonetime","followtime"],maxEffectLoadCount:5,iconSize:48,itemsSeen:[],initialize:function(A){this.elm=A;if(this.moreActivityId){this.moreActivity=$(this.moreActivityId)}if(this.moreActivityLinkId){this.moreActivityLink=$(this.moreActivityLinkId)}if(this.noActivityId){this.noActivity=$(this.noActivityId)}if(this.moreActivityLink){this.moreActivityLink.observe("click",function(C){try{C.element.blur()}catch(B){}C.stop();this.loadMore()}.bind(this))}document.observe("ui:refreshactivity",this.refresh.bind(this));document.observe("ui:newactivity",this.loadNew.bind(this))},destroy:function(){if(this.moreActivityLink){this.moreActivityLink.stopObserving("click")}document.stopObserving("ui:refreshactivity")},refresh:function(){if(!this.loadingTimeout){this.loadingTimeout=setTimeout(this.setLoadingMsg.bind(this),300)}delete this.lastResult;if(this.requiredAPIOpts){Object.extend(this.apiOpts,this.requiredAPIOpts)}(new PBwiki.APIRequest(this.apiMethod,this.apiOpts,{cacheability:this.apiCacheability,onSuccess:function(A){if(this.loadingTimeout){clearTimeout(this.loadingTimeout);delete this.loadingTimeout}this.updateDisplay(A);this.lastResult=A;this.lastTimes=Object.clone(PBinfo.GetTimes)}.bind(this),onFailure:function(A){PBwiki.info(A);if(this.loadingTimeout){clearTimeout(this.loadingTimeout);delete this.loadingTimeout}this.elm.update(A)}.bind(this)}))},setLoadingMsg:function(){if(this.moreActivity){this.moreActivity.hide()}if(this.noActivity){this.noActivity.hide()}this.elm.update('<li class="loading">&nbsp;</li>')},loadMore:function(){if(this.isLoading){return }this.isLoading=true;this.apiOpts.count=(this.apiOpts.count||0)+(this.displayCount*2);this.elm.appendChild(new Element("li",{"class":"loading"}));if(this.moreActivity){this.moreActivity.hide()}(new PBwiki.APIRequest(this.apiMethod,this.apiOpts,{cacheability:this.apiCacheability,onSuccess:function(A){this.updateDisplay(A,this.apiOpts.count-1);this.lastResult=A;this.lastTimes=Object.clone(PBinfo.GetTimes);this.isLoading=false}.bind(this),onFailure:function(A){alert(A)}}))},hasPotentialChangesSince:function(C){if(this.apiMethod=="GetUpdates"&&C.userupdatetime==this.lastTimes.userupdatetime){return false}var B=this.apiCacheability;var A=false;B.each(function(D){if(parseInt(PBinfo.GetTimes[D],10)!=parseInt(this.lastTimes[D],10)){A=true}},this);return A},loadNew:function(B){if(!this.lastResult||!this.lastResult.changes||!this.lastResult.changes[0]){return this.refresh()}var A=Object.clone(this.apiOpts);if(this.lastResult&&this.lastResult.changes&&this.lastResult.changes[0]){A.after=this.lastResult.changes[0]["time"]}(new PBwiki.APIRequest(this.apiMethod,A,{cacheability:this.apiCacheability,onSuccess:function(C){if(C.updates&&!C.changes){C.changes=C.updates}var D=0;C.changes.each(function(E){if(this.getActivityRowHTML(E)!=this.getActivityRowHTML(this.lastResult.changes[0])){D++}else{throw $break}},this);if(D==0){return }this.lastResult.changes=[].concat(C.changes.slice(0,D),this.lastResult.changes);this.lastTimes=Object.clone(PBinfo.GetTimes);this.lastNewCount+=D;if(B){if(this.lastNewCount<=this.maxEffectLoadCount){this.prependChanges(this.lastResult,this.lastNewCount,this.apiOpts.count-1)}else{this.showRefreshDisplay(this.lastNewCount)}}else{this.showRefreshDisplay(this.lastNewCount)}}.bind(this)}))},showLatestResult:function(){if(this.lastNewCount<=this.maxEffectLoadCount){this.prependChanges(this.lastResult,this.lastNewCount,this.apiOpts.count-1)}else{this.updateDisplay(this.lastResult,this.apiOpts.count-1)}},showRefreshDisplay:function(A){$$("p.dashboard-bc-refresh").each(function(C){var B=new Element("a",{href:"#"}).observe("click",function(D){D.stop();this.showLatestResult()}.bind(this)).update("Show "+A+" new item"+(A>1?"s":""));if(C.firstChild){C.removeChild(C.firstChild)}C.appendChild(B);C.show()},this)},contains:function(A){return this.itemsSeen.indexOf(A.hash)>-1},prependChanges:function(F,H,B){var A=new Element("div");var E=(typeof Effect!="undefined");var G=0;for(var D=0;D<H;D++){if(!this.contains(F.changes[D])){A.innerHTML+=this.getActivityRowHTML(F.changes[D]);this.itemsSeen.push(F.changes[D].hash);G++}}for(var D=A.childNodes.length-1;D>=0;D--){if(E){$(A.childNodes[D]).hide()}this.elm.insertBefore(A.childNodes[D],this.elm.firstChild);if(E){Effect.Appear(this.elm.firstChild)}}var C=false;while(this.elm.childNodes.length>B){$(this.elm.childNodes[this.elm.childNodes.length-1]).remove();C=true}this.lastNewCount=0;$$("p.dashboard-bc-refresh").invoke("hide");if(this.moreActivity){this.moreActivity.style.visibility=(C)?"visible":"hidden";((C)?this.moreActivity.show():this.moreActivity.hide())}Tooltips.addLinkTooltips(this.elm);return G},updateDisplay:function(E,A){var D="";var C=0;var B=false;if(E.updates&&!E.changes){E.changes=E.updates}if(E.changes.last()){E.changes.last().className="last"}var F=E.changes.collect(function(G){if(C==(A||this.displayCount)){B=true;throw $break}C++;return this.getActivityRowHTML(G)},this);this.elm.innerHTML=F.join("");this.itemsSeen=E.changes.collect(function(G){return G.hash});if(this.noActivity){this.noActivity.style.display=(F.length==0)?"block":"none"}this.lastCount=C;this.lastNewCount=0;$$("p.dashboard-bc-refresh").invoke("hide");if(this.moreActivity){this.moreActivity.style.visibility=(B)?"visible":"hidden";((B)?this.moreActivity.show():this.moreActivity.hide())}Tooltips.addLinkTooltips(this.elm);if(this.onUpdate){this.onUpdate(F)}return B},refreshTimes:function(){this.elm.select("span.activity-ago-time").each(function(A){A.innerHTML=Util.time_ago(PBwiki.getTimestamp()-A.getAttribute("time"))+" ago"})},getActivityRowHTML:function(A){if(!this.template){this.template=new Template(this.activityRowTemplate)}if(A.user){A.userLink=Util.getAuthorNameFromObject(A.user).escapeHTML()}if(A.title){A.escapedTitle=A.title.toString().escapeTruncate()}if(this.apiOpts.wiki_filter&&!A.wiki){A.wiki=this.apiOpts.wiki_filter}if(A.user.image&&A.user.image.indexOf("http://")===0){A.user.image="https://"+A.user.image.substring(7)}A.userImage='<img src="'+(A.user.image||"/uimg/bread.png")+'" alt="activity-thumb" width="'+this.iconSize+'" height="'+this.iconSize+'"/>';if(A.time){A.ago=Util.time_ago(PBwiki.getTimestamp()-A.time)+" ago";A.datestring=new Date(A.time*1000).toString()}if(A.op_word){A.opTitle=(A.type=="task"||A.type=="milestone")?A.op_word+" "+A.type:A.op_word}if(A.type=="userupdate"){A.typetext="Status update"}else{A.typetext=A.type.capitalize()}if(A.type=="userupdate"&&A.data){A.status=" "+this.escapedChangeTxt(A.data);A.opTitle=""}else{if(A.op=="mv"||A.op=="mvf"){A.opTitle="renamed '"+A.title.toString().escapeTruncate()+"' to ";A.escapedTitle=A.to.escapeTruncate()}else{if(A.op=="network_userjoined"){A.escapedTitle=""}else{if(A.op=="del"||A.op=="rm"){A.opTitle="deleted"+(A.op=="rm"?" file":"")+" '"+A.title.toString().escapeTruncate()+"'";A.escapedTitle=""}else{if(A.data){A.dataSpan='<span class="data">'+this.escapedChangeTxt(A.data)+"</span><br />"}}}}}if(A.wiki_title){if(this.wikiTitleLinks){A.wikiTitle=' on <a href="'+Util.URLRelativeToContext("/",{wiki:A.wiki})+'" onclick="document.fire(\''+this.workspaceFilterEvent+"', {'wiki': this.getAttribute('workspace'), 'title': this.innerText ? this.innerText : this.textContent }); return false;\" workspace=\""+A.wiki.escapeHTML()+'">'+A.wiki_title.escapeHTML()+"</a>"}else{A.wikiTitle=" on "+A.wiki_title.escapeHTML()}}return this.template.evaluate(A)},escapedChangeTxt:function(A){var D=/(http(s)?:(\/\/)([\w]+(.[\w]+))([\w\-\.,@?^=%&:;\/~\+#]*[\w\-\@?^=%&:;\/~\+#])?)/gi;var C=A.escapeHTML();var E=[];while(url=D.exec(A)){if(!url[0]||E.indexOf(url[0].escapeHTML())!=-1){continue}var B="";if(url[0].length>60){B=url[0].substr(0,50).escapeHTML()+"&hellip;"}else{B=url[0].escapeHTML()}C=C.replace(new RegExp(url[0].escapeHTML(),"g"),"<a href='"+url[0]+"' target=\"_blank\" class='status-link'>"+B+"</a>");E.push(url[0].escapeHTML())}return C},setFilterOptions:function(C,D,B,A,E){var F={};if(C){F.workspace=C}if(A){F.updates=true}if(E){F={notifications:true}}if(this.setHistory){PBwiki.History.setItems(F)}if(E){this.apiMethod="GetNetworkChanges";this.apiOpts={ignore_self:true,filter_mode:"following_starred",my:true}}else{if(A){this.apiMethod="GetUpdates";if(D=="following_starred"){D="following"}this.apiOpts={filter:D||"all",format_as_getchanges:true,count:this.displayCount+1,user_id:PBwiki.getUID()};delete this.event_filter}else{this.apiMethod="GetNetworkChanges";this.apiOpts={filter_mode:D||"all",count:this.displayCount+1};if(C){this.apiOpts.wiki_filter=C}else{this.apiOpts.my=true}if(B){this.apiOpts.event_filter=B}this.event_filter=B}}this.refresh()}});PBwiki.Dashboard.ActivityStream=Class.create(PBwiki.ActivityStream,{displayCount:20,filterFieldId:"dashboard-activity-event-filter",moreActivityId:"dashboard-more-activity",moreActivityLinkId:"dashboard-more-activity-link",noActivityId:"dashboard-no-activity",activityRowTemplate:'<li class="clearfix #{className}">\n  <a class="activity-pic usercard_trigger" ui:uid="#{user.uid}" href="/n/user-profile?uid=#{user.uid}">\n    #{userImage}\n  </a>\n  <p class="activity-text #{type}">\n  <span class="who"><a href="/n/user-profile?uid=#{user.uid}" class="usercard_trigger" ui:uid="#{user.uid}">#{userLink}</a></span><span class="said">#{status}</span>\n  <span class="action">#{opTitle}</span>\n  <span class="what"><a class="preview" wiki="#{wiki}" time="#{time}" href="#{url}">#{escapedTitle}</a></span><br/>\n  #{dataSpan}\n  <span class="type #{type}" title="#{typetext}"></span><span class="when" title="#{datestring}"><span class="activity-ago-time" time="#{time}">#{ago}</span>#{wikiTitle}</span>\n  </p>\n</li>',workspaceFilterEvent:"dashboard:filter-workspace",wikiTitleLinks:true,setHistory:true});PBwiki.Profile.ActivityStream=Class.create(PBwiki.ActivityStream,{displayCount:10,filterFieldId:"profile-activity-event-filter",moreActivityId:"profile-more-activity",moreActivityLinkId:"profile-more-activity-link",noActivityId:"profile-no-activity",activityRowTemplate:'<li>\n  <span class="who">#{userLink}</span><span class="said">#{status}</span>\n  <span class="action">#{opTitle}</span>\n  <span class="what"><a class="preview" wiki="#{wiki}" time="#{time}" href="#{url}">#{escapedTitle}</a></span><br/>\n  #{dataSpan}\n  <span class="type #{type}" title="#{typetext}"></span><span class="when" title="#{datestring}">#{ago}#{wikiTitle}</span>\n</li>',workspaceFilterEvent:"profile:workspace-activity",wikiTitleLinks:true,setHistory:false,initialize:function($super,B,A){this.requiredAPIOpts={user_id_filter:A};$super(B)}});PBwiki.LiveActivityStream=Class.create(PBwiki.ActivityStream,{displayCount:10,requiredAPIOpts:{ignore_self:true,filter_mode:"following_starred",my:true},iconSize:22,noActivityId:"notifications-no-activity",activityRowTemplate:'<li>\n  #{userImage}\n  <div class="notification-message">\n    <span class="who">#{userLink}</span><span class="said">#{status}</span>\n    <span class="action">#{opTitle}</span>\n    <span class="what"><a class="preview" wiki="#{wiki}" time="#{time}" href="#{url}">#{escapedTitle}</a></span><br/>\n    #{dataSpan}\n    <span class="type #{type}" title="#{typetext}"></span><span class="when" title="#{datestring}">#{ago}#{wikiTitle}</span>\n  </div>\n</li>',wikiTitleLinks:false,initialize:function($super,A){$super(A)},onUpdate:function(A){if(A.length==0){$("notifications-footer").hide()}else{$("notifications-footer").show()}}});