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

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/abandoned_060517_9t.jpg";
	imgsGallery[0].title = "06.05.17 #9";
	imgsGallery[0].caption = "8\" x 10\" tintype. Ferragudo, Portugal";
	
	imgsGallery[1] = new Object();
	imgsGallery[1].image = "images/abandoned_060518_4t.jpg";
	imgsGallery[1].title = "06.05.18 #4";
	imgsGallery[1].caption = "6.5\" x 8.5\" tintype. Sesmarias, Portugal";

    imgsGallery[2] = new Object();
	imgsGallery[2].image = "images/abandoned_051007_1a.jpg";
	imgsGallery[2].title = "05.10.07 #1A";
	imgsGallery[2].caption = "6.5\" x 8.5\" ambrotype. Deer Isle";
	
	imgsGallery[3] = new Object();
	imgsGallery[3].image = "images/abandoned_051004_5t.jpg";
	imgsGallery[3].title = "05.10.04 #5";
	imgsGallery[3].caption = "8\" x 10\" tintype. Fog Bell Tower, Arrowsic";
	
	imgsGallery[4] = new Object();
	imgsGallery[4].image = "images/abandoned_051031_5.jpg";
	imgsGallery[4].title = "05.10.31 #5";
	imgsGallery[4].caption = "6.5\" x 8.5\" tintype. Broken Bridge, Shelter Island";

    imgsGallery[5] = new Object();
	imgsGallery[5].image = "images/abandoned_050222_9.jpg";
	imgsGallery[5].title = "05.02.22 #9";
	imgsGallery[5].caption = "8\" x 10\" ambrotype. Hunter's Shack, Darien";

    imgsGallery[6] = new Object();
	imgsGallery[6].image = "images/abandoned_050221_9.jpg";
	imgsGallery[6].title = "05.02.21 #9";
	imgsGallery[6].caption = "6/5\" x 8.5\" ambrotype. Bent Tree,  Jekyll Island";
	
	imgsGallery[7] = new Object();
	imgsGallery[7].image = "images/abandoned_050221_2.jpg";
	imgsGallery[7].title = "05.02.21 #2";
	imgsGallery[7].caption = "8\" x 10\" ambrotype. Medusa Tree,  Jekyll Island";
	
	imgsGallery[8] = new Object();
	imgsGallery[8].image = "images/abandoned_050219_2.jpg";
	imgsGallery[8].title = "05.02.19 #2";
	imgsGallery[8].caption = "8\" x 10\" ambrotype. Round Chimney, Darien";
	
    imgsGallery[9] = new Object();
	imgsGallery[9].image = "images/abandoned_050220_6.jpg";
	imgsGallery[9].title = "05.02.20 #6";
	imgsGallery[9].caption = "6/5\" x 8.5\" ambrotype. Tabby ruins, Rum Factory. Tolomato";
	
	imgsGallery[10] = new Object();
	imgsGallery[10].image = "images/abandoned_060208_5.jpg";
	imgsGallery[10].title = "06.02.08 #5";
	imgsGallery[10].caption = "30\" x 40\" gelatin silver print. Bunny Ruins, Sapelo Island";
	
	imgsGallery[11] = new Object();
	imgsGallery[11].image = "images/abandoned_060209_5.jpg";
	imgsGallery[11].title = "06.02.09 #5";
	imgsGallery[11].caption = "30\" x 40\" gelatin silver print. Broken Home, Sapelo Island";
	
	imgsGallery[12] = new Object();
	imgsGallery[12].image = "images/abandoned_051005_1.jpg";
	imgsGallery[12].title = "05.10.05 #1";
	imgsGallery[12].caption = "30\" x 40\" gelatin silver print. Fort Popham, Maine";

	
    imgsGallery[13] = new Object();
	imgsGallery[13].image = "images/abandoned_041010_8a_hicks_island_chimney.jpg";
	imgsGallery[13].title = "04.10.10 #8a";
	imgsGallery[13].caption = "6.5\" x 8.5\" ambrotype. Hicks Island Chimney";
	
	imgsGallery[14] = new Object();
	imgsGallery[14].image = "images/abandoned_040825_7a_double_rock.jpg";
	imgsGallery[14].title = "04.08.25 #7a";
	imgsGallery[14].caption = "6.5\" x 8.5\" ambrotype. Double Rock, Rocky Point";
	
    imgsGallery[15] = new Object();
	imgsGallery[15].image = "images/abandoned_040720_8.jpg"
	imgsGallery[15].title = "04.07.20 #8A";
	imgsGallery[15].caption = "6.5\" x 8.5\" tintype. Lands End with Ladies";

    imgsGallery[16] = new Object();
	imgsGallery[16].image = "images/abandoned_040719_4_fish_farm_pier.jpg"
	imgsGallery[16].title = "04.07.19 #4T";
	imgsGallery[16].caption = "6.5\" x 8.5\" tintype. Fish Farm Pier";

    imgsGallery[17] = new Object();
	imgsGallery[17].image = "images/abandoned_040817_8.jpg"
	imgsGallery[17].title = "04.08.17 #8";
	imgsGallery[17].caption = "8\" x 10\" ambrotype. Broken Home, Napeague";

    imgsGallery[18] = new Object();
	imgsGallery[18].image = "images/abandoned_040511_3_princes_harbor.jpg";
	imgsGallery[18].title = "04.05.11 #3";
	imgsGallery[18].caption = "4\" x 5\" ambrotype. Prince's Harbor, Staten Island";
	
    imgsGallery[19] = new Object();
	imgsGallery[19].image = "images/abandoned_040418_8_pylons_staten_island.jpg";
	imgsGallery[19].title = "04.04.18 #8";
	imgsGallery[19].caption = "4\" x 5\" ambrotype. New Dorp Pylons, Staten Island";
	
	imgsGallery[20] = new Object();
	imgsGallery[20].image = "images/abandoned_040520_7_beach_barrier_staten_island.jpg";
	imgsGallery[20].title = "04.05.20 #7";
	imgsGallery[20].caption = "5\" x 7\" tintype. Beach Barrier, Staten Island";
		
    imgsGallery[21] = new Object();
	imgsGallery[21].image = "images/abandoned_040613_5_right_angle.jpg";
	imgsGallery[21].title = "04.06.13 #5";
	imgsGallery[21].caption = "5\" x 7\" ambrotype. Right Angle, Staten Island";
		
    imgsGallery[22] = new Object();
	imgsGallery[22].image = "images/abandoned_040921_7t_straight line_.jpg";
	imgsGallery[22].title = "04.09.21 #7";
	imgsGallery[22].caption = "5\" x 7\" tintype. Straight Line, Staten Island";
		
    imgsGallery[23] = new Object();
	imgsGallery[23].image = "images/abandoned_041122_4_sugar_factory_red_hook.jpg";
	imgsGallery[23].title = "04.11.22 #4";
	imgsGallery[23].caption = "5\" x 7\" tintype. Sugar factory, Red Hook";
		
    imgsGallery[24] = new Object();
	imgsGallery[24].image = "images/abandoned_041205_2t.jpg";
	imgsGallery[24].title = "04.12.05 #2";
	imgsGallery[24].caption = "5\" x 7\" tintype. Red Hook";
	
    imgsGallery[25] = new Object();
	imgsGallery[25].image = "images/abandoned_040416_11_sunken_ship_red_hook.jpg";
	imgsGallery[25].title = "04.04.16 #11";
	imgsGallery[25].caption = "4\" x 5\" ambrotype. Sunken Ship, Red Hook";
		

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