Javascript changing source of an image
<p>I have some javascript which runs a timer that animates something on the website.</p>

<p>It all works perfectly but I want to get an image to change when the animation is run, It uses jquery: </p>

<pre><code>if(options.auto &amp;&amp; dir=="next" &amp;&amp; !clicked)
{
    timeout = setTimeout(function(){
if (document.images['bullet1'].src == "img/bulletwhite.png")
{
        document.images['bullet1'].src = "img/bullet.png";
        document.images['bullet2'].src = "img/bulletwhite.png";
}
animate("next",false);
                    },diff*options.speed+options.pause);
                }
</code></pre>

<p>options.auto means that its automatically cycling, dir is the direction of the motion and clicked is whether or not the user clicked it.</p>

<p>Is there something wrong with my syntax here? I ran firebug with it, and it doesn't throw any errors, it simply won't work. Any advice would help!</p>

<p>I should mention that the src of bullet1 starts at bulletwhite.png and then I was hoping for it to change to bullet.png and have bullet2 change to bulletwhite.png.</p>
