var slideshow = Class.create({
	
	initialize: function(container) {
		
		
		
		
		this.initshow(container);
		
	},
	initshow: function(container){
		
		this.container = $(container);
	
		this.image_slides = this.container.select('.fade-box');
		this.pos = this.image_slides.length-1;
		this.image_slides.each(function(b){
			b.hide();
		})
	
		this.StartSlide();
	},
	StartSlide: function(){
	
		if(this.play){
				window.clearInterval(this.play);
			};
			
		this.play = setInterval(this.PlaySlide.bind(this),2000);
		this.PlaySlide();
	},
	SwapImages: function(x,y){
		this.image_slides[x].appear({ duration: 1.0 });
		this.image_slides[y].fade({duration: 1.0});
	
	},
	stop: function(){
		if(this.play){
				window.clearInterval(this.play);
			};
	},
	PlaySlide: function(){
		
		

		var imageShow = this.pos+1;
		var imageHide = this.pos;
		
		
	
		if (imageShow == this.image_slides.length) {
			this.SwapImages(0,imageHide);	
			this.pos = 0;					
		} else {
			this.SwapImages(imageShow,imageHide);			
			this.pos++;
		}
	}
	


});