  var timerID;
  var timerRunning = false;
  var now = new Date();
  var lastday = new Date("July, 7 2010 18:00");
  var secPerDay = 1000;
  var minPerDay = 60000;
  var hourPerDay = 60*60*1000;
  var PerDay = 24 * 60 * 60 * 1000;

  function stopclock (){
    if(timerRunning)
    clearTimeout(timerID);
    timerRunning = false;
  }
  function startclock () {
    stopclock();
    showtime();
  }
  function showtime () {
    now = new Date();
    /*Seconds*/
    secsLeft = (lastday.getTime() - now.getTime()) / minPerDay;
    decremain = (lastday.getTime() - now.getTime()) / secPerDay;
    decround = Math.round(decremain);
    decremain = decround + " seconds";
    secsRound = Math.round(secsLeft);
    secsRemain = secsLeft - secsRound;
    secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain = (secsLeft - secsRound) * 60;
    secsRemain = Math.round(secsRemain);
    /*Minutes*/
    minLeft = ((lastday.getTime() - now.getTime()) / hourPerDay);
    minRound = Math.round(minLeft);
    minRemain = minLeft - minRound;
    minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60) : minRemain = ((minLeft - minRound) * 60);
    minRemain = Math.round(minRemain - 0.495);
    /*Hours*/
    hoursLeft = ((lastday.getTime() - now.getTime()) / PerDay);
    hoursRound = Math.round(hoursLeft);
    hoursRemain = hoursLeft - hoursRound;
    hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft) * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24);
    hoursRemain = Math.round(hoursRemain - 0.5);
    /*Days*/
    daysLeft = ((lastday.getTime() - now.getTime()) / PerDay);
    daysLeft = (daysLeft - 0.5);
    daysRound = Math.round(daysLeft);
    daysRemain = daysRound;
    /*Time*/
    timeRemain = "Countdown Peestoemp 2010 nog " + daysRemain + " dagen, " + hoursRemain + " uren, " + minRemain + " min, " + secsRemain + " sec";
    document.getElementById("countdown").innerHTML =  timeRemain;
    //timerID = setInterval("showtime()",1000);
    timerID = setTimeout("showtime()",1000);
    timerRunning = true;
    if (daysRemain < 0) {
      clearTimeout(timerID);
      timerRunning = false;
      document.getElementById("countdown").innerHTML = "Als je dit leest ben je te laat, we zijn al weg";
    }
  }
window.onload=showtime;

