/**********************PROGRAM HEADER*******************************************
* FILENAME:
*     imageRotate.js
* DATE:
*     01 September 2007
* AUTHOR:
*	Kevin Browne - kevin@workpump.com
*
*----------------------PROGRAM DESCRIPTION--------------------------------------
*
*	On loading of page, script will find "<div id="photoRotate">" and insert
*	"<p><img></p>" with a randomly chosen "src" attribute from populated array.
*
*----------------------REQUIRED FUNCTIONS---------------------------------------
*	
*	- addLoadEvent()
*	
********************************************************************************/


/***********************GLOBAL VARIABLES****************************************/
// Implied global: addLoadEvent, document


// Declare and populate array of image sources
var imgSource = [];
imgSource[0] = "includes/graphics/imageRotate/rand000.jpg";
imgSource[1] = "includes/graphics/imageRotate/rand001.jpg";
imgSource[2] = "includes/graphics/imageRotate/rand002.jpg";
imgSource[3] = "includes/graphics/imageRotate/rand003.jpg";
imgSource[4] = "includes/graphics/imageRotate/rand004.jpg";
imgSource[5] = "includes/graphics/imageRotate/rand005.jpg";
imgSource[6] = "includes/graphics/imageRotate/rand006.jpg";
imgSource[7] = "includes/graphics/imageRotate/rand007.jpg";
imgSource[8] = "includes/graphics/imageRotate/rand008.jpg";
imgSource[9] = "includes/graphics/imageRotate/rand009.jpg";
imgSource[10] = "includes/graphics/imageRotate/rand010.jpg";
imgSource[11] = "includes/graphics/imageRotate/rand011.jpg";
imgSource[12] = "includes/graphics/imageRotate/rand012.jpg";
imgSource[13] = "includes/graphics/imageRotate/rand013.jpg";
imgSource[14] = "includes/graphics/imageRotate/rand014.jpg";
imgSource[15] = "includes/graphics/imageRotate/rand015.jpg";
imgSource[16] = "includes/graphics/imageRotate/rand016.jpg";
imgSource[17] = "includes/graphics/imageRotate/rand017.jpg";
imgSource[18] = "includes/graphics/imageRotate/rand018.jpg";
imgSource[19] = "includes/graphics/imageRotate/rand019.jpg";
imgSource[20] = "includes/graphics/imageRotate/rand020.jpg";
imgSource[21] = "includes/graphics/imageRotate/rand021.jpg";
imgSource[22] = "includes/graphics/imageRotate/rand022.jpg";
imgSource[23] = "includes/graphics/imageRotate/rand023.jpg";
imgSource[24] = "includes/graphics/imageRotate/rand024.jpg";
imgSource[25] = "includes/graphics/imageRotate/rand025.jpg";

// Find number of images available and create and assign a random number
var imageCount = imgSource.length;
var whichImage = Math.floor(Math.random() * imageCount);

// Insert the image HTML 
function showImage() {
	var elemPara = document.createElement("p");
	var photodiv = document.getElementById("photoRotate");
	var elemImage = document.createElement("img");
	elemPara.appendChild(elemImage);
	photodiv.appendChild(elemPara);
	elemImage.setAttribute("src",imgSource[whichImage]);
}

addLoadEvent(showImage);


