/* jQuery tooltip() -  matiasj.lescano@gmail.com */
jQuery.fn.extend({
	tooltip: function() {
	
		jQuery(this).hover(
			function() {
				var _this = jQuery(this);
				var _parent = _this.parent();
				
				var tp = jQuery('<div />')
					.addClass('mug-tooltip')
					.html(_this.attr('title'))
					.css('postition', 'absolute')
				;
				
				if(_parent.css('position') == 'static') { _parent.css('position', 'relative') };
				
				_this
					.data('title', _this.attr('title'))
					.data('tooltip', tp)
					.attr('title', '')
				;
				_parent.append(tp);
				
				var _left = (_this.offset().left + (_this.width() / 2)) - (tp.width() / 2);
				var _top = _this.offset().top + _this.height()
				tp.offset({
					left: _left,
					top: _top
				});
				
			},
			function() {
				var _this = jQuery(this);
				
				_this
					.attr('title', _this.data('title'))
					.data('tooltip').remove()
				;
			}
		);
		
		return jQuery(this);
	}
});
