var tipsHeight = 200;
var tipsWidth  = 350;
var tipsPaddingHeight = 5 ;
var tipsPaddingWidth  = 5 ;

$(function(){
	$("#contentBlock ul li dl").mouseover(function(){ openTips(this.id); });
	$("#contentBlock ul li dl").mouseout(function(){ closeTips(this.id); });
	$("#contentBlock ul li dl").mousemove(function(e){ moveTips(this.id,e); });
	$("dl.movement dd a.explain").mouseover(function(){ openExplain($(this).attr("rel")); });
	$("dl.movement dd a.explain").mouseout(function(){ closeExplain($(this).attr("rel")); });
});


function openTips(id){
	var obj = "#"+id+" dd";
	$(obj).css("display","block");
}
function closeTips(id){
	var obj = "#"+id+" dd";
	$(obj).css("display","none");
}
function moveTips(id,e){
	var obj = "#"+id+" dd";

	// マウス位置取得
	var resultX = e.pageX
	var resultY = e.pageY

	// 通常時の出力位置（パッディングを勘案）
	resultX += tipsPaddingWidth ;
	resultY += tipsPaddingHeight ;

	// 右端最大値
	var maxWidth = document.body.clientWidth + document.documentElement.scrollLeft + document.body.scrollLeft ;
	// tips通常右端位置
	var tipsMaxWidth = e.pageX + tipsWidth + tipsPaddingWidth ;
	// 右端位置の確定
	if(tipsMaxWidth > maxWidth){
		resultX -= ( tipsMaxWidth - maxWidth );
	}
	// 下端最大値
	var maxHeight ;
	if(document.documentElement.clientHeight){ // IE6以外
		maxHeight = document.documentElement.clientHeight + document.documentElement.scrollTop + document.body.scrollTop ;
	}else{
		maxHeight = document.body.clientHeight + document.documentElement.scrollTop + document.body.scrollTop ;
	}
	// tips通常下端位置
	var tipsMaxHeight = e.pageY + tipsHeight + tipsPaddingHeight ;
	// 上端端位置の確定
	if(tipsMaxHeight > maxHeight){
		resultY = e.pageY - tipsHeight - tipsPaddingHeight ;
	}

//	$(obj).html(
//	"document.body.clientWidth : "+document.body.clientWidth+"<br>"+
//	"document.documentElement.scrollWidth : "+document.documentElement.scrollWidth+"<br>"+
//	"document.documentElement.scrollLeft : "+document.documentElement.scrollLeft+"<br>"+
//	"document.body.scrollLeft : "+document.body.scrollLeft+"<br>"+
//	"e.pageX : "+e.pageX+"<br>"+
//	"maxWidth : "+maxWidth+"<br>"+
//	"tipsMaxWidth : "+tipsMaxWidth+"<br><br>"+
//	"document.body.clientHeight : "+document.body.clientHeight+"<br>"+
//	"document.documentElement.clientHeight : "+document.documentElement.clientHeight+"<br>"+
//	"document.documentElement.scrollHeight : "+document.documentElement.scrollHeight+"<br>"+
//	"document.documentElement.scrollTop : "+document.documentElement.scrollTop+"<br>"+
//	"document.body.scrollTop : "+document.body.scrollTop+"<br>"+
//	"e.pageY : "+e.pageY+"<br>"+
//	"maxHeight : "+maxHeight+"<br>"+
//	"tipsMaxHeight : "+tipsMaxHeight+"<br><br>"+
//	"");

	$(obj).css("left",resultX+"px");
	$(obj).css("top",resultY+"px");
}

function openExplain(t){
	$("div.conditonSearchBody div#"+t).css("display","block");
}
function closeExplain(t){
	$("div.conditonSearchBody div#"+t).css("display","none");
}