function ChangingCovers(){
	
	var current_image = 0;
	var images = new Array();
	var image_sources = new Array();

    this.init = function(){
    	(function($) {
			if ($('#changingCovers')) {
				images = $('#changingCovers > div');
				changingCovers.preload();
				
				//hide open book 
				// IF IE
				
				if ($.browser.msie) {
					$('#bookOpenContent').css('visibility', "hidden");
				}
				else {
					$('#bookOpenContent').css('display', "none");
				}
		
				
				
				$('#changingCovers').css('display', "block");
				$('#readMore').css('display', "block");
				
				if(images.length > 1)
				window.setTimeout("changingCovers.showNext()", 2000);
			}
    	})(jQuery);
    }
	
    
	this.showNext = function(){
		(function($) {
			changingCovers.preload();
			
			if ($.browser.msie) 
			$(images[current_image]).css('display', "none");
			else 
			$(images[current_image]).fadeOut('slow');
			
			
			if(current_image < images.length - 1)
			current_image++;
			else 
			current_image = 0;
			
			if ($.browser.msie) 
			$(images[current_image]).css('display', "block");
			else 
			$(images[current_image]).fadeIn('slow');
			
				
			
			
			window.setTimeout("changingCovers.showNext()", 2000);
			
		})(jQuery);
	}
	
	this.showContent = function(){
		if ($.browser.msie) {
			$('#changingCovers').css('display', "none");
			$('#readMore').css('display', "none");
			$('#bookOpenContent').css('visibility', "visible");
		}
		else {
			$('#changingCovers').fadeOut('slow');
			$('#readMore').fadeOut('slow');
			$('#bookOpenContent').fadeIn('slow');
		}
	}
	
	this.showCovers = function(){
		if ($.browser.msie) {
			$('#changingCovers').css('display', "block");
			$('#readMore').css('display', "block");
			$('#bookOpenContent').css('visibility', "hidden");
		}
		else {
			$('#changingCovers').fadeIn('slow');
			$('#readMore').fadeIn('slow');
			$('#bookOpenContent').fadeOut('slow');
		}
	}
	
	this.preload = function(){
		if(current_image < images.length - 2)
		$('#'+ images[current_image + 2].id + ' img')[0].src = image_sources[current_image + 2];
		
		if(current_image < images.length - 1)
		$('#'+ images[current_image + 1].id + ' img')[0].src = image_sources[current_image + 1];
	} 
	
	this.setImageSources = function(is){
		image_sources = is;
	}

    var self = this;
}

var changingCovers = new ChangingCovers();


(function($) {
	$(document).ready(function(){
		changingCovers.init();
	});

})(jQuery);
