function addListener(b,a,c){if(b.addEventListener){b.addEventListener(a,c,false)}else{if(b.attachEvent){b.attachEvent("on"+a,c)}}} function removeListener(b,a,c){if(b.removeEventListener){b.removeEventListener(a,c,false)}else{if(b.detachEvent){b.detachEvent("on"+a,c)}}} 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);this.handle=document.createElement("div");this.handle.className="jstHandle";var a=this.resizeDragStart;var c=this;addListener(this.handle,"mousedown",function(d){a.call(c,d)});addListener(window,"unload",function(){var d=c.handle.parentNode.removeChild(c.handle);delete(c.handle)});this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling);this.context=null;this.toolNodes={}} function jsButton(d,c,b,a){this.title=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");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:{},getMode:function(){return this.mode},setMode:function(a){this.mode=a||"wiki"},switchMode:function(a){a=a||"wiki";this.draw(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","")}}};jsToolBar.prototype.elements.del={type:"button",title:"Deleted",fn:{wiki:function(){this.singleTag("--")},markdown:function(){this.singleTag("","")}}};jsToolBar.prototype.elements.quote={type:"button",title:"Inline quote",fn:{wiki:function(){this.singleTag("{{","}}")},markdown:function(){this.singleTag("","")}}};jsToolBar.prototype.elements.code={type:"button",title:"Code",fn:{wiki:function(){this.singleTag("@@")},markdown:function(){this.singleTag("`")}}};jsToolBar.prototype.elements.space1={type:"space"};jsToolBar.prototype.elements.br={type:'button',title:'Line break',fn:{wiki:function(){this.encloseSelection('%%%'+"\n",'')},markdown:function(){this.encloseSelection(' '+"\n",'')}}};jsToolBar.prototype.elements.space2={type:"space"};jsToolBar.prototype.elements.ul={type:"button",title:"Unordered list",fn:{wiki:function(){this.encloseSelection("","",function(a){a=a.replace(/\r/g,"");return"* "+a.replace(/\n/g,"\n* ")})},markdown:function(){this.encloseSelection('','',function(str){str=str.replace(/\r/g,'');return'* '+str.replace(/\n/g,"\n* ");});}}};jsToolBar.prototype.elements.ol={type:"button",title:"Ordered list",fn:{wiki:function(){this.encloseSelection("","",function(a){a=a.replace(/\r/g,"");return"# "+a.replace(/\n/g,"\n# ")})},markdown:function(){this.encloseSelection('','',function(str){str=str.replace(/\r/g,'');return'1. '+str.replace(/\n/g,"\n1. ");});}}};jsToolBar.prototype.elements.pre={type:'button',title:'Preformatted',fn:{wiki:function(){this.encloseSelection('','',function(a){a=a.replace(/\r/g,'');return' '+a.replace(/\n/g,"\n ");});},markdown:function(){this.encloseSelection("\n",'',function(str){str=str.replace(/\r/g,'');return' '+str.replace(/\n/g,"\n ");});}}};jsToolBar.prototype.elements.bquote={type:'button',title:'Block quote',fn:{wiki:function(){this.encloseSelection('','',function(a){a=a.replace(/\r/g,'');return'> '+a.replace(/\n/g,"\n> ");});},markdown:function(){this.encloseSelection("\n",'',function(str){str=str.replace(/\r/g,'');return'> '+str.replace(/\n/g,"\n> ");});}}};jsToolBar.prototype.elements.space3={type:"space"};jsToolBar.prototype.elements.link={type:"button",title:"Link",fn:{},href_prompt:"Please give page URL:",hreflang_prompt:"Language of this page:",default_hreflang:"",prompt:function(b,a){b=b||"";a=a||this.elements.link.default_hreflang;b=window.prompt(this.elements.link.href_prompt,b);if(!b){return false} a=window.prompt(this.elements.link.hreflang_prompt,a);return{href:this.stripBaseURL(b),hreflang:a}}};jsToolBar.prototype.elements.link.fn.wiki=function(){var b=this.elements.link.prompt.call(this);if(b){var c="[";var a="|"+b.href;if(b.hreflang){a=a+"|"+b.hreflang} a=a+"]";this.encloseSelection(c,a)}};jsToolBar.prototype.elements.link.fn.markdown=function(){var link=this.elements.link.prompt.call(this);if(link){var stag='[';var etag=']('+link.href;if(link.title){etag=etag+' "'+link.title+'"';} etag=etag+')';this.encloseSelection(stag,etag);}};