BxEditor=function(A){this._name=A;};BxEditor.prototype.setName=function(A){this._name=A;};BxEditor.prototype.init=function(){this._el=document.getElementById(this._name);if(!this._el.contentDocument){this._el=window[this._name];}this._doc=this._el.document?this._el.document:this._el.contentDocument;if(!this._doc.designMode){alert("please upgrade your browser");return;}this._doc.designMode="on";};BxEditor.prototype.initMenu=function(){var a={0:{left:0,make:"Bold"},1:{left:-18,make:"Italic"},2:{left:-36,make:"Underline"},3:{left:-216,make:"Code"},4:{left:-162,make:"BulletedList"},5:{left:-144,make:"NumberedList"},6:{left:-180,make:"Outdent"},7:{left:-198,make:"Indent"},8:{left:-288,make:"RemoveFormat"}};var len=9;var ul=document.createElement("ul");var img=document.createElement("img");var $this=this;img.src="sp.gif";img.style.width="18px";img.style.height="18px";img.style.border="none";ul.style.listStyle="none";ul.style.margin="0";ul.style.marginTop="5px";ul.style.marginBottom="5px";ul.style.padding="0";ul.style.clear="both";ul.style.height="20px";ul.style.width=(len*20)+"px";ul.style.backgroundColor="#999999";ul.style.overflow="hidden";for(var r in a){var li=document.createElement("li");var img2=img.cloneNode(false);li._func=a[r].make;li.style.width="18px";li.style.height="18px";li.style.border="1px solid #999999";li.style.backgroundImage="url(toolbar.gif)";li.style.backgroundPosition=a[r].left+"px 0px";li.style.overflow="hidden";li.style.styleFloat="left";li.style.cssFloat="left";li.title=a[r].make;li.onmouseover=function(){this.style.border="1px solid #ffffff";};li.onmouseout=function(){this.style.border="1px solid #999999";this.style.backgroundColor="transparent";};li.onmousedown=function(){this.style.backgroundColor="#bbbbbb";};li.onmouseup=function(){this.style.backgroundColor="transparent";};li.onclick=function(){eval("$this.make"+this._func+"()");};li.appendChild(img2);ul.appendChild(li);}if(this._el.frameElement){this._el.frameElement.parentNode.insertBefore(ul,this._el.frameElement);}else{this._el.parentNode.insertBefore(ul,this._el);}};BxEditor.prototype.makeBold=function(){this._el.focus();this._doc.execCommand("bold",false,null);};BxEditor.prototype.makeItalic=function(){this._el.focus();this._doc.execCommand("italic",false,null);};BxEditor.prototype.makeUnderline=function(){this._el.focus();this._doc.execCommand("underline",false,null);};BxEditor.prototype.makeBulletedList=function(){this._el.focus();this._doc.execCommand("InsertUnorderedList",false,null);};BxEditor.prototype.makeNumberedList=function(){this._el.focus();this._doc.execCommand("InsertOrderedList",false,null);};BxEditor.prototype.makeOutdent=function(){this._el.focus();this._doc.execCommand("outdent",false,null);};BxEditor.prototype.makeIndent=function(){this._el.focus();this._doc.execCommand("indent",false,null);};BxEditor.prototype.makeRemoveFormat=function(){this._el.focus();this._doc.execCommand("RemoveFormat",false,true);};BxEditor.prototype.makeCode=function(){var A=this._doc.execCommand("FormatBlock",false,"blockquote");if(!A){this._doc.execCommand("FormatBlock",false,"Definition");this._format_pre_ie();}else{this._format_pre_moz();}this._el.focus();};BxEditor.prototype.makeFont=function(){this._el.focus();this._doc.execCommand("FontName",false,"Arial");};BxEditor.prototype.makeHeading=function(A){this._el.focus();if(!this._doc.execCommand("FormatBlock",false,"h"+A)){this._doc.execCommand("FormatBlock",false,"Heading "+A);}};BxEditor.prototype.getText=function(){if(this._el.contentDocument){return this._el.contentDocument.body.innerHTML;}else{return this._el.document.body.innerHTML;}};BxEditor.prototype.setText=function(A){if(this._el.contentDocument){this._el.contentDocument.body.innerHTML=A;}else{if(this._el.document&&this._el.document.body){this._el.document.body.innerHTML=A;}}};BxEditor.prototype._get_selection_bounds=function(G){var E,C,H,B;if(G.getSelection){var F=G.getSelection();E=F.getRangeAt(0);H=E.startContainer;B=E.endContainer;C=E.commonAncestorContainer;if(H==B){C=H;}if(H.nodeName.toLowerCase()=="body"){return null;}if(H.nodeName=="#text"){H=H.parentNode;}if(B.nodeName=="#text"){B=B.parentNode;}return{root:C,start:H,end:B};}else{if(G.document.selection){E=G.document.selection.createRange();if(!E.duplicate){return null;}var D=E.duplicate();var A=E.duplicate();D.collapse(true);A.moveToElementText(D.parentElement());A.setEndPoint("EndToStart",D);H=D.parentElement();D=E.duplicate();A=E.duplicate();A.collapse(false);D.moveToElementText(A.parentElement());D.setEndPoint("StartToEnd",A);B=A.parentElement();C=E.parentElement();if(H==B){C=H;}return{root:C,start:H,end:B};}}return null;};BxEditor.prototype._find_tags_in_subtree=function(A,D,H,E){var I=A.root;var C=A.start;var G=A.end;if(C==G){return[C];}if(!E){this._global_stage=H;}if(this._global_stage==2){return[];}if(!this._global_stage){this._global_stage=0;}D=D.toLowerCase();var B=[];for(var F=I.firstChild;F;F=F.nextSibling){if(F==C&&this._global_stage==0){this._global_stage=1;}if(F.nodeName.toLowerCase()==D&&F.nodeName!="#text"||D==""){if(this._global_stage==1){B.push(F);}}if(F==G&&this._global_stage==1){this._global_stage=2;}B=B.concat(this._find_tags_in_subtree({root:F,start:C,end:G},D,this._global_stage,true));}return B;};BxEditor.prototype._closest_parent_by_tag_name=function(A,C){C=C.toLowerCase();var B=A;do{if(C==""||B.nodeName.toLowerCase()==C){return B;}}while(B=B.parentNode);return A;};BxEditor.prototype._get_selected_tags=function(B,C){if(C){C=C.toLowerCase();}else{C="";}var A=this._get_selection_bounds(B);if(!A){return null;}A.start=this._closest_parent_by_tag_name(A.start,C);A.end=this._closest_parent_by_tag_name(A.end,C);return this._find_tags_in_subtree(A,C);};BxEditor.prototype._clean_nodes=function(B,E){if(!B){return;}var A=B.length-1;var F;var D="";for(var C=A;C>=0;C--){D+="<p>"+B[C].innerHTML+"</p>";F=B[C].parentNode;F.removeChild(B[C]);}if(F){F.innerHTML=D;}};BxEditor.prototype._format_pre_moz=function(){var D=this._el;var A=this._doc;A.execCommand("RemoveFormat",false,true);var B=this._get_selected_tags(D.contentWindow,"blockquote");var E;for(var C=0;C<B.length;C++){E=A.createElement("pre");E.innerHTML=B[C].innerHTML;B[C].parentNode.replaceChild(E,B[C]);}};BxEditor.prototype._format_pre_ie=function(){var D=this._el;var A=this._doc;A.execCommand("RemoveFormat",false,true);this._clean_nodes(this._get_selected_tags(D,"dd"));var B=this._get_selected_tags(D,"dl");var E;for(var C=0;C<B.length;C++){E=A.createElement("pre");E.innerHTML=B[C].innerHTML;B[C].parentNode.replaceChild(E,B[C]);}};BxEditor.prototype._format_inline=function(F,E){this._magic_unusual_color="#00f001";var D=this._el;var A=this._doc;A.execCommand("RemoveFormat",false,true);this._clean_nodes(this._get_selected_tags(D.contentWindow,"span"));if(F!=""){A.execCommand("ForeColor",false,this._magic_unusual_color);var B=this._get_selected_tags(D.contentWindow,"font");var G;for(var C=0;C<B.length;C++){if(B[C].getAttribute("color")!=this._magic_unusual_color){continue;}G=A.createElement(F);G.innerHTML=B[C].innerHTML;B[C].parentNode.replaceChild(G,B[C]);}}D.focus();};BxEditor.prototype._wysiwyg_format_block=function(E){var F="h1";var D=this._el;var A=this._doc;if(!this._doc.execCommand("FormatBlock",false,F)){this._doc.execCommand("FormatBlock",false,"Heading 1");}var B=this._get_selected_tags(D.contentWindow,F);for(var C=0;C<B.length;C++){if(E){B[C].className=E;}else{B[C].removeAttribute("class");B[C].removeAttribute("className");}}D.focus();};