// WTN*jQuery sample:: Tooltip sample script.(use jQuery1.2.6)
// Copyright (c) 2008 Tenderfeel. http://tenderfeel.xsrv.jp
// MIT & GPL (GPL-LICENSE.txt) licenses.

$(function (){
	if($('#imgmap')){
		
		$('#Map area').each(function(i){
		var name = $(this).attr('href');
		 $(name).css({
				"display":"none",
				"position": "absolute",
				"zIndex": "9999",
				"display": "none"
		 });
			$(this).mouseover(
				function(e){ 
				  var bodyX =$(window).width();
				  var bodyY =$(window).height();
				  var Y = ((e.clientY-$(name).height()) -15);
				  var X = e.clientX;
				  
				  if(Y < 0){
					   Y = e.clientY +15;
				  }
				  var eqY = Y+$(name).height();
				  var eqX = X+$(name).width();
				  if( eqY > bodyY){
					 Y = e.clientY+(bodyY-eqY);
				  }
				  if( eqX > bodyX){
					  eX = bodyX-X;
					  X = bodyX-(eX+$(name).width())-20;
				  }else{
					  X=X+15;
				  }
					$(name).css({ "display":"block","left":X+"px","top":Y+"px"});
				});
			$(this).mouseout(
				function(){ 
				
					$(name).css({ "display":"none"});
			});
		});
	}
});