// Copyright (c) 2009 Anders Toxboe & Benjamin Media - For White Album Gallery

document.observe('dom:loaded', function() {
	new BrightGallery();
});

BrightGallery = Class.create({
	next_url: null,
	previous_url: null,

	initialize: function(container_id) {
		this.retrieveNavigationURLs();
		document.observe('keydown', this.onKeyPress.bind(this));
		document.observe('keyup', this.onKeyPress.bind(this));
	},

	retrieveNavigationURLs: function() {
		this.next_url = $('next') ? $('next').getAttribute('href') : null;
		this.previous_url = $('previous') ? $('previous').getAttribute('href') : null;
	},

	onKeyPress: function(event) {
		if (this.previous_url && [Event.KEY_LEFT, 74, 106].include(event.keyCode)) {
			location.href = this.previous_url;
		}
		if (this.next_url && [Event.KEY_RIGHT, 75, 107].include(event.keyCode)) {
			location.href = this.next_url;
		}
	}
});