﻿var year = 2101, month = 1, day = 1;
var i = 0, theDay = new Date(year, month-1, day), timerId;
function secCountDown() {
   if (i <= 1800) {
      i++;
      var now = new Date(), today = now.getTime(), timeToGo = theDay.getTime() - today;
      var secondsToGo = (timeToGo >= 0) ? Math.ceil(timeToGo/1000) : "";
      document.getElementById("countdown").innerHTML = "２２世紀まであと" + secondsToGo + "秒！";
      timerId = setTimeout("secCountDown()", 1000);
      } else {
         clearTimeout(timerId);
         document.getElementById("countdown").innerHTML = "";
   }
}
