var GalleryPager = Class.create();

GalleryPager.prototype = {

	width: 120,
	current: 0,
	items: 0,
	next: null,
	prev: null,
	content: null,

	initialize: function(next, prev, content) {
		this.next    = $(next);
		this.prev    = $(prev);
		this.content = $(content);
		this.items   = $(content).getElementsBySelector('img').length;

		this.next.observe('click', function() { this.move('next') }.bind(this));
		this.prev.observe('click', function() { this.move('prev') }.bind(this));
	},

	move: function(way) {
		if('next' == way && this.current+1 < this.items) {
			this.current = this.current+1;
		} else if('prev' == way && this.current-1 >= 0) {
			this.current = this.current-1;
		}

		$('images').setStyle({bottom: (this.width*this.current)+'px'});
	}
}

Event.observe(window, 'load', function() { new GalleryPager('gallery_next', 'gallery_prev', 'frame') });

