// -----------------------------------------------------------------------------------
// 
// 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 = 10;

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

// Define each photo's name, height, width, and caption
var photoArray = new Array(
	// Source, Width, Height, Caption
new Array("2006_0825(000).jpg", "640", "473", "Golf"),
new Array("2006_0825(001).jpg", "640", "475", "Golf"),
new Array("2006_0825(002).jpg", "640", "463", "Golf"),
new Array("2006_0825(003).jpg", "640", "480", "Golf"),
new Array("2006_0825(005).jpg", "640", "477", "Golf"),
new Array("2006_0825(007).jpg", "640", "480", "Golf"),
new Array("2006_0825(008).jpg", "640", "476", "Golf"),
new Array("2006_0825(009).jpg", "640", "479", "Golf"),
new Array("2006_0825(010).jpg", "640", "479", "Golf"),
new Array("2006_0825(011).jpg", "640", "480", "Golf"),
new Array("2006_0825(012).jpg", "640", "473", "Golf"),
new Array("2006_0825(013).jpg", "640", "480", "Golf"),
new Array("2006_0825(016).jpg", "412", "640", "Golf"),
new Array("2006_0825(018.jpg", "640", "467", "Golf"),
new Array("2006_0825(021).jpg", "640", "492", "Golf"),
new Array("2006_0825(025).jpg", "429", "640", "Golf"),
new Array("2006_0825(027).jpg", "480", "640", "Golf"),
new Array("2006_0825(028).jpg", "640", "480", "Golf"),
new Array("2006_0825(036).jpg", "417", "640", "Golf"),
new Array("2006_0825(038).jpg", "640", "456", "Golf"),
new Array("2006_0825(039).jpg", "640", "488", "Golf"),
new Array("2006_0825(041).jpg", "640", "468", "Golf"),
new Array("2006_0825(042).jpg", "640", "463", "Golf"),
new Array("2006_0825(054).jpg", "640", "473", "Golf"),
new Array("2006_0825(056).jpg", "640", "492", "Golf"),
new Array("2006_0825(061).jpg", "640", "450", "Golf"),
new Array("2006_0825(075).jpg", "640", "458", "Golf"),
new Array("2006_0825(077).jpg", "640", "459", "Golf"),
new Array("2006_0825(081).jpg", "640", "469", "Golf"),
new Array("2006_0825(083).jpg", "640", "461", "Golf"),
new Array("2006_0825(084).jpg", "436", "640", "Golf"),
new Array("2006_0825(085).jpg", "640", "480", "Golf"),
new Array("2006_0825(086).jpg", "425", "640", "Golf"),
new Array("2006_0825(089).jpg", "640", "491", "Golf"),
new Array("2006_0825(093).jpg", "640", "463", "Golf"),
new Array("2006_0825(094).jpg", "640", "450", "Golf"),
new Array("2006_0825(095).jpg", "441", "640", "Golf"),
new Array("2006_0825(096).jpg", "480", "640", "Golf"),
new Array("2006_0825(097).jpg", "441", "640", "Golf"),
new Array("2006_0825(098).jpg", "640", "466", "Golf"),
new Array("2006_0825(099).jpg", "429", "640", "Golf"),
new Array("2006_0825(100).jpg", "392", "640", "Golf"),
new Array("2007-001.jpg", "640", "480", "Golf"),
new Array("2007-003.jpg", "640", "427", "Golf"),
new Array("2007-004.jpg", "640", "439", "Golf"),
new Array("2007-005.jpg", "640", "440", "Golf"),
new Array("bgcl golf 006.jpg", "640", "451", "Golf"),
new Array("bgcl golf 007.jpg", "640", "448", "Golf"),
new Array("bgcl golf 009.jpg", "640", "455", "Golf"),
new Array("bgcl golf 010.jpg", "640", "457", "Golf"),
new Array("bgcl golf 011.jpg", "427", "640", "Golf"),
new Array("bgcl golf 013.jpg", "640", "427", "Golf"),
new Array("bgcl golf 014.jpg", "640", "464", "Golf"),
new Array("bgcl golf 016.jpg", "640", "454", "Golf"),
new Array("bgcl golf 019.jpg", "640", "436", "Golf"),
new Array("bgcl golf 020.jpg", "640", "427", "Golf"),
new Array("bgcl golf 021.jpg", "640", "427", "Golf"),
new Array("bgcl golf 025.jpg", "640", "441", "Golf"),
new Array("bgcl golf 028.jpg", "640", "451", "Golf"),
new Array("bgcl golf 029.jpg", "640", "427", "Golf"),
new Array("bgcl golf 030.jpg", "640", "463", "Golf"),
new Array("bgcl golf 031.jpg", "640", "466", "Golf"),
new Array("bgcl golf 032.jpg", "640", "427", "Golf"),
new Array("bgcl golf 036.jpg", "640", "463", "Golf"),
new Array("bgcl golf 037.jpg", "640", "466", "Golf"),
new Array("bgcl golf 039.jpg", "640", "454", "Golf"),
new Array("bgcl golf 040.jpg", "640", "427", "Golf"),
new Array("bgcl golf 042.jpg", "640", "427", "Golf"),
new Array("bgcl golf 044.jpg", "353", "640", "Golf"),
new Array("bgcl golf 046.jpg", "640", "439", "Golf"),
new Array("bgcl golf 048.jpg", "640", "449", "Golf"),
new Array("bgcl golf 049.jpg", "640", "462", "Golf"),
new Array("bgcl golf 056.jpg", "640", "438", "Golf"),
new Array("bgcl golf 057.jpg", "640", "427", "Golf"),
new Array("bgcl golf 058.jpg", "640", "427", "Golf"),
new Array("bgcl golf 060.jpg", "640", "427", "Golf"),
new Array("bgcl golf 061.jpg", "640", "464", "Golf"),
new Array("bgcl golf 062.jpg", "640", "427", "Golf"),
new Array("bgcl golf 063.jpg", "640", "427", "Golf"),
new Array("bgcl golf 068.jpg", "640", "450", "Golf"),
new Array("bgcl golf 072.jpg", "640", "477", "Golf"),
new Array("bgcl golf 073.jpg", "640", "468", "Golf"),
new Array("bgcl golf 076.jpg", "640", "427", "Golf"),
new Array("bgcl golf 080.jpg", "640", "476", "Golf"),
new Array("bgcl golf 085.jpg", "640", "484", "Golf"),
new Array("bgcl golf 086.jpg", "406", "640", "Golf"),
new Array("bgcl golf 087.jpg", "640", "427", "Golf"),
new Array("bgcl golf 088.jpg", "640", "427", "Golf"),
new Array("bgcl golf 092.jpg", "640", "427", "Golf"),
new Array("bgcl golf 095.jpg", "451", "640", "Golf"),
new Array("bgcl golf 097.jpg", "640", "427", "Golf"),
new Array("bgcl golf 099.jpg", "640", "451", "Golf"),
new Array("bgcl golf 104.jpg", "640", "427", "Golf"),
new Array("bgcl golf 106.jpg", "640", "427", "Golf"),
new Array("bgcl golf 107.jpg", "640", "427", "Golf"),
new Array("bgcl golf 108.jpg", "640", "460", "Golf"),
new Array("bgcl golf 109.jpg", "640", "437", "Golf"),
new Array("bgcl golf 110.jpg", "640", "455", "Golf"),
new Array("bgcl golf 113.jpg", "640", "427", "Golf"),
new Array("bgcl golf 117.jpg", "431", "640", "Golf"),
new Array("bgcl golf 126.jpg", "427", "640", "Golf"),
new Array("bgcl golf 128.jpg", "392", "640", "Golf"),
new Array("bgcl golf 131.jpg", "640", "428", "Golf"),
new Array("bgcl golf 132.jpg", "640", "460", "Golf"),
new Array("bgcl golf 133.jpg", "427", "640", "Golf"),
new Array("bgcl golf 139.jpg", "640", "453", "Golf"),
new Array("IMG_5343.jpg", "640", "427", "Golf"),
new Array("IMG_5344.jpg", "640", "427", "Golf"),
new Array("IMG_5346.jpg", "640", "427", "Golf"),
new Array("IMG_5347.jpg", "640", "427", "Golf"),
new Array("IMG_5348.jpg", "427", "640", "Golf"),
new Array("IMG_5349.jpg", "640", "427", "Golf"),
new Array("IMG_5350.jpg", "640", "427", "Golf"),
new Array("IMG_5351.jpg", "640", "427", "Golf"),
new Array("IMG_5355.jpg", "640", "427", "Golf"),
new Array("IMG_5358.jpg", "427", "640", "Golf"),
new Array("IMG_5359.jpg", "640", "427", "Golf"),
new Array("IMG_5360.jpg", "640", "427", "Golf"),
new Array("IMG_5361.jpg", "640", "427", "Golf"),
new Array("IMG_5362.jpg", "640", "427", "Golf"),
new Array("IMG_5363.jpg", "427", "640", "Golf"),
new Array("IMG_5364.jpg", "427", "640", "Golf"),
new Array("IMG_5365.jpg", "427", "640", "Golf"),
new Array("IMG_5366.jpg", "640", "427", "Golf"),
new Array("IMG_5367.jpg", "640", "427", "Golf"),
new Array("IMG_5368.jpg", "427", "640", "Golf"),
new Array("IMG_5370.jpg", "427", "640", "Golf"),
new Array("IMG_5371.jpg", "427", "640", "Golf"),
new Array("IMG_5376.jpg", "640", "427", "Golf"),
new Array("IMG_5377.jpg", "427", "640", "Golf"),
new Array("IMG_5378.jpg", "427", "640", "Golf"),
new Array("IMG_5379.jpg", "427", "640", "Golf"),
new Array("IMG_5380.jpg", "640", "427", "Golf"),
new Array("IMG_5384.jpg", "640", "427", "Golf"),
new Array("IMG_5385.jpg", "427", "640", "Golf"),
new Array("IMG_5386.jpg", "427", "640", "Golf"),
new Array("IMG_5387.jpg", "427", "640", "Golf"),
new Array("IMG_5388.jpg", "427", "640", "Golf"),
new Array("IMG_5389.jpg", "640", "427", "Golf"),
new Array("IMG_5390.jpg", "640", "427", "Golf"),
new Array("IMG_5391.jpg", "640", "427", "Golf"),
new Array("IMG_5392.jpg", "640", "427", "Golf"),
new Array("IMG_5393.jpg", "427", "640", "Golf"),
new Array("IMG_5394.jpg", "427", "640", "Golf"),
new Array("IMG_5395.jpg", "640", "427", "Golf"),
new Array("IMG_5396.jpg", "427", "640", "Golf"),
new Array("IMG_5397.jpg", "427", "640", "Golf"),
new Array("IMG_5398.jpg", "640", "427", "Golf"),
new Array("IMG_5399.jpg", "427", "640", "Golf"),
new Array("IMG_5401.jpg", "427", "640", "Golf"),
new Array("IMG_5402.jpg", "640", "427", "Golf"),
new Array("IMG_5403.jpg", "640", "427", "Golf"),
new Array("IMG_5404.jpg", "427", "640", "Golf"),
new Array("IMG_5405.jpg", "640", "427", "Golf"),
new Array("IMG_5407.jpg", "640", "427", "Golf"),
new Array("IMG_5409.jpg", "640", "427", "Golf"),
new Array("IMG_5410.jpg", "640", "427", "Golf"),
new Array("IMG_5411.jpg", "640", "427", "Golf"),
new Array("IMG_5413.jpg", "427", "640", "Golf"),
new Array("IMG_5415.jpg", "640", "427", "Golf"),
new Array("IMG_5416.jpg", "427", "640", "Golf"),
new Array("IMG_5418.jpg", "640", "427", "Golf"),
new Array("IMG_5420.jpg", "427", "640", "Golf"),
new Array("IMG_5421.jpg", "640", "427", "Golf"),
new Array("IMG_5423.jpg", "640", "427", "Golf"),
new Array("IMG_5424.jpg", "640", "427", "Golf"),
new Array("IMG_5425.jpg", "427", "640", "Golf"),
new Array("IMG_5426.jpg", "427", "640", "Golf"),
new Array("IMG_5427.jpg", "640", "427", "Golf"),
new Array("IMG_5428.jpg", "640", "427", "Golf"),
new Array("IMG_5429.jpg", "640", "427", "Golf"),
new Array("IMG_5430.jpg", "640", "427", "Golf"),
new Array("IMG_5431.jpg", "427", "640", "Golf"),
new Array("IMG_5432.jpg", "640", "427", "Golf"),
new Array("IMG_5434.jpg", "640", "427", "Golf"),
new Array("IMG_5435.jpg", "640", "427", "Golf"),
new Array("IMG_5436.jpg", "640", "427", "Golf"),
new Array("IMG_5437.jpg", "640", "427", "Golf"),
new Array("IMG_5438.jpg", "640", "427", "Golf"),
new Array("IMG_5439.jpg", "640", "427", "Golf"),
new Array("IMG_5440.jpg", "427", "640", "Golf"),
new Array("IMG_5441.jpg", "427", "640", "Golf"),
new Array("IMG_5443.jpg", "640", "427", "Golf"),
new Array("IMG_5444.jpg", "640", "427", "Golf"),
new Array("IMG_5446.jpg", "427", "640", "Golf"),
new Array("IMG_5447.jpg", "640", "427", "Golf"),
new Array("IMG_5450.jpg", "640", "427", "Golf"),
new Array("IMG_5451.jpg", "640", "427", "Golf"),
new Array("IMG_5454.jpg", "427", "640", "Golf"),
new Array("IMG_5455.jpg", "640", "427", "Golf"),
new Array("IMG_5456.jpg", "640", "427", "Golf"),
new Array("IMG_5457.jpg", "427", "640", "Golf"),
new Array("IMG_5458.jpg", "640", "427", "Golf"),
new Array("IMG_5460.jpg", "640", "427", "Golf"),
new Array("IMG_5461.jpg", "640", "427", "Golf"),
new Array("IMG_5462.jpg", "640", "427", "Golf"),
new Array("IMG_5463.jpg", "640", "427", "Golf"),
new Array("IMG_5465.jpg", "640", "427", "Golf"),
new Array("IMG_5466.jpg", "640", "427", "Golf"),
new Array("IMG_5468.jpg", "640", "427", "Golf"),
new Array("IMG_5470.jpg", "640", "427", "Golf"),
new Array("IMG_5471.jpg", "640", "427", "Golf"),
new Array("IMG_5472.jpg", "640", "427", "Golf"),
new Array("IMG_5473.jpg", "640", "427", "Golf"),
new Array("IMG_5474.jpg", "640", "427", "Golf"),
new Array("IMG_5475.jpg", "427", "640", "Golf"),
new Array("IMG_5476.jpg", "640", "427", "Golf"),
new Array("IMG_5477.jpg", "640", "427", "Golf"),
new Array("IMG_5479.jpg", "640", "427", "Golf"),
new Array("IMG_5480.jpg", "427", "640", "Golf"),
new Array("IMG_5481.jpg", "640", "427", "Golf"),
new Array("IMG_5482.jpg", "640", "427", "Golf"),
new Array("IMG_5483.jpg", "640", "427", "Golf"),
new Array("IMG_5484.jpg", "640", "427", "Golf"),
new Array("IMG_5490.jpg", "640", "427", "Golf"),
new Array("IMG_5492.jpg", "427", "640", "Golf"),
new Array("IMG_5496.jpg", "640", "427", "Golf"),
new Array("IMG_5500.jpg", "640", "427", "Golf"),
new Array("IMG_5501.jpg", "640", "427", "Golf"),
new Array("IMG_5504.jpg", "640", "427", "Golf"),
new Array("IMG_5505.jpg", "640", "427", "Golf"),
new Array("IMG_5506.jpg", "640", "427", "Golf"),
new Array("IMG_5507.jpg", "640", "427", "Golf"),
new Array("IMG_5508.jpg", "427", "640", "Golf"),
new Array("IMG_5509.jpg", "640", "427", "Golf")
	);

