/* rndmImg.js
* 
*  A simple script that will calculate a random number and then 
*  use that number to select an image to be loaded into the page.
*  The offset value ensures that the same image will not be loaded
*  on a page if the function is called more than once.
*
*  Christopher Wingard, December 2001.
*/

// Select a random number between 0 and 1 and multiply by 49.
// Note, I use 49 here because that's how many images I have to
// select from (actually 50-1).  This number would change depending
// on how many images one wanted to select from.
var rndmNum = Math.round(Math.random() * 49);

// Select and load the random image.
function rndmImg(imName,offset,dir) {
	if (!document.images) {return};
	var whichIm, imNum;
	
	whichIm = document.images[imName];
	imNum = rndmNum - offset;
	
	if (imNum < 10) {
		whichIm.src = "images/random/" + dir + "/biooptics0" + [imNum] + ".jpg";
	} else {
		whichIm.src = "images/random/" + dir + "/biooptics" + [imNum] + ".jpg"; 
	};
}; 