function showimage(objid) {
	if(window.photoCurrent) {
		$(window.photoCurrent).hide();
		hideComments();
		var thumb = window.photoCurrent + 'thumb';
		//$(thumb).setStyle({	'border-style': 'soild', 'border-width': '1px', 'border-color': '#AEC1CC'});
		$(thumb).style.border='1px solid #AEC1CC';
	}
	var currthumb = objid + 'thumb';
	// ie ignores correct prototype code
	//$(currthumb).setStyle({	'border-style': 'soild', 'border-width': '1px', 'border-color': '#000000'});
	$(currthumb).style.border='1px solid #000000';
	Effect.Appear(objid);
	window.photoCurrent = objid;
}

function showComments() {
	stopSlides();
	var currComments = window.photoCurrent + 'comments';
	var currImage = window.photoCurrent + 'img';
	// get size of current photo
	var dimensions = $(currImage).getDimensions();

	// give comments box same size as photo
	Element.setStyle(currComments, {
		width: dimensions.width + 'px',
		height: dimensions.height + 'px'
	});
	Effect.BlindDown(currComments);
	var currCommentsLink = 'togglecomments' + noFromPhoto(window.photoCurrent);
	$(currCommentsLink).update('<a href="#" onclick="hideComments()">Hide Comments</a>');
}
function hideComments() {
	var currComments = window.photoCurrent + 'comments';
	Effect.BlindUp(currComments);
	var currCommentsLink = 'togglecomments' + noFromPhoto(window.photoCurrent);
	$(currCommentsLink).update('<a href="#" onclick="showComments()">Show Comments</a>');
}

function noFromPhoto(objid) {
	return parseInt(objid.substring(5))
}

function skip(flag) {
	if(flag == 'next') {
		next = noFromPhoto(window.photoCurrent) + 1;
		if(next <= window.photoNo) {
			showimage('photo'+next);
		} else {
			stopSlides();
			return '';
		}
	} else if(flag == 'previous') {
		stopSlides();
		if(noFromPhoto(window.photoCurrent) > 1 ) {
			previous = noFromPhoto(window.photoCurrent) - 1;
			showimage('photo'+previous);
		} else {
			return '';
		}
	}
}

function toggleSlides() {
	// are slides playing?
	if(window.slideplaying == true) {
		stopSlides();
	} else {
		playSlides();
	}
}

function playSlides() {
	window.slideplaying = true;
	showimage('photo1');
	var skipinterval = window.setInterval('skip(\'next\')',2600);
	window.skipinterval = skipinterval;
	$('playslides').update('<img src="images/stop.gif">');
}
function stopSlides() {
	if(window.slideplaying == true) {
		clearInterval(window.skipinterval);
		$('playslides').update('<img src="images/play.gif">');
		window.slideplaying = false;
		return true;
	} else {
		return false;
	}
}
function slideNote(flag) {
	if(window.slideplaying == true) {
		$('playslidesnote').update('Stop<br />Slideshow');
	} else {
		$('playslidesnote').update('Start<br />Slideshow');
	}
	if(flag == 'hide') {
		$('playslidesnote').hide();
	} else {	
		$('playslidesnote').show();
	}
}
