String.prototype.html_entity_decode = function ()
{	
	var str = new String(this);
	
	str = str.replace(new RegExp( String.fromCharCode(10), "g" ),"<br>");
	str = str.replace(new RegExp( String.fromCharCode(13), "g" ),"<br>");

	var ta=document.createElement("textarea");
	ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace();
	
	return ta.value.replace(new RegExp( "<br>", "g" ),"\n");
}

String.prototype.trim = function ()
{
	var str = new String(this);
	return str.replace(/^\s+|\s+$/g,"");  
}