/**
 * @author hugh.maclachlan
 */
(function($){
	
	var s;
	
	var defaults = {
		maxChars: null,
		cutoffIndicator: '...'	
	};
	
	$.fn.textLimit = function(o) {
        return this.each(function(index) {
			new $tl(this, o, index);
        });
    };
	
	$.textLimit = function(e, o, index){
		this.settings = $.extend({}, defaults, o || {});
        s = this.settings;
		
		var text = $(e).html();
		if (text.length > s.maxChars) {
			$(e).html(jQuery.trim(text.substr(0, (s.maxChars - s.cutoffIndicator.length))) + s.cutoffIndicator);
		}
	};
	
	$tl = $.textLimit;
	
})(jQuery);

