/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 

(function($) {

	$.fn.tooltip = function(){
		
			var xOffset = 5;
			var yOffset = 20;
			
			$(this).each(function(){
				
				this.myTitle = $(this).attr('title');
								  
				$(this).hover(function(e){
				   	$(this).removeAttr('title');
					$("body").append("<p id='tooltip'>" + this.myTitle + "</p>");
					$("#tooltip").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").show();
				},
				function(){
					$(this).attr('title', this.myTitle);
					$("#tooltip").remove();
				});
				
			});
			
			
			this.mousemove(function(e){
				$("#tooltip").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px");
			});
	};

})(jQuery); // Call and execute the function immediately passing the jQuery object