// アナログ放送終了（2011年7月24日）カウントダウン
window.onload=showday;
year=2011; //年
mon=7; //月
day=25; //日
time=0; //時
xday = new Date(year,mon-1,day,time,00,00);	// 基準になる年月日

function showday() {
	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;}

	if((xday - nowday) > 0){
		// document.tbox.dspmsg.value = "地上デジタル放送完全移行"
		// document.tbox.dspmsg2.value = "アナログ放送終了まで"
		// document.tbox.dspmsg3.value = "（2011年 7月24日）"
		// document.tbox.dspday.value =  " あと "+cnt_day+"日"+cnt_hour+"時間"+cnt_min+"分"
		document.tbox.dspday.value = cnt_day+"日"
	}
	else {
		document.tbox.dspday.value = "カウントダウンは終了。"
		document.getElementById("countdown").style.display = "none";
		clearTimeout(timerID);
	}
	timerID = setTimeout('showday()', 1000);
}

