/**
 * jQuery glueTip Plugin
 * Author: Nic Luciano
 * Website: http://nicluciano.com/
 * Usage: Pass in selectors only that match attr[tooltip]
 * 		  ie. $("a[tooltip]").glueTip();
 */

(function($){ 
	$.fn.glueTip = function() {
		return this.each(function() {
			var anchor = $(this);
			var offset = anchor.offset();
			$(this).mouseover(function() {
				$("#tooltip").remove();
				var tooltip = $("<div id=\"tooltip\">").css({'position': 'absolute', 'display': 'none'}).append($("<span>").text(anchor.attr("tooltip")));
				$("body").append(tooltip);
				tooltip.css({'left': offset.left, 'top': offset.top - tooltip.outerHeight()}).fadeIn("fast");
			});
			$(this).mouseout(function() {
				$("#tooltip").fadeOut("fast", function() {
					$(this).remove();
				});
			});
		});
	};
	$.fn.initGlueTip = function() {
		return this.each(function() {
			var anchor = $(this);
			var offset = anchor.offset();
			$("#tooltip").remove();
			var tooltip = $("<div id=\"tooltip\">").css({'position': 'absolute', 'display': 'none'}).append($("<span>").text(anchor.attr("tooltip")));
			$("body").append(tooltip);
			tooltip.css({'left': offset.left, 'top': offset.top - tooltip.outerHeight()}).fadeIn("fast");
		});
	};
})(jQuery);