$(document).ready(function() {
	$(".banner").hover(
		function() {$("span.tooltip").css({ display: "block" }); },
		function() { $("span.tooltip").css({ display: "none" }); }
	);

	$(".banner").mousemove(function(e) {
		// calculate box position
		var x = e.pageX + 10;
		var y = e.pageY + 5;
		// if the box goes outside the window, flip it to the other side of mouse
		if ( x + $("span.tooltip").width() > $(window).width() ) { x = x - $("span.tooltip").width() - 20; }
		if ( y + $("span.tooltip").height() > $(window).height() ) { y = y - $("span.tooltip").height() - 10; }
		$("span.tooltip").offset({ top: y, left: x });
	});
	$(".right_banner p img").hover(
		function() {$("span.tooltip").css({ display: "block" }); },
		function() { $("span.tooltip").css({ display: "none" }); }
	);

	$(".right_banner p img").mousemove(function(e) {
		// calculate box position
		
		var x = e.pageX + 10;
		var y = e.pageY + 5;
		// if the box goes outside the window, flip it to the other side of mouse
		if ( x + $("span.tooltip").width() > $(window).width() ) { x = x - $("span.tooltip").width() - 20; }
		if ( y + $("span.tooltip").height() > $(window).height() ) { y = y - $("span.tooltip").height() - 10; }
		$("span.tooltip").offset({ top: y, left: x });
	});
});

