// JavaScript Document

(function($){
		  
	$.fn.tooltip = function(options) {
	
		var defaults = {
			background : '#e3e3e3',
			color : '#333333',
			rounded : false
		}
	
		settings = $.extend({}, defaults, options); // merge defaults and options
	
		this.each(function() { // loop for the object
						   
			var $this = $(this);
			var title = this.title;
						
			if($this.attr('title') != '')  {
				this.title = '';
				$this.hover(function(e) { // hover
					$('<div id="tooltip" />').appendTo('body').text(title).hide().css({
						backgroundColor : settings.background,
						color : settings.color,
						top : e.pageY - 25,
						left : e.pageX - 230
					})
					.fadeIn(350);
					if(settings.rounded) {
						$('#tooltip').addClass('rounded');
					}
				}, 
				function() { // mouse out
					$('#tooltip').remove();	
				});
			}
				
			$this.mousemove(function(e) { // mouse tracking
				$('#tooltip').css({
					top : e.pageY - 25,
					left : e.pageX - 230
				});
			});
			
		});
		
		return this; // returns the object for chain-ability
		
	}
	
})(jQuery);
