function jsToolBar(b){if(!document.createElement){return}if(!b){return}if((typeof(document.selection)=="undefined")&&(typeof(b.setSelectionRange)=="undefined")){return}this.textarea=b;this.editor=document.createElement("div");this.editor.className="jstEditor";this.textarea.parentNode.insertBefore(this.editor,this.textarea);this.editor.appendChild(this.textarea);this.toolbar=document.createElement("div");this.toolbar.className="jstElements";this.editor.parentNode.insertBefore(this.toolbar,this.editor);if(this.editor.addEventListener){this.handle=document.createElement("div");this.handle.className="jstHandle";var a=this.resizeDragStart;var c=this;this.handle.addEventListener("mousedown",function(d){a.call(c,d)},false);window.addEventListener("unload",function(){var d=c.handle.parentNode.removeChild(c.handle);delete (c.handle)},false);this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling)}this.context=null;this.toolNodes={}}function jsButton(d,c,b,a){if(typeof jsToolBar.strings=="undefined"){this.title=d||null}else{this.title=jsToolBar.strings[d]||d||null}this.fn=c||function(){};this.scope=b||null;this.className=a||null}jsButton.prototype.draw=function(){if(!this.scope){return null}var a=document.createElement("button");a.setAttribute("type","button");a.tabIndex=200;if(this.className){a.className=this.className}a.title=this.title;var b=document.createElement("span");b.appendChild(document.createTextNode(this.title));a.appendChild(b);if(this.icon!=undefined){a.style.backgroundImage="url("+this.icon+")"}if(typeof(this.fn)=="function"){var c=this;a.onclick=function(){try{c.fn.apply(c.scope,arguments)}catch(d){}return false}}return a};function jsSpace(a){this.id=a||null;this.width=null}jsSpace.prototype.draw=function(){var a=document.createElement("span");if(this.id){a.id=this.id}a.appendChild(document.createTextNode(String.fromCharCode(160)));a.className="jstSpacer";if(this.width){a.style.marginRight=this.width+"px"}return a};function jsCombo(e,a,d,c,b){this.title=e||null;this.options=a||null;this.scope=d||null;this.fn=c||function(){};this.className=b||null}jsCombo.prototype.draw=function(){if(!this.scope||!this.options){return null}var a=document.createElement("select");if(this.className){a.className=className}a.title=this.title;for(var d in this.options){var b=document.createElement("option");b.value=d;b.appendChild(document.createTextNode(this.options[d]));a.appendChild(b)}var c=this;a.onchange=function(){try{c.fn.call(c.scope,this.value)}catch(f){alert(f)}return false};return a};jsToolBar.prototype={base_url:"",mode:"wiki",elements:{},help_link:"",getMode:function(){return this.mode},setMode:function(a){this.mode=a||"wiki"},switchMode:function(a){a=a||"wiki";this.draw(a)},setHelpLink:function(a){this.help_link=a},button:function(d){var c=this.elements[d];if(typeof c.fn[this.mode]!="function"){return null}var a=new jsButton(c.title,c.fn[this.mode],this,"jstb_"+d);if(c.icon!=undefined){a.icon=c.icon}return a},space:function(b){var a=new jsSpace(b);if(this.elements[b].width!==undefined){a.width=this.elements[b].width}return a},combo:function(f){var b=this.elements[f];var e=b[this.mode].list.length;if(typeof b[this.mode].fn!="function"||e==0){return null}else{var a={};for(var d=0;d<e;d++){var c=b[this.mode].list[d];a[c]=b.options[c]}return new jsCombo(b.title,a,this,b[this.mode].fn)}},draw:function(j){this.setMode(j);while(this.toolbar.hasChildNodes()){this.toolbar.removeChild(this.toolbar.firstChild)}this.toolNodes={};var g=document.createElement("div");g.className="help";g.innerHTML=this.help_link;"<a href=\"/help/wiki_syntax.html\" onclick=\"window.open('/help/wiki_syntax.html', '', 'resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes'); return false;\">Aide</a>";this.toolbar.appendChild(g);var a,d,c;for(var e in this.elements){a=this.elements[e];var f=a.type==undefined||a.type==""||(a.disabled!=undefined&&a.disabled)||(a.context!=undefined&&a.context!=null&&a.context!=this.context);if(!f&&typeof this[a.type]=="function"){d=this[a.type](e);if(d){c=d.draw()}if(c){this.toolNodes[e]=c;this.toolbar.appendChild(c)}}}},singleTag:function(b,a){b=b||null;a=a||b;if(!b||!a){return}this.encloseSelection(b,a)},encloseLineSelection:function(f,j,h){this.textarea.focus();f=f||"";j=j||"";var a,d,c,b,i,g;if(typeof(document.selection)!="undefined"){c=document.selection.createRange().text}else{if(typeof(this.textarea.setSelectionRange)!="undefined"){a=this.textarea.selectionStart;d=this.textarea.selectionEnd;b=this.textarea.scrollTop;a=this.textarea.value.substring(0,a).replace(/[^\r\n]*$/g,"").length;d=this.textarea.value.length-this.textarea.value.substring(d,this.textarea.value.length).replace(/^[^\r\n]*/,"").length;c=this.textarea.value.substring(a,d)}}if(c.match(/ $/)){c=c.substring(0,c.length-1);j=j+" "}if(typeof(h)=="function"){g=(c)?h.call(this,c):h("")}else{g=(c)?c:""}i=f+g+j;if(typeof(document.selection)!="undefined"){document.selection.createRange().text=i;var e=this.textarea.createTextRange();e.collapse(false);e.move("character",-j.length);e.select()}else{if(typeof(this.textarea.setSelectionRange)!="undefined"){this.textarea.value=this.textarea.value.substring(0,a)+i+this.textarea.value.substring(d);if(c){this.textarea.setSelectionRange(a+i.length,a+i.length)}else{this.textarea.setSelectionRange(a+f.length,a+f.length)}this.textarea.scrollTop=b}}},encloseSelection:function(f,j,h){this.textarea.focus();f=f||"";j=j||"";var a,d,c,b,i,g;if(typeof(document.selection)!="undefined"){c=document.selection.createRange().text}else{if(typeof(this.textarea.setSelectionRange)!="undefined"){a=this.textarea.selectionStart;d=this.textarea.selectionEnd;b=this.textarea.scrollTop;c=this.textarea.value.substring(a,d)}}if(c.match(/ $/)){c=c.substring(0,c.length-1);j=j+" "}if(typeof(h)=="function"){g=(c)?h.call(this,c):h("")}else{g=(c)?c:""}i=f+g+j;if(typeof(document.selection)!="undefined"){document.selection.createRange().text=i;var e=this.textarea.createTextRange();e.collapse(false);e.move("character",-j.length);e.select()}else{if(typeof(this.textarea.setSelectionRange)!="undefined"){this.textarea.value=this.textarea.value.substring(0,a)+i+this.textarea.value.substring(d);if(c){this.textarea.setSelectionRange(a+i.length,a+i.length)}else{this.textarea.setSelectionRange(a+f.length,a+f.length)}this.textarea.scrollTop=b}}},stripBaseURL:function(a){if(this.base_url!=""){var b=a.indexOf(this.base_url);if(b==0){a=a.substr(this.base_url.length)}}return a}};jsToolBar.prototype.resizeSetStartH=function(){this.dragStartH=this.textarea.offsetHeight+0};jsToolBar.prototype.resizeDragStart=function(a){var b=this;this.dragStartY=a.clientY;this.resizeSetStartH();document.addEventListener("mousemove",this.dragMoveHdlr=function(c){b.resizeDragMove(c)},false);document.addEventListener("mouseup",this.dragStopHdlr=function(c){b.resizeDragStop(c)},false)};jsToolBar.prototype.resizeDragMove=function(a){this.textarea.style.height=(this.dragStartH+a.clientY-this.dragStartY)+"px"};jsToolBar.prototype.resizeDragStop=function(a){document.removeEventListener("mousemove",this.dragMoveHdlr,false);document.removeEventListener("mouseup",this.dragStopHdlr,false)};
