// JavaScript Document
var bodyElem = document.getElementsByTagName('BODY')[0];
if (bodyElem != null)
{
	// Create <div id="lightboxBackground">
	var lightboxBackgroundElem = document.createElement('div');
	lightboxBackgroundElem.setAttribute('id', 'lightboxBackground');
	
	var pageSizeScrollArr = getPageSizeWithScroll();
	
	lightboxBackgroundElem.style.width = (pageSizeScrollArr[0]-19)+'px';
	lightboxBackgroundElem.style.height = (pageSizeScrollArr[1])+'px';
		
	// Add <div id="lightboxBackground"> to <body>
	bodyElem.appendChild(lightboxBackgroundElem);
	
	// Create <div id="lightbox">
	var lightboxElem = document.createElement('div');
	lightboxElem.setAttribute('id', 'lightbox');
	
	// Add <div id="lightbox"> to <body>
	bodyElem.appendChild(lightboxElem);
}

function ShowLightboxImg(imgPath, width, height)
{
	document.getElementById('video').style.display = 'none';
	
	var lightboxBackgroundElem = document.getElementById('lightboxBackground');
	lightboxBackgroundElem.style.display = 'block';
	
	// Get X and Y scroll of page within browser window
	var pageScrollArr = getPageSizeWithScroll();
	
	var lightboxElem = document.getElementById('lightbox');
	lightboxElem.setAttribute('onClick','HideLightboxImg()');

	var lightboxImg = document.createElement('img');
	lightboxImg.setAttribute('src', imgPath);
	if (height == 162)
	{
		lightboxElem.style.width = 760;
		lightboxElem.style.height = 1014;
		lightboxElem.setAttribute('width', 760);
		lightboxElem.setAttribute('height', 1014);
		lightboxImg.style.width = 760;
		lightboxImg.style.height = 1014;
		lightboxImg.setAttribute('width', 760);
		lightboxImg.setAttribute('height', 1014);
		lightboxElem.style.top = (pageScrollArr[5]) + "px";
		lightboxElem.style.left = ((pageScrollArr[0]-760)/2) + "px";
	}
	else if (width == 162)
	{
		lightboxElem.style.width = 1014;
		lightboxElem.style.height = 760;
		lightboxElem.setAttribute('width', 1014);
		lightboxElem.setAttribute('height', 760);
		lightboxImg.style.width = 1014;
		lightboxImg.style.height = 760;
		lightboxImg.setAttribute('width', 1014);
		lightboxImg.setAttribute('height', 760);
		lightboxElem.style.top = (pageScrollArr[5]) + "px";
		lightboxElem.style.left = ((pageScrollArr[0]-1014)/2) + "px";
	}
	lightboxImg.setAttribute('border', '0');
	lightboxImg.setAttribute('alt', 'Click on this image to close');
	lightboxImg.style.cursor = 'hand';
	lightboxElem.appendChild(lightboxImg);
	lightboxElem.style.display = 'block';
}

function HideLightboxImg()
{
	document.getElementById('video').style.display = 'block';
	
	document.getElementById('lightboxBackground').style.display = 'none';
	var lightboxElem = document.getElementById('lightbox');
	lightboxElem.style.display = 'none';	
	// Remove all content inside <div id="lightbox">
	while (lightboxElem.childNodes.length > 0)
	{
		lightboxElem.removeChild(lightboxElem.childNodes[0]);
	}
}

function getPageSizeWithScroll()
{
	if (window.innerHeight && window.scrollMaxY) 
	{
		// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} 
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ 
		// all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} 
	else 
	{ 
		// works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  }
	
	// Retrieve viewable height
	var windowWidth, windowHeight;
	// All except Internet Explorer 5.0+
	if (self.innerHeight) 
	{	
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}  
	// Internet Explorer 6 Strict Mode
	else if (document.documentElement && document.documentElement.clientHeight) 
	{
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	// Other Explorers 
	else if (document.body) 
	{
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	
	var xScroll, yScroll;
	if (window.pageXOffset)
	{
		xScroll = window.pageXOffset;
		yScroll = window.pageYOffset;
	}
	else if (document.documentElement)
	{
		xScroll = document.documentElement.scrollLeft;
		yScroll = document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		xScroll = document.body.scrollLeft;
		yScroll = document.body.scrollTop;
	}		
	
	arrayPageSizeWithScroll = new Array(xWithScroll, yWithScroll, windowWidth, windowHeight, xScroll, yScroll);
	//alert('\nxWithScroll: ' + xWithScroll + '\nyWithScroll: ' + yWithScroll + '\nwindowWidth: ' + windowWidth + '\nwindowHeight: ' + windowHeight + '\nxScroll: ' + xScroll + '\nyScroll: ' + yScroll);
	return arrayPageSizeWithScroll;
}