messageLightbox = {}

messageLightbox.overlay = 'warning_overlay'

messageLightbox.lightbox = 'warning_lightbox'

messageLightbox.init = function()
{	
	var objBody = document.getElementsByTagName("body").item(0);
	
	// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id', messageLightbox.overlay);	
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '190';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	
	var arrayPageSize = this.getPageSize();
	var arrayPageScroll = this.getPageScroll();

	// create lightbox div, same note about styles as above
	var objLightbox = document.createElement("div");
	objLightbox.setAttribute('id', messageLightbox.lightbox);
	objLightbox.style.display = 'none';
	objLightbox.style.position = 'absolute';
	objLightbox.style.zIndex = '200';	
	objBody.insertBefore(objLightbox, objOverlay.nextSibling);	
}

messageLightbox.getPageScroll = function()
{
	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;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

messageLightbox.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;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

messageLightbox.hide = function()
{	
	// get objects
	objOverlay = document.getElementById(messageLightbox.overlay);
	objLightbox = document.getElementById(messageLightbox.lightbox);
	
	// hide lightbox and overlay    
	objOverlay.style.display = 'none';
	objLightbox.style.display = 'none';
	objLightbox.innerHTML = '';

	// make select boxes visible
	selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}	
}

messageLightbox.show = function(pars)
{			
	// prep objects
	var objOverlay = document.getElementById(this.overlay);
	var objLightbox = document.getElementById(this.lightbox);	
	
	var arrayPageSize = this.getPageSize();
	var arrayPageScroll = this.getPageScroll();	

	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';	
				
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - pars[2]) / 2); 
	var lightboxLeft = ((arrayPageSize[0] - 20 - pars[1]) / 2); 
		
	pars[0].style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
	pars[0].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++) {
          selects[i].style.visibility = "hidden";
    }

    //objLightbox.innerHTML = '';
	objLightbox.style.display = 'block';
	
	arrayPageSize = this.getPageSize();
	objOverlay.style.height = (arrayPageSize[1] + 'px');	
	
	//objLightbox.appendChild(pars[0]);
}