/* Site scripts */
/* Requires Scriptaculous 1.8 */

Event.observe(window,'load',function(){
	Intro.init({trans: 2, pause: 3});
	Slides.init({trans: 2, pause: 8});
});

var Intro = {

	init: function(options) {
		if(!$('intro')) return false;
		Intro.cont = $('intro');
		Intro.trans = options.trans;
		Intro.pause = options.pause;
		Intro.start();
	},
	
	start: function() {
	
		$('intro1').appear({ duration: Intro.trans });
		Intro.tween.delay(Intro.pause);
	},
	
	tween: function() {
		$('intro1').fade({ duration: Intro.trans });
		$('intro2').appear({ duration: Intro.trans });
		Intro.end.delay(Intro.pause);
	},
	
	end: function() {
		$('intro2').fade({ duration: Intro.trans });
		(function(){window.location = 'home.html';}).delay(Intro.trans+1);
	}

};

var Slides = {

	init: function(options) {
		if(!$('slides')) return false;
		Slides.cont = $('slides');
		Slides.slides = $('slides').select('li');
		Slides.count = 0;
		Slides.trans = options.trans;
		Slides.pause = options.pause;
		Slides.start();
	},
	
	start: function() {
		current = Slides.slides[Slides.count];
		$(current).appear({ duration: Slides.trans });
		Slides.tween.delay(Slides.pause);
	},
	
	tween: function() {
		current = Slides.slides[Slides.count];
		Slides.count = (Slides.count + 1 ) % Slides.slides.length;
		next = Slides.slides[Slides.count];
		current.fade({ duration: Slides.trans });
		next.appear({ duration: Slides.trans });
		Slides.tween.delay(Slides.pause);
	}

};