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

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 = "http://www.tokyophoto.org/img-slide/Butterfly.jpg";
	imgsGallery[0].kei = "<hr class=\"hr3\" width=\"79px\" align=\"left\" Size=\"0.1\">";
	imgsGallery[0].caption = "Ryan McGinley \"Butterfly\" / 2010  Image courtesy of Ratio 3, San Francisco";

	imgsGallery[1] = new Object();
	imgsGallery[1].image = "http://www.tokyophoto.org/img-slide/marymcCartney.jpg";
	imgsGallery[1].kei = "<hr class=\"hr3\" width=\"79px\" align=\"left\" Size=\"0.1\">";
	imgsGallery[1].caption = "©Mary McCartney - Kate in boots";

	imgsGallery[2] = new Object();
	imgsGallery[2].image = "http://www.tokyophoto.org/img-slide/kishin.jpg";
	imgsGallery[2].kei = "<hr class=\"hr3\" width=\"79px\" align=\"left\" Size=\"0.1\">";
	imgsGallery[2].caption = "© Kishin Shinoyama &nbsp; Atokata-1 　　";
	
	imgsGallery[3] = new Object();
	imgsGallery[3].image = "http://www.tokyophoto.org/img-slide/Giesmann_&_Shultz.jpg";
	imgsGallery[3].kei = "<hr class=\"hr3\" width=\"79px\" align=\"left\" Size=\"0.1\">";
	imgsGallery[3].caption = "© André Giesemann and Daniel Schulz / courtesy of TEN HAAF Projects";
	
	imgsGallery[4] = new Object();
	imgsGallery[4].image = "http://www.tokyophoto.org/img-slide/sato.jpg";
	imgsGallery[4].kei = "<hr class=\"hr3\" width=\"79px\" align=\"left\" Size=\"0.1\">";
	imgsGallery[4].caption = "Tokihiro Sato / Hakkoda #2 / Courtesy of Zeit-Foto Salon";
	
	imgsGallery[5] = new Object();
	imgsGallery[5].image = "http://www.tokyophoto.org/img-slide/sleepwalker.jpg";
	imgsGallery[5].kei = "<hr class=\"hr3\" width=\"79px\" align=\"left\" Size=\"0.1\">";
	imgsGallery[5].caption = "Chris Shaw / Sleepwalker / from the series \"Life As a Night Porter\" / 1995-2005　";
	
	imgsGallery[6] = new Object();
	imgsGallery[6].image = "http://www.tokyophoto.org/img-slide/venue01.jpg";
	imgsGallery[6].kei = "<hr class=\"hr3\" width=\"79px\" align=\"left\" Size=\"0.1\">";
	imgsGallery[6].caption = "TOKYO PHOTO 2010 [1/4]";
	
	imgsGallery[7] = new Object();
	imgsGallery[7].image = "http://www.tokyophoto.org/img-slide/venue02.jpg";
	imgsGallery[7].kei = "<hr class=\"hr3\" width=\"79px\" align=\"left\" Size=\"0.1\">";
	imgsGallery[7].caption = "TOKYO PHOTO 2010 [2/4]";
	
	imgsGallery[8] = new Object();
	imgsGallery[8].image = "http://www.tokyophoto.org/img-slide/venue03.jpg";
	imgsGallery[8].kei = "<hr class=\"hr3\" width=\"79px\" align=\"left\" Size=\"0.1\">";
	imgsGallery[8].caption = "TOKYO PHOTO 2010 [3/4]";
	
	imgsGallery[9] = new Object();
	imgsGallery[9].image = "http://www.tokyophoto.org/img-slide/venue04.jpg";
	imgsGallery[9].kei = "<hr class=\"hr3\" width=\"79px\" align=\"left\" Size=\"0.1\">";
	imgsGallery[9].caption = "TOKYO PHOTO 2010 [4/4]";
	
	
	var start = 0;
	imgs = new MudFadeGallery('imgs', 'imgDisplay', imgsGallery, {startNum: start, preload: true, autoplay: 2});


	$("imgDisplay").src = imgsGallery[start].image;	
	// set the initial captions
//	var title = (imgsGallery[0].title) ? imgsGallery[0].title : "No Title";
	var caption = (imgsGallery[0].caption) ? imgsGallery[0].caption : "No caption";
	var kei = (imgsGallery[0].kei) ? imgsGallery[0].kei : "No kei";

//	$("imgDisplay_title").innerHTML = title;
	$("imgDisplay_caption").innerHTML = caption;
	$("imgDisplay_kei").innerHTML = kei;
	
	//$("imgDisplay_number").innerHTML = "1/ " + imgsGallery.length;
}

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

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