﻿/* メニュー作成支援ツール２号 */

var garyMenu = new Array();
var garyMenuObj = new Array(20);
var gidTimer;

function mbSetMenu
( pidMbtn, pidMenu, pflgButton, pstrDirect, pflgTimer, plngSecond
	, pstrMFFlg, pstrMFClr1, pstrMFClr2, pstrMBFlg, pstrMBClr1, pstrMBClr2
	, pstrIFFlg, pstrIFClr1, pstrIFClr2, pstrIBFlg, pstrIBClr1, pstrIBClr2 ){
	var wflgFound;
	var wflgTimer;

	wflgFound = false;
	wflgTimer = false;
	for( var wCnt=0 ; wCnt<garyMenuObj.length ; wCnt++ ){
		if( garyMenuObj[wCnt] == null ){
			if( wflgFound == false ){
				garyMenuObj[wCnt] = new MenuButton(pidMbtn,pidMenu);
				with( garyMenuObj[wCnt] ){
					setButton( pflgButton );
					setDirect( pstrDirect );
					setTimer( pflgTimer, plngSecond );
					setMbtnForeColor( pstrMFFlg, pstrMFClr1, pstrMFClr2 );
					setMbtnBackColor( pstrMBFlg, pstrMBClr1, pstrMBClr2 );
					setItemForeColor( pstrIFFlg, pstrIFClr1, pstrIFClr2 );
					setItemBackColor( pstrIBFlg, pstrIBClr1, pstrIBClr2 );
				}
				garyMenu[pidMbtn] = garyMenuObj[wCnt];
			}
			break;
		}else{
			if( garyMenuObj[wCnt].getMbtnID() == pidMbtn ){
				wflgFound = true;
			}else{
				garyMenuObj[wCnt].Close();
			}
			if( garyMenuObj[wCnt].getTimerEnable == true ){
				wflgTimer = true;
			}
		}
	}

	if( wflgTimer == true || pflgTimer == true ){
		if( gidTimer == null ){
			gidTimer = setInterval("mbMenuTimer();", 1000)
		}
	}else if( wflgTimer == false && pflgTimer == false ){
		if( gidTimer != null ){
			clearInterval(gidTimer);
			gidTimer = null;
		}
	}
}
function mbAutoMenu( pidMbtn ){
	garyMenu[pidMbtn].Auto();
}
function mbOpenMenu( pidMbtn ){
	garyMenu[pidMbtn].Open();
}
function mbCloseMenu( pidMbtn ){
	garyMenu[pidMbtn].Close();
}
function mbSetClose( pidMbtn ){
	try{
		garyMenu[pidMbtn].setClose();
	}catch( e ){}
}
function mbMenuTimer(){
	var wlngCnt;

	for( var wCnt=0 ; wCnt<garyMenuObj.length ; wCnt++ ){
		if( garyMenuObj[wCnt] == null ){
			break;
		}else{
			garyMenuObj[wCnt].Wait();
		}
	}
}

