/*
 * $Id: fotoModule.js 27 2010-09-09 06:53:12Z root $
 */
/**
 * Foto album JavaScript
 * @author Joris van de Sande   <joris@prezent.nl>
 */
 
function FotoScroller(images, element) {
    this.images = images;
    this.imgElement = element.getElementsByTagName('img')[0];
    this.currentImage = 1;
    
    this.next = function () { 
            if (this.currentImage < this.images.length) { this.show(this.currentImage+1); }
        };
        
    this.previous = function () { 
            if (this.currentImage > 1) { this.show(this.currentImage-1); }
        };
    
    this.show = function(nr) {
            if (nr > 0 && nr <= this.images.length) {
                this.currentImage = nr;
                --nr;
                var img = new Image();
                var imgElement = this.imgElement;
                img.onload = function() { imgElement.src = images[nr]; }
                img.src = images[nr];
            }
        };
    
}

var fotoScroller;
