// -----------------------------------------------------------------------------------
// 
// This page coded by Scott Upton
// http://www.uptonic.com | http://www.couloir.org
//
// This work is licensed under a Creative Commons License
// Attribution-ShareAlike 2.0
// http://creativecommons.org/licenses/by-sa/2.0/
//
// Associated APIs copyright their respective owners
//
// -----------------------------------------------------------------------------------
// --- version date: 11/28/05 --------------------------------------------------------


// get current photo id from URL
var thisURL = document.location.href;
var splitURL = thisURL.split("#");
var photoId = splitURL[1] - 1;

// if no photoId supplied then set default
var photoId = (!photoId)? 0 : photoId;

// CSS border size x 2
var borderSize = 20;

// Photo directory for this gallery
var photoDir = "photos/";

// Define each photo's name, height, width, and caption
var photoArray = new Array(
	// Source, Width, Height, Caption
new Array("Cuba_001.jpg", 	"800", "531", 	"	Trip to Cuba, July – August  2007	"),
new Array("Cuba_002.jpg", 	"800", "531", 	"	The places we´ve visited	"),
new Array("Cuba_003.jpg", 	"800", "531", 	"	Cuba isn't a cheap place...	"),
new Array("Cuba_004.jpg", 	"398", "600", 	"	Capitolio Nacional, Centro Habana	"),
new Array("Cuba_005.jpg", 	"800", "531", 	"	Assembly hall of Capitolio Nacional, Centro Habana	"),
new Array("Cuba_006.jpg", 	"398", "600", 	"	Policemen are everywhere..., Havana	"),
new Array("Cuba_007.jpg", 	"398", "600", 	"	Plaza de San Francisco de Asís, Centro Habana	"),
new Array("Cuba_008.jpg", 	"398", "600", 	"	Iglesia y Monasterio de Francisco de Asís, Centro Habana	"),
new Array("Cuba_009.jpg", 	"800", "531", 	"	Catedral de San Cristóbal de la Habana, Centro Habana	"),
new Array("Cuba_010.jpg", 	"398", "600", 	"	Memorial José Martí (142 m), Plaza de la Revolución, Vedado, Havana	"),
new Array("Cuba_011.jpg", 	"800", "531", 	"	Fruit market, Prado, Centro Habana	"),
new Array("Cuba_012.jpg", 	"398", "600", 	"	Cajita and pizza, fast food ala cubano 	"),
new Array("Cuba_013.jpg", 	"800", "531", 	"	Life in Centro Habana	"),
new Array("Cuba_014.jpg", 	"398", "600", 	"	Famous La Bodeguita del Medio, Ernest Hemingway's favourite bar, Habana Vieja	"),
new Array("Cuba_015.jpg", 	"398", "600", 	"	Famous La Bodeguita del Medio, Ernest Hemingway's favourite bar, Habana Vieja	"),
new Array("Cuba_016.jpg", 	"800", "170", 	"	View of Havana from Castillo de Los Tres Santos Reyes Magnos del Morro, Havana	"),
new Array("Cuba_017.jpg", 	"398", "600", 	"	Castillo de Los Tres Santos Reyes Magnos del Morro, Havana	"),
new Array("Cuba_018.jpg", 	"800", "531", 	"	Hands up! Castillo de Los Tres Santos Reyes Magnos del Morro, Havana	"),
new Array("Cuba_019.jpg", 	"398", "600", 	"	At bloody sunset, Castillo de Los Tres Santos Reyes Magnos del Morro, Havana	"),
new Array("Cuba_020.jpg", 	"800", "531", 	"	View of shining Malecón from Castillo de Los Tres Santos Reyes Magnos del Morro, Havana	"),
new Array("Cuba_021.jpg", 	"800", "531", 	"	Malecón at night, full of drinking 'Habaneros', Havana	"),
new Array("Cuba_022.jpg", 	"398", "600", 	"	Flood-light Palacio Nacional, Centro Habana	"),
new Array("Cuba_023.jpg", 	"800", "531", 	"	Gran Teatro de la Habana, Centro Habana	"),
new Array("Cuba_024.jpg", 	"398", "600", 	"	¡Viva la Revolución!	"),
new Array("Cuba_025.jpg", 	"800", "531", 	"	Museo de la Revolución, Centro Habana	"),
new Array("Cuba_026.jpg", 	"800", "531", 	"	'Corner of the cretins' in Museo de la Revolución, Centro Habana	"),
new Array("Cuba_027.jpg", 	"800", "531", 	"	Colourful streets in Centro Habana	"),
new Array("Cuba_028.jpg", 	"398", "600", 	"	A street leading to Capitolio Nacional, Centro Habana	"),
new Array("Cuba_029.jpg", 	"800", "531", 	"	Laughing druggists, Havana	"),
new Array("Cuba_030.jpg", 	"800", "531", 	"	At butchery, Havana	"),
new Array("Cuba_031.jpg", 	"800", "531", 	"	Shop windows, it isn't a bad joke, it is a real life…	"),
new Array("Cuba_032.jpg", 	"398", "600", 	"	Colourful streets in Centro Habana	"),
new Array("Cuba_033.jpg", 	"398", "600", 	"	Nonavailability of the space parts is one of the biggest problems, Havana	"),
new Array("Cuba_034.jpg", 	"800", "531", 	"	'Parked' horse, Havana	"),
new Array("Cuba_035.jpg", 	"800", "531", 	"	Metrobus called 'camello' is normally abnormally full, substitut for metro in Havana	"),
new Array("Cuba_036.jpg", 	"800", "220", 	"	Panorama of marvelous countryside, Viñales	"),
new Array("Cuba_037.jpg", 	"800", "531", 	"	The best way how to see local country, Viñales	"),
new Array("Cuba_038.jpg", 	"800", "531", 	"	'Tractor natural', Viñales	"),
new Array("Cuba_039.jpg", 	"398", "600", 	"	Coffee processing at small family farm, Viñales	"),
new Array("Cuba_040.jpg", 	"800", "531", 	"	Process of cigars making at small family farm, Viñales	"),
new Array("Cuba_041.jpg", 	"398", "600", 	"	A farmer, Viñales	"),
new Array("Cuba_042.jpg", 	"800", "531", 	"	Our jovial guide, Viñales	"),
new Array("Cuba_043.jpg", 	"800", "531", 	"	Sierra de Órganos, chalk mountains called 'mogots', Viñales	"),
new Array("Cuba_044.jpg", 	"800", "531", 	"	Work on field, Viñales	"),
new Array("Cuba_045.jpg", 	"800", "531", 	"	¡Fidel for perpetuity!, Viñales	"),
new Array("Cuba_046.jpg", 	"398", "600", 	"	Fidel as a young lawyer and a flaming leader	"),
new Array("Cuba_047.jpg", 	"800", "531", 	"	The best time for football comes after rain or at sunset, Viñales	"),
new Array("Cuba_048.jpg", 	"398", "600", 	"	A field of 'the honest resident', Viñales	"),
new Array("Cuba_049.jpg", 	"800", "531", 	"	That's right to express an opinion..., Viñales	"),
new Array("Cuba_050.jpg", 	"800", "531", 	"	Our dinner at casa particular – chicken, fried bananas, rice and black beans, Viñales	"),
new Array("Cuba_051.jpg", 	"800", "531", 	"	Local bakery, bread is called “suave”, Viñales	"),
new Array("Cuba_052.jpg", 	"800", "531", 	"	Our guide at excursion of Gran Caverna de Santo Tomas, the third biggest cave complex in America which covers 48 km in 8 levels, west of Viñales	"),
new Array("Cuba_053.jpg", 	"398", "600", 	"	Gran Caverna de Santo Tomas, west of Viñales	"),
new Array("Cuba_054.jpg", 	"800", "531", 	"	Friendly villagers, Viñales	"),
new Array("Cuba_055.jpg", 	"800", "531", 	"	A beautiful scenery, Viñales 	"),
new Array("Cuba_056.jpg", 	"800", "531", 	"	A beautiful scenery, Viñales 	"),
new Array("Cuba_057.jpg", 	"398", "600", 	"	Short stop by hotel La Ermita, Viñales	"),
new Array("Cuba_058.jpg", 	"800", "531", 	"	One of the type of local transportation, not very good for environment, Viñales	"),
new Array("Cuba_059.jpg", 	"800", "531", 	"	A bus for young pioneer, Viñales	"),
new Array("Cuba_060.jpg", 	"800", "531", 	"	The beach of Cayo Jutías, west of Viñales	"),
new Array("Cuba_061.jpg", 	"800", "531", 	"	The beach of Cayo Jutías, west of Viñales	"),
new Array("Cuba_062.jpg", 	"800", "531", 	"	The beach of Cayo Jutías, west of Viñales	"),
new Array("Cuba_063.jpg", 	"800", "531", 	"	Crab on the beach of Cayo Jutías, west of Viñales	"),
new Array("Cuba_064.jpg", 	"800", "531", 	"	A rest, beach of Cayo Jutías, west of Viñales	"),
new Array("Cuba_065.jpg", 	"800", "531", 	"	One of the beautiful old car, Viñales	"),
new Array("Cuba_066.jpg", 	"398", "600", 	"	Che Guevara, an idol of all Cubans, Cienfuegos	"),
new Array("Cuba_067.jpg", 	"398", "600", 	"	Under the reconstruction, Cienfuegos	"),
new Array("Cuba_068.jpg", 	"398", "600", 	"	Children, Cienguegos	"),
new Array("Cuba_069.jpg", 	"800", "531", 	"	Afternoon rain, Cienfuegos	"),
new Array("Cuba_070.jpg", 	"800", "531", 	"	Sunset on Malecón, Cienfuegos	"),
new Array("Cuba_071.jpg", 	"800", "531", 	"	Local cafeteria, Cienfuegos	"),
new Array("Cuba_072.jpg", 	"800", "531", 	"	Palacio de Valle, Cienfugos	"),
new Array("Cuba_073.jpg", 	"398", "600", 	"	Palacio de Valle, Cienfugos	"),
new Array("Cuba_074.jpg", 	"800", "531", 	"	Local transportation, Cienfuegos	"),
new Array("Cuba_075.jpg", 	"800", "531", 	"	Local transportation, Cienfuegos	"),
new Array("Cuba_076.jpg", 	"800", "531", 	"	Jineteros looking out of tourists in bus terminal, Trinidad	"),
new Array("Cuba_077.jpg", 	"800", "531", 	"	A coster of fruit, Trinidad	"),
new Array("Cuba_078.jpg", 	"800", "531", 	"	Domino player in the street of Trinidad	"),
new Array("Cuba_079.jpg", 	"800", "531", 	"	Empanada vendor, Trinidad	"),
new Array("Cuba_080.jpg", 	"800", "531", 	"	Cuban shop with basic food, Trinidad	"),
new Array("Cuba_081.jpg", 	"398", "600", 	"	Flowing water in Trinidad	"),
new Array("Cuba_082.jpg", 	"398", "600", 	"	An old lady, Trinidad	"),
new Array("Cuba_083.jpg", 	"800", "531", 	"	A playing boy, Trinidad	"),
new Array("Cuba_084.jpg", 	"398", "600", 	"	Young 'gangsters', Trinidad	"),
new Array("Cuba_085.jpg", 	"800", "531", 	"	Madness, Trinidad	"),
new Array("Cuba_086.jpg", 	"800", "531", 	"	Emotion, Trinidad	"),
new Array("Cuba_087.jpg", 	"800", "531", 	"	Cuban beauty, Trinidad	"),
new Array("Cuba_088.jpg", 	"800", "531", 	"	Big brother and big sister, Trinidad	"),
new Array("Cuba_089.jpg", 	"398", "600", 	"	A street of Trinidad	"),
new Array("Cuba_090.jpg", 	"800", "531", 	"	Trip to Valle de Los Ingenios, East of Trinidad	"),
new Array("Cuba_091.jpg", 	"800", "155", 	"	Panorama of Valle de Los Ingenios, East of Trinidad	"),
new Array("Cuba_092.jpg", 	"398", "600", 	"	Locals on the way to Gran Piedra mountain (1234 m), east of Santiago de Cuba	"),
new Array("Cuba_093.jpg", 	"398", "600", 	"	Producing juice of sugar cane on farm, Valle de Los Ingenios, East of Trinidad"),
new Array("Cuba_094.jpg", 	"800", "531", 	"	Bathing by Cascada El Cubano, East of Trinidad	"),
new Array("Cuba_095.jpg", 	"398", "600", 	"	Street of Trinidad	"),
new Array("Cuba_096.jpg", 	"800", "531", 	"	Cuban art, Trinidad	"),
new Array("Cuba_097.jpg", 	"800", "531", 	"	Musicians, Trinidad	"),
new Array("Cuba_098.jpg", 	"800", "175", 	"	View of Valle de Los Ingenios, East of Trinidad		"),
new Array("Cuba_099.jpg", 	"398", "600", 	"	Manaca Iznaga, tower which served to looking-out of servants, Valle de Los Ingenios, East of Trinidad 	"),
new Array("Cuba_100.jpg", 	"800", "531", 	"	Fruit called 'mamoncillo', slimy but delicious	"),
new Array("Cuba_101.jpg", 	"800", "531", 	"	On the way home from work, Trinidad	"),
new Array("Cuba_102.jpg", 	"800", "531", 	"	Life in Trinidad	"),
new Array("Cuba_103.jpg", 	"800", "531", 	"	Life in Trinidad	"),
new Array("Cuba_104.jpg", 	"800", "531", 	"	Slogan to anniversary of Revolución de 26 Julio, Camagüey	"),
new Array("Cuba_105.jpg", 	"800", "531", 	"	Plaza de la Revolución, Camagüey	"),
new Array("Cuba_106.jpg", 	"398", "600", 	"	Hot salsa at night at anniversary of 26 Julio, Camagüey	"),
new Array("Cuba_107.jpg", 	"800", "531", 	"	In Mercado Agropecuario El Río, Camagüey 	"),
new Array("Cuba_108.jpg", 	"398", "600", 	"	In Mercado Agropecuario El Río, Camagüey 	"),
new Array("Cuba_109.jpg", 	"800", "531", 	"	In Mercado Agropecuario El Río, Camagüey 	"),
new Array("Cuba_110.jpg", 	"800", "531", 	"	In Mercado Agropecuario El Río, Camagüey 	"),
new Array("Cuba_111.jpg", 	"800", "531", 	"	In Mercado Agropecuario El Río, Camagüey 	"),
new Array("Cuba_112.jpg", 	"800", "531", 	"	Sculpture and its model, Camagüey 	"),
new Array("Cuba_113.jpg", 	"800", "531", 	"	Weather changes so quickly, Camagüey 	"),
new Array("Cuba_114.jpg", 	"800", "531", 	"	After excellent dinner at casa particular, Camagüey	"),
new Array("Cuba_115.jpg", 	"800", "531", 	"	Santiago de Cuba	"),
new Array("Cuba_116.jpg", 	"800", "531", 	"	Spirit of Cuba, Santiago de Cuba 	"),
new Array("Cuba_117.jpg", 	"398", "600", 	"	Cuban art, Santiago de Cuba	"),
new Array("Cuba_118.jpg", 	"800", "531", 	"	At the time of Carnival, Santiago de Cuba	"),
new Array("Cuba_119.jpg", 	"800", "531", 	"	A beautiul old Cadillac, Santiago de Cuba	"),
new Array("Cuba_120.jpg", 	"398", "600", 	"	Castillo de San Pedro del Morro, south of Santiago de Cuba	"),
new Array("Cuba_121.jpg", 	"398", "600", 	"	Castillo de San Pedro del Morro, south of Santiago de Cuba	"),
new Array("Cuba_122.jpg", 	"800", "531", 	"	Cooks of the 'famous' state restaurant Santiago 1900, I know now why we've waited more than 2 hours for our meal!, Santiago de Cuba	"),
new Array("Cuba_123.jpg", 	"398", "600", 	"	A waitress of the restaurant Santiago 1900, Santiago de Cuba	"),
new Array("Cuba_124.jpg", 	"800", "531", 	"	Guard-changing by the tomb of José Martí in Cementerio Santa Ifigenia, Santiago de Cuba 	"),
new Array("Cuba_125.jpg", 	"800", "531", 	"	View of Santiago de Cuba"),
new Array("Cuba_126.jpg", 	"800", "531", 	"	Young Cubans bath near by factories, Santiago de Cuba	"),
new Array("Cuba_127.jpg", 	"800", "531", 	"	Local transportation to Gran Piedra mountain (1234 m), east of Santiago de Cuba	"),
new Array("Cuba_128.jpg", 	"800", "531", 	"	Locals on the way to Gran Piedra mountain (1234 m), east of Santiago de Cuba	"),
new Array("Cuba_129.jpg", 	"800", "531", 	"	Road to the peak of Gran Piedra mountain (1234 m), east od Santiago de Cuba	"),
new Array("Cuba_130.jpg", 	"800", "135", 	"	View of country from peak of Gran Piedra mountain (1234 m), east of Santiago de Cuba	"),
new Array("Cuba_131.jpg", 	"800", "531", 	"	Plaza de la Reolución, Santiago de Cuba	"),
new Array("Cuba_132.jpg", 	"800", "531", 	"	Live statue in Plaza de la Reolución, Santiago de Cuba	"),
new Array("Cuba_133.jpg", 	"800", "531", 	"	Camioneta, Santiago de Cuba	"),
new Array("Cuba_134.jpg", 	"800", "195", 	"	Panorama of Baracoa	"),
new Array("Cuba_135.jpg", 	"398", "600", 	"	'A pet', Baracoa	"),
new Array("Cuba_136.jpg", 	"800", "531", 	"	Baracoa at night	"),
new Array("Cuba_137.jpg", 	"800", "531", 	"	Fernando and his Chevrolet from 1955, Baracoa	"),
new Array("Cuba_138.jpg", 	"800", "531", 	"	Interior of Chevrolet from 1955, Baracoa	"),
new Array("Cuba_139.jpg", 	"398", "600", 	"	Mix of coconut and dried fruit called 'cucurucho', speciality of Baracoa 	"),
new Array("Cuba_140.jpg", 	"800", "531", 	"	Marvelous natural Playa Maguana, north of Baracoa	"),
new Array("Cuba_141.jpg", 	"398", "600", 	"	Marvelous natural Playa Maguana, north of Baracoa	"),
new Array("Cuba_142.jpg", 	"800", "531", 	"	Our lunch on Playa Maguana, north of Baracoa	"),
new Array("Cuba_143.jpg", 	"800", "531", 	"	Ship-wrecked person looking out of help? Playa Maguana, north of Baracoa	"),
new Array("Cuba_144.jpg", 	"800", "531", 	"	Colourful streets of Baracoa	"),
new Array("Cuba_145.jpg", 	"800", "531", 	"	Catedral de Nestra Señora de la Asunción, Baracoa	"),
new Array("Cuba_146.jpg", 	"800", "531", 	"	Overcrowed camioneta, Baracoa	"),
new Array("Cuba_147.jpg", 	"800", "531", 	"	Cuban 'fast food', Santiagio de Cuba	"),
new Array("Cuba_148.jpg", 	"800", "531", 	"	People, Santiagio de Cuba	"),
new Array("Cuba_149.jpg", 	"800", "531", 	"	People, Santiagio de Cuba	"),
new Array("Cuba_150.jpg", 	"800", "531", 	"	People, Santiagio de Cuba	"),
new Array("Cuba_151.jpg", 	"800", "531", 	"	Domino, Santiagio de Cuba	"),
new Array("Cuba_152.jpg", 	"800", "531", 	"	Domino player, Santiagio de Cuba	"),
new Array("Cuba_153.jpg", 	"800", "531", 	"	Dramatic game, Santiagio de Cuba	"),
new Array("Cuba_154.jpg", 	"800", "531", 	"	Overnight train from Santiago de Cuba to Santa Clara	"),
new Array("Cuba_155.jpg", 	"398", "600", 	"	Passengers, overnight train from Santiago de Cuba to Santa Clara	"),
new Array("Cuba_156.jpg", 	"398", "600", 	"	Trainstop on the way to Santa Clara	"),
new Array("Cuba_157.jpg", 	"800", "531", 	"	Trainstop on the way to Santa Clara	"),
new Array("Cuba_158.jpg", 	"800", "531", 	"	Block of flats, Caibarién	"),
new Array("Cuba_159.jpg", 	"800", "531", 	"	Non-turistic beach for Cubans, Caibarién	"),
new Array("Cuba_160.jpg", 	"800", "531", 	"	Fernando and his wife, abord a train from Caibarién	"),
new Array("Cuba_161.jpg", 	"800", "531", 	"	Abord a train from Caibarién	"),
new Array("Cuba_162.jpg", 	"800", "531", 	"	Fernando, abord a train from Caibarién	"),
new Array("Cuba_163.jpg", 	"800", "531", 	"	Abord a train from Caibarién	"),
new Array("Cuba_164.jpg", 	"800", "175", 	"	16 km long beach, Varadero	"),
new Array("Cuba_165.jpg", 	"800", "531", 	"	Turistic part of beach, Varadero	"),
new Array("Cuba_166.jpg", 	"800", "531", 	"	An allinclusive hotel where we 'had to' spend our last night because of trouble with our plane	"),
new Array("Cuba_167.jpg", 	"800", "531", 	"	Sunset at Varadero	"),
new Array("Cuba_168.jpg", 	"800", "531", 	"	¡Hasta la vista!	")

);

