function wpj_slideshow(options) {
      
   var _this = this;
   
   // Settings
   this.settings = {
      interval: 6500, // Interval between slides
      duration: 500, // Slide transition duration
      object: "[rel=slideshow]", //JQuery string for object selection
	  images: new Array()
   }
   
   if(options != null)
      jQuery.extend(this.settings, options);
   
   // Current position and number of images
   this.index = 0;
   this.size = this.settings.images.length;
   
   // Current position
   this.first = false;
   
   // Is nex image loaded?
   this.loaded = false;
   this.waitForLoad = false;
   
   this.nextImage = function(){
      this.elements[this.first?0:1].attr("src", this.settings.images[(++this.index)%this.size].src);
      if(this.settings.images[(this.index)%this.size].alt)
         this.elements[this.first?0:1].attr("alt", this.settings.images[(this.index)%this.size].alt);
      this.elements[this.first?0:1].parent().attr("href", this.settings.images[(this.index)%this.size].url);
      if(this.elements[this.first?0:1].supersleight)
         this.elements[this.first?0:1].supersleight({shim: '/images/x.gif'});
      this.first = !this.first;
   }
   
   this.animationComplete = function(){
      this.nextImage();
   }
   
   // Slideshow main function
   this.next = function(){
      
      if(this.loaded)
         this.waitForLoad = false;
      else{
         this.waitForLoad = true;
         return;
      }
      
      this.elements[0].animate({opacity:"toggle"}, this.settings.duration, "linear", function run(){_this.animationComplete();});
      this.elements[1].animate({opacity:"toggle"}, this.settings.duration);
      
      this.loaded = false;
   }
   
   // New slide is loaded
   this.imageLoaded = function(eventObject) {
      this.loaded = true;
      
      if(this.waitForLoad)
         this.next();
   }
   
   // Elements of transition
   tmpElements = $(this.settings.object);
   if(tmpElements.length != 2){
      window.alert("Selector '"+this.settings.object+"' returned "+tmpElements.length+" objects. Exactly two objects needed.");
      return false;
   }
   this.elements = new Array ($(tmpElements.get(0)),$(tmpElements.get(1)));
   this.elements[0].show();
   this.elements[1].hide();
   
   // Append event to mark the nex image is loaded.
   tmpElements.load(
      function run(e){
         _this.imageLoaded(e);
      }
   );
   
   this.nextImage();
   
   // Interval handler
   this.clock = setInterval(
      function run(){
         _this.next();
      }
      , this.settings.interval);
}
