function Image(src, width, height) {
  this.src    = src;
  this.width  = width;
  this.height = height;
}

function ImagePair(id, largeSrc, largeWidth, largeHeight) {
  var img          = document.getElementById(id); // existing small image

  this.smallImage  = new Image(img.src,  img.width,  img.height);
  this.largeImage  = new Image(largeSrc, largeWidth, largeHeight);
  this.smallActive = 1;
  img.title        = 'Click to enlarge';
}

function SwapImage(id, imagePair) {
  var newImage, newTitle;

  with(imagePair) {
    if (smallActive == 0) {
      // Switch to small
      newImage    = smallImage;
      newTitle    = 'Click to enlarge';
      smallActive = 1;
    } else {
      // Switch to large
      newImage    = largeImage;
      newTitle    = 'Click to reduce';
      smallActive = 0;
    }
  }

  // Load it
  var img    = document.getElementById(id);
  img.src    = newImage.src;
  img.width  = newImage.width;
  img.height = newImage.height;
  img.title  = newTitle;
}