var photoArray = new Array(
new Array("IMG_8403.jpg", "400", "600", "Golf"),
new Array("IMG_8436A.jpg", "600", "400", "Golf"),
new Array("IMG_8435.jpg", "600", "400", "Golf"),
new Array("IMG_8431.jpg", "600", "400", "Golf"),
new Array("IMG_8407.jpg", "384", "600", "Golf"),
new Array("IMG_8369.jpg", "600", "400", "Golf"),
new Array("IMG_8366.jpg", "600", "400", "Golf"),
new Array("IMG_8434.jpg", "600", "400", "Golf"),
new Array("IMG_8437.jpg", "407", "600", "Golf"),
new Array("IMG_8436.jpg", "600", "400", "Golf"),
new Array("IMG_8420.jpg", "600", "400", "Golf"),
new Array("IMG_8347.jpg", "600", "400", "Golf"),
new Array("IMG_8351.jpg", "385", "600", "Golf"),
new Array("IMG_8427.jpg", "385", "600", "Golf"),
new Array("IMG_8379.jpg", "600", "400", "Golf"),
new Array("IMG_8361.jpg", "600", "400", "Golf"),
new Array("IMG_8433.jpg", "600", "400", "Golf"),
new Array("IMG_8432.jpg", "600", "400", "Golf"),
new Array("IMG_8348.jpg", "600", "400", "Golf"),
new Array("IMG_8341.jpg", "600", "422", "Golf"),
new Array("IMG_8404.jpg", "400", "600", "Golf"),
new Array("IMG_8336.jpg", "600", "400", "Golf"),
new Array("IMG_8325.jpg", "600", "399", "Golf"),
new Array("IMG_8383.jpg", "600", "406", "Golf"),
new Array("IMG_8360.jpg", "404", "600", "Golf"),
new Array("IMG_8338.jpg", "400", "600", "Golf"),
new Array("IMG_8358.jpg", "600", "400", "Golf"),
new Array("IMG_8430.jpg", "600", "400", "Golf"),
new Array("IMG_8349.jpg", "400", "600", "Golf"),
new Array("IMG_8415.jpg", "600", "400", "Golf"),
new Array("IMG_8327.jpg", "600", "406", "Golf"),
new Array("IMG_8419.jpg", "400", "600", "Golf"),
new Array("IMG_8342.jpg", "600", "400", "Golf"),
new Array("IMG_8331.jpg", "600", "400", "Golf"),
new Array("IMG_8377.jpg", "600", "400", "Golf"),
new Array("IMG_8426.jpg", "400", "600", "Golf"),
new Array("IMG_8380.jpg", "400", "600", "Golf"),
new Array("IMG_8332.jpg", "373", "600", "Golf"),
new Array("IMG_8393.jpg", "400", "600", "Golf"),
new Array("IMG_8321.jpg", "600", "400", "Golf"),
new Array("IMG_8333.jpg", "600", "422", "Golf"),
new Array("IMG_8322.jpg", "600", "400", "Golf"),
new Array("IMG_8365.jpg", "400", "600", "Golf"),
new Array("IMG_8410.jpg", "400", "600", "Golf"),
new Array("IMG_8390.jpg", "400", "600", "Golf"),
new Array("IMG_8408.jpg", "600", "400", "Golf"),
new Array("IMG_8378.jpg", "400", "600", "Golf"),
new Array("IMG_8418.jpg", "600", "420", "Golf"),
new Array("IMG_8395.jpg", "600", "400", "Golf"),
new Array("IMG_8416.jpg", "600", "400", "Golf"),
new Array("IMG_8374.jpg", "600", "418", "Golf"),
new Array("IMG_8363.jpg", "600", "400", "Golf"),
new Array("IMG_8429.jpg", "400", "600", "Golf"),
new Array("IMG_8437B.jpg", "600", "450", "Golf"),
new Array("IMG_8330.jpg", "600", "400", "Golf"),
new Array("IMG_8400.jpg", "600", "400", "Golf"),
new Array("IMG_8357.jpg", "420", "600", "Golf"),
new Array("IMG_8328.jpg", "400", "600", "Golf"),
new Array("IMG_8385.jpg", "400", "600", "Golf"),
new Array("IMG_8324.jpg", "600", "413", "Golf"),
new Array("IMG_8392.jpg", "400", "600", "Golf"),
new Array("IMG_8396.jpg", "600", "400", "Golf"),
new Array("IMG_8352.jpg", "600", "425", "Golf"),
new Array("IMG_8428.jpg", "600", "400", "Golf"),
new Array("IMG_8370.jpg", "400", "600", "Golf"),
new Array("IMG_8382.jpg", "600", "400", "Golf"),
new Array("IMG_8421.jpg", "600", "400", "Golf"),
new Array("IMG_8320.jpg", "600", "400", "Golf"),
new Array("IMG_8343.jpg", "600", "426", "Golf"),
new Array("IMG_8344.jpg", "600", "400", "Golf"),
new Array("IMG_8335.jpg", "600", "400", "Golf"),
new Array("IMG_8371.jpg", "600", "400", "Golf"),
new Array("IMG_8423.jpg", "600", "400", "Golf"),
new Array("IMG_8367.jpg", "600", "400", "Golf"),
new Array("IMG_8405.jpg", "600", "400", "Golf"),
new Array("IMG_8329.jpg", "401", "600", "Golf"),
new Array("IMG_8353.jpg", "600", "438", "Golf"),
new Array("IMG_8364.jpg", "600", "400", "Golf"),
new Array("IMG_8406.jpg", "600", "424", "Golf"),
new Array("IMG_8334.jpg", "600", "428", "Golf"),
new Array("IMG_8323.jpg", "600", "407", "Golf"),
new Array("IMG_8372.jpg", "600", "400", "Golf"),
new Array("IMG_8381.jpg", "600", "400", "Golf"),
new Array("IMG_8355.jpg", "400", "600", "Golf"),
new Array("IMG_8337.jpg", "600", "400", "Golf"),
new Array("IMG_8391.jpg", "600", "400", "Golf"),
new Array("IMG_8389.jpg", "600", "400", "Golf"),
new Array("IMG_8340.jpg", "600", "420", "Golf"),
new Array("IMG_8339.jpg", "400", "600", "Golf"),
new Array("IMG_8350.jpg", "400", "600", "Golf"),
new Array("IMG_8345.jpg", "600", "400", "Golf"),
new Array("IMG_8412.jpg", "600", "400", "Golf"),
new Array("IMG_8346.jpg", "600", "438", "Golf"),
new Array("IMG_8319.jpg", "600", "400", "Golf"),
new Array("IMG_8376.jpg", "600", "400", "Golf"),
new Array("IMG_8394.jpg", "600", "400", "Golf"),
new Array("IMG_8356.jpg", "600", "400", "Golf"),
new Array("IMG_8388.jpg", "600", "400", "Golf"),
new Array("IMG_8386.jpg", "600", "400", "Golf"),
new Array("IMG_8399.jpg", "391", "600", "Golf"),
new Array("IMG_8397.jpg", "600", "438", "Golf")
	);

// 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.5, 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.5, duration: 0.3});
		// Workaround for problems calling object method "afterFinish"
		new Effect.Appear(this.photo, {duration: 0.5, 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();
		}
	},
	'#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();
		}
	}
};

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