var matList = [
{ title: 'Gres 1', src: 'img/gres1.jpg'},
{ title: 'Gres 2', src: 'img/gres2.jpg'},
{ title: 'Gres 3', src: 'img/gres3.jpg'},
{ title: 'Gres 4', src: 'img/gres4.jpg'},
{ title: 'Gres 5', src: 'img/gres5.jpg'},
{ title: 'Gres 6', src: 'img/gres6.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);



