var slideShow = {
	images: null,
	timer: null,
	effect: null,
	interval: 7000,
	current: 0,
	max: 0,
	showNext: function () {
		this.timer = setTimeout('slideShow.renderEffect()', this.interval);
		this.current++;
		if (this.current >= slideShow.max)
			this.current = 0;
	},
	renderEffect: function () {
		if (this.current == 0){
			for (i = 1; i < this.max-1; i++)
				this.images[i].hide();
			this.effect = Effect.Fade(slideShow.images[slideShow.max-1], {afterFinish: slideShow.showNext(), duration: 4.0});
		} else
			this.effect = Effect.Appear(slideShow.images[slideShow.current], {afterFinish: slideShow.showNext(), duration: 4.0});
	},
	init: function () {
		this.images = $$('#header div.image');
		this.max = this.images.length;
		if (this.max) {
			$('header').addClassName('slideshow');
			if (this.max > 1) {
				for (i = 1; i < this.max; i++)
					this.images[i].hide();
				this.showNext();
			}
		}
	}
};

Event.observe(window, 'load', function() {
	slideShow.init();
	$$('a.mailto').each(function(e){
		e.innerHTML = e.innerHTML.toLowerCase().replace('(at)', '@');
		Event.observe(e, 'click', function(){
			window.location = 'mailto:'+this.innerHTML;
		});
	});
});
