function PixGallery_ImagePopupWindow(ImagePath, ImageWidth, ImageHeight, ImageAlt)
{
	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>");
}

var Cursor				= {X:0, Y:0};
var	DragDropPosition	= {X:0, Y:0, StartX: 0, StartY: 0};
var DragDropObject		= null;
var DragDropActive		= false;

window.onload = PixGallery_Initalize;

function PixGallery_Initalize() 
{
	if (!window.event) 
		document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);

	document.onmousemove	= PixGallery_EventMouseMove;
	document.onmousedown	= PixGallery_EventMouseDown;
	document.onmouseup		= PixGallery_EventMouseUp;
}

function PixGallery_EventMouseDown(e) 
{
	if (window.event)
		e = window.event;

	if (document.all)
		GetObject	= e.srcElement;
	else
		GetObject	= e.target;

	while ((GetObject.tagName != "HTML" && GetObject.tagName != "BODY") && 
		(GetObject.className != "PixGalleryPopupDrag"))
		{
		if (document.all)
			GetObject = GetObject.parentElement;
		else
			GetObject = GetObject.parentNode;		
		}

	if (GetObject.className != "PixGalleryPopupDrag")
		return true;

	DragDropObject			= GetObject;

	DragDropPosition.X		= e.clientX;
	DragDropPosition.Y		= e.clientY;

	DragDropPosition.StartX = parseInt(DragDropObject.style.left);
	DragDropPosition.StartY = parseInt(DragDropObject.style.top);

	return true;
}

function PixGallery_EventMouseUp() 
{
	DragDropObject = null;
}

function PixGallery_EventMouseMove(e) 
{
	if (window.event)
		e = window.event;

	if (e.pageX || e.pageY) 
		{
		Cursor.X = e.pageX;
		Cursor.Y = e.pageY;
		} 
	else 
		{
		Cursor.X = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - 
					document.documentElement.clientLeft;
		Cursor.Y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - 
					document.documentElement.clientTop;
		}

	if (DragDropObject) 
		{
		DragDropObject.style.left	= DragDropPosition.StartX + e.clientX - DragDropPosition.X + "px";
		DragDropObject.style.top	= DragDropPosition.StartY + e.clientY - DragDropPosition.Y + "px";
		}
}

function PixGallery_ImagePopupLayer(ImagePath, ImageWidth, ImageHeight, ImageAlt)
{
	var PopupLayer	= document.getElementById('PixGalleryPopupLayer');
	var PopupImage	= document.getElementById('PixGalleryPopupImage');
	var PopupClose	= document.getElementById('PixGalleryPopupClose');
	var PopupText	= document.getElementById('PixGalleryPopupText');

	PopupImage.src = ImagePath;

	if (document.documentElement)
		{
		WindowHeight	= document.documentElement.offsetHeight;
		WindowWidth		= document.documentElement.offsetWidth;
		}
	if (document.body)
		{
		WindowHeight	= document.body.offsetHeight;
		WindowWidth		= document.body.offsetWidth;
		}

	/* Opens image center page, below mouse click */

	PopupLayer.style.left	= ((WindowWidth - ImageWidth) / 2) + "px";
	PopupLayer.style.top	= (Cursor.Y + 5) + "px";
	PopupLayer.style.width	= ImageWidth + "px";
	PopupLayer.style.height	= (ImageHeight + 26) + "px";

	PopupText.innerHTML = ImageAlt;

	PopupLayer.style.visibility = 'visible';
}

function PixGallery_ImagePopupLayerClose()
{
	var PopupLayer = document.getElementById('PixGalleryPopupLayer');

	PopupLayer.style.visibility = 'hidden';
}