I am trying create a function which correlates to a button in my slideshow, and when called upon displays the photos in any given folder in a random order rather then a sequential one. I used arrays to define my list of photos. The following is my code, I just need the random function

var photosArrayGlobal;
var photoIndexGlobal;
var displayGlobal;
main();

function main() {
document.getElementById("slideShowButton").onclick= slideShow;
document.getElementById("randomSlideShowButton").onclick= randomShow;
document.getElementById("previousSlideButton").onclick= previousPhoto;
document.getElementById("nextSlideButton").onclick= nextPhoto;
displayGlobal= document.getElementById("initialImage");
photoIndexGlobal= 0;
}

function getArrayPhotosNames() {
var photoFolder;
var commonName;
var startNumber;
var endNumber;
var tempArray;
var i;

photoFolder= document.getElementById("photoFolder").value;
commonName= document.getElementById("commonName").value;
startNumber= Number(document.getElementById("startNumber").value);
endNumber= Number(document.getElementById("endNumber").value);
tempArray= new Array((endNumber - startNumber) + 1);


for (i=0; i < tempArray.length; i++) {
tempArray [i] = photoFolder + commonName + (i + startNumber) + ".jpg";

}

return tempArray;
}