function openImageViewer(imageID, width, height)
{
	var imageViewer=document.getElementById("imageViewer");

	if (imageViewer != null)
	{
		var image = document.getElementById(imageID);

		if (image != null)
		{
			var imageViewerImage=document.getElementById("imageViewerImage");

			imageViewerImage.src = image.src;

			imageViewer.style.display="block";

			var top=findCenterY(width, height);
			var left=findCenterX(width, height);

			imageViewer.style.top=top + "px";
			imageViewer.style.left=left + "px";

			imageViewer.style.width="auto";
			imageViewer.style.height="auto";

			var imageViewerBackground=document.getElementById("imageViewerBackground");

			if (imageViewerBackground != null)
			{
				imageViewerBackground.style.display="block";
			}
		}
	}
}

function closeImageViewer()
{
	var imageViewer=document.getElementById("imageViewer");

	if (imageViewer != null)
	{
		imageViewer.style.display="none";
	}

	var imageViewerBackground=document.getElementById("imageViewerBackground");

	if (imageViewerBackground != null)
	{
		imageViewerBackground.style.display="none";
	}
}

function findCenterX(width, height)
{
	var output = 0;

	var viewportWidth;

	if (typeof window.innerWidth != 'undefined')
	{
		// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
		viewportWidth = window.innerWidth;
	}
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0)
	{
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		viewportWidth = document.documentElement.clientWidth;
	}
	else
	{
		// older versions of IE
		viewportWidth = document.getElementsByTagName('body')[0].clientWidth;
	}
	
	//output = (viewportWidth / 2) - (image.width / 2);
	output = (viewportWidth / 2) - (width / 2);

	return output;
}

function findCenterY(width, height)
{
	var output = 0;

	var viewportHeight;

	if (typeof window.innerHeight != 'undefined')
	{
		// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
		viewportHeight = window.innerHeight;
	}
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientHeight !='undefined' && document.documentElement.clientHeight != 0)
	{
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		viewportHeight = document.documentElement.clientHeight;
	}
	else
	{
		// older versions of IE
		viewportHeight = document.getElementsByTagName('body')[0].clientHeight;
	}

	//output = (viewportHeight / 2) - (image.height / 2);
	output = (viewportHeight / 2) - (height / 2);

	return output;
}

function findPositionX(obj)
{
	var output = 0;

	if (obj)
	{
		if(obj.offsetParent)
		{
			output=obj.offsetLeft;

			output+=findPositionX(obj.offsetParent);
		}
		else if(obj.x)
		{
			output=obj.x;
		}
	}

	return output;
}

function findPositionY(obj)
{
	var output = 0;

	if (obj)
	{
		if(obj.offsetParent)
		{
			output=obj.offsetTop;

			output+=findPositionY(obj.offsetParent);
		}
		else if(obj.y)
		{
			output=obj.y;
		}
	}

	return output;
}

