﻿
// -------------------------------------------
// This script is a image slideshow writen for
// Net Album Generator http://netalbum.tk
//
// Script writen by Christer Backman (c) 2005
// mail: asphalt_world (a) hotmail dot com
// 
// You are free to improve or modyfie this script
// as you see fit.
// -------------------------------------------

// Setup on load event
window.onload = startSlideshow

// Where to start slideshow (image index)
var nCurrentIndex = 0;
// Delay between slides
var nDelay = 3000;
// Timeout code used to stop slideshow
var nTimeoutCode = -1;
// Indicates if the slideshow is running
var bIsRunning = false;

// The image object
var imageObj;
// The image name object
var imageNameObj;
// The image description object
var imageDescObj;

// Array to hold arrays with image, name and description
var arrImages;

// -------------------------------------------
// This function starts the slideshow by loading
// the image information geting hold of the 
// objects and then loading the next image.
// -------------------------------------------
function startSlideshow() {
	if (! bIsRunning) {
		bIsRunning = true;
		arrImages= new Array();
	
		// Load images
		//arrImages[0] = ['1.jpg', 'Bild ett', 'Detta r bild nummer ett'];
		//arrImages[1] = ['2.jpg', 'Bild tv', 'tv tv tv tv tv tv tv tv tv tv tv tv tv tv tv'];
		arrImages[0] = ['./images/01 Pufferfish.jpg', '01 Pufferfish.jpg', ''];
arrImages[1] = ['./images/02 Pufferfish.jpg', '02 Pufferfish.jpg', ''];
arrImages[2] = ['./images/03 Conch.jpg', '03 Conch.jpg', ''];
arrImages[3] = ['./images/04 Different species of pufferfish.jpg', '04 Different species of pufferfish.jpg', ''];
arrImages[4] = ['./images/05 Black thannng actually a nudibranch.jpg', '05 Black thannng actually a nudibranch.jpg', ''];
arrImages[5] = ['./images/06 Anemone.jpg', '06 Anemone.jpg', ''];
arrImages[6] = ['./images/07 Different species of anemone.jpg', '07 Different species of anemone.jpg', ''];
arrImages[7] = ['./images/08 Seabed general view.jpg', '08 Seabed general view.jpg', ''];
arrImages[8] = ['./images/09 Anemonefish in their host.jpg', '09 Anemonefish in their host.jpg', ''];
arrImages[9] = ['./images/10 Nudibranch.jpg', '10 Nudibranch.jpg', ''];
arrImages[10] = ['./images/11 Nudibranch with smallpox.jpg', '11 Nudibranch with smallpox.jpg', ''];
arrImages[11] = ['./images/12 Wotchoo lookin at.jpg', '12 Wotchoo lookin at.jpg', ''];
arrImages[12] = ['./images/13 Peacock worm.jpg', '13 Peacock worm.jpg', ''];
arrImages[13] = ['./images/14 Moray eel.jpg', '14 Moray eel.jpg', ''];
arrImages[14] = ['./images/15 Moray ell closeup.jpg', '15 Moray ell closeup.jpg', ''];
arrImages[15] = ['./images/16 Juvenile fish masquerading as a nudibranch.jpg', '16 Juvenile fish masquerading as a nudibranch.jpg', ''];
arrImages[16] = ['./images/17 Banded sea krate.jpg', '17 Banded sea krate.jpg', ''];
arrImages[17] = ['./images/18 Banded sea krate.jpg', '18 Banded sea krate.jpg', ''];
arrImages[18] = ['./images/19 Seahorse.jpg', '19 Seahorse.jpg', ''];
arrImages[19] = ['./images/20 Lionfish.jpg', '20 Lionfish.jpg', ''];
arrImages[20] = ['./images/21 Filefish.jpg', '21 Filefish.jpg', ''];
arrImages[21] = ['./images/22 Shoaling fish.jpg', '22 Shoaling fish.jpg', ''];
arrImages[22] = ['./images/23 Shark in the haze.jpg', '23 Shark in the haze.jpg', ''];
arrImages[23] = ['./images/24 Another lionfish.jpg', '24 Another lionfish.jpg', ''];

		
		imageObj	 = getObj("theimage");
		imageNameObj = getObj("imageName");
		imageDescObj = getObj("imageDesc");
		
		nextImage();
	}
}

// -------------------------------------------
// This function uses the timeout code to stop 
// the slideshow.
// -------------------------------------------
function stopSlideshow() {
	if (bIsRunning) {
		clearTimeout(nTimeoutCode);
		bIsRunning = false;
	}
}

// -------------------------------------------
// This function getts the next image information
// and loads the image and text and then sets a
// timeout to call this function again.
// -------------------------------------------
function nextImage() {
	
	imageObj.src			= arrImages[nCurrentIndex][0];
	imageNameObj.innerHTML = arrImages[nCurrentIndex][1];
	imageDescObj.innerHTML = arrImages[nCurrentIndex][2];
	
	nCurrentIndex++;
	if (nCurrentIndex >= arrImages.length) {
		nCurrentIndex = 0;
	}
	
	nTimeoutCode = setTimeout("nextImage()", nDelay);
}

// -------------------------------------------
// This function returns the object with the 
// supplied id
// -------------------------------------------
function getObj(name)
{
	var obj;
	if (document.getElementById)
	{
		obj = document.getElementById(name);
	}
	else if (document.all)
	{
		obj = document.all[name];
	}
	else if (document.layers)
	{
		obj = document.layers[name];
	}
	
	return obj;
}










