var	timerID = null;
var	timerCount = 0;
var	stsMsg0 = "　　　　　　　";
var	stsMsg1 = "（１）当サイトはデスクトップ機能を提供する事を目的としています。";
var	stsMsg2 = "（２）ブラウザはIE6以降を使用する事を推奨致します。";
var	stsMsg3 = "（３）日本語以外はサポートしていませんが、当頁を英語に翻訳する事は可能です。";
var	stsMsg = stsMsg1+stsMsg0+stsMsg2+stsMsg0+stsMsg3+stsMsg0;

//------------------------カレンダー表示
function Java_Calender(u_iMax, u_iDay, u_iY, u_iM, u_iD) {
	var w = u_iDay;
	if(w>6) w = 0;
	var w_tStr = "<TABLE BORDER=0 CLASS='koyomi' CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=CENTER><FONT COLOR=#FFFFFF><B>" + u_iY + "年" + u_iM + "月</B></FONT></TD></TR>\n<TR><TD>";
	w_tStr = w_tStr + "<TABLE WIDTH=100 BORDER=0  CLASS='koyomi' CELLSPACING=1 CELLPADDING=1>\n<TR><TD  CLASS='koyomi'><FONT COLOR=#FF0000><B>日</B></FONT></TD><TD CLASS='koyomi'><FONT CLASS='koyomi'><B>月</B></FONT></TD><TD CLASS='koyomi'><FONT CLASS='koyomi'><B>火</B></FONT></TD><TD CLASS='koyomi'><FONT CLASS='koyomi'><B>水</B></FONT></TD><TD CLASS='koyomi'><FONT CLASS='koyomi'><B>木</B></FONT></TD><TD CLASS='koyomi'><FONT CLASS='koyomi'><B>金</B></FONT></TD><TD CLASS='koyomi'><FONT CLASS='koyomi'><B>土</B></FONT></TD></TR>\n<TR>";
	for(i=1;i<=u_iMax;i++) {
		if(i==1) {
			if(w>0) {
				for(j=0; j<w; j++) {
					w_tStr = w_tStr + "<TD ALIGN=CENTER BGCOLOR=#FFFFFF>&nbsp;</TD>";
				}
			}
		} else {
			if(w>6) {
				w=0;
				w_tStr = w_tStr + "</TR>\n<TR>";
			}
		}
		if(w==0) {
			w_FontColor = "RED";
		} else if(w==6) {
			w_FontColor = "BLUE";
		} else {
			w_FontColor = "BLACK";
		}
		var ws_Date = u_iY*10000 + u_iM*100 + i;
		for(var j=0; j<Holidays.length; j++) {
			if(Holidays[j]==ws_Date) {
				w_FontColor = "RED";
				break;
			}
		}
		if(i==u_iD) {
			//if(w>0) w_FontColor = "WHITE";
			//w_tStr = w_tStr + "<TD ALIGN=CENTER CLASS='koyomiH'><FONT COLOR=" + w_FontColor + "><B>" + i + "</B></FONT></TD>";
			w_tStr = w_tStr + "<TD ALIGN=CENTER BGCOLOR=#DDDDDD><FONT COLOR=" + w_FontColor + "><B>" + i + "</B></FONT></TD>";
		} else {
			//if(w==0) w_FontColor = "COLOR=RED"; else w_FontColor = "CLASS='koyomi'";
			//w_tStr = w_tStr + "<TD ALIGN=CENTER BGCOLOR=#FFFFFF><FONT " + w_FontColor + "><B>" + i + "</B></FONT></TD>";
			w_tStr = w_tStr + "<TD ALIGN=CENTER BGCOLOR=#FFFFFF><FONT COLOR=" + w_FontColor + "><B>" + i + "</B></FONT></TD>";
		}
		w++;
	}
	if(w>0 && w<7) {
		w_tStr = w_tStr + "<TD BGCOLOR=#FFFFFF COLSPAN=" + (7-w) + ">&nbsp;</TD>\n";
	}
	w_tStr = w_tStr + "</TR>\n</TABLE>\n";
	w_tStr = w_tStr + "</TD></TR></TABLE>\n";
	return w_tStr;
}

