var afLoadHandlers = Array();
function AddHandler(fHandler)
{
	afLoadHandlers[afLoadHandlers.length] = fHandler;
}
function OnLoad()
{
	for(var i=0;i<afLoadHandlers.length;i++)
	{
		afLoadHandlers[i]();
	}
}

sImageTitle = '';
oImage = null;

function ShowPhoto(sPath,sTitle)
{
	cancelBubble(window.event);
	stopDef(window.event);

	var eZoomLoading = document.getElementById("zoom_loading");
	var eZoomCaption = document.getElementById("zoom_caption");

	// 
	eZoomLoading.style.visibility = "visible";
	eZoomLoading.style.top = GetWindowScrollTop() + 64;
	eZoomLoading.style.left = ( GetWindowClientWidth() - eZoomLoading.offsetWidth ) / 2;

	// 
	eZoomCaption.innerHTML = sTitle;

	// 
	oImage = new Image();
	oImage.onload = OnPictureLoaded;
	oImage.src = sPath;

	return false;
}

function OnPictureLoaded()
{
	var eZoomLoading = document.getElementById("zoom_loading");
	var eZoom = document.getElementById("zoom");
	var eZoomImage = document.getElementById("zoom_image");
	var eZoomCaption = document.getElementById("zoom_caption");
	var eZoomClose = document.getElementById("zoom_close");

	// 
	eZoomLoading.style.visibility = "hidden";
	// 
	eZoom.style.visibility = "visible";

	if( oImage.width / oImage.height > 1 )
	{
		// horizontal
		eZoom.style.width = 700;
		eZoom.style.height = 500;
		eZoom.style.background = "url('images/zoom_horizontal.png')";
		// 
		eZoomImage.style.top = 32;
		eZoomImage.style.left = 32;
		eZoomImage.style.width = 586;
		eZoomImage.style.height = 440;
		// 
		eZoomClose.style.top = 24;
		eZoomClose.style.left = 656;
		// 
		eZoomCaption.style.top = 40;
		eZoomCaption.style.left = 40;
	}
	else
	{
		// vertical
		eZoom.style.width = 500;
		eZoom.style.height = 700;
		eZoom.style.background = "url('images/zoom_vertical.png')";
		// 
		eZoomImage.style.top = 80;
		eZoomImage.style.left = 28;
		eZoomImage.style.width = 440;
		eZoomImage.style.height = 586;
		// 
		eZoomClose.style.top = 24;
		eZoomClose.style.left = 460;
		// 
		eZoomCaption.style.top = 32;
		eZoomCaption.style.left = 30;
	}

	// 
	eZoom.style.top = GetWindowScrollTop() + 64;
	eZoom.style.left = ( GetWindowClientWidth() - eZoom.offsetWidth ) / 2;
	// 
	eZoomImage.src = oImage.src;
	eZoomImage.style.visibility = "visible";
}

function CloseZoom()
{
	cancelBubble(window.event);
	stopDef(window.event);

	var eZoom = document.getElementById("zoom");
	var eZoomImage = document.getElementById("zoom_image");
	var eZoomCaption = document.getElementById("zoom_caption");

	eZoom.style.visibility = "hidden";
	eZoomImage.style.visibility = "hidden";

	return false;
}

function GetWindowScrollTop()
{
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0)
	{
		if (window.pageYOffset)
			ScrollTop = window.pageYOffset;
		else
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	return ScrollTop;
}

function GetWindowClientWidth()
{
    if( document.all )
		return window.document.body.clientWidth;
	else
		return window.innerWidth;
}

function GetWindowClientHeight()
{
    if( document.all )
		return window.document.body.clientHeight;
	else
		return window.innerHeight;
}

function stopDef(e)
{
	if (e &&e.preventDefault)
		e.preventDefault();
	else if (window.event && window.event.returnValue)
		window.eventReturnValue = false;
}

function cancelBubble(netEvent) {
    if (document.all)
		window.event.cancelBubble = true;
	else
		netEvent.cancelBubble = true;
}

