﻿/**
 *@Class slideShow
 */
function slideShow(){
	this.queue = 0;
	this.delay = 4000;
	this.textDelay = 400;
	this.slides = $('.frames').find('.frame');
}
slideShow.prototype.update = function(){
	if(this.queue >= this.slides.length - 1 ){
		this.queue = 0;
	}else{
		this.queue ++;
	}
	this.slideFadeIn();
}
slideShow.prototype.slideFadeIn = function(){
	var self = this;
	$(this.slides[this.queue]).fadeIn('slow', function(){
		self.showText( $(this) );
	});
}
slideShow.prototype.showText = function( slide ){
	var self = this;
	function show(){
		slide.find('img.text').fadeIn('slow');
		self.slideFadeOut( slide );
	}
	setTimeout(show, this.textDelay);
}
slideShow.prototype.slideFadeOut = function( slide ){
	var self = this;
	function hide(){
		slide.fadeOut('slow',function(){
			$(this).find('img.text').hide();
			self.update();
		});
		
	}
	setTimeout(hide, this.delay);
}
