var ELLIPSIS_MARKS='...';var MAX_LENGTH='maxLength';jQuery.applyEllipsis=function(text,maxWidth){if(jQuery.textWidth(text)>maxWidth){var ellipsisWidth=jQuery.textWidth(ELLIPSIS_MARKS);while((jQuery.textWidth(text)+ellipsisWidth)>maxWidth){text=text.substring(0,(text.length-1));}
if(!(text.match(ELLIPSIS_MARKS+"$")==ELLIPSIS_MARKS)){text+='...';}}
return text;};jQuery.textWidth=function(text){jQuery('body').append('<div id="textWidth" class="hidden">'+text+'</div>');var width=jQuery('#textWidth').width();jQuery('#textWidth').remove();return width;}
jQuery.setMaxLength=function(element){jQuery(element).bind('keypress keydown keyup',function(e){var key=e.which;if(key>=48||key==13||key==32){if(jQuery(this).val().length>=jq(this).attr(MAX_LENGTH)){cancelEvent(e);}}});}
