var MinimumTopPosition = 150
var TopPositionBump = 80

function PixGallery_ImagePopupWindow(ImagePath, ImageWidth, ImageHeight, ImageAlt, CallingEl)
{
	var PopupWindow = window.open(ImagePath, '', config='height=' + ImageHeight + ', width=' + ImageWidth + '');

	if (ImageAlt != "")
		PopupWindow.document.write("<title>" + ImageAlt + "</title>");

	PopupWindow.document.write("<style>body { margin: 0px; padding: 0px;}</style><body>");
	PopupWindow.document.write("<img src=\"" + ImagePath + "\"></body>");
}

function PixGallery_ImagePopupLayer(ImagePath, ImageWidth, ImageHeight, ImageAlt, CallingEl)
{
	var PopupLayer	= document.getElementById('popuplayer');
	var PopupImage	= document.getElementById('popupimage');

	PopupImage.src = "/images/layout/loading.jpg";
	PopupImage.src = ImagePath;

	if (document.body)
	{
		WindowHeight = document.body.offsetHeight;
		WindowWidth = document.body.offsetWidth;
	} else if (document.documentElement)
	{
		WindowHeight = document.documentElement.offsetHeight;
		WindowWidth = document.documentElement.offsetWidth;
	}
	
	var TopPosition = CallingEl.offsetTop - TopPositionBump;
	if (TopPosition < MinimumTopPosition) {
		TopPosition = MinimumTopPosition
	}
	
	/* Opens image center page, below mouse click */

	PopupLayer.style.left	= ((WindowWidth - ImageWidth) / 2) + "px";
	PopupLayer.style.top	= TopPosition + "px";
	PopupLayer.style.width	= (ImageWidth + 10)+ "px";
	PopupLayer.style.height	= (ImageHeight + 26) + "px";

	PopupLayer.style.visibility = 'visible';
}

function PixGallery_ImagePopupLayerClose()
{
	var PopupLayer = document.getElementById('popuplayer');
	var PopupImage	= document.getElementById('popupimage');
	
	PopupImage.src = "/images/layout/loading.jpg";
	PopupLayer.style.width	= (682 + 10)+ "px";
	PopupLayer.style.height	= (525 + 26) + "px";
	PopupLayer.style.visibility = 'hidden';
	PopupLayer.style.left = "-1000em";
	PopupLayer.style.top = "-1000em";
}
