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