function overlayImage() {
  var selfRef = this;

  this.overlay = getOverlay();

  this.wrapper = document.createElement('div');
  this.wrapper.className = 'imageWrapper';
  this.overlay.appendChild(this.wrapper);

  this.mainDiv = document.createElement('div');
  this.mainDiv.className = 'overlayImage';
  this.wrapper.appendChild(this.mainDiv);

  var closeIcon = document.createElement('div');
  closeIcon.className = 'close';
  closeIcon.onclick = function() { selfRef.overlay.hide(); };
  this.mainDiv.appendChild(closeIcon);
}

overlayImage.prototype.show = function(imageUrl) {
  this.overlay.show();

  if (!this.image || imageUrl != this.image.src) {
    var selfRef = this;
    var newImage = new Image();
    newImage.style.visibility = 'hidden';
    newImage.onload = function() {
      selfRef.mainDiv.style.width = this.width+'px';
      this.style.visibility = 'visible';
    }
    newImage.onclick = function() { selfRef.overlay.hide(); };
    newImage.src = imageUrl;
    if (this.mainDiv.lastChild && this.mainDiv.lastChild.className != 'close') {
      this.mainDiv.replaceChild(newImage, this.mainDiv.lastChild);
    } else {
      this.mainDiv.appendChild(newImage);
    }
    this.image = newImage;
  }
  
  this.reposition();
  this.wrapper.style.display = 'block';
};

overlayImage.prototype.hide = function() {
  this.wrapper.style.display = '';
};

overlayImage.prototype.reposition = function() {
  // offset from top
  var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	
	this.wrapper.style.top = (yScroll+110)+'px';
}