loading image while javascript function(s) run
<p>is there a way to show a loading image while a javascript function is running. I have one that takes about 2-5 seconds, would be nice if i could have something like the jquery-ajax function</p>

<pre><code>$("#loading").bind("ajaxStart", function(){
    $(this).attr("style", "visibility: visible")
}).bind("ajaxStop", function(){
    $(this).attr("style", "visibility: hidden")
});
</code></pre>

<p>clarification edit:</p>

<p>The idea is that every time a javascript function runs and takes over, say 3/4 of a second, the loading image would be displayed. It really has nothing to do with this ajax function, just the same principle of always catching a running javascript and timing it.</p>

<p>Thanks!</p>
