// Shuffler
//
// Given elements and a morph, it will perform the morph on each element at a set interval.
// You can do a lot of different effects with this thing.
// Also, you can specify initial properties in startProps, either is a property list, or a css class.

var Shuffler = new Class ({		
	
	Extends: Fx.CSS,
	
	initialize: function (elements, options, startProps) {
		this.elements = $$(elements);
		if (!options) options = new Object();
		this.options = options;
		if (!options.duration) this.options.duration = 400;
		if (!options.transition) this.options.transition = Fx.Transitions.Back.easeOut;
		if (!options.link) this.options.link = 'ignore';

		if ($type(startProps) == 'string') startProps = this.search(startProps);
		this.elements.each(function(el, i){
			for (var p in startProps){
				el.setStyle (p, startProps[p]);
			}
		}, this);

		return this;
	},
	
	
	start: function(properties, period) {
		if (!period) period = 150;
		var timer = 0;
		var slidefxs = [];
		
		this.elements.each(function(el, i){
			timer += period;
			slidefxs[i] = new Fx.Morph(el, this.options);
			slidefxs[i].start.delay(timer, slidefxs[i], properties);

		}, this);
	}
});
