Custom image shuffler not working?
<p>Basically, what I'm trying to do is shuffle through images using some JavaScript code. All it does is change the display style of the current image to <code>block</code>, and at the same time change the previous one to <code>none</code>.</p>

<p>The HTML code:</p>

<pre><code>&lt;body&gt;
&lt;img src="http://bit.ly/yOqqbg" id="image1" style="display: block;"&gt;
&lt;img src="http://bit.ly/dezBUZ" id="image2" style="display: none;"&gt;
&lt;img src="http://bit.ly/IvM5HE" id="image3" style="display: none;"&gt;
&lt;/body&gt;​
</code></pre>

<p>The JavaScript code:</p>

<pre><code>var id = ["image1", "image2", "image3"]; //Array with the id's in the document you want        
to shuffle through
var i = 0; //Set inital array element
initiateTimer(); //Get the loop going

function initiateTimer() {       
if (i &gt; id.length) {
    i = 0;
    initiateTimer();
}
setTimeout(function() { changeElement(); }, 2000); //2000 = 2 seconds
}

function changeElement() {  
if (id === 0) {
    document.getElementById(id[2]).style.display = 'none';
    document.getElementById(id[i]).style.display = 'block';
} else {
    document.getElementById(id[i - 1]).style.display = 'none';
    document.getElementById(id[i]).style.display = 'block';
}
i += 1;
initiateTimer();
} ​
</code></pre>
