/*-------------------------------------------------------------------------------
	A Better jQuery Tooltip
	Version 1.0
	By Jon Cazier
	jon@3nhanced.com
	01.22.08
-------------------------------------------------------------------------------*/

$.fn.betterTooltip2 = function(options2){
	
	/* Setup the options for the tooltip that can be 
	   accessed from outside the plugin              */
	var defaults2 = {
		speed2: 200,
		delay2: 300
	};
	
	var options2 = $.extend(defaults2, options2);
	
	/* Create a function that builds the tooltip 
	   markup. Then, prepend the tooltip to the body */
	getTip2 = function() {
		
		
		var tTip2 = 
			"<div class='tip2'>" +
				"<div class='tipMid2'>"	+
				"</div>" +
				"<div class='tipBtm2'></div>" +
			"</div>";
		
		
		
		return tTip2;
	}
	$("body").prepend(getTip2());
	
	/* Give each item with the class associated with 
	   the plugin the ability to call the tooltip    */
	$(this).each(function(){
		
		var $this = $(this);
		
		var tip2 = $('.tip2');
		var tipInner2 = $('.tip2 .tipMid2');
		
		
		var tTitle2 = (this.title);
		this.title = "";
		
		var offset2 = $(this).offset();
		var tLeft2 = offset2.left;
		var tTop2 = offset2.top;
		var tWidth2 = $this.width();
		var tHeight2 = $this.height();
		
		/* Mouse over and out functions*/
		$this.hover(
			function() {
				tipInner2.html(tTitle2);
				setTip2(tTop2, tLeft2);
				setTimer2();
			}, 
			function() {
				stopTimer2();
				tip2.hide();
			}
		);		   
		
		/* Delay the fade-in animation of the tooltip */
		setTimer2 = function() {
			$this.showTipTimer = setInterval("showTip2()", defaults2.delay2);
		}
		
		stopTimer2 = function() {
			clearInterval($this.showTipTimer);
		}
		
		/* Position the tooltip relative to the class 
		   associated with the tooltip                */
		setTip2 = function(top2, left2){
			var topOffset2 = tip2.height();
			var xTip2 = (left2-30)+"px";
			var yTip2 = (top2-topOffset2-60)+"px";
			tip2.css({'top' : yTip2, 'left' : xTip2});
		}
		
		/* This function stops the timer and creates the
		   fade-in animation                          */
		showTip2 = function(){
			stopTimer2();
			tip2.animate({"top": "+=20px", "opacity": "toggle"}, defaults2.speed2);
		}
	});
};
