Triggering javascript setTimeOut events prematurely
<p>I'm using setTimeOut to control an automatic slideshow.</p>

<p>(You can see it here: <a href="http://thingist.com/labs/ipad.shtml" rel="nofollow">http://thingist.com/labs/ipad.shtml</a> -- basically something pretty to look at while I'm working.  Images are coming from reddit's API)</p>

<p>The code looks approximately like this:</p>

<pre><code>next() {
   image_url = images[key]["url"]
   $("#image").html(vsprintf("&lt;img src='%s'&gt;", [image_url]));
   key++;
   setTimeOut(function() { next(); }, 30000);
</code></pre>

<p>The problem is that if I trigger the "next" function in another way (for instance with a div onclick), the setTimeOut callback function is still queued.  So I'll "next" an image, but when the callback fires, it "next"s an image again.  If you "next" many times in a row, there is an approx 30 second delayed burst that will follow you.  (Once all of the queued timeouts fire).</p>

<p>Is there a way to prematurely trigger a setTimeOut's callback?  Or to just dequeue it altogether?</p>
