function ShowPhoto(image) {
	var backdrop = document.getElementById('backdrop');

	SetPhoto(image);
	new Effect.Opacity(backdrop,
		{duration: 1.0,
		transition: Effect.Transitions.linear,
		from: 0.0, to: 0.75,
		beforeStart: function() {
			var backdrop = document.getElementById('backdrop');
			backdrop.style.display = 'block';
		},
		afterFinish: function() {
			var photo = document.getElementById('photo');
			var content = document.getElementById('content');
			photo.style.display = 'block';
			photo.style.marginLeft = '0px';
			var width = (navigator.appName.indexOf('Microsoft')!=-1 ? content.offsetWidth : document.body.offsetWidth);
			photo.style.marginLeft = ((width - photo.firstChild.firstChild.offsetWidth) / 2) + 'px';
			document.body.style.overflow = 'hidden';
		}}
	);
}

function HidePhoto() {
	var backdrop = document.getElementById('backdrop');
	var photo = document.getElementById('photo');
	photo.style.display = 'none';
	new Effect.Opacity(backdrop,
		{duration: 1.0,
		transition: Effect.Transitions.linear,
		from: 0.75, to: 0.0,
		afterFinish: function() {
			var backdrop = document.getElementById('backdrop');
			backdrop.style.display = 'none';
			document.body.style.overflow = 'auto';
		}}
	);
}

function ChangePhoto(offset) {
	current += offset;
	if (current < 0) current = photos.length - 1;
	if (current >= photos.length) current = 0;
	SetPhoto(current);
}

function SetPhoto(image) {
	current = image;
	var photo = document.getElementById('photo');
	photo.firstChild.firstChild.src = '/library/?image=' + photos[image].image + '&height=700&width=700&method=bestfit';
	photo.lastChild.innerHTML = photos[image].caption;
	photo.style.marginLeft = ((document.body.offsetWidth - photo.firstChild.firstChild.offsetWidth) / 2) + 'px';
}