An accurate timer written in javascript