var HSlideshow = Class.create({//{{{
  initialize:function(rootId,info) {//{{{
    var i=0;
    this.objRoot = $(rootId);
    this.arrInfo = urlDecodeArray(info);
    this.arrImages = new Array();
    this.intCurrpos = 0;

    for(var i=0; i<this.arrInfo.length; i++) {
      var img = new Element('img');
      img.src = this.arrInfo[i][0];
      this.arrImages.push(img);
      this.objRoot.appendChild(this.arrImages[i]);
    }
  },//}}}
  run:function() {/*{{{*/
    this.intCurrpos = 0;
    this.next();
    new PeriodicalExecuter(this.next.bind(this),8);
    //setInterval(HSlideshow.next.bind(this),5000);
  },/*}}}*/
  next:function() {/*{{{*/
    if(this.arrImages.length <= 1)
      return;
    var i=0;
    var newpos = this.intCurrpos + 1;
    if(newpos == this.arrImages.length)
      newpos = 0;
    // Set current z-index to 2
    this.arrImages[this.intCurrpos].style.zIndex = 2;
    // New image z-index to 3
    this.arrImages[newpos].style.zIndex = 3;
    // Set other z-indexes to 1
    for(i=0; i<this.arrImages.length; i++) {
      if(i != newpos && i != this.intCurrpos) {
	this.arrImages[i].style.sIndex = 1;
      }
    }
    // Fade current out
    this.arrImages[this.intCurrpos].fade({"duration":"3.0"});
    // Fade new in
    this.arrImages[newpos].appear({"duration":"3.0"});

    $('slideshowtext').innerHTML = "";
    $('slideshowtext').appendChild(document.createTextNode(
	  " - " + this.arrInfo[newpos][1]
	  ));

    // Update current pos (to new)
    this.intCurrpos = newpos;
  }/*}}}*/
});//}}}