// メニューボタンクラス
function MenuButton( pidMbtn, pidMenu ){
	this.midMbtn = pidMbtn;
	this.midMenu = pidMenu;
	this.mflgButton = false;
	this.mstrDirect = "bottom";
	this.mflgExtend = true;

// タイマー関連
	this.mmapTimer = new Array();
	this.mmapTimer["use"]	= false;
	this.mmapTimer["sec"]	= 10;
	this.mmapTimer["wait"]= 0;

// 色関連
	this.mmapColor = new Array();
	this.mmapColor["MbtnForeFlg"]	= false;
	this.mmapColor["MbtnForeOut"]	= "";
	this.mmapColor["MbtnForeOver"]= "";
	this.mmapColor["MbtnBackFlg"]	= false;
	this.mmapColor["MbtnBackOut"]	= "";
	this.mmapColor["MbtnBackOver"]= "";
	this.mmapColor["ItemForeFlg"]	= false;
	this.mmapColor["ItemForeOut"]	= "";
	this.mmapColor["ItemForeOver"]= "";
	this.mmapColor["ItemBackFlg"]	= false;
	this.mmapColor["ItemBackOut"]	= "";
	this.mmapColor["ItemBackOver"]= "";


// メニューボタン押下時スタイル設定メソッド
	this.setButton = function( pflgBtn ){
		var wflgRet = false;

		if( pflgBtn == true || pflgBtn == false ){
			this.mflgButton = pflgBtn;
			wflgRet = true;
		}

		return wflgRet;
	}
// 表示方向設定メソッド
	this.setDirect = function( pstrDirect ){
		var wstrDir = pstrDirect.toLowerCase();
		var wflgRet = false;

		if( wstrDir == "top" || wstrDir	== "right" || wstrDir	== "bottom" || wstrDir	== "left" ){
			this.mstrDirect = wstrDir;
			wflgRet = true;
		}else{
			wflgRet = false;
		}

		return wflgRet;
	}
// タイマー設定メソッド
	this.setTimer = function(){
		var wflgRet = false;

		if( 0 < arguments.length && arguments.length < 3 ){
			if( arguments[0] == true || arguments[0] == false &&	0 < arguments[1] && arguments[1] < 600 ){
				switch( arguments.length ){
					case 2:
						this.mmapTimer["sec"]	= arguments[1];
					case 1:
						this.mmapTimer["use"]	= arguments[0];
						wflgRet = true;
				}
			}
		}

		return wflgRet;
	}
// Mbtn文字色設定メソッド
	this.setMbtnForeColor = function(){
		var wflgRet = false;

		if( 0 < arguments.length && arguments.length < 4 ){
			if( arguments[0] == true || arguments[0] == false ){
				switch( arguments.length ){
					case 3:
						this.mmapColor["MbtnForeOver"]	= arguments[2];
					case 2:
						this.mmapColor["MbtnForeOut"]	= arguments[1];
					case 1:
						this.mmapColor["MbtnForeFlg"]	= arguments[0];
						wflgRet = true;
				}
			}
		}

		return wflgRet;
	}
// Mbtn背景色設定メソッド
	this.setMbtnBackColor = function(){
		var wflgRet = false;

		if( 0 < arguments.length && arguments.length < 4 ){
			if( arguments[0] == true || arguments[0] == false ){
				switch( arguments.length ){
					case 3:
						this.mmapColor["MbtnBackOver"]	= arguments[2];
					case 2:
						this.mmapColor["MbtnBackOut"]	= arguments[1];
					case 1:
						this.mmapColor["MbtnBackFlg"]	= arguments[0];
						wflgRet = true;
				}
			}
		}

		return wflgRet;
	}
// Item文字色設定メソッド
	this.setItemForeColor = function(){
		var wflgRet = false;

		if( 0 < arguments.length && arguments.length < 4 ){
			if( arguments[0] == true || arguments[0] == false ){
				switch( arguments.length ){
					case 3:
						this.mmapColor["ItemForeOver"]	= arguments[2];
					case 2:
						this.mmapColor["ItemForeOut"]	= arguments[1];
					case 1:
						this.mmapColor["ItemForeFlg"]	= arguments[0];
						wflgRet = true;
				}
			}
		}

		return wflgRet;
	}
// Item背景色設定メソッド
	this.setItemBackColor = function(){
		var wflgRet = false;

		if( 0 < arguments.length && arguments.length < 4 ){
			if( arguments[0] == true || arguments[0] == false ){
				switch( arguments.length ){
					case 3:
						this.mmapColor["ItemBackOver"]	= arguments[2];
					case 2:
						this.mmapColor["ItemBackOut"]	= arguments[1];
					case 1:
						this.mmapColor["ItemBackFlg"]	= arguments[0];
						wflgRet = true;
				}
			}
		}

		return wflgRet;
	}
// 取得系メソッド
	this.getMbtnID	= function(){return this.midMbtn;}
	this.getMenuID	= function(){return this.midMenu;}
	this.getButton	= function(){return this.mflgButton;}
	this.getDirect	= function(){return this.mstrDirect;}
	this.getExtend	= function(){return this.mflgExtend;}
	this.getTimerEnable	= function(){return this.mmapTimer["use"];}
	this.getTimerSecond	= function(){return this.mmapTimer["sec"];}
	this.getTimerRemain	= function(){return this.mmapTimer["wait"];}
	this.getMbtnForeEnable= function(){return this.mmapColor["MbtnForeFlg"];}
	this.getMbtnForeMOut	= function(){return this.mmapColor["MbtnForeOut"];}
	this.getMbtnForeMOver	= function(){return this.mmapColor["MbtnForeOver"];}
	this.getMbtnBackEnable= function(){return this.mmapColor["MbtnBackFlg"];}
	this.getMbtnBackMOut	= function(){return this.mmapColor["MbtnBackOut"];}
	this.getMbtnBackMOver	= function(){return this.mmapColor["MbtnBackOver"];}
	this.getItemForeEnable= function(){return this.mmapColor["ItemForeFlg"];}
	this.getItemForeMOut	= function(){return this.mmapColor["ItemForeOut"];}
	this.getItemForeMOver	= function(){return this.mmapColor["ItemForeOver"];}
	this.getItemBackEnable= function(){return this.mmapColor["ItemBackFlg"];}
	this.getItemBackMOut	= function(){return this.mmapColor["ItemBackOut"];}
	this.getItemBackMOver	= function(){return this.mmapColor["ItemBackOver"];}
// タイマー
	this.Wait = function(){
		if( this.mmapTimer["use"] == true ){
			if( this.mflgExtend == true ){
				if( this.mmapTimer["wait"] > 0 ){
					this.mmapTimer["wait"] -= 1;
				}else{
					this.Close();
				}
			}
		}
	}
// メニュー開
	this.Open = function(){
		var welmMbtn
		var welmMenu;
		var welmTmp, wlngTop, wlngLeft;

		welmMbtn = document.getElementById(this.midMbtn);
		welmMenu = document.getElementById(this.midMenu);

		if( !welmMenu.hasChildNodes() ){
			return;
		}

		welmTmp	= welmMbtn;
		wlngTop	= 0;
		wlngLeft = 0;
		while( welmTmp != document.body ){
			wlngTop	+= welmTmp.offsetTop;
			wlngLeft += welmTmp.offsetLeft;
			welmTmp	=	welmTmp.offsetParent;
		}

		this.fncHide(welmMenu);
		with( welmMenu.style ){
			display	= "block";
			switch( this.mstrDirect ){
				case "top":
//					top	= welmMbtn.offsetTop - welmMenu.offsetHeight - 1;
//					left = welmMbtn.offsetLeft;
					top	= wlngTop - welmMenu.offsetHeight - 1;
					left = wlngLeft;
					break;
				case "right":
//					top	= welmMbtn.offsetTop;
//					left = welmMbtn.offsetLeft + welmMbtn.offsetWidth + 1;
					top	= wlngTop;
					left = wlngLeft + welmMbtn.offsetWidth + 1;
					break;
				case "bottom":
//					top	= welmMbtn.offsetTop + welmMbtn.offsetHeight + 1;
//					left = welmMbtn.offsetLeft;
					top	= wlngTop + welmMbtn.offsetHeight + 1;
					left = wlngLeft;
					break;
				case "left":
//					top	= welmMbtn.offsetTop;
//					left = welmMbtn.offsetLeft - welmMenu.offsetWidth - 1;
					top	= wlngTop;
					left = wlngLeft - welmMenu.offsetWidth - 1;
					break;
			}
		}
//		if( this.mflgButton == true ){
			welmMbtn.style.borderStyle = "inset";
//	}else{
		if( this.mflgButton != true ){
			welmMbtn.focus();
		}
		if( this.mmapColor["MbtnForeFlg"] == true ){
			welmMbtn.style.color = this.mmapColor["MbtnForeOver"];
		}
		if( this.mmapColor["MbtnBackFlg"] == true ){
			welmMbtn.style.backgroundColor = this.mmapColor["MbtnBackOver"];
		}
		if( this.mmapTimer["use"] == true ){
			this.mmapTimer["wait"] = this.mmapTimer["sec"];
		}
		this.mflgExtend = true;
	}
// メニュー閉
	this.Close = function(){
		var welmMbtn
		var welmMenu;

		welmMbtn = document.getElementById(this.midMbtn);
		welmMenu = document.getElementById(this.midMenu);

		this.fncHide(welmMenu);
		welmMenu.style.display = "none";
//		if( this.mflgButton == true ){
			welmMbtn.style.borderStyle = "outset";
//		}
		if( this.mmapColor["MbtnForeFlg"] == true ){
			welmMbtn.style.color = this.mmapColor["MbtnForeOut"];
		}
		if( this.mmapColor["MbtnBackFlg"] == true ){
			welmMbtn.style.backgroundColor = this.mmapColor["MbtnBackOut"];
		}
		if( this.mmapTimer["use"] == true ){
			this.mmapTimer["wait"] = 0;
		}
		this.mflgExtend = false;
	}
// メニュー開閉動作
	this.Auto = function(){
		var welmMenu;

		welmMenu = document.getElementById(this.midMenu);

		if( welmMenu.style.display != "block" ){
			this.Open();
		}else{
			this.Close();
		}
	}
// フォーカス解除時にメニューを閉める
	this.setClose = function(){
		setTimeout("garyMenu['" + this.midMbtn + "'].Close();",200);
	}
// リスト要素選択時の動作
	this.actList = function( pidList, pelmThis ){
		this.fncHide(pelmThis.parentNode);
		with( pelmThis.style ){
			if( this.mmapColor["ItemForeFlg"] == true ){
				color		= this.mmapColor["ItemForeOver"];
			}
			if( this.mmapColor["ItemBackFlg"] == true ){
				backgroundColor	= this.mmapColor["ItemBackOver"];
			}
		}

		with( document.getElementById(pidList).style ){
			display	= "block";
			switch( this.mstrDirect ){
				case "top":
					top	= pelmThis.offsetTop + pelmThis.offsetHeight - document.getElementById(pidList).offsetHeight;
					left = pelmThis.offsetLeft + pelmThis.offsetWidth;
					break;
				case "right":
					top	= pelmThis.offsetTop;
					left = pelmThis.offsetLeft + pelmThis.offsetWidth;
					break;
				case "bottom":
					top	= pelmThis.offsetTop;
					left = pelmThis.offsetLeft + pelmThis.offsetWidth;
					break;
				case "left":
					top	= pelmThis.offsetTop;
					left = pelmThis.offsetLeft - pelmThis.offsetWidth;
					break;
			}
		}

		if( this.mmapTimer["use"] == true ){
			this.mmapTimer["wait"] = this.mmapTimer["sec"];
		}
	}
	this.actLink = function( pelmThis ){
		this.fncHide(pelmThis.parentNode);
		with( pelmThis.style ){
			if( this.mmapColor["ItemForeFlg"] == true ){
				color		= this.mmapColor["ItemForeOver"];
			}
			if( this.mmapColor["ItemBackFlg"] == true ){
				backgroundColor	= this.mmapColor["ItemBackOver"];
			}
		}

		if( this.mmapTimer["use"] == true ){
			this.mmapTimer["wait"] = this.mmapTimer["sec"];
		}
	}
// リストを隠す
	this.fncHide = function( pelmThis ){
		var wlngCnt;
		var wndlElm;

		wndlElm = pelmThis.childNodes;
		for( wlngCnt = wndlElm.length-1 ; wlngCnt>=0 ; wlngCnt-- ){
			switch( wndlElm.item(wlngCnt).nodeName.toLowerCase() ){
				case "div":
					this.fncHide( wndlElm.item(wlngCnt) );
					wndlElm.item(wlngCnt).style.display = "none";
					break;
				case "a":
					with( wndlElm.item(wlngCnt).style ){
						if( this.mmapColor["ItemForeFlg"] == true ){
							color		= this.mmapColor["ItemForeOut"];
						}
						if( this.mmapColor["ItemBackFlg"] == true ){
							backgroundColor	= this.mmapColor["ItemBackOut"];
						}
					}
					break;
			}
		}
	}
}

