xinha_editors = null;
xinha_init    = null;
xinha_config  = null;
xinha_plugins = null;

xinha_init = xinha_init ? xinha_init : function()
{
	/** List The Plugins ****************************************************/

	xinha_plugins = xinha_plugins ? xinha_plugins :
	[
	 'ContextMenu',
	 'CharacterMap',
//	 'CharCounter',
	 'FindReplace',
//	 'Forms',
	 'InsertAnchor',
//	 'ImageManager',
	 'Linker',
	 'SuperClean',
	 'TableOperations'
	];
	if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;

	/** List textareas Dynamically ******************************************/

	var textareas = document.getElementsByTagName('textarea');
	var xinha_editors = new Array();
	for(var i in textareas) {
	   if(textareas[i].id) {
	  xinha_editors.push(textareas[i].id);
	   }
	}

	/** Customize Your Menu *************************************************/

	xinha_config = xinha_config ? xinha_config : new HTMLArea.Config();

	xinha_config.width  = 400;
	xinha_config.height = 400;

	xinha_config.toolbar =
	[
		["FR-findreplace"],
		["separator"],
		["formatblock","fontname","fontsize"],
		["separator"],
		["textindicator"],
		["linebreak"],
		["bold","italic","underline","strikethrough","subscript","superscript"],
		["separator"],
		["justifyleft","justifycenter","justifyright","justifyfull"],
		["separator"],
		["forecolor","hilitecolor"],
		["separator"],
		["killword","removeformat"],
		["linebreak"],
		["insertorderedlist","insertunorderedlist","outdent","indent"],
		["separator"],
		["inserthorizontalrule","createlink","insertimage"],
		["separator"],
		["undo","redo"],
//		(HTMLArea.is_gecko ? [] : ["cut","copy","paste"]),
		["separator"],
		["htmlmode"],
		["separator"],
		["inserttable","toggleborders","lefttoright", "righttoleft", "separator"]
	];

	this.fontname = {
		"&mdash; font &mdash;":         '',
		"Arial":	   'arial,helvetica,sans-serif',
		"Courier New":	   'courier new,courier,monospace',
		"Georgia":	   'georgia,times new roman,times,serif',
		"Tahoma":	   'tahoma,arial,helvetica,sans-serif',
		"Times New Roman": 'times new roman,times,serif',
		"Verdana":	   'verdana,arial,helvetica,sans-serif'
	};

	xinha_config.formatblock = {
		"&mdash; format &mdash;"  : "",
		"Heading 1": "h1",
		"Heading 2": "h2",
		"Heading 3": "h3",
		"Heading 4": "h4",
		"Heading 5": "h5",
		"Heading 6": "h6",
		"Normal"   : "p",
		"Formatted": "pre"
	};

	/** Create The Editors **************************************************/

	xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);

	/** Start The Editors **************************************************/

	HTMLArea.startEditors(xinha_editors);
}

window.onload = xinha_init;