﻿(function($) {	
	$.fn.tooltip = function() {
		return this.each(function() {
			var title = $(this).attr('title');
			$(this).hover(function() {		
				$(this).removeAttr('title');
				wh = $(this).width()/2;
				var positions = $(this).position();					
				var documentHeight = $(document).height(); 
				//alert("" + positions.top + "  " + documentHeight);
				/*if((positions.top+200) < documentHeight)
				{
					$(this).append($(
						'<div class="toolTipWrapper">'
							+'<div class="toolTipTop"></div>'
							+'<div class="toolTipMid">'
								+ title
							+'</div>'
							+'<div class="toolTipBtm"></div>'
						+'</div>'
					));
					$(this).find('.toolTipWrapper').css({left:positions.left+wh,top:positions.top+10})			
				}*/
				//else
				{
						$(this).append($(
							'<div class="toolTipWrapper">'
							+'<div class="toolTipBtm1"></div>'
							+'<div class="toolTipMid1">'
								+title
							+'</div>'
							+'<div class="toolTipTop1"></div>'
							+'</div>'
						));
					$(this).find('.toolTipWrapper').css({left:positions.left+wh,top:positions.top-90})		
				}
				$('.toolTipWrapper').fadeIn(300);
			},
			function() {
				$('.toolTipWrapper').fadeOut(100);
				$(this).children().remove();
			}
		)});
	};
})(jQuery)

