/**
 * Utility function to restrict message length on the textarea (other controls apply)
 * It requires DOM element has an arbitrary attribute called "maxlength"
 * something like this : <textarea onkeypress="autoTrim(this);" onkeyup="autoTrim(this);" onchange="autoTrim(this);" maxlength="500" cols="70" rows="10">
 * Some element has legit "maxlength" built-in. some don't. It will auto detect
 * @param obj	the HTML DOM object. Can be "this" referenced inline or from getElementById()
 */
function autoTrim(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length > mlength) {
		obj.value=obj.value.substring(0,mlength);
	}
}
