// (c) 2008 Iris Associates Ltd.

var imageSlideshow = {
	imageList: null,
	activeImage: 0,

	init: function() {
		var ilContainer = null;
		if(ilContainer = $('main'))
		{
			this.imageList = new Array();
			$A(ilContainer.getElementsByTagName('img')).each(function(s, i) {
				imageSlideshow.imageList.push(s);
			});

			new PeriodicalExecuter(this.changeImage.bindAsEventListener(imageSlideshow), 5);
		}
	},

	changeImage: function() {
		var maxImages = this.imageList.length - 1;
		var nextIndex = ((this.activeImage + 1) > maxImages) ? 0 : (this.activeImage + 1);

		Effect.Fade(this.imageList[this.activeImage], { from: 1.0, to: 0.0, afterFinish: function() { Effect.Appear(imageSlideshow.imageList[nextIndex], { from: 0.0, to: 1.0 }) } });
		//Effect.Appear(imageSlideshow.imageList[nextIndex]);
		this.activeImage = nextIndex;
	}
};

imageSlideshow.init();

Event.observe(window, 'load', function() { new accordion('vertical_container').activate($$('#vertical_container .accordion_toggle')[0]); }, false);

var verticalAccordions = $$('.accordion_toggle');
verticalAccordions.each(function(accordion) {
	$(accordion.next(0)).setStyle({
	  height: '0px'
	});
});