var FotoAnim = function(){
	var FotoAnim = {
		tempo: 3,
		foto: null,
		imgPreload: 0,
		iF: 0,
		idFoto: '',
		idTime: 0,
		fade_time: 0.25,
		
		//PARAMETRI DA SETTARE (necessari)
		root: '/',
		w_foto: 100,
		h_foto: 100,
		
		Init: function(){
			this.foto = new Array();
		},
		Add: function(filepath){
			this.foto[ this.foto.length ] = filepath;
			var imgObj = new Image();
			imgObj.onload = function(){
				FA.imgPreload++;
			};
			imgObj.src = this.root+'_ext/scripts/image.php?f='+filepath+'&w='+this.w_foto+'&h='+this.h_foto+'&prop=1&bg=ffffff';
		},
		Play: function(){
			if(this.foto.length>0 && this.foto.length==this.imgPreload){
				NS_fade(this.idFoto,100,0,this.fade_time, {callback: "changeFoto", obj: this});
			}
		},
		changeFoto: function(){
			if(this.idTime>0)
				clearTimeout(this.idTime);
			this.iF = this.iF == this.foto.length-1 ? 0 : this.iF+1;
			$(this.idFoto).src = this.root+'_ext/scripts/image.php?f='+this.foto[this.iF]+'&w='+this.w_foto+'&h='+this.h_foto+'&prop=1&bg=ffffff';
			NS_fade(this.idFoto,0,100,this.fade_time,false);
			this.idTime = setTimeout("FA.Play()",this.tempo*1000);
		}
	};
	FotoAnim.Init();
	return FotoAnim;
}
