<!--

// global variables

var phc=0;			// variable to count the number of captions

var phs=0;			// variable to count the number of photos

var currImg = 0;	// variable for the current photo counter

var autoplay = 0;	// variable to toggle the autoplay function on and off



// this function is for initialising the photo array - fill it with references to your own images

// this is really the only code you need to change for your own photo viewer

function initPhotos() 

{

	phSRC = new Array();				// this array holds all the file paths to the photos in the gallery

	phCAP = new Array();				// this array holds all the captions for the corresponding photos

	

	/*

	 * Duplicate the line below as many times as you like, replacing the photo link with your own picture

	 */	
	
	phSRC[phs++] = "images/photos/Thaidream1.jpg";
	phSRC[phs++] = "images/photos/Thaidream2.jpg";
	phSRC[phs++] = "images/photos/bar2.jpg";

	phSRC[phs++] = "images/photos/bar3.jpg";

	phSRC[phs++] = "images/photos/bar4.jpg";

	phSRC[phs++] = "images/photos/Salmom salad.jpg";

	phSRC[phs++] = "images/photos/Grilled Prawn.jpg";

	phSRC[phs++] = "images/photos/Garlic Prawn.jpg";

	phSRC[phs++] = "images/photos/Panaeng Curry.jpg";
	


	

	/*

	 * insert your photo captions here (make sure you have the same number captions as photos)

	 * WARNING - don't use quote marks in the captions

	 */
	phCAP[phc++] = "Thaidream";

	phCAP[phc++] = "Thaidream";

	phCAP[phc++] = "Dinning room";

	phCAP[phc++] = "Bar";

	phCAP[phc++] = "Bar";

	phCAP[phc++] = "Salmon salad";

	phCAP[phc++] = "Grilled prawn";

	phCAP[phc++] = "Garlic prawn";

	phCAP[phc++] = "Panaeng Curry";
	

	

	// now all the photos are initialised, pop the first one in the viewer

	setPhoto();

	

}



// this function puts the picture into the box and sets-up the caption information

function setPhoto()

{

	var temp;										// a temporary variable used to copy the text object names

	

	p = new Image();

	p.src = phSRC[currImg];							// create a new Image object and copy the current photo to it

	

	document.ImgBox.src= p.src;						// puts the next photo into the placeholder ImgBox

	document.ImgBox.width = 350;				// re-sets the width of the placeholder to fit the new photo

	document.ImgBox.height = 180;				// re-sets the height of the placeholder to fit the photo

	document.ImgBox.alt=phCAP[currImg];				// copies the caption to the image's Alt Attribute

	

	temp = document.getElementById("ImgCaption");	// find the image caption text object and copy it to temp variable

	temp.firstChild.nodeValue = phCAP[currImg];		// copy the current photo caption to the image caption

			

	temp = document.getElementById("count");		// find the counter text object and copy it to the temp variable

	temp.firstChild.nodeValue = currImg+1;			// copy the number of the current image to the counter 

													// add 1 (currImg+1) because arrays always start from 0 

													

	temp = document.getElementById("total");		// find the total number of photos text and copy it again

	temp.firstChild.nodeValue = phc;				// copy the phc counter variable to the total count text

}



// this function is used to incrementally fade in the image placeholder when a new photo is loaded

function fadeInPhoto()

{

    var timer = 0, x; 



	// loop around from 0 (invisible) to 100 (opaque)

	for(x = 0; x < 100; x++){

		// setTimeOut is used to periodically call a function to change the image's opacity

		setTimeout("opacityChange("+x+")", (timer*5));

		timer++;

	}

	

}



// this function is used to change the image placeholder's opacity style setting

// the value passed to this function is the transparency level: 0=invisible, 100=opaque

function opacityChange(op)

{

	// setting the alpha transparency for Internet Explorer (valid range 0 - 100)

	document.ImgBox.style.filter = "alpha(opacity=" + op + ")";

	// setting the opacity level for Netscape/Mozilla (valid range 0.0 to 1.0 - so "op" is divided by 100)

	document.ImgBox.style.MozOpacity = op / 100;

}	





// this function loads the next photo in the sequence and updates the page accordingly

// it requires a value to be passed to it. This determines which button has been pressed

function nextPhoto(dir)

{

	var temp;										// another temporary variable for copying text object names



	opacityChange(0);								// switch off the previous photo by making the box invisible

	fadeInPhoto();									// fade in the next photo



	switch(dir)									// switches are used to check a variable for different values

	{

		case 0:										// if dir=0, or the "previous photo" button has been pressed

			if(--currImg < 0)						// subtract the counter by one, but check that it's not less than 0

				currImg = phc-1;					// if it is, set the counter to the last image in the gallery

			break;									// break; is used to jump out of the switch sub-routine

		case 1:										// if dir=1, or if the "next photo" button has been pressed

			if(++currImg >= phc) 					// add one to the counter. Check it's not more than there are photos

				currImg = 0;						// if it is, set the counter to the first photo or 0

			break;

			

		case 2:												 // if dir=2, or the "jump to" button has been pressed

			

			temp = parseInt(document.gotoform.jumpto.value); // copy any numerical data typed into the form to "temp"

			if(temp > 0 && temp <= phc)						 // check that temp is within the range of photos in the gallery

				currImg = temp-1;							 // if it is, update the counter

			break;											 // subtract one because arrays always start from 0

			

		default:

			currImg=0;								// if any erroneous data is supplied to the function, just reset it

	}



	setPhoto();										// update the display by calling the setPhoto() function

}



// this line executes the slideShow() function every 2.5 seconds

// change 2500 to a different value to alter the speed of the slide show 

setInterval("slideShow()", 4000);	



function slideShow()

{

     if(autoplay){		// if autoplay is on or 1 then increment the photo counter 

		nextPhoto(1);

	}

}

// switches auto-play on and off according to "mode": 1 for on, 0 for off

function togglePlay(mode)

{

	autoplay=mode;

}

//-->

