// Function to return random integer number between 0 and N-1
function RandomInteger(N)
{
	return Math.floor(Math.random() * (N - 1) + 0.5) ;
}

// Function to write the current date
function WriteDate()
{
var now = new Date();
var monthNames = new Array(12);
monthNames[0] = "January";
monthNames[1] = "Febuary";
monthNames[2] = "March";
monthNames[3] = "April";
monthNames[4] = "May";
monthNames[5] = "June";
monthNames[6] = "July";
monthNames[7] = "August";
monthNames[8] = "September";
monthNames[9] = "October";
monthNames[10] = "November";
monthNames[11] = "December";
var month = now.getMonth();
document.write(monthNames[now.getMonth()] + " " + now.getDate() + ", " + now.getFullYear());
}

///////////////////////////////////////////////////////////////////////////////////
// Random Image Class
///////////////////////////////////////////////////////////////////////////////////

// The source of the Image with the name "ImageName" is changed to one of the image
// urls at random.
function RandomImage(ImgSrc, ImgName)
{
	// ImgSrc: Array of Image Urls to randomly display.
	// ImgName: Name of the Image that displays the random images.
	this.ImageUrls = ImgSrc ;
	this.ImageName = ImgName ;
	this.Length = ImgSrc.length ;
	this.Index = 1 ;
}

// This function displays the random image from the list of image urls.
function RandomImage_display()
{
	// Determine the image to display
	this.Index = RandomInteger(this.Length) ;

	// Display the random image
	document[this.ImageName].src = this.ImageUrls[this.Index] ;
}

// Instance method to display random images.
RandomImage.prototype.display = RandomImage_display ;

// This function displays the next image from the list looping when necessary
function RandomImage_next()
{
	// Display the next image in the list
	document[this.ImageName].src = this.ImageUrls[this.Index++] ;
	
	// Loop if necessary
	this.Index = this.Index % this.Length ;
}

// Instance method to display next image
RandomImage.prototype.next = RandomImage_next ;

///////////////////////////////////////////////////////////////////////////////////
// End of the Random Image class
///////////////////////////////////////////////////////////////////////////////////