function getPageSize(){
	
	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;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function showLightbox()
{
	var arrayPageSize=getPageSize();
	var objOverlay = document.getElementById('overlay');
	var objLightbox = document.getElementById('lightbox');
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		objOverlay.style.width = '100%';
		objOverlay.style.height = (arrayPageSize[1] + 'px');
	}else{
		objOverlay.style.width = (arrayPageSize[0] + 'px');
		objOverlay.style.height = ((arrayPageSize[1]+40) + 'px');
	}
	objOverlay.style.display = 'block';
	objLightbox.style.display = 'block';	
}

function hideLightbox()
{
	// get objects
	objOverlay = document.getElementById('overlay');
	objLightbox = document.getElementById('lightbox');

	//hide lightbox and overlay
	objOverlay.style.display = 'none';
	objLightbox.style.display = 'none';
}
function setLightbox(objLightboxWidth)
{
	var arrayPageSize=getPageSize();
	objLightbox = document.getElementById('lightbox');
	objLightbox.style.marginLeft = '-'+(objLightboxWidth/2)+'px';
	objLightbox.style.marginTop =((document.documentElement.scrollTop+(arrayPageSize[3]/2)-100) + 'px');
}
function initLightbox()
{
	var objBody = document.getElementsByTagName("body").item(0);
	
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '90';
	objOverlay.style.display = 'none';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	
	var objLightbox = document.createElement("div");
	objLightbox.setAttribute('id','lightbox');
	objLightbox.style.display = 'none';
	objLightbox.style.position = 'absolute';
	objLightbox.style.zIndex = '100';
	objLightbox.style.marginTop = '360px';
	objLightbox.style.left = '50%';
	objLightbox.style.marginLeft = '-300px';
	objBody.insertBefore(objLightbox, objOverlay.nextSibling);
}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}

}

//addLoadEvent(initLightbox);	// run initLightbox onLoad
