/*
var PaginationClass = new Class({

	initialize: function(el, max) {
		this.element = $(el);
		this.max = max;

		this.historyKey = this.element.id + '-page';
		this.history = HistoryManager.register(
			this.historyKey,
			[1],
			function(values) {
				this.to(parseInt(values[0]));
			}.bind(this),
			function(values) {
				return [this.historyKey, '(', values[0], ')'].join('');
			}.bind(this),
			this.historyKey + '\\((\\d+)\\)');
	},

	by: function(dir) {
		this.to(this.page + dir);
	},

	to: function(page) {
		page = Math.max(Math.min(this.max, page), 1);
		this.page = page;
		this.element.setHTML('Page ', this.page);
		this.history.setValue(0, this.page);
	}

});
*/
/**
 * Extends Accordion with history state
 */
Accordion = Accordion.extend({

	options: {
		id: null,
		useHistory: false
		
	},

	initialize: function(togglers, elements, options) {
		this.setOptions(options);
		this.id = $pick(this.options.id, 'accordion-' + (Accordion.count++));
		if (this.options.useHistory) {
			this.history = HistoryManager.register(
				this.id,
				[this.options.display],
				function(args) { this.display(args[0]); }.bind(this),
				false,
				false);
		}
		return this.parent(togglers, elements, options);
	},

	display: function(index) {
		if (this.history) this.history.setValue(0, index);
		this.parent(index);
	}

});

Accordion.count = 0;


