var HomepageSlides = new Class.create({
	vars: {
		img_height: 497, // fixed pixel height of each image
		timeout: 3000, // pause between slides (ms) 
		speed: 2000, // duration of transition (ms)
		transition: Effect.Transitions.spring  // scriptaculous transition effect 
	},
	
	initialize: function(){
		this.wrapper = $('homepage_slides').down('.images');
		
		this.current = 1;
		this.total = this.wrapper.select('li').length;

		// let's begin
		setTimeout(function(){
			this.go();
		}.bind(this), this.vars.timeout);
	},
	
	go: function(){
		this.next = (this.total == this.current ? 1:this.current+1);
		
		this.wrapper.morph({
			top:'-'+(this.vars.img_height*(this.next-1))+'px'
		},{
			duration:this.vars.speed/1000,
			transition: this.vars.transition
		});

		setTimeout(function(){
			this.go();
		}.bind(this),this.vars.timeout+this.vars.speed);
		this.current = this.next;
	}
});

Event.observe(window,"load", function(){

	var hps = new HomepageSlides();
});
