var pictures, Pictures = Class.create();

Pictures.prototype = {
	initialize: function(){
		this.container = $("pictures");
		window.setTimeout(function(){ this.container.addClassName("loaded"); }.bind(this), 2000);

		this.elements = this.container.select('div.picture');
		
		this.first = true;

		this.play(false);
	},
	
	play: function(skip_first){
		i = 0;
		if(skip_first) i = 1;
	
		for(var i; i<this.elements.length; i++){
			this.highlight.bind(this).delay((i*5.5), i);
		}
		
		window.setTimeout(function(){
			pictures.move_up(pictures.elements.length-1);
		
			pictures.play(false);
		}, (this.elements.length)*5500);
	},
	
	highlight: function(index){	
		if(index > 0){
			this.move_up(index-1);
		}
		
		this.move_down(index);
	},
	
	move_up: function(index){
		if(!Prototype.Browser.IE) this.elements[index].fade({duration: 0.5});
		else {
			window.setTimeout(function(){ this.elements[index].hide(); }.bind(this, index), 750);
		}
		
		new Effect.Move(this.elements[index], {y: -124, mode: 'relative', duration: 0.75, transition: Effect.Transitions.EaseFromTo});
	},
	
	move_down: function(index){
		if(!Prototype.Browser.IE) this.elements[index].appear({delay: 1, duration: 0.5});
		else {
			window.setTimeout(function(){ this.elements[index].show(); }.bind(this, index), 1000);
		}

		new Effect.Move(this.elements[index], {y: 124, mode: 'relative', duration: 1, delay: 1, transition: Effect.Transitions.Bounce});
	}
}