// JavaScript Document
function addMCEs(frm){
	var tm = 1;
	if($(frm).hasClass("modal")) tm=300;
	$(frm).find("textarea.smEditor").each(function(e){ setTimeout('addMCE(\''+this.id+'\')',tm); });
	return false;
}

function addMCE(id){
	//MCEs.push(id);
	mce = $('#'+id);
	var val = getVal(mce);
	//alert('val='+val);
	//alert('id');
	tinyMCE.execCommand('mceAddControl', false, id);
	tinyMCE.get(id).setContent(val);
	mce.addClass("mce");
	
	//alert(id+'\naddMCE'+'\n'+val+'\ncount='+MCEs.length);
	return false;
}

function removeMCEs(frm){
	frm = $(frm);
	if(!frm.hasClass("modal")) frm.find(".mce").each(function(e){ removeMCE(this); });
	return false;
}

function removeMCE(mce){
	$(mce).removeClass("mce");
    //var val= tinyMCE.get(id).getContent();
	tinyMCE.execCommand('mceRemoveControl', false, mce.id);
	//$('#'+id).val(val);
	//alert(id+'\removeMCE'+'\n'+val+'\ncount='+MCEs.length);
	return false;
}


tinyMCE.init({
	theme : "advanced",
	mode : "none",
	
	plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

	// Theme options
	theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect",
	theme_advanced_buttons2 :"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,|,insertdate,inserttime,preview,|,forecolor",
	theme_advanced_buttons3 : "",
	theme_advanced_buttons4 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : true
});
/*
tinyMCE.init({
	theme : "simple",
	mode : "none",
    editor_selector : "smEditor",    
	language : "en",
	theme_simple_layout_manager : "SimpleLayout",
	theme_simple_toolbar_location : "top",
	theme_simple_toolbar_align : "left",
	theme_simple_buttons1 : "bold,italic,underline",
	theme_simple_buttons2 : "",
	theme_simple_buttons3 : ""
});
*/
