var PhotoSlideshow = Class.create({
 initialize: function(el, timeout) {
   this.el = el;
   this.timeout = timeout || 5000;
   Event.observe(window, 'load', this.onload.bind(this));
 },
 
 onload: function() {
   this.el = $(this.el);
   this.photos = this.el.childElements();
   if (this.photos.length <= 1) return;
   for (var i = 1; i < this.photos.length; i++) {
     this.photos[i].setOpacity(0.0);
     this.photos[i].show();
   }
   this.current = 0;
   if (this.photos.length == 0) return;
   window.setTimeout(this.next.bind(this), this.timeout);
 },
 
 next: function() {
   var hide = new Effect.Fade($(this.photos[this.current]), { sync: true, queue: 'end' });
   this.current = (this.current + 1) % this.photos.length;
   var show = new Effect.Appear($(this.photos[this.current]), { sync: true, queue: 'end' });
   new Effect.Parallel([hide, show], { duration: 2.0 });
   window.setTimeout(this.next.bind(this), this.timeout);
 }
});