Source code for this file: slideshow.php
I have chosen a random start location the "first time", that is, when there is no query string.
On the other hand, if you wish to shuffle the names using JavaScript (see "slideshow.html), you will need to use Math.random(), a Google search will turn up several "shuffle" functions that people have written for JavaScript.
There is no way for JavaScript to read your directory on the server. If you want to do that, and even shuffle them besides, use some php to "print" the actual new Array values and proceed as in slideshow.html.