function onMouseOverTextarea(t)
{
	$(t).style.backgroundColor = "#FFEEBB";
}

function onMouserOutTextArea(t)
{
	$(t).style.backgroundColor = "transparent";
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


/**
 * @author lantonio
 * @since 0.2
 */
activateSendPost = function(c1, c2, c3)
{
	if($(c1).className != 'LastPost LastPostEnabled')
	{
		$(c1).className = 'LastPost LastPostEnabled';
		$(c1).value = '';
		$(c1).innerHTML = '';
	
		$(c3).style.display = 'inline';
	}
};

/**
 * @author lantonio
 * @since 0.2
 */
disableSendPost = function(c1, c2, c3)
{
	$(c1).className = 'LastPost LastPostDisabled';
	$(c1).blur();
	$(c3).style.display = 'none'; 
};

/**
 * @param {Object} c1
 * @param {Object} c2
 * @param {Object} c3
 */
cancelSend = function(c1, c2, c3)
{
	$(c1).value = $(c2).value;
	$(c1).innerHTML = $(c2).value;
	
	disableSendPost(c1, c2, c3);
}

/**
 * @author lantonio
 * @since 0.2
 * 
 * @return {int}
 */
function validateSend(event, c1, c2, c3)
{
	var e = event;
	
	if(!e)
	{
		e = window.event;
	} 
	
	var targ;
	
	if (e.target)
	{
		targ = e.target;
	}
	else if (e.srcElement)
	{
		targ = e.srcElement;
	}
	
	//Bug no Safari
	if (targ.nodeType == 3)
	{
		targ = targ.parentNode;
	}
	
	var auxCode;
	
	if (e.keyCode)
	{
		auxCode = e.keyCode;
	}
	else if (e.which)
	{
		auxCode = e.which;
	}
	
	var auxText = new String(trim($(c1).value));
	
	if(auxCode == 27) // ESC
	{
		cancelSend(c1, c2, c3);
		
		return false;
	}
	
	if(auxCode == 13) // ENTER
	{
		if(auxText.length == 0)
		{
			cancelSend(c1, c2, c3);
			
			return false;
		}
		
		$(c1).value = trim($(c1).value);
		$(c1).innerHTML = $(c1).value;
		
		$C(c2).set('value',$(c1).value);
		
		disableSendPost(c1, c2, c3);
		
		return true;
	}
	
	return false;
}