var current_photo = 1;
var scroll_current_photo = 1;
var transitioning = false;

function nextPhoto(id) {
	if ( images.length == 0 ) { return; }
	if ( current_photo >= images.length ) { current_photo = 1; }
	else { current_photo = current_photo + 1; }
	document.getElementById(id).src = images[current_photo -1];
	document.getElementById('photo_count').innerHTML = 'Photo '+ current_photo +' of '+ images.length;
}

function prevPhoto(id) {
	if ( images.length == 0 ) { return; }
	if ( current_photo <= 1 ) { current_photo = images.length; }
	else { current_photo = current_photo - 1; }
	document.getElementById(id).src = images[current_photo -1];
	document.getElementById('photo_count').innerHTML = 'Photo '+ current_photo +' of '+ images.length;
}

function setImg(id,srcstr,pnum) {
	document.getElementById(id).src = srcstr;
	current_photo = pnum;
	document.getElementById('photo_count').innerHTML = 'Photo '+ current_photo +' of '+ images.length;
}

function endTransition(obj) {
	transitioning = false;
}

function scrollRight() {
	if ( images.length == 0 || transitioning ) { return; }
	if ( scroll_current_photo >= images.length -5 ) { return; }
	else { scroll_current_photo = scroll_current_photo + 1; }
	transitioning = true;
	new Effect.Move('gallery_inside', { x: -108, y: 0, fps: 100, afterFinish: endTransition });
}

function scrollLeft() {
	if ( images.length == 0 || transitioning ) { return; }
	if ( scroll_current_photo <= 1 ) { return; }
	else { scroll_current_photo = scroll_current_photo - 1; }
	transitioning = true;
	new Effect.Move('gallery_inside', { x: 108, y: 0, fps: 100, afterFinish: endTransition });
}
