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

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;
				}
				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;
		}
	}
}

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

function init() {
	setOnMouseClick();
	// images gallery
	// load images note: imgsGallery[].image isn't an array of images, just strings to hold location
	imgsGallery[0] = new Object();
	imgsGallery[0].image = "images/seasky_020710_9.jpg";
	imgsGallery[0].title = "02.07.10 #9";
	imgsGallery[0].caption = "40\" x 50\" Gelatin Silver Print on Ilford MG Matte paper";
	
	imgsGallery[1] = new Object();
	imgsGallery[1].image = "images/seasky_020217_1a.jpg";
	imgsGallery[1].title = "02.02.17 #1A";
	imgsGallery[1].caption = "40\" x 50\" Gelatin Silver Print on Ilford MG Matte paper";

	imgsGallery[2] = new Object();
	imgsGallery[2].image = "images/seasky_011226_1.jpg";
	imgsGallery[2].title = "01.12.26 #1";
	imgsGallery[2].caption = "40\" x 60\" Gelatin Silver Print on Ilford MG Matte paper";
	
    imgsGallery[3] = new Object();
	imgsGallery[3].image = "images/seasky_011120_4.jpg";
	imgsGallery[3].title = "01.11.20 #4";
	imgsGallery[3].caption = "40\" x 60\" Gelatin Silver Print on Ilford MG Matte paper";

	imgsGallery[4] = new Object();
	imgsGallery[4].image = "images/seasky_070702_8A.jpg";
	imgsGallery[4].title = "05.07.02 #8A";
	imgsGallery[4].caption = "20\" x 24\" Gelatin Silver Print on Ilford MG Matte paper";
	
	imgsGallery[5] = new Object();
	imgsGallery[5].image = "images/seasky_011214_11.jpg";
	imgsGallery[5].title = "01.12.14 #11";
	imgsGallery[5].caption = "40\" x 60\" Gelatin Silver Print on Ilford MG Matte paper";

	imgsGallery[6] = new Object();
	imgsGallery[6].image = "images/seasky_011122_1.jpg";
	imgsGallery[6].title = "01.11.22 #1";
	imgsGallery[6].caption = "40\" x 60\" Gelatin Silver Print on Ilford MG Matte paper";
	
	imgsGallery[7] = new Object();
	imgsGallery[7].image = "images/seasky_010717_8.jpg";
	imgsGallery[7].title = "01.07.17 #8";
	imgsGallery[7].caption = "40\" x 60\" Gelatin Silver Print on Ilford MG Matte paper";
	
	imgsGallery[8] = new Object();
	imgsGallery[8].image = "images/seasky_020710_8.jpg";
	imgsGallery[8].title = "02.07.10 #8";
	imgsGallery[8].caption = "40\" x 50\" Gelatin Silver Print on Ilford MG Matte paper";
	
    var start = 0;
	var page = document.location.toString().split("?")[1];
	if (page != null) {
		start = page;
}
	imgs = new MudFadeGallery('imgs', 'imgDisplay', imgsGallery, {startNum: start, preload: true, autoplay: 0});
	
	// set the initial captions
	var title = (imgs.imgsArray[imgs.imgCurrent].title) ? imgs.imgsArray[imgs.imgCurrent].title : "No Title";
	var caption = (imgs.imgsArray[imgs.imgCurrent].caption) ? imgs.imgsArray[imgs.imgCurrent].caption : "No caption";
	$("imgDisplay_title").innerHTML = title;
	$("imgDisplay_caption").innerHTML = caption;
	$(imgs.id+"_number").innerHTML = (parseInt(imgs.imgCurrent)+1) + " of " + imgs.imgTotal;
	$("imgDisplay").src = imgsGallery[start].image;
}

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

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