// QEffects helper class used in conjunction with Mootools to animate and chain a group of objects
// These functions are specific to mootools.

QElements = new Class({
	initialize: function (elements, options) {
		this.elements = $$(elements);
		this.options = options;
	},

	start: function (props) {
		this.elements.each (function (el, j) {
			el.get('morph', this.options).start(props);
		}, this);
		this.options = null;	// required for chaining
		return this;
	}
});

// QShuffler
//
// 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 in a property list, or a css class.

QShuffler = 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 (startProps) {
			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);
	}
});

