From http://www.tristanwaddington.com/2010/08/javascript-clock/