var FieldEditor=new Class({Extends:Field,Implements:Options,options:{theme:"advanced",mode:"exact",elements:null,plugins:"pagebreak,images,advimage",theme_advanced_buttons1:"bold,italic,underline,strikethrough,|,justifyleft,justifyright,justifycenter,justifyfull,|,bullist,numlist,link,unlink,undo,redo,cutbutton,image,pagebreak,images",theme_advanced_buttons2:"code",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"bottom",theme_advanced_toolbar_align:"left",theme_advanced_statusbar_location:"bottom",theme_advanced_resizing:true,theme_advanced_resize_horizontal:false,theme_advanced_resizing_use_cookie:true,readonly:false,force_p_newlines:false,force_br_newlines:true,forced_root_block:""},_doOnChange:function(){if(this.onChange){this.onChange();}},initialize:function(id,html,options){if(options){this.setOptions(options);}
var self=this;var input=null;if(!$defined(html)){html=$(document);}
this.id=this.e_prefix=id;this.dom={root:html,errors:new Hash(),messages:{},input:null,parent:null};this.dom.parent=this.dom.root.getElement("#"+id+"-row");input=html.getElement("#"+id);if(input==null){throw new ExElementNotExist("Field element: "+id,this);}
this.dom.input=input;this.editor=tinyMCE;this.options.onchange_callback=function(){self._doOnChange();};this.options.handle_node_change_callback=function(){self._doOnChange();};this.editor.init(this.options);this.rules={};},_getMode:function(){return this.editor.get(this.id)?1:0;},showEditor:function(){if(this._getMode()==0){this.editor.execCommand("mceAddControl",false,this.id);}},hideEditor:function(){if(this._getMode()==1){this.editor.execCommand("mceRemoveControl",false,this.id);}},toggleEditor:function(){this.editor.execCommand("mceToggleEditor",false,this.id);},value:function(value){return typeof(value)!="undefined"?this._setValue(value):this._getValue();},_setValue:function(value){this._value=value;this.setHTML(value);return this;},_getValue:function(){return this.getHTML();},setHTML:function(value){if(this._getMode()==1){this.editor.selectedInstance.setContent(value)}else{$setValue(this.dom.input,value);}},getHTML:function(){if(this._getMode()==1){return this.editor.selectedInstance.getContent();}else{return $getValue(this.dom.input);}},reset:function(){this.value(this._value);},clear:function(){this.value("");},isChanged:function(){return this.value()==this._value?false:true;},readonly:function(readonly){return false;},disable:function(flag){return false;},storeToHash:function(){var data={};data[this.id]=this.value();return data;},addEvent:function(event,callback){},removeEvents:function(){},getInput:function(){return null;}});