document.observe("dom:loaded", function()
{
	var contents = $$('div.billboards_contents');
	var togglers = $$('div.billboards_toggler table td.last_column a');

	Fx.Accordion.addMethods({
		__hide_all: function()
		{
			this.__prev_index = null;
			if(this.previousClick != 'nan') {
				this.__prev_index = this.previousClick;
			}
			this.elements.each(function(el, key){
				if(this.__prev_index != key && !el.hasClassName('opened')) {
					el.hide();
				}
			}.bind(this));
		},
		__click: function(ind) {
			this.__prev_index = ind;
		}
	});

	var acc = new Fx.Accordion(togglers, contents, {
		start: null,
		onComplete: function() {
			if( this.__prev_index != null
				&& this.__prev_index != this.previousClick) {
				this.elements[this.__prev_index].hide();
			}
			this.__click(this.previousClick);
		},
		onActive: function(e) {
			e.addClassName('open');
			container = $('image_container_' + e.id.toString().replace('more_info_', ''));
			container.src = container.readAttribute('longdesc');
		},
		onBackground: function(e) {
			if (e.hasClassName('opened')) e.removeClassName('opened');
			e.removeClassName('open');
		}
	});
	acc.__hide_all();
	
});

function showBigImage(container, src) {
	$(container).src = src;
}
