var zoomWindow = null;
var zoomImages = new Array();

function showPopup(urlImage, zoomlink)
{
	if (zoomWindow != null)
	{
	    zoomWindow.close();
        zoomWindow = null;
	}
	
	// get dimensions
	var height = 450;
	var width = 600;
	
    var zoomImagesIndex;
    for (zoomImagesIndex = 0; zoomImagesIndex < document.images.length; zoomImagesIndex++)
    {
        if (document.images[zoomImagesIndex].parentNode == zoomlink)
        {
            img = document.images[zoomImagesIndex];
            height = zoomImages[zoomImagesIndex].height;
            width = zoomImages[zoomImagesIndex].width;
            break;
        }
    }
    
	zoomWindow = window.open("","Zoom","width="+width+",height="+height+",location=no,menubar=no,status=no,toolbar=no,resizable=yes");
    zoomWindow.focus();
    zoomWindow.document.open("text/html", "replace");
	zoomWindow.document.write('<html><head><link type="text/css" rel="stylesheet" href="../../res/popup.css" /></head><body><img src="' + urlImage + '" /></body></html>');
	zoomWindow.document.close();
}

function initZoomPopups()
{
    var zoomImagesIndex;
    for (zoomImagesIndex = 0; zoomImagesIndex < document.images.length; zoomImagesIndex++)
    {
        if (document.images[zoomImagesIndex] == null)
            continue;

        var img = document.images[zoomImagesIndex];
        if (img.src == null || 
            document.images[zoomImagesIndex].src == null ||
            document.images[zoomImagesIndex].src.indexOf("/PICS/") < 0)
            continue;
            
        var zoomlink = img.parentNode;
        if (zoomlink.href == null)
            continue;
            
        zoomImages[zoomImagesIndex] = new Image();
        zoomImages[zoomImagesIndex].src = zoomlink.href;
    }
}
