/*
Script: Fx.MorphList.js
	Animates lists of objects with a morphing background.

	License:
		MIT-style license.

	Authors:
		Guillermo Rauch
*/

Fx.MorphList = new Class({   
	
	Implements: [Events, Options],
	
	initialize: function(options){
		var self = this;
		this.setOptions(options);
	},

	
	setCurrent: function(el, effect){  
		if (el && !this.current){
			this.bg.set('styles', el.getCoordinates(this.element));
			(effect) ? this.bg.fade('in') : this.bg.fade('show');
		}
		if (this.current) this.current.removeClass('current');
		if (el) this.current = el.addClass('current');    
		return this;
	},         
         
	morphTo: function(to){
		if (to){
			var c = to.getCoordinates(this.element);
			delete c['right']; delete c['bottom'];
			this.bg.morph(c);
			this.fireEvent('morph', to);
		}
		return this;
	}

});
