<!--
	// -------------------------------------------------
	// gallery
	// -------------------------------------------------

    function CL_galleryFireEvent(name,index)
    {
        var o_doc = parent.document;
        
        if (o_doc && o_doc.doGallerySetImage!=null)
            o_doc.doGallerySetImage(index);
        
    }
    
    function CL_gallerySetImage(index)
    {
        var o_image = MM_findObj('GalleryImage');

        if (o_image)
        {
            _currentImage = parseInt(index);
            o_image.src = _imageUrls[index];
            o_image.title = _imageTooltips[index];
        }

        var o_div = MM_findObj('GalleryPosition');
        if (o_div)
            o_div.innerHTML = _positionFormat.replace('{0}', _currentImage+1).replace('{1}',_maxImages);

        var o_desc = MM_findObj('GalleryImageDescription');
        if (o_desc)
            o_desc.innerHTML = _imageDescriptions[index];
            
        window.scrollTo(0, 0);
    }    
    
    function CL_galleryMove(direction) 
    {
        switch (direction) {
            case "previous":
                if (_currentImage>0) 
                    _currentImage--;
                else
                    _currentImage = _maxImages-1;                    
                break;
                
            case "next":
                if (_currentImage < _maxImages-1) 
                    _currentImage++;
                else
                    _currentImage=0;                
                break;
                
            case "first":
                _currentImage = 0;
                break;
                
            case "last":
                _currentImage = _maxImages-1;
                break;
        }
        
        CL_gallerySetImage(_currentImage);
    }

    function CL_DoSlideShow()
    {
        if (!_showStopped)
        {
            CL_galleryMove('next');
            window.setTimeout("CL_DoSlideShow()", NI_TIMEOUT);
        }
    }

    function CL_gallerySlideShowStop()
    {
        _showStopped = true;
        CL_gallerySetImage(0);
        
        var o_image = MM_findObj('GalleryToggleImage');
        if (o_image) o_image.src = '/media/gallery/icon_start.gif';
    }

    function CL_gallerySlideShowToggle()
    {
        _showStopped = !_showStopped;

        var o_image = MM_findObj('GalleryToggleImage');
        if (o_image)
            o_image.src = _showStopped ? '/media/gallery/icon_start.gif' : '/media/gallery/icon_break.gif';
        
        window.setTimeout("CL_DoSlideShow()", NI_TIMEOUT);
    }

	// -------------------------------------------------
	// definitions
	// -------------------------------------------------

    // definitions
    var NI_TIMEOUT = 3000;

    // variables
    var _currentImage = 0;
    var _showStopped = true;
    
    // register function
    document.doGallerySetImage = CL_gallerySetImage;

//-->

//---------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------//
function Gallery()
{
    // some contants
    var timeout = 3000;
    
    // ids of the used html elements
    var galleryImage = "GalleryImage";
    var galleryToggleImage = "GalleryToggleImage";
    var galleryImageDescription = "GalleryImageDescription";
    var galleryPosition = "GalleryPosition";
    var positionFormat = "{0}/{1}";

    
    // implementation

    this.current_image = 0;
    this.images = new Array();
    
    this.setImage = function(i) 
    {
        obj = document.getElementById(galleryImage);
        if (obj != null) {
        
            obj.src = this.images[i].file;
            //obj.src = obj.src.replace("_n_", "_b_");
            this.current_image = i;
        }
        
        var o_div = MM_findObj(galleryPosition);
        if (o_div)
            o_div.innerHTML = positionFormat.replace('{0}', this.current_image + 1).replace('{1}',this.images.length);

        var o_desc = MM_findObj(galleryImageDescription);
        if (o_desc)
            o_desc.innerHTML = this.images[i].description;
    }
    
    this.move = function (direction)
    {
        switch (direction) {
            case "previous":
                if (this.current_image>0) 
                    this.current_image--;
                else
                    this.current_image = this.images.length - 1;                    
                break;
                
            case "next":
                if (this.current_image < this.images.length - 1)
                    this.current_image++;
                else
                    this.current_image=0;                
                break;
                
            case "first":
                this.current_image = 0;
                break;
                
            case "last":
                this.current_image = this.images.length - 1;
                break;
        }
        
        this.setImage(this.current_image);        
    }    

    // Slideshow specific stuff

    this.slideshowStop = function()
    {
        showStopped_ = true;
        this.setImage(0);
        
        var o_image = MM_findObj(galleryToggleImage);
        if (o_image) o_image.src = '/media/gallery/icon_start.gif';
    }

    this.slideshowToggle = function()
    {
        showStopped_ = !showStopped_;

        var o_image = MM_findObj(galleryToggleImage);
        if (o_image)
            o_image.src = showStopped_ ? '/media/gallery/icon_start.gif' : '/media/gallery/icon_break.gif';
        
        window.setTimeout(Slideshow, timeout);
    }
    
    var that = this;
    var showStopped_ = true;

    function Slideshow()
    {
        if (!showStopped_)
        {
            that.move('next');
            window.setTimeout(Slideshow, timeout);
        }
    }
}

fotogallery = new Gallery();