/*
 * Tooltip (for jQuery)
 * Version: 0.1 ALPHA (19/01/2010)
 * @requires jQuery v1.3 or later (may and probably will work with earlier versions, but not tested)
 * 
 * Licensed under the MIT:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright 2010 Johannes Walleboom [ johannes@walleboom.se ]
 *
 * Usage:
 *  
 *  jQuery(document).ready(function() {
 *    jQuery('a[rel*=tooltip]').tooltip();
 *  });
 *
 */

(function($) {
	$.fn.extend({
		tooltip: function(options) {
			var defaults = {
				xOffset: 50,
				yOffset: 80
            };

			var options = $.extend(defaults, options);

			return this.each(function() {
				var obj = $(this);
				
				obj.hover(function(e) {
					this.temp = this.title;
					this.title = '';
					$('body').append('<div id="tooltip"> \
										<div class="rounded-tooltip-box"> \
										<div class="rounded-tooltip-box-content"> \
											<div class="t"></div> \
											<div class="hd"></div> \
											<div style="clear: both;"></div> \
											<div class="bd"> \
											<p style="margin: 0; padding: 20px 0 0 0; background: none; color: #fff;">' + this.temp + '</p> \
										</div> \
										</div> \
										<div class="b"><div style="float: left;"></div></div> \
										</div> \
										</div>');
					$('#tooltip')
						.css('top', (e.pageY - options.yOffset) + "px")
						.css('left', (e.pageX - options.xOffset) + "px")
						.fadeIn('fast');
					
				}, function() {
						this.title = this.temp;
						$('#tooltip').remove();
					}
				);
			});
		}
	});
})(jQuery);