/* ----------------------------------------------------------
 * サブメニュー（subMenu.js）
 * ---------------------------------------------------------- */

var currentID = null;
var hideTimer;
var bodyWidth = 820;

function showLayer (id, menuLeft) {
	if (id) {
		if (currentID && currentID != id) layerChange (false);
		currentID = id; layerChange (true);
		layerLeft (id, menuLeft);
	}
	clearTimeout (hideTimer);
}
function hideLayer () {
	hideTimer = setTimeout ("layerChange (false)", 1000);
}
function layerChange (flag) {
	layerObject (currentID).visibility = (flag) ? "visible" : "hidden";
	if (!flag) currentID = null;
}
function layerLeft (id, menuLeft) {
	var winWidth = (document.layers) ? innerWidth : document.body.clientWidth;
	var bodyLeft = Math.floor ((winWidth - bodyWidth) / 2);
	menuLeft = (bodyLeft > 0) ? bodyLeft + menuLeft : menuLeft;
	if (document.getElementById || document.all) layerObject (id).pixelLeft = menuLeft;
	if (document.layers) layerObject (id).moveTo (menuLeft, layerObject (id).top);
}
function layerObject (id) {
	if (document.getElementById) return document.getElementById (id).style;
	if (document.all)            return document.all (id).style;
	if (document.layers)         return document.layers [id];
}