// big image popup
oImgPopup = null;

/*function preloadImage(url)
{
	var image = new Image();
	image.src = url;
}

function hideImagePopup()
{
	if(oImgPopup != null)
		oImgPopup.hide();
}

function showImagePopup(url)
{
	if(!oImgPopup)
		oImgPopup = window.createPopup();

	var oPopBody = oImgPopup.document.body;

	oPopBody.innerHtml = '<img src="'+url+'" alt="Click to close" onclick="hidePopup()" />';

	oImgPopup.show(100, 100, 200, 50, document.body);
}*/


var g_openZoom = false;

function viewportGetHeight()
{
    var retval = 0;

    if (window.innerHeight)
        retval = window.innerHeight - 18;
    else if (document.documentElement && document.documentElement.clientHeight)
        retval = document.documentElement.clientHeight;
    else if (document.body && document.body.clientHeight)
        retval = document.body.clientHeight;

    return retval;
}

function viewportGetWidth()
{
    var retval = 0;

    if (window.innerWidth)
        retval = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth)
        retval = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth)
        retval = document.body.clientWidth;

    return retval;
}

function viewportGetScrollY()
{
    var retval = 0;

    if (typeof window.pageYOffset == "number")
        retval = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
        retval = document.documentElement.scrollTop;
    else if (document.body && document.body.scrollTop)
        retval = document.body.scrollTop;
    else if (window.scrollY)
        retval = window.scrollY;

    return retval;
}

function hideLr(id)
{
    var elm = document.getElementById(id);
    if (elm) {
        elm.style.display = "none";
    }
}

function _clickZoomable(id, imgWidth, imgHeight)
{
	if(g_openZoom == 0)
	{
		var elem = document.getElementById('zoomImage' + id);
		var elmShade = document.getElementById("zoomImageShade");

		if(elem != null)
		{
			var shadeborder = 8;

//			var imgX = viewportGetWidth() / 2 - imgWidth / 2;
//	        var imgY = Math.round( (viewportGetHeight() - imgHeight)/2 ) + viewportGetScrollY();

			var imgX = 30;
	        var imgY = 30;

            if (imgY < 0) { imgY = 0; }
	        // if (imgX < 0) { imgX = 0; }

    	    elmShade.style.left = (imgX - shadeborder) + "px";
        	elmShade.style.width = (imgWidth + shadeborder * 2) + "px";
	        elmShade.style.top = (imgY - shadeborder) + "px";
    	    elmShade.style.height = (imgHeight + shadeborder * 2) + "px";

	        elem.style.left = imgX + "px";
    	    elem.style.top = imgY + "px";
        	/*if (elmCloseButton) {
            	elmCloseButton.style.left = (imgWidth - 19) + "px";
	        } */

    	    elem.style.display = "block";
        	elmShade.style.display = "block";

	        g_openZoom = id;
		}
	}
}

function _clickZoomed()
{
    hideLr("zoomImageShade");
    hideLr("zoomImage" + g_openZoom);
    g_openZoom = 0;
}
