﻿/***********************************************************/
/*                    tinyTips Plugin                      */
/*                      Version: 1.0                       */
/*                      Mike Merritt                       */
/*                 Updated: Feb 4th, 2010                  */
/***********************************************************/

(function($){
	$.fn.tinyTips = function (tip) {
		var tipFrame = '';
		if (tip == 'tip1') tipFrame = '<div class="tinyTip tip1"><div class="tip1"><div class="tip1"><div class="content"></div></div></div></div>';
		if (tip == 'tip2') tipFrame = '<div class="tinyTip tip2"><div class="tip2"><div class="tip2"><div class="content"></div></div></div></div>';

		var animSpeed = 300;
		var tinyTip;
		var tText;
		
		$(this).hover(function() {
			$('body').append(tipFrame);
			tinyTip = $('div.tinyTip');
			tinyTip.hide();
			
			var tipCont = $(this).attr('title');
			$('.tinyTip .content').html(tipCont);
			tText = $(this).attr('title');
			$(this).attr('title', '');
			
			var yOffset = -$(this).height()-5;
			var xOffset = (((tinyTip.width()-10)/2)) - ($(this).width()/2-5);
			
			var pos = $(this).offset();
			var nPos = pos;
			
			nPos.top = pos.top - yOffset;
			nPos.left = pos.left - xOffset;
			tinyTip.css('position', 'absolute').css('z-index', '1000');
			tinyTip.css(nPos).fadeIn(animSpeed);
		}, function() {
			$(this).attr('title', tText);
			$('div.tinyTip').fadeOut(animSpeed, function() {
				$(this).remove();
			});
		});
	}

})(jQuery);
