Random rollover - on image

A mouseover on the image triggers it to randomly change to one of 5 random images.

0







Example of what the code around the image looks like

(P.S. Don't copy this code on the page. Instead, copy it from the source in the body when you have the page open in your HTML editor.)
<body onload="preloadImages();">


<a href="#" onmouseover="randomchangeImageif('numberimg'); return true;"><img id="numberimg" src="images/0.gif" width="100" height="100" alt="0"></a>

Example of what the code in the head looks like

(P.S. Don't copy this code on the page. Instead, copy it from the source in the head when you have the page open in your HTML editor.)

function randInt(low,high) {
	return Math.floor(Math.random()*(high-low+1)+low);
 }

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}


function randomchangeImageif(image) { 
  var Image2Change = document.getElementById(image);
  var n = randInt(1,5);
  var i ="";
  if (n == 1) i = "images/1.gif";
  else if (n == 2) i = "images/2.gif";
  else if (n == 3) i= "images/3.gif";
  else if (n == 4) i= "images/4.gif";
  else if (n == 5) i= "images/5.gif";
  Image2Change.src = i;
}


var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		img1 = newImage("images/1.gif");
		img2 = newImage("images/2.gif");
		img3 = newImage("images/3.gif");
		img4 = newImage("images/4.gif");
		img5 = newImage("images/5.gif");
		preloadFlag = true;
	}
}
The images are preloaded because they might randomly be picked.
Here are the images used: