var editorLastElement2='';

function editorAreacreate(oareaID){
	if(document.getElementById(oareaID)){
		//if(tinyMCE.get(oareaID))
			//tinyMCE.get(oareaID).remove();
		if(editorLastElement2!=''){
			//alert(editorLastElement);
			//tinyMCE.execCommand("mceRemoveControl", true, editorLastElement2);
			tinyMCE.execCommand("mceAddControl", true, oareaID);
		}
		else{
			
		tinyMCE.init({
				//mode : "textareas",
				mode : "exact",
				elements : oareaID,
				theme : "advanced",
				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 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
				theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
				theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
				theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
				theme_advanced_toolbar_location : "top",
				theme_advanced_toolbar_align : "left",
				theme_advanced_statusbar_location : "bottom",
				theme_advanced_resizing : true  
		
				
			});
		}
		editorLastElement2=oareaID;
	}
}

var editorLastElement='';

function editorAreacreateMini(oareaID){
	
	if(oareaID && document.getElementById(oareaID)){
		
		if(editorLastElement!=''){
			//alert(editorLastElement);
			//tinyMCE.execCommand("mceRemoveControl", true, oareaID);
			
		  
		  /*if (tinyMCE.getInstanceById(editorLastElement) != null) {
			  tinyMCE.execCommand('mceRemoveControl', false, editorLastElement);
		   }
		   */

			tinyMCE.execCommand("mceAddControl", true, oareaID);
			//tinyMCE.triggerSave();
			//tinyMCE.triggerSave(false,true);

		}
		else{

		tinyMCE.init({
				
				mode : "exact",
				elements : oareaID,
				theme : "advanced",
				plugins : "save,emotions,media,fullscreen",
		
			
				theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,undo,redo,|,charmap,emotions,|,link,unlink,image,|,media,fullscreen",
				theme_advanced_buttons2 : "",
				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 

				
			});
		
		}
		// add editor
		//tinyMCE.execCommand("mceAddControl", true, elementId);
		
		// remove editor
		//tinyMCE.execCommand("mceRemoveControl", true, elementId);
		
		
		editorLastElement=oareaID;
	}

}

function editorHiddenarea(oelement){
	if(oelement && document.getElementById(oelement)){
		var areaSeaTD=document.getElementById(oelement);
		areaindex=0;
		while(areaSeaTD.getElementsByTagName('textarea')[areaindex]){
			var testarea=areaSeaTD.getElementsByTagName('textarea')[areaindex];
			if(testarea.id){
				if(tinyMCE.get(testarea.id)){
					tinyMCE.get(testarea.id).remove();

				}
			}
			areaindex++;
		}	
	}

}
