title: javascript setInterval - countdown lagging
body: <p>I use this code below for a countdown in seconds. The problem is that when the part of the page including the countdown is loaded again using jquery .load, the new countdown becomes wrong : at every second, we see fast 2 seconds, like this : 9-8...7-6...5-4... as if it was not synchronised with the clock...  See it there : aorbaroquethrash.com/test (for the problem to happen, I have to change song while you're there)</p>
  
  <p>Any idea how I can solve this?   </p>
  
  <pre><code>&lt;script type = "text/javascript"&gt;
  /*author Philip M. 2010*/
  
  var timeInSecs;
  var ticker;
  
  function startTimer(secs){
  timeInSecs = parseInt(secs)-1;
  ticker = setInterval("tick()",1000);   // every second
  }
  
  function tick() {
  var secs = timeInSecs;
  if (secs&gt;0) {
  timeInSecs--;
  }
  else {
  clearInterval(ticker); // stop counting at zero
  }
  
  document.getElementById("countdown").innerHTML = secs;
  } 
  startTimer(&lt;?php echo $stream['info']['length'];?&gt;);
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Patrick</p>