var clock = 0;

function UpdateClock() {
   if(clock) {
      clearTimeout(clock);
      clock = 0;
   }

   document.getElementById('clock').innerHTML = GetTime();
   
   
   clock = setTimeout("UpdateClock()", 1000);
}

function StartClock() {
   clock = setTimeout("UpdateClock()", 500);
}

function GetTime(){

   var tDate = new Date();
   
   hour = ''+tDate.getHours();
   minutes = ''+tDate.getMinutes();
   seconds = ''+tDate.getSeconds();
   if(hour.length == 1){ hour = '0'+hour; }
   if(minutes.length == 1){ minutes = '0'+minutes; }
   if(seconds.length == 1){ seconds = '0'+seconds; }

   return hour+':'+minutes+':'+seconds;
}


function KillClock() {
   if(clock) {
      clearTimeout(clock);
      clock = 0;
   }
}
