var randomBackgroundCycle = new Class({
	
	
	Implements: [Options],
	
	
	options: {
		cycleTime: 4000
	},
	
	
	initialize: function(container, images, options) {
		
		
		this.setOptions(options);
		this.container = container;
		this.images = images;
		this.imageIndex = 1;
		
		
		this.loadImage.delay(this.options.cycleTime, this);
	},
	
	
	loadImage: function() {
		if (this.imageIndex == this.images.length) {
			this.imageIndex = 0;
			this.images.shuffle();
		}
		var image = new Asset.image(this.images[this.imageIndex], {
			onload: function() {
				$(this.container).setStyle('background-image', 'url(' + this.images[this.imageIndex] + ')');
				this.imageIndex++;
				this.loadImage.delay(this.options.cycleTime, this);
			}.bind(this)
		});
	}
	
	
});

