var images = [];
var i = 1;

window.addEvent('domready', function() {
	images = $$('.home-links .images div');
	
	images.setOpacity(0);
	images[0].setOpacity(1);
	
	setTimeout('animation()', 4000);
});

function animation() {
	if (i < images.length) {
		images[i].effects().start({'opacity': 1}, 500).chain(function() {
			var prev = i - 2;
			if (prev > 0) images[prev].setOpacity(0);
			setTimeout('animation()', 4000);
		});
	} else if (i == images.length) {
		images[i - 1].effects().start({'opacity': 0}, 500).chain(function() {
			setTimeout('animation()', 4000);
		});
	}
	
	if (i++ >= images.length) i = 1;
}