function phxCleanup(type, value)
{
	//alert(type);
	switch (type) {
		case "get_from_editor":
			alert("Value HTML string: " + value);
			// Do custom cleanup code here
			break;
	}
}

function RICHTEXT_getListeChamp(specialclass)
{
//	alert("RICHTEXT_getListeChamp("+specialclass+")");
	
	var specialclass = specialclass || "";
	var tabObjChamp = new Array();
	var idtext = idtext || "";
	
	if(specialclass != "")
	{
		rule = 'textarea.' + specialclass;
	}
	else
	{
		rule = 'textarea';
	}

//	alert("Rule : " + rule);

	if(rule != "")
	{
		tabObjChamp = $$(rule);
	}
	
	return tabObjChamp;
}
function RICHTEXT_load(specialclass,force_unload, myid)
{
	//alert("RICHTEXT_load("+specialclass+","+force_unload+","+myid+")");
	
	var specialclass = specialclass || "";
	var force_unload = force_unload || false;
	var myid = myid || "";
	var list_champ_richtext = new Array();
	
	if(force_unload == true)
	{
		RICHTEXT_unload(specialclass);
	}
	
	if(myid == "")
	{
		list_champ_richtext = RICHTEXT_getListeChamp(specialclass);
	}
	else
	{
		if($(myid))
		{
			list_champ_richtext[0] = $(myid);
		}else{
			alert("RICHTEXT_load/Precise : ID NOT FOUND");
		}
	}
		
	for(var ch = 0; ch < list_champ_richtext.length; ch++)
	{
    	//alert("LOAD TINY : "+list_champ_richtext[ch].id);
    	if(typeof window.tinyMCE != 'undefined')
    	{
	    	tinyMCE.execCommand('mceAddControl', false, list_champ_richtext[ch].id);	
    	}
	}
}

function RICHTEXT_unload(specialclass, myid)
{
	//alert("RICHTEXT_load("+specialclass+","+myid+")");

	var myid = myid || "";
	var list_champ_richtext = new Array();

	if(myid == "")
	{
		list_champ_richtext = RICHTEXT_getListeChamp(specialclass);
	}
	else
	{
		if($(myid))
		{
			list_champ_richtext[0] = $(myid);
		}else{
			alert("RICHTEXT_load/Precise : ID NOT FOUND");
		}
	}

	for(var ch = 0; ch < list_champ_richtext.length; ch++)
	{
    	//alert("UNLOAD TINY : "+list_champ_richtext[ch].id);
    	if(typeof window.tinyMCE != 'undefined')
    	{
	    	tinyMCE.execCommand('mceRemoveControl', false, list_champ_richtext[ch].id);
    	}
	}
}

function RICHTEXT_get(idTxtArea)
{
	var tnContent = "";
	
	if($(idTxtArea))
	{
    	if(typeof window.tinyMCE != 'undefined')
    	{
			var tnInstanc = tinyMCE.getInstanceById(idTxtArea);
			if(tnInstanc != "undefined")
			{
				tnContent = tnInstanc.getDoc().body.innerHTML;
				//alert(tnContent);
			}
    	}else{
    		tnContent = $(idTxtArea).value;
    	}
	}else{
		tnContent = "undefined";
	}

	tnContent = tnContent.replace('<br mce_bogus="1">','');

	return tnContent;
}

function RICHTEXT_exists(id)
{
   	if(typeof window.tinyMCE != 'undefined')
	{
		var tnInstanc = tinyMCE.getInstanceById(id);
		
		if(typeof(tnInstanc) == "undefined")
		{
			return false;
		}else{
			return true;
		}
	}else{
		if($(id))
		{
			return true;
		}else{
			return false;
		}
	}
}

function RICHTEXT_clear(idTxtArea)
{
   	if(typeof window.tinyMCE != 'undefined')
	{
		var tnInstanc = tinyMCE.getInstanceById(idTxtArea);
		if(tnInstanc != "undefined")
		{
			tnInstanc.getDoc().body.innerHTML = '';
		}
	}else{
		$(idTxtArea).value = "";
	}
}