Show random images

by BinaryAcid

JavaScript

// Set up the image files to be used.
var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

theImages[0] = 'http://animal.discovery.com/healthy-pets/cat-health-101/images/thumbnails/stop-cat-fights-100.jpg'
theImages[1] = 'http://allergy.immunodefence.com/i/hypoallergenic_cat.jpg'
theImages[2] = 'http://www.catname.org/images/cat02.jpg'
theImages[3] = 'http://images.gizmag.com/gallery_tn/cats-and-dogs-7.jpg'
theImages[4] = 'http://img.brothersoft.com/games/flash/icon/m/matching-cats-13586-1264178522.jpg'
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}