javascriptのいくつかのカウントダウン関数


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<title>     </title>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body onload="Load()">
	<!--         ,    ,       -->
	
	<!--    : -->
	<script type="text/javascript">
		function Load(){
			var dateTime=new Date();
			var strEndDate="2012/5/20";
			var endDate=new Date(strEndDate);
			var num=endDate.getTime()-dateTime.getTime();
			var miao=parseInt(num/1000%60);
			var fen=parseInt(num/1000/60%60);
			var shi=parseInt(num/1000/60/60%24);
			var tian=parseInt(num/1000/60/60/24);
			document.getElementById("djs").innerHTML=tian+" "+shi+" "+fen+" "+miao+" ";
			setTimeout(Load,1000);
		}
	</script>
	<center>   :<font id="djs"></font></center>

	<!--    : -->
	<center>    :<span id="endtime">10</span></center>
	<script type="text/javascript">
	var CID = "endtime";
	if(window.CID != null)
	{
		var iTime = document.getElementById(CID).innerText;
		var Account;
		RemainTime();
	}
	function RemainTime()
	{
		var iDay,iHour,iMinute,iSecond;
		var sDay="",sHour="",sMinute="",sSecond="",sTime="";
		if (iTime >= 0)
		{
        iDay = parseInt(iTime/24/3600);
        if (iDay > 0)
        {
            sDay = iDay + " ";
        }
        iHour = parseInt((iTime/3600)%24);
        if (iHour > 0){
            sHour = iHour + "  ";
        }
        iMinute = parseInt((iTime/60)%60);
        if (iMinute > 0){
            sMinute = iMinute + "  ";
        }
        iSecond = parseInt(iTime%60);
        if (iSecond >= 0){
            sSecond = iSecond + " ";
        }
        if ((sDay=="")&&(sHour=="")){
            sTime="<span style='color:darkorange'>" + sMinute+sSecond + "</font>";
        }
        else
        {
            sTime=sDay+sHour+sMinute+sSecond;
        }
        if(iTime==0){
            clearTimeout(Account);
              sTime="<span style='color:green'>    !</span>";
        }
        else
        {
            Account = setTimeout("RemainTime()",1000);
        }
        iTime=iTime-1;
		}
		else
		{
			sTime="<span style='color:red'>     !</span>";
		}
		document.getElementById(CID).innerHTML = sTime;
	}
	</script>
	
	<!--    : -->
	<center><div id="time">     </div></center>
	<script type="text/javascript">
		var time=<%=5%>;
		var t = setInterval("f1()", 1000);
		function f1()
		{
			document.all("time").innerHTML="  :"+time+" ";
			time--;
			if(time<0)
			{
				clearInterval(t);
			}
		}
	</script>
	
	<!--     -->
	<center><input type="button" onclick="qq()" id="btn" value="  "></center>
	<script language="JavaScript">
		function qq(){
			//    
			var btn = document.getElementById("btn")
			btn.disabled=true
			c(5)
		}
		function c(i){
			var btn = document.getElementById("btn")
			i--;
			if(i==0){
				btn.value = "  "
				btn.disabled=false
			}
			else{
				btn.value = "  ("+i+")"
				setTimeout("c("+i+")",1000)	//setTimeout()  
			}
		}
	</script>
  
</body>
</html>