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

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 "s1":
				elements[i].onclick = function() {
					 imgs.showImg(0);
					 return false;
				}
				break;
			case "s2":
				elements[i].onclick = function() {
					 imgs.showImg(1);
					 return false;
				}
				break;
			case "s3":
				elements[i].onclick = function() {
					 imgs.showImg(2);
					 return false;
				}
				break;
			case "s4":
				elements[i].onclick = function() {
					 imgs.showImg(3);
					 return false;
				}
				break;
			case "s5":
				elements[i].onclick = function() {
					 imgs.showImg(4);
					 return false;
				}
				break;
			case "s6":
				elements[i].onclick = function() {
					 imgs.showImg(5);
					 return false;
				}
				break;
			case "s7":
				elements[i].onclick = function() {
					 imgs.showImg(6);
					 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/collections/dining_sets/kokoon/kokoon_oval.jpg";
	imgsGallery[0].title = "Kokoon Oval Dining Set";
	imgsGallery[0].caption = "Java Brown - Polypeel";
	
	imgsGallery[1] = new Object();
	imgsGallery[1].image = "../../images/collections/dining_sets/kokoon/kokoon.jpg";
	imgsGallery[1].title = "Kokoon with Palm Dining Chair";
	imgsGallery[1].caption = "Java Brown - Polypeel";
	
	imgsGallery[2] = new Object();
	imgsGallery[2].image = "../../images/collections/dining_sets/kokoon/armchair.jpg";
	imgsGallery[2].title = "Summer Armchair";
	imgsGallery[2].caption = "58 x 59 x 86";
	
	imgsGallery[3] = new Object();
	imgsGallery[3].image = "../../images/collections/dining_sets/kokoon/palm_chair.jpg";
	imgsGallery[3].title = "Palm Dining Chair";
	imgsGallery[3].caption = "48 x 60 x 93";
	
	imgsGallery[4] = new Object();
	imgsGallery[4].image = "../../images/collections/dining_sets/kokoon/ria_chair.jpg";
	imgsGallery[4].title = "Ria Dining Chair";
	imgsGallery[4].caption = "48 x 60 x 93";
	
	imgsGallery[5] = new Object();
	imgsGallery[5].image = "../../images/collections/dining_sets/kokoon/table.jpg";
	imgsGallery[5].title = "Kokoon Dining Table";
	imgsGallery[5].caption = "90 Dia. x 74";
	
	imgsGallery[6] = new Object();
	imgsGallery[6].image = "../../images/collections/dining_sets/kokoon/oval_table.jpg";
	imgsGallery[6].title = "Kokoon Oval Dining Table";
	imgsGallery[6].caption = "200 x 100 x 74";
	
	var start = 0;
	imgs = new MudFadeGallery('imgs', 'imgDisplay', imgsGallery, {startNum: start, preload: true, autoplay: 5});
	
	// 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 of " + imgsGallery.length + " products";
	$("imgDisplay").src = imgsGallery[start].image;
}

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

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