window.addEvent('domready', function() {
	
	var VotingPanel = new Class({
		initialize: function(element) {
			this.controller = $(element);
			this.panel = $(this.controller.id.replace(/show/, ''));
			this.panel.style.display = 'none';
			this.controller.addEvent('click', this.onClick.bindWithEvent(this));
			this.controller.style.cursor = 'pointer';
		},
		togglePanel: function() {
			if (this.panel.style.display != '') {
				this.panel.style.display = '';
			} else {
				this.panel.style.display = 'none';
			}
		},
		toggleController: function() {
			if (this.controller.innerHTML != i18n.t('show all details')) {
				this.controller.innerHTML = i18n.t('show all details');
			} else {
				this.controller.innerHTML = i18n.t('hide all details');
			}
		},
		onClick: function(evt) {
			this.togglePanel();
			this.toggleController();
		}
	});

	$$('span.showallvotes').each(function(item, index) {
		new VotingPanel(item);
	});
	if (clearFixer) {
		clearFixer.fix();
	}
});