
function sleep(milliseconds) { 
		var start=new Date().getTime(); 
		for(var i=0;i<i+2;i++) {		
			if((new Date().getTime()-start)>milliseconds){ 
				break ;
			} 
	   } 
 } 
    
if (typeof XQA_EDITOR == "undefined") {
	var XQA_EDITOR = {};
}
XQA_EDITOR.create = function (_var_name, _editor_id, _onInitialized, _fileBrowserCallBack) {
//	function onContentLoaded(){
//		tinyMCE.setContent(parent.unEscapeAnd(parent.document.getElementById("hiddenArea").innerHTML));
//	};
	this.getEscapeContent = function () {
		return escape(tinyMCE.getContent());
	};
	this.getContent = function () {
		var content =  tinyMCE.getContent();
		sleep(300);
		return content;
		
	};
	
	

	this.setContent = function (c) {
		tinyMCE.setContent(c);
	};
	this.onInitialized = function () {};
	this.fileBrowserCallBack = function (field_name, url, type, win) {};	

	tinyMCE.init({
			mode : "textareas",
			theme : "advanced",
			plugins : "layer,advhr,emotions,insertdatetime,preview,zoom,media,searchreplace,contextmenu,paste",
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,forecolor,backcolor,|,formatselect,fontselect,fontsizeselect",
			theme_advanced_buttons2 : "justifyleft,justifycenter,justifyright,|,cut,copy,paste,pastetext,pasteword,|,link,unlink,|,image,media,emotions,|,code,preview",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			content_css : "globals/tinymce_style.css",
		    plugin_insertdate_dateFormat : "%Y-%m-%d",
		    plugin_insertdate_timeFormat : "%H:%M:%S",
			file_browser_callback : _fileBrowserCallBack == null ? _var_name + ".fileBrowserCallBack" : _fileBrowserCallBack,
			setupcontent_callback : _onInitialized == null ? _var_name + ".onInitialized" : _onInitialized,
			paste_use_dialog : false,
			theme_advanced_resizing : true,
			theme_advanced_resize_horizontal : true,
			paste_auto_cleanup_on_paste : true,
			paste_convert_headers_to_strong : false,
			paste_strip_class_attributes : "all",
			paste_remove_spans : false,
			paste_remove_styles : false	
		});
};

