title: decrement progressbar instead of increment with javascript
body: <p>I'm not very good with javascript yet... but I need to edit this code to make the value in <code>#showsecs</code> to decrement instead of increment. As in, a count-down timer. I think I can see where the problem is, but I can't figure out how to make it work properly. Any help is appreciated!</p>
  
  <pre><code>containerWidth = 485;     
  intervalDuration = 250;   
  
  drawBar=0;
  
  function progressBar(duration) { 
      resetStart();                                                                                                           
      ref=new Date();  start=ref.getTime();                                                                                       
      increment = intervalDuration*containerWidth/duration;                                                                       
      barWidth = interval*increment;                                                                                              
      drawBar = setInterval('progress('+duration%intervalDuration+')', intervalDuration);                                         
  }
  
  function progress(lastms) {
      document.getElementById('bar').style.width=barWidth;                                                                        
      document.getElementById('showsecs').innerHTML=Math.floor(interval*intervalDuration/1000);                               
      interval++;                                                                                                             
      if(interval*increment &gt; containerWidth) {                                                                               
          clearInterval(drawBar);                                                                                             
          end=new Date(); end=lastms+end.getTime();                                                                           
          setTimeout("document.getElementById('bar').style.width=containerWidth",lastms);                                     
          setTimeout("document.getElementById('showsecs').innerHTML="+(lastms+intervalDuration*(interval-1))/1000, lastms);   
          setTimeout('window.open("timeout.html");');                                                                         
          }
          else barWidth = interval*increment;                                                                                 
      }
  
      function resetStart() {                                                                                                     
           if(drawBar) clearInterval(drawBar);                                                                                    
           document.getElementById('bar').style.width = 0;                                                                        
           document.getElementById('showsecs').innerHTML = 0;                                                                     
           interval = 1;                                                                                                          
  }
  </code></pre>