// JavaScript Document
var HOME = {
	init : function(){
		var total = $$('#imagesHome img').length;
		var tamanioFotos = new Array;
		var tamanio = 0;
		$$('#imagesHome img').each(function(element, index){
			tamanio += element.getSize().x;
			tamanioFotos[index+1] = element.getSize().x;
		});
		$('imagesHome').style.width = tamanio+'px';
		
		var posFot = 1;
		var posleft = 0;
		var divFx = new Fx.Morph($('imagesHome'), {duration:1500, transition: Fx.Transitions.Sine.easeOut});
		var sliderImg = function(){
			if (posFot == total){
				posFot = 1;
				posleft = 0;
				divFx.start({left:0});
			}
			else{
				posleft += tamanioFotos[posFot];
				divFx.start({left:'-'+posleft+'px'});
				++posFot;
			}
		}
		sliderImg.periodical(5000);
	}	
}

/* LOAD */

function addLoadEvent(fn)
{
var old = window.onload;
	if(typeof window.onload != 'function')
		window.onload = fn;
	else
	window.onload = function()
	{
		old();
		fn();
	}
}

addLoadEvent( function() { HOME.init(); } );
