// This script selects a random element from an array, assigns variable values based on
// that element, and then prints the results in the browser window.

function randomNumber(n){
	var number = Math.floor(Math.random() * (n + 1));
	return number;
}

// STEP 1 of 2:  To add new photo, add an element to this array 'photoArray'
var photoArray = new Array();
	photoArray[0] = "00";
	photoArray[1] = "01";
	photoArray[2] = "02";
	photoArray[3] = "03";
	photoArray[4] = "04";
	photoArray[5] = "05";
	photoArray[6] = "06";
	photoArray[7] = "07";
	photoArray[8] = "08";

// Calls the randomNumber function, and automatically chooses the right value for 'n'
var t = randomNumber((photoArray.length - 1));

// This variable replaces a large chunk of repetitive HTML code
var FILE_PATH = "images/monarch_pride/headers/";

var COPYRIGHT1 = " (Photo &copy;2002 Tom Feist)";
var COPYRIGHT2 = " (Photo &copy;2002 University Photography)";
var COPYRIGHT3 = "";

// STEP 2 of 2:  To add new photo, add an if statement corresponding to the photoArray value above
if (photoArray[t] == "00"){
 var filename = "falllion.jpg";
 var caption = "The Monarch, the symbol of Old Dominion University, atop his pedestal in front of Webb Center." + COPYRIGHT1;
}
if (photoArray[t] == "01"){
 var filename = "fallbike.jpg";
 var caption = "Koch Walk, one of campuses\' delightful autumn treasures." + COPYRIGHT1;
}
if (photoArray[t] == "02"){
 var filename = "fallwalk.jpg";
 var caption = "A crossroads is buzzing with activity and ablaze with autumn color." + COPYRIGHT1;
}
if (photoArray[t] == "03"){
 var filename = "scarletlion.jpg";
 var caption = "Autumn is a beautiful time to experience ODU." + COPYRIGHT1;
}
if (photoArray[t] == "04"){
 var filename = "autumnnight.jpg";
 var caption = "One of campuses\' busiest thoroughfares on a quiet autumn evening." + COPYRIGHT1;
}
if (photoArray[t] == "05"){
 var filename = "leaves.jpg";
 var caption = "A Japanese maple in late afternoon light." + COPYRIGHT2;
}
if (photoArray[t] == "06"){
 var filename = "golden.jpg";
 var caption = "Crepe myrtles, a Norfolk signature tree, enliven campus twice a year with spectacular color." + COPYRIGHT2;
}
if (photoArray[t] == "07"){
 var filename = "classic.jpg";
 var caption = "A crisp autumn morning in the Classic Campus." + COPYRIGHT2;
}
if (photoArray[t] == "08"){
 var filename = "crepeautumn.jpg";
 var caption = "Crepe myrtles, a Norfolk signature tree, enliven campus twice a year with spectacular color." + COPYRIGHT2;
}

// -- Add new element if statements above this line ------------------------------
document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>');
document.write('<td width="505" height="110" bgcolor="#ffffff" valign="top"><img src="'+ FILE_PATH + filename +'" width="505" height="110" border="0" alt="' + caption + '" /></td>');
document.write('<td width="100%" height="110" bgcolor="#ffffff" background="'+ FILE_PATH + 'right.gif" valign="top">&nbsp;</td>');
document.write('<td width="18" height="110" valign="top"><img src="'+ FILE_PATH + 'farright.gif" width="18" height="110" border="0" /></td>');
document.write('</tr><tr>');
document.write('<td colspan="3" height="7" valign="top">&nbsp;&nbsp;&nbsp;&nbsp;<font size="-2" color="#999999">' + caption + '</font></td></tr></table>');
document.close();