function displayPsyoGalleryImage(src, name, full)
{
    $('psyo_gallery_image').src = src;
    $('psyo_gallery_image_name').innerHTML = name;
    $('psyo_gallery_image_full').href = full;
}
var psyoGalleryNavigationNext = null;
var psyoGalleryNavigationPrev = null;
function psyoGalleryDisplayPrev()
{
    var temp = null;
    $$('#psyo_gallery_images li a').each(function(el){
        if (el.href==$('psyo_gallery_image').src)
        {
            if (temp) 
            {
                temp.onclick();
                return true;
            }
        }
        temp = el;
    });    
}
function psyoGalleryDisplayNext()
{
    var temp = null;
    $$('#psyo_gallery_images li a').each(function(el){
        if ((temp) && (temp.href==$('psyo_gallery_image').src))
        {
            el.onclick();
            return true;
        }
        temp = el;
    });    
}    
var psyoGalleryImageHolder = new Array;

function Slideshow(slideshow, timeout) {
  this.slides = [];
  var nl = $(slideshow).getElementsByTagName('div');
  for (var i = 0; i < nl.length; i++) {
    if (Element.hasClassName(nl[i], 'slide')) {
      this.slides.push(nl[i]);
    }
  }
  this.timeout = timeout;
  this.current = 0;

  for (var i = 0; i < this.slides.length; i++) {
    this.slides[i].style.zIndex = this.slides.length - i;
  }

  Element.show(slideshow);
  setTimeout((function(){this.next();}).bind(this), this.timeout + 850);
}
Slideshow.prototype = {
  next: function() {
    for (var i = 0; i < this.slides.length; i++) {
      var slide = this.slides[(this.current + i) % this.slides.length];
      slide.style.zIndex = this.slides.length - i;
    }

    Effect.Fade(this.slides[this.current], {
      afterFinish: function(effect) {
        effect.element.style.zIndex = 0;
        Element.show(effect.element);
        Element.setOpacity(effect.element, 1);
      }
    });
    
    this.current = (this.current + 1) % this.slides.length;
    setTimeout((function(){this.next();}).bind(this), this.timeout + 850);
  }
}