Button=new Class({initialize:function(C,A){this.id=C;this.options=A},render:function(A){return this.build(this,A)},build:function(A,C){return component=new Element("img",{src:A.options.icon,styles:{cursor:"pointer"},events:{click:function(){A.execute(C,null)},mouseenter:function(){this.src=A.options.hover},mouseleave:function(){this.src=A.options.icon}}})},execute:function(A,C){A.restore();Debug.info("executing command "+this.options.command+" with value : "+C);try{A.content.execCommand(this.options.command,false,C)}catch(D){Debug.error("failed in executing "+this.options.command+". Cause: "+D.message)}A.focus()}});ColorChooserButton=Button.extend({initialize:function(D,A,C){this.parent(D,C);this.color=A},getColors:function(){if(this.options.colors!=null){return this.options.colors()}else{return[["#000","#930","#330","#030","#036","#007","#339","#333"],["#700","#f60","#770","#070","#077","#00f","#669","#777"],["#f00","#f90","#9c0","#396","#3cc","#36f","#707","#999"],["#f0f","#fc0","#ff0","#0f0","#0ff","#0cf","#936","#ccc"],["#f9c","#fc9","#ff9","#cfc","#cff","#9cf","#c97","#fff"]]}},build:function(L,F){this.colorChooser=new Element("div",{styles:{"background-color":"#eee",position:"absolute"}});var D=0;var C=0;var J=0;var H=0;$each(this.getColors(),function(M){$each(M,function(O){var N=new Element("div",{styles:{"background-color":O,height:"14px",width:"14px","float":"left",position:"absolute"},events:{click:function(){L.color=O;L.execute(F,O)},mouseenter:function(){this.setStyle("width",12);this.setStyle("height",12);this.setStyle("border","1px solid #fff")},mouseleave:function(){this.setStyle("width",14);this.setStyle("height",14);this.setStyle("border","none")}}});N.setHTML("&nbsp;");N.setStyle("font-size","1px");N.setStyle("top",D*18+4);N.setStyle("left",C*18+4);C++;L.colorChooser.adopt(N)});D++;if(H<C){H=C}C=0});J=D;var K=J*18+4;var A=H*18+4;this.colorChooser.setStyle("width",A);this.colorChooser.setStyle("height",K);var G=new Element("div",{styles:{height:"100%",width:"18px","text-align":"center",cursor:"pointer"},events:{mouseenter:function(){this.adopt(L.colorChooser);if(window.ie){L.colorChooser.setStyle("left",this.getCoordinates().left+2)}},mouseleave:function(){L.colorChooser.remove()}}});var E=this.parent(L,F);this.colorPreview=new Element("div",{styles:{margin:"1px 1px 1px 1px","background-color":L.color,border:"1px solid #ccc","font-size":"1px"}});this.colorPreview.setStyle("height","4px");this.colorPreview.setStyle("width","15px");this.colorPreview.setHTML("&nbsp;");G.adopt(E);G.adopt(this.colorPreview);return G},execute:function(A,C){C=C.charAt(0)+C.charAt(1)+C.charAt(1)+C.charAt(2)+C.charAt(2)+C.charAt(3)+C.charAt(3);this.colorPreview.setStyle("background-color",C);this.colorChooser.remove();this.parent(A,C)}});StyleChooserButton=Button.extend({initialize:function(D,C,A){A.icon="../../images/arrow.gif";A.hover="../../images/arrow-hover.gif";this.style=C;this.parent(D,A)},build:function(A,E){this.styleChooser=new Element("div",{styles:{"background-color":"#f5f5f5",border:"2px solid #ccc",position:"absolute",padding:"5px"}});this.stylePreview=new Element("div",{styles:{"float":"left","font-family":"Trebuchet MS","font-size":"12px","padding-left":"5px"}});this.stylePreview.setText(this.style);if(window.webkit420){this.stylePreview.setStyle("padding-top","2px")}$each(this.options.values,function(H,G){var F=new Element("div",{styles:{"text-align":"left",color:"#333","font-family":"Trebuchet MS","font-size":"12px"},events:{click:function(){this.setStyle("text-decoration","none");A.styleChooser.remove();A.stylePreview.setText(G);A.execute(E,H)},mouseenter:function(){this.setStyle("text-decoration","underline")},mouseleave:function(){this.setStyle("text-decoration","none")}}});F.setText(G);A.options.stylize(F,H);A.styleChooser.adopt(F)});var C=new Element("div",{styles:{height:"100%","text-align":"center",cursor:"pointer",width:"100px"},events:{mouseenter:function(){A.styleChooser.setOpacity(0);this.adopt(A.styleChooser);var F=this.getCoordinates();var G=A.styleChooser.getCoordinates();if(G.width<F.width){if(window.ie){A.styleChooser.setStyle("width",F.width+4)}else{A.styleChooser.setStyle("width",F.width-12)}}A.styleChooser.setStyle("left",F.left+1);A.styleChooser.setStyle("top",F.top+19);A.styleChooser.setOpacity(1)},mouseleave:function(){A.styleChooser.remove()}}});var D=this.parent(A,E);D.setStyle("float","right");C.adopt(D);C.adopt(this.stylePreview);return C}});Separator=Button.extend({build:function(A,C){return new Element("img",{src:A.options.icon})}});var S=new Separator("S",{icon:"../../images/separator.gif"});var B=new Button("B",{command:"Bold",icon:"../../images/bold.gif",hover:"../../images/bold-hover.gif"});var I=new Button("I",{command:"Italic",icon:"../../images/italic.gif",hover:"../../images/italic-hover.gif"});var U=new Button("U",{command:"Underline",icon:"../../images/underline.gif",hover:"../../images/underline-hover.gif"});var OL=new Button("OL",{command:"InsertOrderedList",icon:"../../images/orderedlist.gif",hover:"../../images/orderedlist-hover.gif"});var UL=new Button("UL",{command:"InsertUnOrderedList",icon:"../../images/unorderedlist.gif",hover:"../../images/unorderedlist-hover.gif"});var JL=new Button("JL",{command:"JustifyLeft",icon:"../../images/justifyleft.gif",hover:"../../images/justifyleft-hover.gif"});var JC=new Button("JC",{command:"JustifyCenter",icon:"../../images/justifycenter.gif",hover:"../../images/justifycenter-hover.gif"});var JR=new Button("JR",{command:"JustifyRight",icon:"../../images/justifyright.gif",hover:"../../images/justifyright-hover.gif"});var FG=new ColorChooserButton("FG","#000",{command:"ForeColor",icon:"../../images/forecolor.gif",hover:"../../images/forecolor-hover.gif"});var BG;if(window.gecko||window.opera){BG=new ColorChooserButton("BG","#000",{command:"HiliteColor",icon:"../../images/backcolor.gif",hover:"../../images/backcolor-hover.gif"})}else{BG=new ColorChooserButton("BG","#000",{command:"BackColor",icon:"../../images/backcolor.gif",hover:"../../images/backcolor-hover.gif"})}var FS=new StyleChooserButton("FS","normal",{command:"FontSize",values:{"x-small":"1",small:"2",normal:"3",big:"5","x-big":"6"},stylize:function(A,C){switch(C){case"1":A.style.fontSize="8px";break;case"2":A.style.fontSize="10px";break;case"3":A.style.fontSize="14px";break;case"5":A.style.fontSize="20px";break;case"6":A.style.fontSize="24px";break}}});var FF=new StyleChooserButton("FF","Trebuchet",{command:"FontName",stylize:function(A,C){A.style.fontFamily=C},value:"Trebuchet MS",values:{Trebuchet:"Trebuchet MS",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",Times:"Times New Roman",Courier:"Courier New",Garamond:"Garamomd"}});Editor=new Class({initialize:function(A){this.options=A;this.frame=new Element("iframe",{styles:{border:"1px solid #ccc","background-color":"#fff",width:"100%",height:"100%",margin:"1px 0px 0px 0px"}})},getButtons:function(){if(this.options&&this.options.buttons){return this.options.buttons()}else{return[B,I,U,JL,JC,JR,S,OL,UL,S,FS,FF,S,FG,BG]}},render:function(A){this.container=A;this.container.setStyle("background-color","#f5f5f5");this.container.setStyle("border","1px solid #ccc");this.container.setStyle("padding","1px 1px 1px 1px");var D=this;var F=this.getButtons();this.toolbar=new Element("div",{styles:{height:"20px"}});$each(F,function(M){var J;if(M instanceof Separator){J="none"}else{J="1px solid #ccc"}var L=new Element("div",{styles:{"float":"left",border:J,height:"19px",margin:"0px 1px 0px 0px"}});var K=M.render(D);L.adopt(K);D.toolbar.adopt(L)});this.container.adopt(this.toolbar);this.container.adopt(this.frame);if(!window.ie){var G=this.container.getCoordinates();var E=this.frame.getCoordinates();var C=E.bottom-G.bottom;var H=E.right-G.right;this.frame.setStyle("width",E.width-H-4);this.frame.setStyle("height",E.height-C-4)}this.frame.addEvent("load",function(){if(window.opera){D.content=this.contentWindow.document}else{if(window.ie){D.content=this.contentWindow.document}else{if(window.gecko){D.content=this.contentDocument}else{if(window.webkit420){D.content=this.contentDocument}}}}if(D.content!=null){if(window.ie){$(D.content.body).setStyle("border","none")}D.content.designMode="on";$(D.content.body).addEvent("click",function(){D.lastSelection=D.content.selection.createRange()});$(D.content.body).addEvent("dblclick",function(){D.lastSelection=D.content.selection.createRange()});if(D.value!=null){D.setValue(D.value)}}else{D.container.appendHTML("Unknown browser. Could not load editor.")}});if(window.webkit420||window.opera){this.frame.fireEvent("load")}},getValue:function(){return this.content.body.innerHTML},setValue:function(A){this.value=A;if(this.content!=null){this.content.body.innerHTML=this.value}},focus:function(){this.frame.contentWindow.focus()},restore:function(){if(window.ie){if(this.lastSelection){this.lastSelection.select()}}}});var Debug=new Class();Debug.build=function(){Debug.container=new Element("div",{styles:{width:"50%",padding:"2px",border:"1px solid #ddd","background-color":"#eee",position:"absolute",top:"0px",right:"0px",border:"none",padding:"10px"}});Debug.menu=new Element("div",{styles:{width:"100%",padding:"2px",border:"1px solid #ddd","margin-bottom":"2px"}});Debug.log=new Element("div",{styles:{width:"100%",padding:"2px",border:"1px solid #ddd"}});$(document.body).adopt(Debug.container);Debug.container.adopt(Debug.menu);Debug.container.adopt(Debug.log);Debug.menu.adopt(new Element("input",{type:"button",value:"clear",events:{click:function(){Debug.log.empty()}}}));Debug.info("debug started")};Debug.title=function(A){Debug.post(A,"normal 10px 'Trebuchet MS'","#fff","#333")};Debug.info=function(A){Debug.post(A,"normal 10px 'Trebuchet MS'","#009933","#fff")};Debug.error=function(A){Debug.post(A,"normal 10px 'Trebuchet MS'","#c00","#fff")};Debug.post=function(E,C,A,F){var G=new Element("div",{styles:{"background-color":F,color:A,font:C,width:"100%"}});var D=new Date();G.setHTML("&nbsp;<b>[ "+D.toTimeString().substring(0,8)+" ]</b> "+E);Debug.log.adopt(G)};