onload = function() {

images = new Array(    
"images/styleassets/indexbox01.jpg",
"images/styleassets/indexbox02.jpg",
"images/styleassets/indexbox03.jpg",
"images/styleassets/indexbox04.jpg"
);// set up an array of the images

rand = Math.floor(Math.random()*images.length); // chose a random number, between 0 and the length of the array -1
currentImage = images[rand]; // set img to the random image's src

document.getElementById("switchimg").src = currentImage; // for img tag
}