/*******************************************************************************

FILE: mud_Scripts.js
REQUIRES: prototype.js, mud_FadeGallery.js
AUTHOR: Takashi Okamoto mud(tm) - http://www.mudcorp.com/
VERSION: 2.0 - converted to use prototype.js
DATE: 01/05/2006

--------------------------------------------------------------------------------

This file is part of MudFadeGallery.

	MudFadeGallery is free for anyone to use, but this header MUST be
	included, and may not be modified.

*******************************************************************************/

////////////////////////////////////////////////////////////////////////////////
// GLOBAL VARS

var imgsGallery = new Array();
var imgs;

///////////////////////////////////////////////////////////////////////////////
// MOUSE EVENTS

function setOnMouseClick() {
	var elements = document.getElementsByTagName("a");
	for (var i = 0; i < elements.length; i++) {
		switch(elements[i].className) {
			case "next":
				elements[i].onclick = function() {
					 imgs.nextImg();
					 return false;
				}
				break;
			case "prev":
				elements[i].onclick = function() {
					 imgs.prevImg();
					 return false;
				}

// Drew, you will have to copy and paste these paragraphs
// and have one for each image.
// You should copy from 'case...' to '...break;'
// After that you should update the 2 instances of numbers
// in the code you have just copied.
// The first number in this block of text shoud be 0 (zero).

				break;
			case "s0":
				elements[i].onclick = function() {
					 imgs.showImg(0);
					 return false;
				}
				break;
			case "s1":
				elements[i].onclick = function() {
					 imgs.showImg(1);
					 return false;
				}
				break;
			case "s2":
				elements[i].onclick = function() {
					 imgs.showImg(2);
					 return false;
				}
				break;
			case "s3":
				elements[i].onclick = function() {
					 imgs.showImg(3);
					 return false;
				}
				break;
			case "s4":
				elements[i].onclick = function() {
					 imgs.showImg(4);
					 return false;
				}
				break;
			case "s5":
				elements[i].onclick = function() {
					 imgs.showImg(5);
					 return false;
				}
				break;
		}
	}
}

////////////////////////////////////////////////////////////////////////////////
// INIT

function init() {
	setOnMouseClick();
	// Drew, this is the other area where code needs to be
	// changed in a similar way to the code above.
	// Copy each chunk of text make sure that there is one
	// paragraph for each image.
	// The number in the square brackets needs to change
	// to correlate to the images. The code should always 
	// start at 0 (zero). The other code to change is the
	// image name in the file path.
	
	imgsGallery[0] = new Object();
	imgsGallery[0].image = "images/image.jpg";
	imgsGallery[0].title = "Title for first Image";
	imgsGallery[0].caption = "This is the first image...";
	
	imgsGallery[1] = new Object();
	imgsGallery[1].image = "images/image2.jpg";
	imgsGallery[1].title = "Title for second Image";
	imgsGallery[1].caption = "This is the second image...";
	
	imgsGallery[2] = new Object();
	imgsGallery[2].image = "images/image3.jpg";
	imgsGallery[2].title = "Title for third Image";
	imgsGallery[2].caption = "This is the third image...";
	
	imgsGallery[3] = new Object();
	imgsGallery[3].image = "images/image4.jpg";
	imgsGallery[3].title = "Title for fourth image";
	imgsGallery[3].caption = "This is the fourth image...";
	
	imgsGallery[4] = new Object();
	imgsGallery[4].image = "images/image5.jpg";
	imgsGallery[4].title = "Title for fifth image";
	imgsGallery[4].caption = "This is the fifth image...";
	
	imgsGallery[5] = new Object();
	imgsGallery[5].image = "images/image6.jpg";
	imgsGallery[5].title = "Title for fifth image";
	imgsGallery[5].caption = "This is the fifth image...";
	
	var start = 0;
	imgs = new MudFadeGallery('imgs', 'imgDisplay', imgsGallery, {startNum: start, preload: true, autoplay: 0});
	
	// set the initial captions
	var title = (imgsGallery[0].title) ? imgsGallery[0].title : "No Title";
	var caption = (imgsGallery[0].caption) ? imgsGallery[0].caption : "No caption";
	$("imgDisplay_title").innerHTML = title;
	$("imgDisplay_caption").innerHTML = caption;
	$("imgDisplay_number").innerHTML = "(1|" + imgsGallery.length + ")";
	$("imgDisplay").src = imgsGallery[start].image;
}


////////////////////////////////////////////////////////////////////////////////
// EVENTS

Event.observe(window, 'load', init, false);
