function tick()
{                                      
  // create a new Date object
  var now = new Date();                              
  // extract the current hours, minutes and seconds
  var hh = now.getHours();   
  var mn = now.getMinutes();   
  var ss = now.getSeconds();
  // ensure each component has two digits
  if( hh <= 9 ) hh = "0" + hh;
  if( mn <= 9 ) mn = "0" + mn; 
  if(ss <= 9 ) ss = "0" + ss; 
   
  // assign the current time string to the div
  window.document.getElementById("clock").innerHTML = hh + ": " +mn+ ": " + ss;        
  
  // set the interval before calling this function again
  window.setTimeout( "tick()", 1000 );                    
}

// start the clock
window.onload=tick;