function ImageSwitcher (id, imgs, start) {
  this.init (id, imgs, start);
}

ImageSwitcher.prototype = {
  constructor: ImageSwitcher,

  init: function(id, imgs, start) {
      this.imgID = id;
      this.images = imgs;
      this.lastImg = this.images.length - 1;
      this.currentImg = start && typeof start == 'number' ? start - 1 : 0;
  },

  next: function() {
      nextImg = this.currentImg + 1;
      if(this.currentImg >= this.lastImg) {
        document.getElementById(this.imgID).src = this.images[0];
        this.currentImg = 0;
      } else {
        document.getElementById(this.imgID).src = this.images[nextImg];
        this.currentImg = nextImg;
      }
  },

  previous: function() {
      previousImg = this.currentImg - 1;
      if(this.currentImg <= 0) {
        document.getElementById(this.imgID).src = this.images[this.lastImg];
        this.currentImg = this.lastImg;
      } else {
        document.getElementById(this.imgID).src = this.images[previousImg];
        this.currentImg = previousImg;
      }
    },

  goTo: function(number) {
      if(this.images[number - 1]) {
        document.getElementById(this.imgID).src = this.images[number - 1];
        this.currentImg = number - 1;
        return true;
      }
      return false;
  }
};       