Cycle through JS array onclick and write value to DOM
<p>So I've got this JavaScript array full of fifty YouTube video id's and a while loop that writes the first two videos to the DOM. This code is being printed using PHP in case you're wondering about the backslashes.</p>

<pre><code>&lt;script type="text/javascript"&gt;
var videoArr=["id1", "id2", etc.];
var i = 0;
while (i&lt;2) {
document.write(\'&lt;iframe width="400" height="225" src="http://www.youtube.com/embed/  \'+videoArr[i]+\'?rel=0&amp;amp;autohide=1&amp;amp;showinfo=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;\');
i++;
}
&lt;/script&gt;
</code></pre>

<p>So basically I need a 'Previous' and 'Next' button that will cycle through this array and write the next or previous two videos to the DOM. What's the best way to do this?</p>
