// MT1.11 Compat
var $E = function(selector, filter){return ($(filter) || document).getElement(selector);};
var $ES = function(selector, filter){return ($(filter) || document).getElements(selector);};

var rotate = {};

window.addEvent('domready', function() {
	var logos = $$('ul.icons li a');
	rotate = new logo_rotate(logos);
});

var logo_rotate = new Class({
	
	fade_delay:		1500,
	fade_duration:	2000,
	
	items:		null,
	cur_item:	null,
	last_item:	null,
	
	initialize: function(elements)
	{
		if(!elements || elements.length == 0) return false;
		
		this.items		=	elements;
		this.cur_item	=	0;
		this.last_item	=	null;
		
		this.items.each(function(el) {
			el.fx	=	new Fx.Tween(el, {property: 'opacity', duration: this.fade_duration});
		}.bind(this));
		
		this.rotate();
	},
	
	rotate: function()
	{
		var fx	=	this.items[this.cur_item].fx;
		
		fx.start(0.2, 1).chain(function() {
			fx.start(1, 0.2);
		});
		
		this.last_item	=	this.cur_item;
		this.cur_item	=	(this.cur_item + 1) % this.items.length;
		
		this.rotate.delay(this.fade_delay, this);
	},
});

