if(typeof(XWiki)=="undefined"){XWiki=new Object()
}if(typeof(XWiki.viewers)=="undefined"){XWiki.viewers=new Object()
}XWiki.viewers.Code=Class.create({initialize:function(a){this.showingLineNumbers=a;
this.toggleLink=$("toggleLineNumbers");
this.showText="$msg.get('core.viewers.code.showLineNumbers')";
this.hideText="$msg.get('core.viewers.code.hideLineNumbers')";
if(this.toggleLink){this.textarea=this.toggleLink.up().down("textarea");
if(this.textarea){this.attachToggleListener()
}}},attachToggleListener:function(){this.toggleLink.href="";
this.toggleLink.observe("click",this.toggleLineNumbers.bindAsEventListener(this))
},toggleLineNumbers:function(f){if(f){f.stop()
}var d="\n";
var b=this.textarea.value.split(d);
var g=b.size()-1;
var c=Math.ceil(Math.log(g+1)/Math.LN10);
for(var e=0;
e<g;
++e){if(this.showingLineNumbers){b[e]=b[e].replace(/^\s*[0-9]+:\s/,"")
}else{var a=e+1+"";
b[e]=" ".times(c-a.length)+a+": "+b[e]
}}this.textarea.value=b.join(d);
this.showingLineNumbers=!this.showingLineNumbers;
if(this.showingLineNumbers){this.toggleLink.update(this.hideText)
}else{this.toggleLink.update(this.showText)
}}});
document.observe("dom:loaded",function(){var a=true;
if(window.location.search.indexOf("showlinenumbers=0")>=0){a=false
}new XWiki.viewers.Code(a)
});