(function($) {
	$.fn.ellipsis = function(enableUpdating){
		var s = document.documentElement.style;
		if (!('textOverflow' in s || 'OTextOverflow' in s)) {
			return this.each(function(){
				var el = $(this);
				if(el.css("overflow") == "hidden"){
					var originalText = el.html();
			        var w = el.width();
			        var t = $("#_ellipsis_calc");
			        var ex = t.length < 1;
			        if(ex){
			        	t = $("<span id='_ellipsis_calc'/>").html(originalText).hide().appendTo("body");
			        }	
			        
			        var text = originalText;
			        while(text.length > 0 && t.width() > el.width()){
			        	text = text.substr(0, text.length - 1);
			        	t.html(text + "...");
			        }
			        el.html(t.html());
			        if(!ex)t.remove();
			        
			        if(enableUpdating == true){
						var oldW = el.width();
			       		setInterval(function(){
				      		if(el.width() != oldW){
				      			oldW = el.width();
				      			el.html(originalText);
				      			el.ellipsis();
				      		}
				      	}, 200);
			        }
			    }  
			});   
	    } else return this;   
	};
})(jQuery);	