Timer not working
<p>My problem is that timer doesn't pause correctly. When I hit pause it looks like it has stopped but actually it continues to cycle, and when I hit start it doesn't continue from where I paused, but from the location it had reached.</p>

<pre><code>&lt;div class="stopwatch"&gt;
    &lt;span&gt;00:00:00,000&lt;/span&gt;&lt;br /&gt;
    &lt;div class="btn start"&gt;play&lt;/div&gt;
    &lt;div class="btn pause"&gt;pause&lt;/div&gt;
    &lt;div class="btn reset"&gt;reset&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<pre class="lang-js prettyprint-override"><code>$(function (){  
    var reload = 1000/60;  
    var timer = null;  
    var startTime = 0;  
    var btn = $('.stopwatch a');  
    var count = $('.stopwatch span');  
    var pause = false;

    $('.pause').click(function (){
        pause = true; 
    });
    $('.start').click(function (){
        pause = false; 
    });
    $('.reset').click(function (){
        return ( (count.text('00:00:00,000')) &amp;&amp; (timer = 0) );
    });

    function zero(num, length) {  
        if ( typeof(length) == 'undefined' ) length = 2;  

        while ( num.toString().length &lt; length ) {  
            num = '0' + num;  
        }  
        return num;  
    }  

    function zero_format(time){  
        return zero(time.getUTCHours()) + ':' + zero(time.getMinutes()) + ':' + zero(time.getSeconds()) + ',' + zero(time.getMilliseconds()); 
    }  

    $('.start').click( function (){  
        if ( !timer ){  
            startTime = new Date();  
            timer = setInterval( function (){  
                if ( pause ){
                    return;
                }

                var currentTime = new Date(new Date() - startTime);  
                count.text(zero_format(currentTime));  
            }, reload);
        }
        return false;
    });
});   
</code></pre>
