window.addEvent('domready', function(){

	var current_photo_left = $$('#imageblock_left div.photo_inner').shift();
	var current_caption_left = $$('#imageblock_left div.caption_container').shift();
	var current_photo_right = $$('#imageblock_right div.photo_inner').shift();
	var current_caption_right = $$('#imageblock_right div.caption_container').shift();

	// gallery - left half
	var scroll_left_photos = new Fx.Scroll('photo_left', {
		wait: false,
		duration: 2000,
		transition: Fx.Transitions.Back.easeInOut
	});
	var scroll_left_captions = new Fx.Scroll('captions_left', {
		wait: false,
		duration: 2000,
		transition: Fx.Transitions.Back.easeInOut
	});

	// gallery - right half
	var scroll_right_photos = new Fx.Scroll('photo_right', {
		wait: false,
		duration: 2000,
		transition: Fx.Transitions.Back.easeInOut
	});
	var scroll_right_captions = new Fx.Scroll('captions_right', {
		wait: false,
		duration: 2000,
		transition: Fx.Transitions.Back.easeInOut
	});

	// scroller events - left half
	$$('#imageblock_left .nav_right').addEvent('click', function(event) {
		event = new Event(event).stop();
		var el_photo = current_photo_left.getNext();
		var el_caption = current_caption_left.getNext();
		if (el_photo && el_caption) {
			scroll_left_photos.toElement(el_photo);
			scroll_left_captions.toElement(el_caption);
			current_photo_left = el_photo;
			current_caption_left = el_caption;
		}
	});
	$$('#imageblock_left .nav_left').addEvent('click', function(event) {
		event = new Event(event).stop();
		var el_photo = current_photo_left.getPrevious();
		var el_caption = current_caption_left.getPrevious();
		if (el_photo && el_caption) {
			scroll_left_photos.toElement(el_photo);
			scroll_left_captions.toElement(el_caption);
			current_photo_left = el_photo;
			current_caption_left = el_caption;
		}
	});

	// scroller events - right half
	$$('#imageblock_right .nav_right').addEvent('click', function(event) {
		event = new Event(event).stop();
		var el_photo = current_photo_right.getNext();
		var el_caption = current_caption_right.getNext();
		if (el_photo && el_caption) {
			scroll_right_photos.toElement(el_photo);
			scroll_right_captions.toElement(el_caption);
			current_photo_right = el_photo;
			current_caption_right = el_caption;
		}
	});
	$$('#imageblock_right .nav_left').addEvent('click', function(event) {
		event = new Event(event).stop();
		var el_photo = current_photo_right.getPrevious();
		var el_caption = current_caption_right.getPrevious();
		if (el_photo && el_caption) {
			scroll_right_photos.toElement(el_photo);
			scroll_right_captions.toElement(el_caption);
			current_photo_right = el_photo;
			current_caption_right = el_caption;
		}
	});

});

