////////////////////// THE DIV BROWSER CLASS //////////////////////
// This is a class which cycles through the divs with the class
// type passed to it on creation (e.g. 'div.browseable')
function DivBrowser(cssHandle, numVisible) {

  this.forward = function() {
    // If we're at the end of the list...
    if( this.firstVisibleDiv == this.divs.length - this.numVisible ) {
      return false;
    } else {
      this.divs[this.firstVisibleDiv].hide();
      this.divs[this.firstVisibleDiv + this.numVisible].show();
      this.firstVisibleDiv++;
      return true;
    }
  }

  this.back = function() {
    // If we're at the beginning of the list...
    if( this.firstVisibleDiv == 0 ) {
      return false;
    } else {
      this.divs[this.firstVisibleDiv - 1].show();
      this.divs[this.firstVisibleDiv + this.numVisible - 1].hide();
      this.firstVisibleDiv--;
      return true;
    }
  }

  // Properties and Initialisation
  this.divs = $$(cssHandle);

  // The index (of the array ids) of the first currently visible div
  this.firstVisibleDiv = 0;
  this.numVisible = numVisible;

  // Hide all divs except the first numVisible
  for(i = 0; i < this.numVisible; i++){
    this.divs[i].show();
  }
  for(i = this.numVisible; i < this.divs.length; i++){
    this.divs[i].hide();
  }

}

/////////// END OF CYCLEOBJECT CLASS //////////////////
