/**
	Tooltips plugin v1.0 by Angel Kostadinov (angel@develop.bg) (c) 2009 CMS BG
	
	Copyright Toxic Media Ltd.
	
	Layout Builder and interanal dependancies are protected by copyright. 
	No part of any of the scripts may be reproduced in any form or by any means, 
	electronic or otherwise, without written permission from the copyright owner.
*/
(function($) 
{
	$.fn.tooltip = function(options) 
	{
		var config = $.extend({}, $.fn.tooltip.defaults, options);
		
		return this.each(function()
		{
			if (this.title.length == 0) return;
			
			var rel = $(this).attr('rel') ? $(this).attr('rel')  : 'general';
				
			$(this).hover(function(e)
			{									  
				this.t = this.title;
				
				$("body").append("<p id='tooltip'>"+ this.t +"</p>");
				$("#tooltip").addClass(rel)
					.css("opacity", config.opacity)
					.css("top",(e.pageY - config.yOffset) + "px")
					.css("left",(e.pageX + config.xOffset) + "px");
		    },
		    function()
		    {
				this.title = this.t;		
				$("#tooltip").remove();
		    });	
		    
			$(this).mousemove(function(e)
			{
				$("#tooltip")
					.addClass(rel)
					.css("top",(e.pageY - config.yOffset) + "px")
					.css("left",(e.pageX + config.xOffset) + "px");
			});			
		});
	};
	
	$.fn.tooltip.defaults = 
	{
		xOffset: 10,
		yOffset: 30,
		opacity: 0.8
	};
})(jQuery);