// JavaScript Document

function slideshow(numero_immagini, larghezza_immagini, sorgente_immagini, riferimento_elemento) {
	this.nImg=numero_immagini;
	this.imgWidth=larghezza_immagini;
	this.imgSrc=sorgente_immagini;
	this.rif=riferimento_elemento;
	this.pos=0;
	$(riferimento_elemento).css("background","url("+sorgente_immagini+") 0 0 no-repeat");
	this.i=1;
	this.slideSwitch=nextSlide;
}


function nextSlide() {
	if(this.i>=this.nImg) this.i=0;
	this.pos=this.imgWidth*this.i;
	var element=this;
	$(element.rif).animate({opacity: 0.0}, 1000, function() {
		$(element.rif).css("background","url("+element.imgSrc+") -"+element.pos+"px 0 no-repeat").animate({opacity: 1.0}, 1500);
	});
	//$(this.rif).css("opacity","0.0").css("background","url("+this.imgSrc+") -"+this.pos+"px 0 no-repeat").animate({opacity: 1.0}, 1500);

	this.i++;	
}


//var slide=new slideshow(3,354,"style/img/machines.png","#macchina");
//$(function() {    setInterval( "slide.slideSwitch()", 4500 ); });

