var ArrowButton = function() {
	var self = this;
	
	this.initialize = function(el) {
		this.el = $(el);
		this.el.click(this.clicked);
		this.parent = this.el.parent();
	};
	
	this.clicked = function(e) {
		var showing = self.parent.find('div.scrollable-div:visible');
		
		if (self.el.text() == 'prev') {
			var prev = showing.prev();
			var show = prev.length == 0 ? self.parent.find('div.scrollable-div:last') : prev;
		} else {
			var next = showing.next();
			var show = next.length == 0 ? self.parent.find('div.scrollable-div:first') : next;
		}
		self.show(show);
			
		return false;
	};
	
	this.show = function(el) {
		self.parent.find('div.scrollable-div').addClass('hidden');
		el.removeClass('hidden');
	};
};

$(document).ready(function() {
	$('.browse-arrow').each(function(x, el) {
		var tmp = new ArrowButton();
		tmp.initialize(el);
	});
});