var clockID = 0;

function UpdateClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }

   var tDate = new Date();

   var tDateSecs,tDateMins,tDateHours;
   if(tDate.getSeconds() < 10) {
       tDateSecs = "0" + tDate.getSeconds();
   }
   else {
       tDateSecs = tDate.getSeconds();
   }
   if(tDate.getMinutes() < 10) {
       tDateMins = "0" + tDate.getMinutes();
   }
   else {
       tDateMins = tDate.getMinutes();
   }
   if(tDate.getHours() < 10) {
       tDateHours = "0" + tDate.getHours();
   }
   else {
       tDateHours = tDate.getHours();
   }

   document.getElementById('theClock').innerHTML = "" 
                                   + tDateHours + ":" 
                                   + tDateMins + ":" 
                                   +  tDateSecs;
   //document.getElementById('theClock').innerHTML = "" + tDate.getHours() + ":" + tDate.getMinutes() + ":" +  tDate.getSeconds();
      
   clockID = setTimeout("UpdateClock()", 1000);
}
function StartClock() {
   //clockID = setTimeout("UpdateClock()", 100);
   clockID = UpdateClock();
}

function KillClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }
}