$(function() {
	$(".detail-clock").hover(function(){CL_show($(this).attr("id"))},function(){$("#clock_tip").hide()});
});

function CL_show(linkId){
	var de = document.documentElement;
	var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;

	var sc_top = document.body.scrollTop || document.documentElement.scrollTop;

	clickElementy = getAbsoluteTop(linkId) - 7; //set y position
	var arrowOffset = getElementWidth(linkId) - 0;
	var clickElementx = getAbsoluteLeft(linkId) + arrowOffset; //set x position

	clockSet(linkId);
	
	$("#clock_tip").css({left: clickElementx+"px", top: clickElementy+"px"});
	$("#clock_tip").show();
}

function clockSet(linkId){
	var view_date="";
	var now_date = new Date();
	var weekchars = new Array( "日", "月", "火", "水", "木", "金", "土" );
	var year = now_date.getFullYear(); // 年
	var year_w = parseInt(now_date.getFullYear() - 2000 + 12); // 和暦(平成のみ)
	var mon  = now_date.getMonth() + 1; // 月
	var date = now_date.getDate(); // 日
	var week = now_date.getDay(); // 曜日
	var hour = now_date.getHours(); // 時
	var min  = now_date.getMinutes(); // 分

	if(mon < 10){mon = "0"+mon;}
	if(date < 10){date = "0"+date;}
	if(hour < 10){hour = "0"+hour;}
	if(min < 10){min = "0"+min;}

	if(linkId == "clock_news" || linkId == "clock_hind" || linkId == "clock_mainte"){
		view_date = year+"年&nbsp;(平成"+year_w+"年)<br />";
	}else{
		view_date = "平成"+year_w+"年&nbsp;("+year+"年)<br />";
	}
	view_date += mon+"月"+date+"日("+weekchars[week]+")&nbsp;"+hour+"時"+min+"分";

	$("#clock_now").html(view_date);
}

document.write("<div id=\"clock_tip\"><div id=\"clock_title\">現在の日時</div><div id=\"clock_now\"></div></div>");

