imageAct=0;
images=new Array();
imageContainer=1;
	
function init_transiciones(el,index){
	imageAct=index
	$(el).innerHTML="<img id='buffer1' src="+images[imageAct].src+" alt=''/>";
	$(el).innerHTML+="<img id='buffer2' src='' alt=''/>";
	$('buffer1').style.position="absolute";
	$('buffer2').style.position="absolute";
	new Effect.Opacity("buffer2",{ duration: 0, from: 1, to: 0 });
	$('subheader').style.height="255px";
}
	
function timer(){
	setInterval("flip()",5000);
}
	
function random(inf,sup){
	numPosibilidades = sup - inf;
	aleat = Math.random() * numPosibilidades;
	aleat = Math.round(aleat);
	return parseInt(inf) + aleat ;
}
	
function getRandomIndexImage(i){
	var temp=0;
	do{
		temp=random(0,images.length-1);
	}while(i==temp);
	return temp;
}
	
function showBuffer1(img){
	var buffer=$("buffer1");
	buffer.src=img.src;
	new Effect.Opacity("buffer1",{ duration: 2.0, from: 0, to: 1 });
	new Effect.Opacity("buffer2",{ duration: 2.0, from: 1, to: 0 });
	imageContainer=1;
}
	
function showBuffer2(img){
	var buffer=$("buffer2");
	buffer.src=img.src;
	new Effect.Opacity("buffer2",{ duration: 2.0, from: 0, to: 1 });
	new Effect.Opacity("buffer1",{ duration: 2.0, from: 1, to: 0 });
	imageContainer=2;
}

function flip(){
	imageAct=getRandomIndexImage(imageAct);
	if (imageContainer==1){
		showBuffer2(images[imageAct]);
	}else{
		showBuffer1(images[imageAct]);
	}		
}

window.addInitHandler(timer);
	