Simple timer with setTimout in Javascript
<p>I'm trying to create a simple timer in javascript that counts down from 5 to 0 on a push of a button.  This is my function that I have for the onclick of the button.  I'm getting stuck though since it is not counting down.  Any hints to where my logic is wrong would be apprciated.  Thanks.</p>

<pre><code>function countdown(num) {
    if (num &gt;= 0) {
        document.getElementById("counter").innerHTML=num;
        timer=setTimeout("countdown()", 1000);
        num--;
    }
    else 
        clearTimeout(timer);
}
</code></pre>