function writeMenu(){
document.write('<table border="0"><tr><td><div id="mbbfpqhbkv0" class="mbMbtn" onclick="mbSetMenu(\'mbbfpqhbkv0\',\'mbtfpqhbkv0\',true,\'bottom\',true,10,true,\'\',\'#000000\',true,\'\',\'#FFCC66\',true,\'\',\'#000000\',true,\'\',\'#FFFFFF\');mbAutoMenu(\'mbbfpqhbkv0\');" onblur="mbSetClose(\'mbbfpqhbkv0\');">Top</div></td><td><div id="mbbeufcr19o" class="mbMbtn" onclick="mbSetMenu(\'mbbeufcr19o\',\'mbteufcr19o\',true,\'bottom\',true,10,true,\'\',\'#000000\',true,\'\',\'#FFCC66\',true,\'\',\'#000000\',true,\'\',\'#FFFFFF\');mbAutoMenu(\'mbbeufcr19o\');" onblur="mbSetClose(\'mbbeufcr19o\');">Profile</div></td><td><div id="mbbeufcs3qn" class="mbMbtn" onclick="mbSetMenu(\'mbbeufcs3qn\',\'mbteufcs3qn\',true,\'bottom\',true,10,true,\'\',\'#000000\',true,\'\',\'#FFCC66\',true,\'\',\'#000000\',true,\'\',\'#FFFFFF\');mbAutoMenu(\'mbbeufcs3qn\');" onblur="mbSetClose(\'mbbeufcs3qn\');">Weblog</div></td><td><div id="mbbeufcsfm6" class="mbMbtn" onclick="mbSetMenu(\'mbbeufcsfm6\',\'mbteufcsfm6\',true,\'bottom\',true,10,true,\'\',\'#000000\',true,\'\',\'#FFCC66\',true,\'\',\'#000000\',true,\'\',\'#FFFFFF\');mbAutoMenu(\'mbbeufcsfm6\');" onblur="mbSetClose(\'mbbeufcsfm6\');">Archives</div></td><td><div id="mbbeufmjjwj" class="mbMbtn" onclick="mbSetMenu(\'mbbeufmjjwj\',\'mbteufmjjwj\',true,\'bottom\',true,10,true,\'\',\'#000000\',true,\'\',\'#FFCC66\',true,\'\',\'#000000\',true,\'\',\'#FFFFFF\');mbAutoMenu(\'mbbeufmjjwj\');" onblur="mbSetClose(\'mbbeufmjjwj\');">Other sites</div></td></tr></table><div id="mbtfpqhbkv0" class="mbList"><a class="mbItem" title="サイトのトップページへ戻る" href="http://homepage2.nifty.com/ke1go/" onmouseover="garyMenu[\'mbbfpqhbkv0\'].actLink(this);">トップページへ戻る</a></div><div id="mbteufcr19o" class="mbList"><a class="mbItem" title="管理人プロフィール" href="http://homepage2.nifty.com/ke1go/profile/" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">管理人プロフィール</a><a class="mbItem" title="管理人愛用のPCスペック紹介" href="http://homepage2.nifty.com/ke1go/profile/pc.htm" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">愛用PC紹介</a><a class="mbItem" title="過去に愛用したPCのライブラリ" href="http://homepage2.nifty.com/ke1go/profile/pc_old.htm" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">過去に愛用したPC</a><a class="mbItem" title="管理人の家庭用ゲーム環境" href="http://homepage2.nifty.com/ke1go/profile/game.htm" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">家庭用ゲーム環境</a><a class="mbItem" onmouseover="garyMenu[\'mbbeufcr19o\'].actList(\'mblfrhyi1td\',this);">&gt;外部サイト</a><div id="mblfrhyi1td" class="mbList"><span class="mbHead">他のサイトにあるプロフィール</span><a class="mbItem" title="アメブロでのプロフィール" href="http://profile.ameba.jp/ke1go/" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">Ameba Room</a><a class="mbItem" title="Xbox ゲーマープロフィール" href="http://live.xbox.com/member/Ke1go" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">Xbox ゲーマープロフィール</a><a class="mbItem" title="Steamでのプロフィール" href="http://steamcommunity.com/id/ke1go/" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">Steam</a><a class="mbItem" href="http://profiles.yahoo.co.jp/ke1go_2000" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">Yahoo!プロフィール</a><a class="mbItem" title="Last.fm ミュージック・プロフィール" href="http://www.lastfm.jp/user/Ke1go" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">Last.fm</a><a class="mbItem" title="Bloggerのプロフィール" href="http://www.blogger.com/profile/27464033" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">Blogger</a><a class="mbItem" title="Wikipedia 利用者ページ" href="http://ja.wikipedia.org/wiki/%E5%88%A9%E7%94%A8%E8%80%85:Ke1go" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">Wikipedia 利用者ページ</a><a class="mbItem" title="about meのプロフィール" href="http://ke1go360.aboutme.jp/" onmouseover="garyMenu[\'mbbeufcr19o\'].actLink(this);">about me</a></div></div><div id="mbteufcs3qn" class="mbList"><a class="mbItem" title="或る男のどうでもいいWeblog" href="http://weblog.ke1go360.net/" onmouseover="garyMenu[\'mbbeufcs3qn\'].actLink(this);">Ke1gonoWeblog</a><a class="mbItem" onmouseover="garyMenu[\'mbbeufcs3qn\'].actList(\'mblfrhylpng\',this);">&gt;外部サイト</a><div id="mblfrhylpng" class="mbList"><span class="mbHead">他のサイトで執筆中のWeblog</span><a class="mbItem" title="管理人の独り言" href="http://twitter.com/Ke1go/" onmouseover="garyMenu[\'mbbeufcs3qn\'].actLink(this);">Twitter / Ke1go</a></div></div><div id="mbteufcsfm6" class="mbList"><a class="mbItem" title="旧サイト『別冊 ケイゴノウォッチャー』時代の記事アーカイブ詰め合わせ" href="http://archives.ke1go360.net/" onmouseover="garyMenu[\'mbbeufcsfm6\'].actLink(this);">Ke1gonoWatcher Archives</a><a class="mbItem" title="誰もリクエストもしていないのに復刻" href="http://homepage2.nifty.com/ke1go/watcher/report/" onmouseover="garyMenu[\'mbbeufcsfm6\'].actLink(this);">ケイゴノリポート 復刻版</a></div><div id="mbteufmjjwj" class="mbList"><a class="mbItem" title="Yahoo!オークション・稀に何か出品しているかも" href="http://auctions.yahoo.co.jp/jp/booth/ke1go_2000" onmouseover="garyMenu[\'mbbeufmjjwj\'].actLink(this);">マイオークションブース</a></div>');
}