//------------------------当月カレンダー表示
function Java_ThisMonth() {
	var date = new Date();
	var date_Y = date.getFullYear();
	var date_M = date.getMonth() + 1;
	var date_D = date.getDate();
	var date_W = date.getDay() + 1 - (date_D % 7);
	if(date_W<0) { date_W = date_W + 7; }
	var days = 31;
	switch(date_M) {
	case 2:
		if((date_Y % 4) == 0) { days=29; } else { days=28; }
		break;
	case 4:
		days = 30;
		break;
	case 6:
		days = 30;
		break;
	case 9:
		days = 30;
		break;
	case 11:
		days = 30;
		break;
	}
	var w_tHtml = Java_Calender(days,date_W,date_Y,date_M,date_D);
	var kr = new kyureki(date.getJD());
	var tUru="";
	if(kr.uruu) {tUru="閏";}
	w_tHtml = w_tHtml + "<FONT STYLE=\"font-size:10pt\" CLASS='koyomi'>旧暦："+tUru+kr.month+"月"+kr.day+"日("+kr.rokuyo+")</FONT>";                                              
	return w_tHtml;
}

//------------------------タイマー（時計）処理
function Java_Time() {
	var now;
	now = new Date();
	if(navigator.appName=="Opera") {
		document.Time.LOCAL.value = ("00" + now.getHours()).substr(-2,2) + ":" + ("00" + now.getMinutes()).substr(-2,2) + ":" + ("00" + now.getSeconds()).substr(-2,2);
	} else {
		var strTime = now.toLocaleString();
		document.Time.LOCAL.value = strTime.substr(strTime.length-8,8);
	}
	window.status = stsMsg;
	stsMsg = stsMsg.substring(6,stsMsg.length) + stsMsg.substring(0,6);
	timerID = setTimeout("Java_Time()",1000);
	if(timerCount>0) {
		timerCount=timerCount-1;
		if(timerCount>0) {
			document.Timer.MIN.value = Math.floor(timerCount / 60) +"";
			document.Timer.SEC.value = (timerCount % 60) + "";
		} else {
			Java_DispWin("timeup.htm", 0, 0, 400, 400, "no");
			document.Timer.MIN.value = "3";
			document.Timer.SEC.value = "0";
		}
	}
}

//------------------------タイマーセット
function Java_SetTimer() {
	var min=document.Timer.MIN.value;
	if(isNaN(min) || min=="") {
		min = "0";
		document.Timer.MIN.value=min;
	}
	var sec=document.Timer.SEC.value;
	if(isNaN(sec) || sec=="") {
		sec = "0";
		document.Timer.SEC.value=sec;
	}
	timerCount=eval(min)*60+eval(sec);
	Java_TimerMove();
}

//------------------------タイマーリセット
function Java_ReSetTimer() {
	document.Timer.MIN.value = "3";
	document.Timer.SEC.value = "0";
	timerCount=0;
}

//------------------------タイマー（時計）処理
function Java_TimerMove() {
	timerID = setTimeout("Java_TimerMove()",1000);
	if(timerCount>0) {
		timerCount=timerCount-1;
		if(timerCount>0) {
			document.Timer.MIN.value = Math.floor(timerCount / 60) +"";
			document.Timer.SEC.value = (timerCount % 60) + "";
		} else {
			Java_DispWin("timeup.htm", 0, 0, 400, 400, "no");
			document.Timer.MIN.value = "3";
			document.Timer.SEC.value = "0";
		}
	}
}

//------------------------日付確認フォーム
function Java_DispDate() {
	var date = new Date();
	var w_tHtml = "";
	w_tHtml = w_tHtml + "<SELECT NAME=\"gengou\">";
	w_tHtml = w_tHtml + "<OPTION VALUE=\"1\">明治</OPTION>";
	w_tHtml = w_tHtml + "<OPTION VALUE=\"2\">大正</OPTION>";
	w_tHtml = w_tHtml + "<OPTION VALUE=\"3\">昭和</OPTION>";
	w_tHtml = w_tHtml + "<OPTION VALUE=\"4\" SELECTED>平成</OPTION>";
	w_tHtml = w_tHtml + "</SELECT>";
	w_tHtml = w_tHtml + "<SELECT NAME=\"year\">";
	w_tHtml = w_tHtml + Java_EdOption(64,date.getFullYear()-1988);
	w_tHtml = w_tHtml + "</SELECT>年<BR>";
	w_tHtml = w_tHtml + "<SELECT NAME=\"month\">";
	w_tHtml = w_tHtml + Java_EdOption(12,date.getMonth() + 1);
	w_tHtml = w_tHtml + "</SELECT>月";
	w_tHtml = w_tHtml + "<SELECT NAME=\"date\">";
	w_tHtml = w_tHtml + Java_EdOption(31,date.getDate());
	w_tHtml = w_tHtml + "</SELECT>日";
	return w_tHtml;
}
