// *********************************** //
// 初期設定・グローバル変数宣言        //
// *********************************** //

var brwsr = 0; // ブラウザ判別用フラグ（Microsoft製IEなら「0」、それ以外なら「1」）;
if(navigator.appName.charAt(0) == "M") { brwsr = 0; }
else { brwsr = 1; }

var timerID = ""; // 遅延消去用のタイマー宣言;
var xpos = 0;     // ポップアップメニューの X座標;
var ypos = 0;     // ポップアップメニューの Y座標;
var tObj;         // ポップアップメニューのオブジェクト;
var xObj;         // 元メニューのオブジェクト;


// *********************************** //
// ポップアップメニュー表示スクリプト  //
// *********************************** //

function mn(n,m){
	if(timerID!=""){
		clearTimeout(timerID);
	}
	dlt2();
	tObj = "";
	xObj = "";
	xpos = 0;
	ypos = 0;
	tObj = document.getElementById(n);
	xObj = document.getElementById(m);
	switch(m){
		case('td1'):
			xObj.style.backgroundColor="#10218A";
			break;
		case('td2'):
			xObj.style.backgroundColor="#10218A";
			break;
		case('td3'):
			xObj.style.backgroundColor="#10218A";
			break;
		case('td4'):
			xObj.style.backgroundColor="#10218A";
			break;
		case('td5'):
			xObj.style.backgroundColor="#10218A";
			break;
		case('td6'):
			xObj.style.backgroundColor="#10218A";
			break;		
		case('td7'):
			xObj.style.backgroundColor="#10218A";
			break;
		case('td8'):
			xObj.style.backgroundColor="#10218A";
			break;
		case('td9'):
			xObj.style.backgroundColor="#10218A";
			break;		
		case('td10'):
			xObj.style.backgroundColor="#10218A";
			break;		
		default:
			xObj.style.backgroundColor="#10218A";
			break;
	}

	// 上記の右端のカラーコードは、オンマウスしたときの元メニューの色
	// （上記の元メニューとは、[menu.1], [menu.2], [menu.3] のセルを示す）

	tObj.style.visibility="visible";
	getXpos(xObj);
	getYpos(xObj);
	ypos += xObj.offsetHeight;

	// if(brwsr==1){ 
	//	tObj.style.MozOpacity = 0.90; 
	// }

	if(brwsr==0){ 
		tObj.style.filter = 'alpha(opacity = 90)';
	}

	// 上記の右端の数値(75)はポップアップ表示されるメニューの透明度
	// （透明度の数値は、0 で透明、100で不透明を示す）※IEのみ

	tObj.style.left = xpos + "px";
	tObj.style.top = ypos + "px";
	tObj.style.zIndex = "1";
}


// *********************************** //
// 消去用遅延スクリプト（タイマー）    //
// *********************************** //

function dlt(){
	if(timerID!=""){clearTimeout(timerID);}
	timerID = setTimeout("dlt2()",500);
}

// 上記の右端の数値(500)は、マウスが離れてからメニュー表示が消えるまでの時間(0.5秒)を示す
// （1000で１秒）



// *********************************** //
// 消去用スクリプト本体                //
// *********************************** //

function dlt2(){
	var dval;
	var tval;
	for (i=1;i<11;i++){

	// 上記の中央の数値(4)は、元メニューの数に「1」を加えた数を記入する
	// 本ページは元メニューが5個 [menu.1],[menu.2],[menu.3],[menu.4], [menu.5]
	// なので、5＋1で「6」

	dval = "dv" + i;
	tval = "td" + i;
	switch(i){
		case(1):
			document.getElementById(tval).style.backgroundColor = "#10218A";
			break;
		case(2):
			document.getElementById(tval).style.backgroundColor = "#10218A";
			break;
		case(3):
			document.getElementById(tval).style.backgroundColor = "#10218A";
			break;
		case(4):
			document.getElementById(tval).style.backgroundColor = "#10218A";
			break;
		case(5):
			document.getElementById(tval).style.backgroundColor = "#10218A";
			break;
		case(6):
			document.getElementById(tval).style.backgroundColor = "#10218A";
			break;
		case(7):
			document.getElementById(tval).style.backgroundColor = "#10218A";
			break;
		case(8):
			document.getElementById(tval).style.backgroundColor = "#10218A";
			break;
		case(9):
			document.getElementById(tval).style.backgroundColor = "#10218A";
			break;
		case(10):
			document.getElementById(tval).style.backgroundColor = "#10218A";
			break;
		default:
			document.getElementById(tval).style.backgroundColor = "#eeeeee";
			break;
		}
		document.getElementById(dval).style.visibility = "hidden";
		document.getElementById(dval).style.zIndex = "0";
	}
}


// *********************************** //
// 元メニュー位置検出（X座標）         //
// *********************************** //

function getXpos(obj){
	xpos = obj.offsetLeft;
	if(obj.offsetParent != null){
		xpos += getXpos(obj.offsetParent);
	}
	return xpos;
}


// *********************************** //
// 元メニュー位置検出（Y座標）         //
// *********************************** //

function getYpos(obj){
	ypos = obj.offsetTop;
	if(obj.offsetParent != null){
		ypos += getYpos(obj.offsetParent);
	}
	return ypos;
}


