// 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')){
		
		$('#imgmap area').each(function(i){
			var name = $(this).attr('href2');
			$(name).css({
					"display":"none",
					"position": "absolute",
					"zIndex": "9998",
					"display": "none"
			});
			$(this).mouseover(function(e){ 
				$('.win-boxs').hide();
			//alert($(window).scrollTop());
			//alert(e.clientY);
				var bodyX =$(window).width();
				var bodyY =$(window).height();
				//var Y = ((e.clientY-$(name).height()) -15);

				var Y = ((e.clientY-$(name).height()) + 15 + $(window).scrollTop());
				var X = e.clientX - 15  + $(window).scrollLeft();
				if(Y < 0){
					Y = e.clientY +15;
					//Y = e.clientY;
				}
//alert("Y="+Y);


				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;
				//	//X = bodyX-(eX+$(name).width());
				//}else{
				//	X=X+15;
				//}
				
				//if(X+$(name).width() > bodyX){
				//	X = bodyX - $(name).width()-15;
				//}

				
				
//alert("Y="+Y);
				$(name).css({ "display":"block","left":X+"px","top":Y+"px"});
			});
			//$(this).mouseout(function(){ 
			//	$(name).css({ "display":"none"});
			//});
		});
	}
	
	//if($('#shareit-clase')){
	//	$(this).click(function(e){ 
	//		var name = $(this).attr('rel');
	//		$(name).css({ "display":"none"});
	//	});
	//}
	
	
	$('.close_bt').click(function () {
		$('#shareit-field').val('');
		$('.win-boxs').hide();
	});
	
	
	
});
