// And the language we need to use in the editor.

var _editor_lang = "fr";

var xinha_plugins =
	[	'ExtendedFileManager',
		'ImageManager',
		'ContextMenu',
		'SuperClean',
		'CSS',
		'InsertAnchor',
		'TableOperations',
		'UnFormat'
	];

function getTextAreas() {
	var tes = document.getElementsByTagName("textarea");
	var noms = new Array(tes.length);
	var index = 0;
	for (var i=0;i<tes.length;i++) {
		if (tes[i].name != 'petit_texte') {
			noms[index] = tes[i].name;
			index++;
		}
	}
	return noms;
}

var xinha_editors = null;
var xinhaTimer;

/*
function initDisplay() {
	for ( var i in xinha_editors ){
		if (!xinha_editors[i]._iframeLoadDone) {
            xinhaTimer = window.setTimeout("initDisplay()",100);
            return false;
        }
    }

    window.clearTimeout(xinhaTimer); // xinha_editors all ready

	if ($('fieldsetEn')) {
		switchToFr()
	}
}
*/

function xinha_init()
{

	
	
	xinha_editors = getTextAreas();
	
	if (xinha_editors.length > 0) {
	
  if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;
  var xinha_config = new Xinha.Config();
  
 
  xinha_config.width = '680px';
  xinha_config.height = '400px';
  xinha_config.statusBar = false;
  
  xinha_config.toolbar = [
  	[	'bold', 'italic', 'superscript',  'separator',
		'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'separator',
		'outdent', 'indent','insertunorderedlist', 'insertorderedlist', 'linebreak',
		'createlink', 'insertimage',
		"copy", "cut", "paste", "separator",
		'htmlmode','linebreak'
		
	]
  ];
  xinha_config.statusBar = false;
  xinha_config.expandRelativeUrl = false;
  xinha_config.pageStyle = "@import url(/css/main.css);@import url(" + _base_url + "/css/interface.css);@import url(" + _base_url + "/css/editor.css);";
  xinha_config.flowToolbars = false;
  
  xinha_config.cssPluginConfig =
  {
    combos : [
      { label: "Style",
        options: {  "Normal"        : "",
					"titrebleu"     : "titrebleu",
					"sous-titre"    : "soustitreorange",
                    "mini-note"     : "mininote"
                 }
      }
    ]
  };
  
 
  xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
  
  Xinha.startEditors(xinha_editors);
  //initDisplay();
	}
}

//addLoadEvent(xinha_init);
FastInit.addOnLoad(xinha_init);