//Initialize and populate array used to hold the random images (without logo bottom)
var aryRBimages = new Array()
aryRBimages[0] = 'images/RandomBanner/rb01.jpg'
aryRBimages[1] = 'images/RandomBanner/rb02.jpg'
aryRBimages[2] = 'images/RandomBanner/rb03.jpg'
aryRBimages[3] = 'images/RandomBanner/rb04.jpg'
aryRBimages[4] = 'images/RandomBanner/rb05.jpg'
aryRBimages[5] = 'images/RandomBanner/rb06.jpg'
aryRBimages[6] = 'images/RandomBanner/rb07.jpg'
aryRBimages[7] = 'images/RandomBanner/rb08.jpg'

//Initialize and populate array used to hold the random images (with logo bottom)
var aryRBLimages = new Array()
aryRBLimages[0] = 'images/RandomBanner/rbl01.jpg'
aryRBLimages[1] = 'images/RandomBanner/rbl02.jpg'

//Retrieve size of each array
var intRBlength = aryRBimages.length;
var intRBLlength = aryRBLimages.length;

//Preload images
var aryPreLoadRB = new Array()
for (i = 0; i < intRBlength; i++) {
   aryPreLoadRB[i] = new Image()
   aryPreLoadRB[i].src = aryRBimages[i]
}

var aryPreLoadRBL = new Array()
for (i = 0; i < intRBLlength; i++) {
   aryPreLoadRBL[i] = new Image()
   aryPreLoadRBL[i].src = aryRBLimages[i]
}

function randomInteger(intMax)	{
	//Calculate random double number between 0 and intMax
	var dblRandom = Math.random() * intMax;

	//Convert random number to an integer and return it
	return Math.floor(dblRandom);
}

//Function is used to display the image
function showBannerImages() {
	document.write('<table width="790" cellpadding="0" cellspacing="0" border="0">');
	document.write('<tr>');

	//Initiate and populate the array to hold images already displayed
	var aryExclude = new Array()
	aryExclude[0] = -1
	aryExclude[1] = -1
	aryExclude[2] = -1
	aryExclude[3] = -1

	//Loop through each of the banner image slots
	for (i = 0; i < 4; i++) {
		//For each slot, retrieve a random integer to use in displaying the image
		var intRBimage = randomInteger(intRBlength);

		//For each slot, loop through the exclude array to see if image is already displayed in another slot
		var j = 0;
		while (j < aryExclude.length) {
			if (intRBimage == aryExclude[j]) {
				//Image is already used, so retrieve a new random integer and start over
				var intRBimage = randomInteger(intRBlength);
				j = 0;
			}
			else {
				//Image is not used yet, so move to next excluded image
				j++;
			}
		}

		//Image is not being used in any slot, so update the exclude array and display the image in this slot
		aryExclude[i] = intRBimage
		document.write('<td><img src="' + aryRBimages[intRBimage] + '" width="158" height="99" border="0"></td>');
	}

	//Display the last image, which has the logo on it
	var intRBLimage = randomInteger(intRBLlength);
	document.write('<td><img src="' + aryRBLimages[intRBLimage] + '" width="158" height="99" border="0"></td>');

	document.write('</tr>');
	document.write('</table>');
}