//////////// Slideshow /////////
//Author:     Ondrej Jaura
//Date:       15. Feb 2009
//Version:    1.0
//Prototype:  v1.6+
//Please leave this note here 
///////////////////////////////////////

var Slideshow = Class.create({
  initialize: function(options) {
    this.div=$("slideshow");
    this.li=this.div.childElements();
    for (var i=0;i<this.li.length;i++) {
      this.li[i].setStyle({
        position: 'absolute',
        top: '0px',
        left: (i*120)+'px'
      });
      this.li[i].observe('mouseover',this.stopScroll.bindAsEventListener(this));
      this.li[i].observe('mouseout',this.startScroll.bindAsEventListener(this));
    }
    this.first=0;
    this.loop=0;
    this.step=1;
    this.delay=0.01;
    this.scrolling=this.scroll.bind(this).delay(this.delay);
  },
  scroll: function() {
    if (this.loop>=120) {
      this.loop=this.step;
      var left=parseInt(this.li[this.first].style.left);
      this.li[this.first].style.left=(left+this.li.length*120)+'px';
      this.first=(this.first+1<this.li.length)?this.first+1:0;
    }
    else {this.loop+=this.step;} 
    for (var i=0;i<this.li.length;i++) {
      this.li[i].style.left=(parseInt(this.li[i].style.left)-this.step)+'px';
    }
    this.scrolling=this.scroll.bind(this).delay(this.delay);
  },
  stopScroll: function() {
    window.clearTimeout(this.scrolling);
  },
  startScroll: function() {
    this.scrolling=this.scroll.bind(this).delay(0.5);
  }
});

function getPage(url) {
  new Ajax.Request(url, {
    onSuccess: function(transport) {
      $("text").innerHTML=transport.responseText;
    }
  });
}