var PhotoSlideshow = Class.create({
 initialize: function(el, timeout) {
   this.el = el;
   this.timeout = timeout || 8000;
   Event.observe(window, 'load', this.onload.bind(this));
 },
 
 onload: function() {
   this.el = $(this.el);
   if(!this.el) return;
   this.photos = this.el.childElements();
   this.current = -1;
   if (this.photos.length == 0) return;
   this.next();
 },
 
 next: function() {
   if (this.current !== -1) {
     new Effect.Fade(this.photos[this.current], { queue: 'end' });
   }

   this.current = (this.current + 1) % this.photos.length;
   
   new Effect.Appear(this.photos[this.current], { queue: 'end' });
   
   window.setTimeout(this.next.bind(this), this.timeout);
 }
});
