var ImageScroller = new Class({
  initialize: function(container) {
    var self = this;
    this.container = container;
    this.nodes = container.getChildren('img');
    this.current = 0;
    if (this.nodes.length > 1) {
      this.container.grab(this.createNav());
    }
    this.nodes[this.current].setStyle('display','');
  },
  createNav: function() {
    var node = new Element('div').set('html',
      '<span class="pagination">Page <span class="page-num">1</span> of <span class="page-total">' + this.nodes.length + '</span></span><a href="#" class="next">Next &raquo;</a>'
    );
    node.getElement('.next').addEvent('click',this.moveNext.bindWithEvent(this));
    return node;
  },
  moveNext: function(ev) {
    new Event(ev).preventDefault();
    this.nodes[this.current].setStyle('display','none');
    this.current++;
    this.current = this.current % this.nodes.length;
    this.nodes[this.current].setStyle('display','');
    this.container.getElement('.page-num').set('text',this.current+1);
  }
});