var matList = [
{ title: 'Cotti 1', src: 'img/cotto1.jpg'},
{ title: 'Cotti 2', src: 'img/cotto2.jpg'},
{ title: 'Cotti 3', src: 'img/cotto3.jpg'},
{ title: 'Cotti 4', src: 'img/cotto4.jpg'},
{ title: 'Cotti 5', src: 'img/cotto5.jpg'}];










var index = 1;
var inche = 2;

function changeMat(index) {
	var img = document.getElementById('imagemat');
	img.alt = img.title = matList[index].title;
	img.src = matList[index].src;
}

function loadNext(inche) {
	var img = document.getElementById('imageload');
	img.alt = img.title = matList[inche].title;
	img.src = matList[inche].src;
}

function nextMat() {
	new Effect.Fade('imagemat', {  
	afterFinish: function() {		
	changeMat(index);
	new Effect.Appear('imagemat');
	loadNext(inche);
	index ++;
	inche ++;
	if (index >= matList.length) index = 1;
	if (inche >= matList.length) inche = 2;
	}
}); 
}

window.setInterval(nextMat, 5000);


