/**
*
*	Based on simpleTooltip jQuery plugin, by Marius ILIE
*	NP.
*
**/
(function($){ $.fn.splashtooltip = function(){
	return this.each(function() {
		var text = $(this).attr("title");
		$(this).attr("title", "");
		if(text != undefined) {
			$(this).hover(function(e){
				var tooltip_width = $("#splash_tooltip").width()
				var tipX = e.pageX -(tooltip_width/2)-19;
				var tipY = e.pageY + 16;
				$(this).attr("title", ""); 
				$("body").append("<div id='splash_tooltip' style='position: absolute; z-index: 100; display: none;'><span>" + text + "</span></div>");
				if($.browser.msie) var tipWidth = $("#splash_tooltip").outerWidth(true)
				else var tipWidth = $("#splash_tooltip").width()
				$("#splash_tooltip").width(tipWidth);
				$("#splash_tooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
			}, function(){
				$("#splash_tooltip").remove();
				$(this).attr("title", text);
			});
			$(this).mousemove(function(e){
				var tooltip_width = $("#splash_tooltip").width()
				var tipX = e.pageX -(tooltip_width/2)-19;
				var tipY = e.pageY + 16;
				var tipWidth = $("#splash_tooltip").outerWidth(true);
				var tipHeight = $("#splash_tooltip").outerHeight(true);
				if(tipX + tipWidth > $(window).scrollLeft() + $(window).width()) tipX = e.pageX - tipWidth;
				if($(window).height()+$(window).scrollTop() < tipY + tipHeight) tipY = e.pageY - tipHeight;
				$("#splash_tooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
			});
		}
	});
}})(jQuery);
