I would be inclined to have a loading image, like:

And forget about preloading everything, that obviously takes too long. So something like:
Code:
var rand1 = 0;
var useRand = 0;
images = [];
images[1] = "images/random/1.jpg";
images[2] = "images/random/2.jpg";
images[3] = "images/random/3.jpg";
images[4] = "images/random/4.jpg";
images[5] = "images/random/5.jpg";
function swapPic() {
var imgnum = images.length - 1;
do {
var randnum = Math.random();
rand1 = Math.round((imgnum - 1) * randnum) + 1;
} while (rand1 == useRand);
useRand = rand1;
document.images.randimg.src = 'loading.gif';
var im = new Image();
im.onload = function(){
document.images.randimg.src = this.src;
}
im.src = images[useRand];
}
If document.images.randimg is in a table cell and is the only thing in that table cell and that cell has a fixed width and height, the loading image when it appears will be centered.
If you want more help:
Please post a link to a page on your site that contains the problematic code so we can check it out.
Bookmarks