var imgactive=null;
var nextimg=null;
var myI = new Array();
var myF = new Array();

function showme() {
	myI = $('photo0','photo1');
	myF = $('fade0','fade1');
	imgactive=0;
	nextimg=1;
	new Effect.Appear(myF[imgactive], {
	  duration: 1,
	  fps: 50,
	  queue:'end'
	});

	// aspetta 7 sec e poi scatena caricamento altra immagine
	if(photoarray.length<2) return;
	setTimeout('loadnext()',7000);
}

function loadnext() {
	myI[1-imgactive].onload = function() { dissolve() }
	myI[1-imgactive].src = photoarray[nextimg++];	// start loading other image
	if(nextimg == photoarray.length) nextimg=0;
}

function dissolve() {
	imgactive=1-imgactive;
	new Effect.Fade(myF[1-imgactive], {
		duration: 1, 
		fps: 50, 
		afterFinish: function() {
			new Effect.Appear(myF[imgactive], {
			  duration: 1,
			  fps: 50,
			  queue:'end'
			})
		} 
	});

	// aspetta 7 sec e poi scatena caricamento altra immagine
	if(photoarray.length<2) return;
	setTimeout('loadnext()',7000);
}