// Number of photos in this gallery
var photoNum = photoArray.length;

/*--------------------------------------------------------------------------*/

// Additional methods for Element added by SU, Couloir
Object.extend(Element, {
	getWidth: function(element) {
   	element = $(element);
   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   	element = $(element);
    	element.style.height = h +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

/*--------------------------------------------------------------------------*/

var Slideshow = Class.create();

Slideshow.prototype = {
	initialize: function(photoId) {
		this.photoId = photoId;
		this.photo = 'Photo';
		this.photoBox = 'Container';
		this.prevLink = 'PrevLink';
		this.nextLink = 'NextLink';
		this.captionBox = 'CaptionContainer';
		this.caption = 'Caption';
		this.counter = 'Counter';
		this.loader = 'Loading';
	},
	getCurrentSize: function() {
		// Get current height and width, subtracting CSS border size
		this.wCur = Element.getWidth(this.photoBox) - borderSize;
		this.hCur = Element.getHeight(this.photoBox) - borderSize;
	},
	getNewSize: function() {
		// Get current height and width
		this.wNew = photoArray[photoId][1];
		this.hNew = photoArray[photoId][2];
	},
	getScaleFactor: function() {
		this.getCurrentSize();
		this.getNewSize();
		// Scalars based on change from old to new
		this.xScale = (this.wNew / this.wCur) * 100;
		this.yScale = (this.hNew / this.hCur) * 100;
	},
	setNewPhotoParams: function() {
		// Set source of new image
		Element.setSrc(this.photo,photoDir + photoArray[photoId][0]);
		// Set anchor for bookmarking
		Element.setHref(this.prevLink, "#" + (photoId+1));
		Element.setHref(this.nextLink, "#" + (photoId+1));
	},
	setPhotoCaption: function() {
		// Add caption from gallery array
		Element.setInnerHTML(this.caption,photoArray[photoId][3]);
		Element.setInnerHTML(this.counter,((photoId+1)+'/'+photoNum));
	},
	resizePhotoBox: function() {
		this.getScaleFactor();
		new Effect.Scale(this.photoBox, this.yScale, {scaleX: false, duration: 0.3, queue: 'front'});
		new Effect.Scale(this.photoBox, this.xScale, {scaleY: false, delay: 0.1, duration: 0.3});
		// Dynamically resize caption box as well
		Element.setWidth(this.captionBox,this.wNew-(-borderSize));
	},
	showPhoto: function(){
		new Effect.Fade(this.loader, {delay: 0, duration: 0.3});
		// Workaround for problems calling object method "afterFinish"
		new Effect.Appear(this.photo, {duration: 0.3, queue: 'end', afterFinish: function(){Element.show('CaptionContainer');Element.show('PrevLink');Element.show('NextLink');}});
	},
	nextPhoto: function(){
		// Figure out which photo is next
		(photoId == (photoArray.length - 1)) ? photoId = 0 : photoId++;
		this.initSwap();
	},
	prevPhoto: function(){
		// Figure out which photo is previous
		(photoId == 0) ? photoId = photoArray.length - 1 : photoId--;
		this.initSwap();
	},
	initSwap: function() {
		// Begin by hiding main elements
		Element.show(this.loader);
		Element.hide(this.photo);
		Element.hide(this.captionBox);
		Element.hide(this.prevLink);
		Element.hide(this.nextLink);
		// Set new dimensions and source, then resize
		this.setNewPhotoParams();
		this.resizePhotoBox();
		this.setPhotoCaption();
	}
}

/*--------------------------------------------------------------------------*/

// Establish CSS-driven events via Behaviour script
var myrules = {
	'#Photo' : function(element){
		element.onload = function(){
			var myPhoto = new Slideshow(photoId);
			myPhoto.showPhoto();
			preloadImages(photoId);
		}
	},
	'#PrevLink' : function(element){
		element.onmouseover = function(){
			soundManager.play('beep');
		}
		element.onclick = function(){
			var myPhoto = new Slideshow(photoId);
			myPhoto.prevPhoto();
			soundManager.play('select');
		}
	},
	'#NextLink' : function(element){
		element.onmouseover = function(){
			soundManager.play('beep');
		}
		element.onclick = function(){
			var myPhoto = new Slideshow(photoId);
			myPhoto.nextPhoto();
			soundManager.play('select');
		}
	},
	a : function(element){
		element.onfocus = function(){
			this.blur();
		}
	}
};

// Automatic slideshow
//setTimeout("play()", 5000);

function play() {
    var myPhoto = new Slideshow(photoId);
	myPhoto.nextPhoto();
	timerID = setTimeout("play()", 5000);
	control = document.getElementById("Controls").innerHTML="<a href='javascript:pause();'>Pause</a>";
}
function pause() {
    clearTimeout(timerID);
    control = document.getElementById("Controls").innerHTML="<a href='javascript:play();'>Play</a>";
}

// Preloading images...
function preloadImages(photoId) {
    var preImages = new Array();
    
    for (i = (photoId+1); i < (photoId+3); i++) {
        preImages[i] = new Image();
        preImages[i].src = photoDir + photoArray[i][0];        
    }
}

// Add window.onload event to initialize
Behaviour.addLoadEvent(init);
Behaviour.apply();
function init() {
	var myPhoto = new Slideshow(photoId);
	myPhoto.initSwap();
	soundManagerInit();
}

