function Gallery() {

	var gallery;
	var wrapper;
	var slider;
	var scroller;
	var images;
	var thumbs;
	var offset;
	
	var linkUp;
	var linkDown;
	
	var scrollerHeight;
	var sliderHeight;
	
	var limiteInf;
	var limiteSup;
	
	var indiceFoto;
	var totaleFoto;
	
	var event;
	
	var G;
	
	this.init = function init(container, event) {
		G = this;
		
		this.gallery  = $(container);
		this.wrapper  = this.gallery.find('.wrapperImmagini');
		this.slider   = this.gallery.find('.sliderImmagini');
		this.scroller = this.slider.find('.scroller');
		this.images   = this.wrapper.find('.immagine');
		this.thumbs   = this.slider.find('.immagine');
		
		this.event    = event;
		
		this.linkUp     = this.gallery.find('.scrollUpHandler');
		this.linkDown   = this.gallery.find('.scrollDownHandler');
		
		this.indiceFoto = this.gallery.find('.indiceFoto');
		this.totaleFoto = this.gallery.find('.totaleFoto');
		
		this.indiceFoto.html(1);
		this.totaleFoto.html(this.images.length);
		
		//calcolo i limiti di scorrimento...
		this.scrollerHeight = this.scroller.height();
		this.sliderHeight   = this.slider.height();
		
		this.limiteInf = this.sliderHeight - this.scrollerHeight +15;
		this.limiteSup = 0;
		
		this.offset = 0;
		
		//preparo le immagini...
		this.images.not(':first').hide();
		
		this.handleEvents();
	}
	
	//cambia l'immagine visualizzata...
	this.swap = function swap(elem) {
			G.index = G.thumbs.index(elem);
			G.currentImage = G.images.eq(G.index);
			G.currentImage.fadeIn('fast');
			G.images.filter(':visible').not(G.currentImage).fadeOut('fast');
			G.indiceFoto.html(G.index + 1);
	}
	
	//muove il pannello in alto
	this.scrollUp = function scrollUp() {
			if (G.offset < G.limiteSup && !G.isMoving()) {
				G.offset += 105;
				G.scroller.animate({top: G.offset});
			}			
	}
	
	//muove il pannello in basso
	this.scrollDown = function scrollDown() {
			if (G.offset > G.limiteInf && !G.isMoving()) {
				G.offset -= 105;
				G.scroller.animate({top: G.offset});
			}
	}
	
	//determina se l'animazione è ancora in corso...
	this.isMoving = function isMoving() {
		if (G.scroller.queue('fx') == 0) {
			return false;
		} else {
			return true;
		}
	}
	
	//gestisce gli eventi della gallery
	this.handleEvents = function handleEvents() {
		//gestisco gli eventi...		
		this.linkDown.click(function() {
			G.scrollDown();
			return false;
		});
		
		this.linkUp.click(function() {
			G.scrollUp();
			return false;
		});
		
		if (G.event == 'mouseover') {
			this.thumbs.mouseover(function() {
				G.swap(this);
			});
		}
		
		this.thumbs.click(function() {
			G.swap(this);
			return false;
		});

		this.slider.mousewheel(function(event, delta) {
			if (delta<0) {
				G.scrollDown();
			} else {
				G.scrollUp();
			}
			return false;
		});
	}
}