function Lightbox() {
	
	var arrayPageSize;
	var arrayPageScroll;
	var lightBoxHeight;
	var lightBoxWidth;
	
	var ScrollY;
	
	//
	// getPageScroll()
	// Returns array with x,y page scroll values.
	// Core code from - quirksmode.org
	//
	this.getPageScroll = function() {
	
		if (self.pageYOffset) {
			this.ScrollY = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			this.ScrollY = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			this.ScrollY = document.body.scrollTop;
		}

	}



	//
	// getPageSize()
	// Returns array with page width, height and window width, height
	// Core code from - quirksmode.org
	// Edit for Firefox by pHaez
	//
	this.getPageSize = function(){
		
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
	
		return new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

	}	
	

	//
	// showLightbox()
	// Preloads images. Pleaces new image in lightbox then centers and displays.
	//
	this.showLightbox = function() {
		
		var tmpPageScroll = 0;
		// tmpPageScroll = this.ScrollY;
		
		// prep objects
		var objOverlay = document.getElementById('overlay');
		var objLightbox = document.getElementById('lightbox');
		
		//  set options to lightbox
		objLightbox.style.height = this.lightBoxHeight + 'px';
		objLightbox.style.width = this.lightBoxWidth + 'px';
	
		this.getPageScroll();
		arrayPageSize = this.getPageSize();
	
		var htmlObj = document.getElementsByTagName("html");
		htmlObj[0].style.overflow = "hidden";
	
		// set height of Overlay to take up whole page and show
		//objOverlay.style.height = (arrayPageSize[1] + 'px');
		objOverlay.style.display = 'block';
	
		window.scrollTo(0, 0);
	
		// center lightbox and make sure that the top and left values are not negative
		// and the image placed outside the viewport
		var lightboxTop = tmpPageScroll + ((arrayPageSize[3] - 35 - this.lightBoxHeight) / 2);
		var lightboxLeft = ((arrayPageSize[0] - 20 - this.lightBoxWidth) / 2);
		
		objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
		objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
	
		// Hide select boxes as they will 'peek' through the image in IE
		selects = document.getElementsByTagName("select");
	  for (i = 0; i != selects.length; i++) {
		  	if (selects[i].id != 'doNotHideForOverlay')
				selects[i].style.visibility = "hidden";
	  }
		
		objLightbox.style.display = 'block';
		
	}



	//
	// hideLightbox()
	//
	this.hideLightbox = function() {
		// get objects
		objOverlay = document.getElementById('overlay');
		objLightbox = document.getElementById('lightbox');
	
		// hide lightbox and overlay
		objOverlay.style.display = 'none';
		objLightbox.style.display = 'none';
	
		// make select boxes visible
		selects = document.getElementsByTagName("select");
		 for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "visible";
		}
		
		var htmlObj = document.getElementsByTagName("html").item(0);
		htmlObj.style.overflow = "auto";
		
		window.scrollTo(0, this.ScrollY);

	}


	this.setLightboxSettings = function(externalWidth, externalHeight) {
			
		this.lightBoxHeight = externalHeight;
		this.lightBoxWidth = externalWidth;
		
	}

	//
	// initLightbox()
	// Function runs on window load, going through link tags looking for rel="lightbox".
	// These links receive onclick events that enable the lightbox display for their targets.
	// The function also inserts html markup at the top of the page which will be used as a
	// container for the overlay pattern and the inline image.
	//
	this.initLightbox = function() {
		
		var objBody = document.getElementsByTagName("body").item(0);
		
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.onclick = function () {return false;}
		objOverlay.style.display = 'none';
		objOverlay.style.position = 'absolute';
		objOverlay.style.top = '0';
		objOverlay.style.left = '0';
		objOverlay.style.zIndex = '90';
		objOverlay.style.width = '2000px';
		objOverlay.style.height = '3000px';
		objBody.insertBefore(objOverlay, objBody.firstChild);	
		
	}



}