//-------------------------------
// 時計を表示する
//-------------------------------


t = 0;

function DspClk() {
	DD = new Date();
	Hours = DD.getHours();
	Minutes = DD.getMinutes();
//	if(Hours < 10) { Hours = "0" + Hours; }
	if(Minutes < 10) { Minutes = "0" + Minutes; }
	DC = document.getElementById('now');
	DC.firstChild.nodeValue = Hours + ":" + Minutes;

	if(Hours < 10) { Hours = "0" + Hours; }
	check_time = Hours + "" + Minutes;

// カウントダウン
	millenium = "";

	if (document.getElementById('next_time')) {
		if (str_next_time == "" || str_next_date == "") {
/*
			DC2 = document.getElementById('next_time');
			DC2.firstChild.nodeValue = "未定";
*/

		} else {
			var arr_date = str_next_date.split("-");
			var year = arr_date[0];					// 年
			var mon = arr_date[1];					// 月
			var day = arr_date[2];					// 日
			var hou = str_next_time.substr(0,2);	// 時
			var min = str_next_time.substr(2,2);	// 分

			var xday = new Date(year,mon-1,day,hou,min,00);//基準になる年月日

			nowday = new Date();
			passtime= xday.getTime()-nowday.getTime();　//今から基準になる日までの経過時間　1/1000秒単位

			cnt_day = Math.floor(passtime/(1000*60*60*24));// カウントダウン表示 (日にち) の取得
			passtime = passtime -(cnt_day*(1000*60*60*24)); // 経過秒から(日にち)を引く

			cnt_hour = Math.floor(passtime/(1000*60*60));// カウントダウン表示 (時) の取得
			passtime = passtime -(cnt_hour*(1000*60*60)); // 経過秒から(時)を引く

			cnt_min = Math.floor(passtime/(1000*60)); // カウントダウン表示 (分) 取得
			passtime = passtime -(cnt_min*(1000*60));// 経過秒から(分)を引く

			cnt_sec = Math.floor(passtime/1000);// カウントダウン表示 (秒) 取得
			passtime = passtime -(cnt_sec*(1000)); // 経過秒から(秒)を引く

			cnt_millisec = Math.floor(passtime/10); // カウントダウン表示 (100/1秒) 取得

			// 分、秒、ミリ秒を２桁で表示する。
			if(cnt_min<10){cnt_min = '0' + cnt_min;}
			if(cnt_sec<10){cnt_sec = '0' + cnt_sec;}
			if(cnt_millisec<10){cnt_millisec = '0' + cnt_millisec;}

			DC2 = document.getElementById('next_time');
			if((xday - nowday) > 0){
				DC2.firstChild.nodeValue = cnt_day+"日と"+cnt_hour+"時間"+cnt_min+"分後の予定です";
//				DC2.firstChild.nodeValue = "[次回] 約 "+cnt_day+"日と "+cnt_hour+"時間"+cnt_min+"分"+cnt_sec+"秒"+cnt_millisec+" で始まります"
			} else {
				DC2.firstChild.nodeValue =  "終了しました"
			}
		}
	}
}

