(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[0].innerHTML;
					var w = el[0].offsetWidth;
					var t = this.cloneNode(true);
					
					t.style.position = 'absolute';
					t.style.width = 'auto';
					t.style.overflow = 'visible';
					t.style.maxWidth = 'inherit';
					t.style.visibility = 'hidden';

					el.after(t);
					
					var text = originalText;
					while(text.length > 0 && t.offsetWidth > w) {
						text = text.substr(0, text.length - 1);
						t.innerHTML = [text,'...'].join('');
					}
					el.html(t.innerHTML);
					t.parentNode.removeChild(t);
					
					/*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);
