//
// メニュー領域の反転表示
//
function menuHover(obj, cls)
{
	var target;
	
	if(document.getElementById) target = document.getElementById(obj);
	else target = document.all(obj);
	
	if(target == null) return;
	
	target.className = cls;
}

//
// サブメニューポップアップ
//
var flag = 0;
var subflag = 0;
var obj;
var sleeptime = 500;

function showMenu(menu, num)
{
	var menuTD;
	
	if(flag) {
		if(menu != obj) {
			if(document.getElementById) menuTD = document.getElementById(("Menu" + obj));
			else menuTD = document.all(("Menu" + obj));
			if(menuTD == null) return;
			menuTD.className="menu0";
			subclose();
		}
	}
	menushow(menu, num);
}

function hideMenu(menu)
{
	subflag = 0;
	setTimeout(("menuhide(" + menu + ")"), sleeptime);
}

function menushow(menu, num)
{
	var menuTD;
	var subDIV;
	var backDIV;
	var baseDIV;
	var baseIFRAME;

	if(document.getElementById) menuTD = document.getElementById(("Menu" + menu));
	else menuTD = document.all(("Menu" + menu));
	if(menuTD == null) return;
	if(document.getElementById) subDIV = document.getElementById(("divSubMenu" + menu));
	else subDIV = document.all(("divSubMenu" + menu));
	if(subDIV == null) return;
	if(document.getElementById) backDIV = document.getElementById("divBack");
	else backDIV = document.all(divBack);
	if(backDIV == null) return;
	if(document.getElementById) baseDIV = document.getElementById("divBase");
	else baseDIV = document.all(divBase);
	if(baseDIV == null) return;
	if(document.getElementById) baseIFRAME = document.getElementById("IFrameBase");
	else baseIFRAME = document.all(IFrameBase);
	if(baseIFRAME == null) return;
	
	if(menuTD.className == "menu0") {
		backDIV.style.top = ((menu - 1) * 20) + 158;
		backDIV.innerHTML = subDIV.innerHTML;
		backDIV.style.display = "block";
		menuTD.className = "menu1";
		flag = 1;
		obj = menu;
		subflag = menu;

		baseDIV.style.top = backDIV.style.top;
		baseIFRAME.style.height = (num * 20) + 4;
		baseDIV.style.display = "block";
	} else {
		menuTD.className = "menu0";
		subclose();
	}
}

function subclose()
{
	var backDIV;
	var baseDIV;

	if(document.getElementById) backDIV = document.getElementById("divBack");
	else backDIV = document.all(divBack);
	if(backDIV == null) return;
	if(document.getElementById) baseDIV = document.getElementById("divBase");
	else baseDIV = document.all(divBase);
	if(baseDIV == null) return;
	
	backDIV.style.display = "none";
	baseDIV.style.display = "none";
	flag = 0;
}

function menuhide(menu)
{
	var menuTD;
	
	if(subflag == 0 && subflag != menu) {
		if(document.getElementById) menuTD = document.getElementById(("Menu" + menu));
		else menuTD = document.all(("Menu" + menu));
		if(menuTD == null) return;
		menuTD.className="menu0";
		subclose();
	}
}

function showSubMenu(menu)
{
	var menuTD;
	
	subflag = menu;
	if(document.getElementById) menuTD = document.getElementById(("Menu" + menu));
	else menuTD = document.all(("Menu" + menu));
	if(menuTD == null) return;
	menuTD.className="menusel";
}

function hideSubMenu(menu)
{
	subflag = 0;
	setTimeout(("menuhide(" + menu + ")"), sleeptime);
}

//
// フォントカラーの変更
//
function fontChangeColor(target, cls)
{
	target.className = cls;
}

//
// リアルタイム日時表示
//
function showRealDateTime(obj)
{
	var now;
	var watch;
	var target;
	
	if(document.getElementById) target = document.getElementById(obj);
	else target = document.all(obj);
	if(target == null) return;

	// ローカル日時を取得 
	now = new Date(); 
	watch = now.toLocaleString();  

	// ローカル日時を表示
	target.innerText = watch; 

	setTimeout(("showRealDateTime('" + obj + "')"), 1000); 
}

//
// リアルタイム日時表示
//
function showRealDateTime2(obj)
{
	var target;
	
	if(document.getElementById) target = document.getElementById(obj);
	else target = document.all(obj);
	if(target == null) return;

	// ローカル日時を取得 
	var now = new Date(); 
	var year = now.getYear();
	var month = now.getMonth() + 1;
	var day = now.getDate();
	var Hour = now.getHours();
	var minute = now.getMinutes();
	var second = now.getSeconds();
	var watch = year + "/";
	if (month < 10) watch += "0";
	watch += month + "/";
	if (day < 10) watch += "0";
	watch += day + " ";
	if (Hour < 10) watch += "0";
	watch += Hour + ":";
	if (minute < 10) watch += "0";
	watch += minute + ":";
	if (second < 10) watch += "0";
	watch += second;

	// ローカル日時を表示
	target.value = watch; 

	setTimeout(("showRealDateTime2('" + obj + "')"), 1000); 
}

//
// フォーカス設定
//
function setFocus(obj)
{
	var target;
	
	if(document.getElementById) target = document.getElementById(obj);
	else target = document.all(obj);
	if(target == null) return;

	target.focus();
}

//
// 年月日のドロップダウンリストの生成
//
function GetDaysForYearMonth( year, month )
{
	var day = new Date();
	day.setFullYear( year );
	day.setMonth( month );
	leapy1 = year % 4;
	leapy2 = year % 100;
	leapy3 = year % 400;

	var numdays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

	if ( leapy1 == 0 )
	{
		if ( leapy2 == 0 && leapy3 != 0 ) numdays[1] = 28;
		else numdays[1] = 29;
	}

	return(numdays[ (month - 1) ]);
}

function SetDaysDropDownList( addstr, year, month, dropdownlist )
{
	var days = GetDaysForYearMonth( year, month );

	var listNum = dropdownlist.length;
	for( i = 0; i < listNum; i++ )
	{
		dropdownlist.remove( 0 );
	}
	
	if ( addstr != 0 )
	{
		oOption = document.createElement("OPTION");
		oOption.text = addstr;
		oOption.value = 0;
		dropdownlist.add(oOption);
	}

	for( i = 0; i < days; i++ )
	{
		var oOption = document.createElement("OPTION");
		var d = i + 1;
		oOption.text = d;
		oOption.value = d;
		dropdownlist.add(oOption);
	}

	dropdownlist.selectedIndex = 0;
}

//
// イメージ画像オープン
//
function OpenImage( imagename, width, height, title )
{
	var newwindow;
	var body;
	var posx, posy;
	
	posx = (window.screen.width / 2) - (677 / 2);
	posy = (window.screen.height / 2) - (550 / 2);
	body = "<head><title>" + title + "</title></head><body topmargin='0' leftmargin='0'><center><p><img border='0' src='images/" + imagename + "' width='" + width + "' height='" + height + "'></p></center></body>";
	newwindow = window.open("",null,"height=550,width=677,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,left=" + posx + ",top=" + posy);
	newwindow.document.write(body);
}

//
// ヘルプウィンドウのオープン
//
function OpenHelp()
{
	var posx, posy;
	
	posx = (window.screen.width / 2) - (600 / 2);
	posy = (window.screen.height / 2) - (550 / 2);
	window.open("Help.aspx",null,"height=550,width=600,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,left=" + posx + ",top=" + posy);
}