/* NicEdit - Micro Inline WYSIWYG
 * Copyright 2007-2008 Brian Kirchoff
 *
 * NicEdit is distributed under the terms of the MIT license
 * For more information visit http://nicedit.com/
 * Do not remove this copyright message
 */
jCore.nedit=true;var bkExtend=function(){var C=arguments;if(C.length==1){C=[this,C[0]]}for(var D in C[1]){C[0][D]=C[1][D]}return C[0]};function bkClass(){}bkClass.prototype.construct=function(){};bkClass.extend=function(E){var D=function(){if(arguments[0]!==bkClass){return this.construct.apply(this,arguments)}};var F=new this(bkClass);bkExtend(F,E);D.prototype=F;D.extend=this.extend;return D};var bkElement=bkClass.extend({construct:function(B){if(typeof (B)=="string"){B=document.createElement(B)}B=$BK(B);return B},appendTo:function(B){B.appendChild(this);return this},appendBefore:function(B){B.parentNode.insertBefore(this,B);return this},addEvent:function(D,C){bkLib.addEvent(this,D,C);return this},setContent:function(B){this.innerHTML=B;return this},pos:function(){var E=curtop=0;var F=obj=this;if(obj.offsetParent){do{E+=obj.offsetLeft;curtop+=obj.offsetTop}while(obj=obj.offsetParent)}var D=(!window.opera)?parseInt(this.getStyle("border-width")||this.style.border)||0:0;return[E+D,curtop+D+this.offsetHeight]},noSelect:function(){bkLib.noSelect(this);return this},parentTag:function(C){var D=this;do{if(D&&D.nodeName&&D.nodeName.toUpperCase()==C){return D}D=D.parentNode}while(D);return false},hasClass:function(B){return this.className.match(new RegExp("(\\s|^)nicEdit-"+B+"(\\s|$)"))},addClass:function(B){if(!this.hasClass(B)){this.className+=" nicEdit-"+B}return this},removeClass:function(B){if(this.hasClass(B)){this.className=this.className.replace(new RegExp("(\\s|^)nicEdit-"+B+"(\\s|$)")," ")}return this},setStyle:function(D){var F=this.style;for(var E in D){switch(E){case"float":F.cssFloat=F.styleFloat=D[E];break;case"opacity":F.opacity=D[E];F.filter="alpha(opacity="+Math.round(D[E]*100)+")";break;case"className":this.className=D[E];break;default:F[E]=D[E]}}return this},getStyle:function(D,E){var F=(!E)?document.defaultView:E;if(this.nodeType==1){return(F&&F.getComputedStyle)?F.getComputedStyle(this,null).getPropertyValue(D):this.currentStyle[bkLib.camelize(D)]}},remove:function(){this.parentNode.removeChild(this);return this},setAttributes:function(C){for(var D in C){this[D]=C[D]}return this}});var bkLib={isMSIE:(navigator.appVersion.indexOf("MSIE")!=-1),addEvent:function(E,F,D){(E.addEventListener)?E.addEventListener(F,D,false):E.attachEvent("on"+F,D)},toArray:function(E){var F=E.length,D=new Array(F);while(F--){D[F]=E[F]}return D},noSelect:function(D){if(D.setAttribute&&D.nodeName.toLowerCase()!="input"&&D.nodeName.toLowerCase()!="textarea"){D.setAttribute("unselectable","on")}for(var C=0;C<D.childNodes.length;C++){bkLib.noSelect(D.childNodes[C])}},camelize:function(B){return B.replace(/\-(.)/g,function(E,D){return D.toUpperCase()})},inArray:function(C,D){return(bkLib.search(C,D)!=null)},search:function(D,E){for(var F=0;F<D.length;F++){if(D[F]==E){return F}}return null},cancelEvent:function(B){B=B||window.event;if(B.preventDefault&&B.stopPropagation){B.preventDefault();B.stopPropagation()}return false},domLoad:[],domLoaded:function(){if(arguments.callee.done){return }arguments.callee.done=true;for(i=0;i<bkLib.domLoad.length;i++){bkLib.domLoad[i]()}},onDomLoaded:function(B){this.domLoad.push(B);if(document.addEventListener){document.addEventListener("DOMContentLoaded",bkLib.domLoaded,null)}else{if(bkLib.isMSIE){document.write("<script id=__ie_onload defer "+((location.protocol=="https:")?"src='javascript:void(0)'":"src=//0")+"><\/script>");$BK("__ie_onload").onreadystatechange=function(){if(this.readyState=="complete"){bkLib.domLoaded()}}}}window.onload=bkLib.domLoaded}};function $BK(B){if(typeof (B)=="string"){B=document.getElementById(B)}return(B&&!B.appendTo)?bkExtend(B,bkElement.prototype):B}var bkEvent={addEvent:function(C,D){if(D){this.eventList=this.eventList||{};this.eventList[C]=this.eventList[C]||[];this.eventList[C].push(D)}return this},fireEvent:function(){var D=bkLib.toArray(arguments),E=D.shift();if(this.eventList&&this.eventList[E]){for(var F=0;F<this.eventList[E].length;F++){this.eventList[E][F].apply(this,D)}}}};function __(B){return B}Function.prototype.closure=function(){var D=this,F=bkLib.toArray(arguments),E=F.shift();return function(){if(typeof (bkLib)!="undefined"){return D.apply(E,F.concat(bkLib.toArray(arguments)))}}};Function.prototype.closureListener=function(){var D=this,E=bkLib.toArray(arguments),F=E.shift();return function(B){B=B||window.event;if(B.target){var C=B.target}else{var C=B.srcElement}return D.apply(F,[B,C].concat(E))}};var nicEditorConfig=bkClass.extend({buttons:{bold:{name:__("Click to Bold"),command:"Bold",tags:["B","STRONG"],css:{"font-weight":"bold"},key:"b"},italic:{name:__("Click to Italic"),command:"Italic",tags:["EM","I"],css:{"font-style":"italic"},key:"i"},underline:{name:__("Click to Underline"),command:"Underline",tags:["U"],css:{"text-decoration":"underline"},key:"u"},left:{name:__("Left Align"),command:"justifyleft",noActive:true},center:{name:__("Center Align"),command:"justifycenter",noActive:true},right:{name:__("Right Align"),command:"justifyright",noActive:true},ol:{name:__("Insert Ordered List"),command:"insertorderedlist",tags:["OL"]},ul:{name:__("Insert Unordered List"),command:"insertunorderedlist",tags:["UL"]},subscript:{name:__("Click to Subscript"),command:"subscript",tags:["SUB"]},superscript:{name:__("Click to Superscript"),command:"superscript",tags:["SUP"]},strikethrough:{name:__("Click to Strike Through"),command:"strikeThrough",css:{"text-decoration":"line-through"}},indent:{name:__("Indent Text"),command:"indent",noActive:true},outdent:{name:__("Remove Indent"),command:"outdent",noActive:true},hr:{name:__("Horizontal Rule"),command:"insertHorizontalRule",noActive:true}},iconsPath:"../nicEditorIcons.gif",buttonList:["bold","italic","underline","left","center","right","ol","ul","fontSize","fontFamily","fontFormat","indent","outdent","link","image"],iconList:{xhtml:1,bgcolor:2,forecolor:3,bold:4,center:5,hr:6,indent:7,italic:8,justify:9,left:10,ol:11,outdent:12,right:13,save:14,strikethrough:15,subscript:16,superscript:17,ul:18,underline:19,image:20,link:21,unlink:22,close:23,arrow:24}});var nicEditors={nicPlugins:[],editors:[],registerPlugin:function(D,C){this.nicPlugins.push({p:D,o:C})},allTextAreas:function(E){var D=document.getElementsByTagName("textarea");for(var F=0;F<D.length;F++){nicEditors.editors.push(new nicEditor(E).panelInstance(D[F]))}return nicEditors.editors},findEditor:function(E){var F=nicEditors.editors;for(var D=0;D<F.length;D++){if(F[D].instanceById(E)){return F[D]}}}};var nicEditor=bkClass.extend({construct:function(E){this.options=new nicEditorConfig();bkExtend(this.options,E);this.nicInstances=new Array();this.loadedPlugins=new Array();var D=nicEditors.nicPlugins;for(var F=0;F<D.length;F++){this.loadedPlugins.push(new D[F].p(this,D[F].o))}nicEditors.editors.push(this);bkLib.addEvent(document.body,"mousedown",this.selectCheck.closureListener(this))},panelInstance:function(F,E){if(typeof (F)=="string"){jareaids.push(F)}F=this.checkReplace($BK(F));var D=new bkElement("DIV").setStyle({width:(parseInt(F.getStyle("width"))||F.clientWidth)+"px"}).appendBefore(F);this.setPanel(D);return this.addInstance(F,E)},checkReplace:function(D){var C=nicEditors.findEditor(D);if(C){C.removeInstance(D);C.removePanel()}return D},addInstance:function(F,E){F=this.checkReplace($BK(F));if(F.contentEditable||!!window.opera){var D=new nicEditorInstance(F,E,this)}else{var D=new nicEditorIFrameInstance(F,E,this)}this.nicInstances.push(D);this.fireEvent("add",D);return this},removeInstance:function(E){E=$BK(E);var F=this.nicInstances;for(var D=0;D<F.length;D++){if(F[D].e==E){F[D].remove();this.nicInstances.splice(D,1)}}},removePanel:function(B){if(this.nicPanel){this.nicPanel.remove();this.nicPanel=null}},instanceById:function(E){E=$BK(E);var F=this.nicInstances;for(var D=0;D<F.length;D++){if(F[D].e==E){return F[D]}}},setPanel:function(B){this.nicPanel=new nicEditorPanel($BK(B),this.options,this);this.fireEvent("panel",this.nicPanel);return this},nicCommand:function(D,C){if(this.selectedInstance){this.selectedInstance.nicCommand(D,C)}},getIcon:function(F,E){var G=this.options.iconList[F];var H=(E.iconFiles)?E.iconFiles[F]:"";return{backgroundImage:"url('"+((G)?this.options.iconsPath:H)+"')",backgroundPosition:((G)?((G-1)*-18):0)+"px 0px"}},selectCheck:function(E,D){var F=false;do{if(D.className&&D.className.indexOf("nicEdit")!=-1){return false}}while(D=D.parentNode);this.fireEvent("blur",this.selectedInstance,D);this.lastSelectedInstance=this.selectedInstance;this.selectedInstance=null;return false}});nicEditor=nicEditor.extend(bkEvent);var nicEditorInstance=bkClass.extend({isSelected:false,construct:function(J,L,M){this.ne=M;this.elm=this.e=J;this.options=L||{};newX=parseInt(J.getStyle("width"))||J.clientWidth;newY=parseInt(J.getStyle("height"))||J.clientHeight;this.initialHeight=newY-8;var I=(J.nodeName.toLowerCase()=="textarea");if(I||this.options.hasPanel){this.editorContain=new bkElement("DIV").setStyle({width:newX+"px",border:"1px solid #ccc",borderTop:0,overflowY:"auto",overflowX:"hidden",maxHeight:(this.ne.options.maxHeight)?this.ne.options.maxHeight+"px":null}).appendBefore(J);var H=new bkElement("DIV").setStyle({width:(newX-8)+"px",margin:"4px",minHeight:newY+"px"}).addClass("main").appendTo(this.editorContain);J.setStyle({display:"none"});if(I){H.setContent(J.value);this.copyElm=J;while(J=J.parentNode){if(J.nodeName=="FORM"){bkLib.addEvent(J,"submit",this.saveContent.closure(this))}}}else{H.innerHTML=J.innerHTML}var N=(bkLib.isMSIE&&!((typeof document.body.style.maxHeight!="undefined")&&document.compatMode=="CSS1Compat"));H.setStyle((N)?{height:newY+"px"}:{overflow:"hidden"});this.elm=H}this.ne.addEvent("blur",this.blur.closure(this));this.init();this.blur();try{this.nicCommand("styleWithCSS",true)}catch(K){}},init:function(){this.elm.setAttribute("contentEditable","true");jnedinst.push(this.elm);if(this.getContent()==""){this.setContent("<br />")}this.instanceDoc=document.defaultView;this.elm.addEvent("mousedown",this.selected.closureListener(this)).addEvent("keypress",this.keyDown.closureListener(this)).addEvent("focus",this.selected.closure(this)).addEvent("blur",this.blur.closure(this)).addEvent("keyup",this.selected.closure(this))},remove:function(){this.saveContent();if(this.copyElm||this.options.hasPanel){this.editorContain.remove();this.e.setStyle({display:"block"});this.ne.removePanel()}this.disable();this.ne.fireEvent("removeInstance",this)},disable:function(){this.elm.setAttribute("contentEditable","false")},getSel:function(){return(window.getSelection)?window.getSelection():document.selection},getRng:function(){var B=this.getSel();if(!B){return null}return(B.rangeCount>0)?B.getRangeAt(0):B.createRange()},selRng:function(C,D){if(window.getSelection){D.removeAllRanges();D.addRange(C)}else{C.select()}},selElm:function(){var G=this.getRng();if(G.startContainer){var F=G.startContainer;if(G.cloneContents().childNodes.length==1){for(var H=0;H<F.childNodes.length;H++){var E=F.childNodes[H].ownerDocument.createRange();E.selectNode(F.childNodes[H]);if(G.compareBoundaryPoints(Range.START_TO_START,E)!=1&&G.compareBoundaryPoints(Range.END_TO_END,E)!=-1){return $BK(F.childNodes[H])}}}return $BK(F)}else{return $BK((this.getSel().type=="Control")?G.item(0):G.parentElement())}},saveRng:function(){this.savedRange=this.getRng();this.savedSel=this.getSel()},restoreRng:function(){if(this.savedRange){this.selRng(this.savedRange,this.savedSel)}},keyDown:function(E,F){if(E.keyCode==13){if(bkLib.isMSIE){var D=this.getRng();D.pasteHTML("<br />");D.collapse(false);D.select();return false}}if(E.ctrlKey){this.ne.fireEvent("key",this,E);if(E.preventDefault){E.preventDefault()}return false}},selected:function(E,D){if(!D){D=this.selElm()}if(!E.ctrlKey){var F=this.ne.selectedInstance;if(F!=this){if(F){this.ne.fireEvent("blur",F,D)}this.ne.selectedInstance=this;this.ne.fireEvent("focus",F,D)}this.ne.fireEvent("selected",F,D);this.isFocused=true;this.elm.addClass("selected")}return false},blur:function(){this.isFocused=false;this.elm.removeClass("selected")},saveContent:function(){if(this.copyElm||this.options.hasPanel){this.ne.fireEvent("save",this);(this.copyElm)?this.copyElm.value=this.getContent():this.e.innerHTML=this.getContent()}},getElm:function(){return this.elm},getContent:function(){this.content=this.getElm().innerHTML;this.ne.fireEvent("get",this);return this.content},setContent:function(B){this.content=B;this.ne.fireEvent("set",this);this.elm.innerHTML=this.content},nicCommand:function(D,C){document.execCommand(D,false,C)}});var nicEditorIFrameInstance=nicEditorInstance.extend({savedStyles:[],init:function(){var D=this.elm.innerHTML.replace(/^\s+|\s+$/g,"");this.elm.innerHTML="";(!D)?D="<br />":D;this.initialContent=D;this.elmFrame=new bkElement("iframe").setAttributes({src:"javascript:;",frameBorder:0,allowTransparency:"true",scrolling:"no"}).setStyle({height:"100px",width:"100%"}).addClass("frame").appendTo(this.elm);if(this.copyElm){this.elmFrame.setStyle({width:(this.elm.offsetWidth-4)+"px"})}var C={fontSize:"font-size",fontFamily:"font-family",fontWeight:"font-weight",color:"color"};for(itm in C){this.savedStyles[itm]=this.elm.getStyle(C[itm])}setTimeout(this.initFrame.closure(this),50)},disable:function(){this.elm.innerHTML=this.getContent()},initFrame:function(){this.frameDoc=$BK(this.elmFrame.contentWindow.document);this.frameDoc.designMode="on";this.frameDoc.open();this.frameDoc.write('<html><head></head><body id="nicEditContent" style="margin: 0 !important; background-color: transparent !important;">'+this.initialContent+"</body></html>");this.frameDoc.close();this.frameWin=$BK(this.elmFrame.contentWindow);this.frameContent=$BK(this.frameWin.document.body).setStyle(this.savedStyles);jnedinst.push(this.frameContent);jnedfd.push(this.frameDoc);this.instanceDoc=this.frameWin.document.defaultView;this.heightUpdate(true);this.frameDoc.addEvent("mousedown",this.selected.closureListener(this)).addEvent("keyup",this.heightUpdate.closureListener(this)).addEvent("keydown",this.keyDown.closureListener(this)).addEvent("keyup",this.selected.closure(this))},getElm:function(){return this.frameContent},setContent:function(B){this.content=B;this.ne.fireEvent("set",this);this.frameContent.innerHTML=this.content;this.heightUpdate()},getSel:function(){return(this.frameWin)?this.frameWin.getSelection():this.frameDoc.selection},heightUpdate:function(B){if(B===true){A=(this.frameContent.offsetHeight<400)?this.frameContent.offsetHeight:400}else{A=this.frameContent.offsetHeight}this.elmFrame.style.height=Math.max(A,this.initialHeight)+"px"},nicCommand:function(D,C){this.frameDoc.execCommand(D,false,C);setTimeout(this.heightUpdate.closure(this),100)}});var nicEditorPanel=bkClass.extend({construct:function(G,J,F){this.elm=G;this.options=J;this.ne=F;this.panelButtons=new Array();this.buttonList=bkExtend([],this.ne.options.buttonList);this.panelContain=new bkElement("DIV").setStyle({overflow:"hidden",width:"100%",border:"1px solid #cccccc",backgroundColor:"#efefef"}).addClass("panelContain");this.panelElm=new bkElement("DIV").setStyle({margin:"2px",marginTop:"0px",zoom:1,overflow:"hidden"}).addClass("panel").appendTo(this.panelContain);this.panelContain.appendTo(G);var I=this.ne.options;var H=I.buttons;for(button in H){this.addButton(button,I,true)}this.reorder();G.noSelect()},addButton:function(buttonName,options,noOrder){var button=options.buttons[buttonName];var type=(button.type)?eval("(typeof("+button.type+') == "undefined") ? null : '+button.type+";"):nicEditorButton;var hasButton=bkLib.inArray(this.buttonList,buttonName);if(type&&(hasButton||this.ne.options.fullPanel)){this.panelButtons.push(new type(this.panelElm,buttonName,options,this.ne));if(!hasButton){this.buttonList.push(buttonName)}}},findButton:function(D){for(var C=0;C<this.panelButtons.length;C++){if(this.panelButtons[C].name==D){return this.panelButtons[C]}}},reorder:function(){var E=this.buttonList;for(var F=0;F<E.length;F++){var D=this.findButton(E[F]);if(D){this.panelElm.appendChild(D.margin)}}},remove:function(){this.elm.remove()}});var nicEditorButton=bkClass.extend({isDisabled:false,isHover:false,isActive:false,construct:function(F,E,G,H){this.options=G.buttons[E];this.name=E;this.ne=H;this.elm=F;this.margin=new bkElement("DIV").setStyle({"float":"left",marginTop:"2px"}).appendTo(F);this.contain=new bkElement("DIV").setStyle({width:"20px",height:"20px"}).addClass("buttonContain").appendTo(this.margin);this.border=new bkElement("DIV").setStyle({backgroundColor:"#efefef",border:"1px solid #efefef"}).appendTo(this.contain);this.button=new bkElement("DIV").setStyle({width:"18px",height:"18px",overflow:"hidden",zoom:1,cursor:"pointer"}).addClass("button").setStyle(this.ne.getIcon(E,G)).appendTo(this.border);this.button.addEvent("mouseover",this.hoverOn.closure(this)).addEvent("mouseout",this.hoverOff.closure(this)).addEvent("mousedown",this.mouseClick.closure(this)).noSelect();if(!window.opera){this.button.onmousedown=bkLib.cancelEvent;this.button.onclick=bkLib.cancelEvent}H.addEvent("selected",this.enable.closure(this)).addEvent("blur",this.disable.closure(this)).addEvent("key",this.key.closure(this));this.disable();this.init()},init:function(){},hide:function(){this.contain.setStyle({display:"none"})},updateState:function(){if(this.isDisabled){this.setBg()}else{if(this.isHover){this.setBg("hover")}else{if(this.isActive){this.setBg("active")}else{this.setBg()}}}},setBg:function(C){switch(C){case"hover":var D={border:"1px solid #666",backgroundColor:"#ddd"};break;case"active":var D={border:"1px solid #666",backgroundColor:"#ccc"};break;default:var D={border:"1px solid #efefef",backgroundColor:"#efefef"}}this.border.setStyle(D).addClass("button-"+C)},checkNodes:function(C){var D=C;do{if(this.options.tags&&bkLib.inArray(this.options.tags,D.nodeName)){this.activate();return true}}while(D=D.parentNode&&D.className!="nicEdit");D=$BK(C);while(D.nodeType==3){D=$BK(D.parentNode)}if(this.options.css){for(itm in this.options.css){if(D.getStyle(itm,this.ne.selectedInstance.instanceDoc)==this.options.css[itm]){this.activate();return true}}}this.deactivate();return false},activate:function(){if(!this.isDisabled){this.isActive=true;this.updateState();this.ne.fireEvent("buttonActivate",this)}},deactivate:function(){this.isActive=false;this.updateState();if(!this.isDisabled){this.ne.fireEvent("buttonDeactivate",this)}},enable:function(C,D){this.isDisabled=false;this.contain.setStyle({opacity:1}).addClass("buttonEnabled");this.updateState();this.checkNodes(D)},disable:function(C,D){this.isDisabled=true;this.contain.setStyle({opacity:0.6}).removeClass("buttonEnabled");this.updateState()},toggleActive:function(){(this.isActive)?this.deactivate():this.activate()},hoverOn:function(){if(!this.isDisabled){this.isHover=true;this.updateState();this.ne.fireEvent("buttonOver",this)}},hoverOff:function(){this.isHover=false;this.updateState();this.ne.fireEvent("buttonOut",this)},mouseClick:function(){if(this.options.command){this.ne.nicCommand(this.options.command,this.options.commandArgs);if(!this.options.noActive){this.toggleActive()}}this.ne.fireEvent("buttonClick",this)},key:function(C,D){if(this.options.key&&D.ctrlKey&&String.fromCharCode(D.keyCode).toLowerCase()==this.options.key){this.mouseClick()}}});var nicPlugin=bkClass.extend({construct:function(D,C){this.options=C;this.ne=D;this.ne.addEvent("panel",this.loadPanel.closure(this));this.init()},loadPanel:function(E){var F=this.options.buttons;for(var D in F){E.addButton(D,this.options)}E.reorder()},init:function(){}});var nicPaneOptions={};var nicEditorPane=bkClass.extend({construct:function(F,G,H,E){this.ne=G;this.elm=F;this.pos=F.pos();this.contain=new bkElement("div").setStyle({zIndex:"99999",overflow:"hidden",position:"absolute",left:this.pos[0]+"px",top:this.pos[1]+"px"});this.pane=new bkElement("div").setStyle({fontSize:"12px",border:"1px solid #ccc",overflow:"hidden",padding:"4px",textAlign:"left",backgroundColor:"#ffffc9"}).addClass("pane").setStyle(H).appendTo(this.contain);if(E&&!E.options.noClose){this.close=new bkElement("div").setStyle({"float":"right",height:"16px",width:"16px",cursor:"pointer"}).setStyle(this.ne.getIcon("close",nicPaneOptions)).addEvent("mousedown",E.removePane.closure(this)).appendTo(this.pane)}this.contain.noSelect().appendTo(document.body);this.position();this.init()},init:function(){},position:function(){if(this.ne.nicPanel){var F=this.ne.nicPanel.elm;var D=F.pos();var E=D[0]+parseInt(F.getStyle("width"))-(parseInt(this.pane.getStyle("width"))+8);if(E<this.pos[0]){this.contain.setStyle({left:E+"px"})}}},toggle:function(){this.isVisible=!this.isVisible;this.contain.setStyle({display:((this.isVisible)?"block":"none")})},remove:function(){if(this.contain){this.contain.remove();this.contain=null}},append:function(B){B.appendTo(this.pane)},setContent:function(B){this.pane.setContent(B)}});var nicEditorAdvancedButton=nicEditorButton.extend({init:function(){this.ne.addEvent("selected",this.removePane.closure(this)).addEvent("blur",this.removePane.closure(this))},mouseClick:function(){if(!this.isDisabled){if(this.pane&&this.pane.pane){this.removePane()}else{this.pane=new nicEditorPane(this.contain,this.ne,{width:(this.width||"270px"),backgroundColor:"#fff"},this);this.addPane();this.ne.selectedInstance.saveRng()}}},addForm:function(M,I){this.form=new bkElement("form").addEvent("submit",this.submit.closureListener(this));this.pane.append(this.form);this.inputs={};for(itm in M){var L=M[itm];var J="";if(I){J=I.getAttribute(itm)}if(!J){J=L.value||""}var H=M[itm].type;if(H=="title"){new bkElement("div").setContent(L.txt).setStyle({fontSize:"14px",fontWeight:"bold",padding:"0px",margin:"2px 0"}).appendTo(this.form)}else{var N=new bkElement("div").setStyle({overflow:"hidden",clear:"both"}).appendTo(this.form);if(L.txt){new bkElement("label").setAttributes({"for":itm}).setContent(L.txt).setStyle({margin:"2px 4px",fontSize:"13px",width:"50px",lineHeight:"20px",textAlign:"right","float":"left"}).appendTo(N)}switch(H){case"text":this.inputs[itm]=new bkElement("input").setAttributes({id:itm,value:J,type:"text"}).setStyle({margin:"2px 0",fontSize:"13px","float":"left",height:"20px",border:"1px solid #ccc",overflow:"hidden"}).setStyle(L.style).appendTo(N);break;case"select":this.inputs[itm]=new bkElement("select").setAttributes({id:itm}).setStyle({border:"1px solid #ccc","float":"left",margin:"2px 0"}).appendTo(N);for(opt in L.options){var K=new bkElement("option").setAttributes({value:opt,selected:(opt==J)?"selected":""}).setContent(L.options[opt]).appendTo(this.inputs[itm])}break;case"content":this.inputs[itm]=new bkElement("textarea").setAttributes({id:itm}).setStyle({border:"1px solid #ccc","float":"left"}).setStyle(L.style).appendTo(N);this.inputs[itm].value=J}}}new bkElement("input").setAttributes({type:"submit"}).setStyle({backgroundColor:"#efefef",border:"1px solid #ccc",margin:"3px 0","float":"left",clear:"both"}).appendTo(this.form);this.form.onsubmit=bkLib.cancelEvent},submit:function(){},findElm:function(J,F,G){var H=this.ne.selectedInstance.getElm().getElementsByTagName(J);for(var I=0;I<H.length;I++){if(H[I].getAttribute(F)==G){return $BK(H[I])}}},removePane:function(){if(this.pane){this.pane.remove();this.pane=null;this.ne.selectedInstance.restoreRng()}}});var nicButtonTips=bkClass.extend({construct:function(B){this.ne=B;B.addEvent("buttonOver",this.show.closure(this)).addEvent("buttonOut",this.hide.closure(this))},show:function(B){this.timer=setTimeout(this.create.closure(this,B),400)},create:function(B){this.timer=null;if(!this.pane){this.pane=new nicEditorPane(B.button,this.ne,{fontSize:"12px",marginTop:"5px"});this.pane.setContent(B.options.name)}},hide:function(B){if(this.timer){clearTimeout(this.timer)}if(this.pane){this.pane=this.pane.remove()}}});nicEditors.registerPlugin(nicButtonTips);var nicSelectOptions={buttons:{fontSize:{name:__("Select Font Size"),type:"nicEditorFontSizeSelect",command:"fontsize"},fontFamily:{name:__("Select Font Family"),type:"nicEditorFontFamilySelect",command:"fontname"},fontFormat:{name:__("Select Font Format"),type:"nicEditorFontFormatSelect",command:"formatBlock"}}};var nicEditorSelect=bkClass.extend({construct:function(F,E,G,H){this.options=G.buttons[E];this.elm=F;this.ne=H;this.name=E;this.selOptions=new Array();this.margin=new bkElement("div").setStyle({"float":"left",margin:"2px 1px 0 1px"}).appendTo(this.elm);this.contain=new bkElement("div").setStyle({width:"90px",height:"20px",cursor:"pointer",overflow:"hidden"}).addClass("selectContain").addEvent("click",this.toggle.closure(this)).appendTo(this.margin);this.items=new bkElement("div").setStyle({overflow:"hidden",zoom:1,border:"1px solid #ccc",paddingLeft:"3px",backgroundColor:"#fff"}).appendTo(this.contain);this.control=new bkElement("div").setStyle({overflow:"hidden","float":"right",height:"18px",width:"16px"}).addClass("selectControl").setStyle(this.ne.getIcon("arrow",G)).appendTo(this.items);this.txt=new bkElement("div").setStyle({overflow:"hidden","float":"left",width:"66px",height:"14px",marginTop:"1px",fontFamily:"sans-serif",textAlign:"center",fontSize:"12px"}).addClass("selectTxt").appendTo(this.items);if(!window.opera){this.contain.onmousedown=this.control.onmousedown=this.txt.onmousedown=bkLib.cancelEvent}this.margin.noSelect();this.ne.addEvent("selected",this.enable.closure(this)).addEvent("blur",this.disable.closure(this));this.disable();this.init()},disable:function(){this.isDisabled=true;this.close();this.contain.setStyle({opacity:0.6})},enable:function(B){this.isDisabled=false;this.close();this.contain.setStyle({opacity:1})},setDisplay:function(B){this.txt.setContent(B)},toggle:function(){if(!this.isDisabled){(this.pane)?this.close():this.open()}},open:function(){this.pane=new nicEditorPane(this.items,this.ne,{width:"88px",padding:"0px",borderTop:0,borderLeft:"1px solid #ccc",borderRight:"1px solid #ccc",borderBottom:"0px",backgroundColor:"#fff"});for(var G=0;G<this.selOptions.length;G++){var H=this.selOptions[G];var E=new bkElement("div").setStyle({overflow:"hidden",borderBottom:"1px solid #ccc",width:"88px",textAlign:"left",overflow:"hidden",cursor:"pointer"});var F=new bkElement("div").setStyle({padding:"0px 4px"}).setContent(H[1]).appendTo(E).noSelect();F.addEvent("click",this.update.closure(this,H[0])).addEvent("mouseover",this.over.closure(this,F)).addEvent("mouseout",this.out.closure(this,F)).setAttributes("id",H[0]);this.pane.append(E);if(!window.opera){F.onmousedown=bkLib.cancelEvent}}},close:function(){if(this.pane){this.pane=this.pane.remove()}},over:function(B){B.setStyle({backgroundColor:"#ccc"})},out:function(B){B.setStyle({backgroundColor:"#fff"})},add:function(D,C){this.selOptions.push(new Array(D,C))},update:function(B){this.ne.nicCommand(this.options.command,B);this.close()}});var nicEditorFontSizeSelect=nicEditorSelect.extend({sel:{1:"1&nbsp;(8pt)",2:"2&nbsp;(10pt)",3:"3&nbsp;(12pt)",4:"4&nbsp;(14pt)",5:"5&nbsp;(18pt)",6:"6&nbsp;(24pt)"},init:function(){this.setDisplay("Font&nbsp;Size...");for(itm in this.sel){this.add(itm,'<font size="'+itm+'">'+this.sel[itm]+"</font>")}}});var nicEditorFontFamilySelect=nicEditorSelect.extend({sel:{arial:"Arial","comic sans ms":"Comic Sans","courier new":"Courier New",georgia:"Georgia",helvetica:"Helvetica",impact:"Impact","times new roman":"Times","trebuchet ms":"Trebuchet",verdana:"Verdana"},init:function(){this.setDisplay("Font&nbsp;Family...");for(itm in this.sel){this.add(itm,'<font face="'+itm+'">'+this.sel[itm]+"</font>")}}});var nicEditorFontFormatSelect=nicEditorSelect.extend({sel:{p:"Paragraph",pre:"Pre",h6:"Heading&nbsp;6",h5:"Heading&nbsp;5",h4:"Heading&nbsp;4",h3:"Heading&nbsp;3",h2:"Heading&nbsp;2",h1:"Heading&nbsp;1"},init:function(){this.setDisplay("Font&nbsp;Format...");for(itm in this.sel){var B=itm.toUpperCase();this.add("<"+B+">","<"+itm+' style="padding: 0px; margin: 0px;">'+this.sel[itm]+"</"+B+">")}}});nicEditors.registerPlugin(nicPlugin,nicSelectOptions);var nicLinkOptions={buttons:{link:{name:"Add Link",type:"nicLinkButton",tags:["A"]},unlink:{name:"Remove Link",command:"unlink",noActive:true}}};var nicLinkButton=nicEditorAdvancedButton.extend({addPane:function(){this.ln=this.ne.selectedInstance.selElm().parentTag("A");this.addForm({"":{type:"title",txt:"Add/Edit Link"},href:{type:"text",txt:"URL",value:"http://",style:{width:"150px"}},title:{type:"text",txt:"Title"},target:{type:"select",txt:"Open In",options:{"":"Current Window",_blank:"New Window"},style:{width:"100px"}}},this.ln)},submit:function(E){var D=this.inputs.href.value;if(D=="http://"||D==""){alert("You must enter a URL to Create a Link");return false}this.removePane();if(!this.ln){var F="javascript:nicTemp();";this.ne.nicCommand("createlink",F);this.ln=this.findElm("A","href",F)}if(this.ln){this.ln.setAttributes({href:this.inputs.href.value,title:this.inputs.title.value,target:this.inputs.target.options[this.inputs.target.selectedIndex].value})}}});nicEditors.registerPlugin(nicPlugin,nicLinkOptions);var nicColorOptions={buttons:{forecolor:{name:__("Change Text Color"),type:"nicEditorColorButton",noClose:true},bgcolor:{name:__("Change Background Color"),type:"nicEditorBgColorButton",noClose:true}}};var nicEditorColorButton=nicEditorAdvancedButton.extend({addPane:function(){var J={0:"00",1:"33",2:"66",3:"99",4:"CC",5:"FF"};var O=new bkElement("DIV").setStyle({width:"270px"});for(var M in J){for(var Q in J){for(var R in J){var N="#"+J[M]+J[R]+J[Q];var K=new bkElement("DIV").setStyle({cursor:"pointer",height:"15px","float":"left"}).appendTo(O);var P=new bkElement("DIV").setStyle({border:"2px solid "+N}).appendTo(K);var L=new bkElement("DIV").setStyle({backgroundColor:N,overflow:"hidden",width:"11px",height:"11px"}).addEvent("click",this.colorSelect.closure(this,N)).addEvent("mouseover",this.on.closure(this,P)).addEvent("mouseout",this.off.closure(this,P,N)).appendTo(P);if(!window.opera){K.onmousedown=L.onmousedown=bkLib.cancelEvent}}}}this.pane.append(O.noSelect())},colorSelect:function(B){this.ne.nicCommand("foreColor",B);this.removePane()},on:function(B){B.setStyle({border:"2px solid #000"})},off:function(C,D){C.setStyle({border:"2px solid "+D})}});var nicEditorBgColorButton=nicEditorColorButton.extend({colorSelect:function(B){this.ne.nicCommand("hiliteColor",B);this.removePane()}});nicEditors.registerPlugin(nicPlugin,nicColorOptions);var nicImageOptions={buttons:{image:{name:"Add Image",type:"nicImageButton",tags:["IMG"]}}};var nicImageButton=nicEditorAdvancedButton.extend({addPane:function(){this.im=this.ne.selectedInstance.selElm().parentTag("IMG");this.addForm({"":{type:"title",txt:"Add/Edit Image"},src:{type:"text",txt:"URL",value:"http://",style:{width:"150px"}},alt:{type:"text",txt:"Alt Text",style:{width:"100px"}},align:{type:"select",txt:"Align",options:{left:"Left",right:"Right"}}},this.im)},submit:function(F){var E=this.inputs.src.value;if(E==""||E=="http://"){alert("You must enter a Image URL to insert");return false}this.removePane();if(!this.im){var D="javascript:nicImTemp();";this.ne.nicCommand("insertImage",D);this.im=this.findElm("IMG","src",D)}if(this.im){this.im.setAttributes({src:this.inputs.src.value,alt:this.inputs.alt.value,align:this.inputs.align.value})}}});nicEditors.registerPlugin(nicPlugin,nicImageOptions);var nicXHTML=bkClass.extend({stripAttributes:["_moz_dirty","_moz_resizing","_extended"],noShort:["style","title","script","textarea","a"],cssReplace:{"font-weight:bold;":"strong","font-style:italic;":"em"},sizes:{1:"xx-small",2:"x-small",3:"small",4:"medium",5:"large",6:"x-large"},construct:function(B){this.ne=B;if(this.ne.options.xhtml){B.addEvent("get",this.cleanup.closure(this))}},cleanup:function(D){var F=D.getElm();var E=this.toXHTML(F);D.content=E},toXHTML:function(S,U,a){var f="";var X="";var W="";var d=S.nodeType;var V=S.nodeName.toLowerCase();var Y=S.hasChildNodes&&S.hasChildNodes();var T=new Array();switch(d){case 1:var e=S.attributes;switch(V){case"b":V="strong";break;case"i":V="em";break;case"font":V="span";break}if(U){for(var g=0;g<e.length;g++){var b=e[g];var Z=b.nodeName.toLowerCase();var R=b.nodeValue;if(!b.specified||!R||bkLib.inArray(this.stripAttributes,Z)||typeof (R)=="function"){continue}switch(Z){case"style":var c=R.replace(/ /g,"");for(itm in this.cssReplace){if(c.indexOf(itm)!=-1){T.push(this.cssReplace[itm]);c=c.replace(itm,"")}}W+=c;R="";break;case"class":R=R.replace("Apple-style-span","");break;case"size":W+="font-size:"+this.sizes[R]+";";R="";break}if(R){X+=" "+Z+'="'+R+'"'}}if(W){X+=' style="'+W+'"'}for(var g=0;g<T.length;g++){f+="<"+T[g]+">"}if(X==""&&V=="span"){U=false}if(U){f+="<"+V;if(V!="br"){f+=X}}}if(!Y&&!bkLib.inArray(this.noShort,Z)){if(U){f+=" />"}}else{if(U){f+=">"}for(var g=0;g<S.childNodes.length;g++){var h=this.toXHTML(S.childNodes[g],true,true);if(h){f+=h}}}if(U&&Y){f+="</"+V+">"}for(var g=0;g<T.length;g++){f+="</"+T[g]+">"}break;case 3:f+=S.nodeValue;break}return f}});nicEditors.registerPlugin(nicXHTML);var nicBBCode=bkClass.extend({construct:function(C){this.ne=C;if(this.ne.options.bbCode){C.addEvent("get",this.bbGet.closure(this));C.addEvent("set",this.bbSet.closure(this));var D=this.ne.loadedPlugins;for(itm in D){if(D[itm].toXHTML){this.xhtml=D[itm]}}}},bbGet:function(C){var D=this.xhtml.toXHTML(C.getElm());C.content=this.toBBCode(D)},bbSet:function(B){B.content=this.fromBBCode(B.content)},toBBCode:function(D){function C(B,E){D=D.replace(B,E)}C(/\n/gi,"");C(/<strong>(.*?)<\/strong>/gi,"[b]$1[/b]");C(/<em>(.*?)<\/em>/gi,"[i]$1[/i]");C(/<span.*?style="text-decoration:underline;">(.*?)<\/span>/gi,"[u]$1[/u]");C(/<ul>(.*?)<\/ul>/gi,"[list]$1[/list]");C(/<li>(.*?)<\/li>/gi,"[*]$1[]");C(/<ol>(.*?)<\/ol>/gi,"[list=1]$1[/list]");C(/<img.*?src="(.*?)".*?>/gi,"[img]$1[/img]");C(/<a.*?href="(.*?)".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");C(/<br.*?>/gi,"\n");C(/<.*?>.*?<\/.*?>/gi,"");return D},fromBBCode:function(C){function D(B,E){C=C.replace(B,E)}D(/\[b\](.*?)\[\/b\]/gi,"<strong>$1</strong>");D(/\[i\](.*?)\[\/i\]/gi,"<em>$1</em>");D(/\[u\](.*?)\[\/u\]/gi,'<span style="text-decoration:underline;">$1</span>');D(/\[list\](.*?)\[\/list\]/gi,"<ul>$1</ul>");D(/\[list=1\](.*?)\[\/list\]/gi,"<ol>$1</ol>");D(/\[\*\](.*?)\[\/\*\]/gi,"<li>$1</li>");D(/\[img\](.*?)\[\/img\]/gi,'<img src="$1" />');D(/\[url=(.*?)\](.*?)\[\/url\]/gi,'<a href="$1">$2</a>');D(/\n/gi,"<br />");return C}});nicEditors.registerPlugin(nicBBCode);var nicCodeOptions={buttons:{xhtml:{name:"Edit HTML",type:"nicCodeButton"}}};var nicCodeButton=nicEditorAdvancedButton.extend({width:"350px",addPane:function(){this.addForm({"":{type:"title",txt:"Edit HTML"},code:{type:"content",value:this.ne.selectedInstance.getContent(),style:{width:"340px",height:"200px"}}})},submit:function(D){var C=this.inputs.code.value;this.ne.selectedInstance.setContent(C);this.removePane()}});nicEditors.registerPlugin(nicPlugin,nicCodeOptions);
