var SlideshowGallery = new Class({
	
	arrSources: [],
	intPrevious: 0,
	
	initialize: function(arrSources)
	{
		this.arrSources = arrSources;
		this.intPrevious = arrSources.indexOf( $('pageImageHolder').getFirst().get('src') );
		
		new Asset.images(
			arrSources,
			{
				onComplete: function()
				{
					this.change.periodical(4000, this);
				}.bind(this)
			}
		);
	},
	
	change: function()
	{
		intCurrent = (this.intPrevious + 2 <= this.arrSources.length) ? this.intPrevious + 1 : 0;
		eleTopImage = $('pageImageHolder').getFirst();
		eleTopImage.setStyles({
			zIndex: 100
		});
		
		eleBottomImage = new Element(
			'img',
			{
				src: this.arrSources[intCurrent],
				'class': 'pageImage',
				style: {
					zIndex: 1
				}
			}
		).inject('pageImageHolder');
		
		eleTopImage.set(
			'tween',
			{
				duration: 800,
				onComplete: function() { this.element.destroy() }
			}
		).tween('opacity', 0);
		this.intPrevious = intCurrent;
	}
	
});


window.addEvent("domready", function() {
	var objGallery = new SlideshowGallery( ["http://www.thebellettini.com/z_img/bellettini_flourish.jpg","http://www.thebellettini.com/z_img/bellettini_goodheart.jpg","http://www.thebellettini.com/z_img/bellettini_strength.jpg"] );
});	

