function clockUpdate() {
  var now = new Date();
  // set this value to the countdown date.
  var then = new Date("april 6, 2008");
  var gap = then.getTime() - now.getTime();

  var obj = document.getElementById("countdown");
 
  var milliseconds = Math.floor(gap % 1000);
  gap = gap/1000;
  var seconds = Math.floor(gap % 60);
  gap = gap/60;
  var minutes = Math.floor(gap % 60);
  gap = gap/60;
  var hours = Math.floor(gap % 24);
  gap = gap/24;
  var days = Math.floor(gap);



  obj.innerHTML= days + " days " + "<br>" + hours + ":" + minutes + ":" + seconds + ":" + String(milliseconds).substr(0,2);
  setTimeout("clockUpdate()",100);
}

function stopClock() {
  obj.innerHTML = "";
}



window.onload = function() {
  clockUpdate();
}

window.onunload = function() {
  stopClock();
}