Bw.Widgets.RichTextEditor =
{
	superclassName: "Bw.Widgets.Editable",
	selfclassName: "Bw.Widgets.RichTextEditor",
	
	create: function ()
	{
		var obj = document.createElement ("div");
		
		Bw.Core.bootstrap (obj, "Bw.Widgets.RichTextEditor");
		
		return obj;
	},

	initialize: function ()
	{
		this.oFCKeditor = new FCKeditor( 'FCK' + this.getAttribute('name') ) ;
		this.oFCKeditor.BasePath	= Valraiso.contextPath + '/optional/script/FCKeditor/' ;
		this.oFCKeditor.Config['CustomConfigurationsPath'] = Valraiso.contextPath + '/js/fckconfig.js';
		this.oFCKeditor.ToolbarSet	= 'cms';
		
		if( this.getAttribute('width') != null )
		{
			this.oFCKeditor.Width = this.getAttribute('width');
		}
		if( this.getAttribute('height') != null )
		{
			this.oFCKeditor.Height = this.getAttribute('height');
		}
		
		var t = document.createElement('TEXTAREA');
		t.id = 'FCK'+ this.getAttribute('name');
		this.appendChild(t);
		this.oFCKeditor.ReplaceTextarea();
	},
	
	getValue: function ()
	{
		//return this.area.getValue();
		var oEditor = FCKeditorAPI.GetInstance('FCK'+ this.getAttribute('name')) ;
		
		return oEditor.GetXHTML( true );
	},
	
	setValue: function (val)
	{
		//this.area.setValue (val);
		
		var _this = this;
		
		if( val == null )
		{
			val = "";	
		}
		
		FCKeditor_OnComplete = function()
		{
			var oEditor = FCKeditorAPI.GetInstance('FCK'+ _this.getAttribute('name')) ;	
			oEditor.SetHTML(val);
		}
		
		try
		{
			var oEditor = FCKeditorAPI.GetInstance('FCK'+ _this.getAttribute('name')) ;	
			oEditor.SetHTML(val);
		}
		catch(err)
		{
				
		}
	}
};

