function SiteImageWin(URL)
{
    var n = Math.round(Math.random()*10000);
    var s = n.toString();
    var winW = 400;
    var winH = 300;
    var winX = (GetWindowWidth( window ) - winW)/2;
    var winY = (GetWindowHeight( window ) - winH)/2;

    w = window.open(URL,'SiteImageWin'+s,'width='+winW+',height='+winH+',left='+winX+',top='+winY+'scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=1');
    w.focus();
}

function FitGalleryImageWin()
{
    var image = document.getElementById('bigGalleryImage');
    if (image)
    {
        var winWidth = image.width + 110;
        var winHeight = image.height + 110;
        window.resizeTo(winWidth,winHeight);

        if (window.opener)
        {
            var winX = (GetWindowWidth( window.opener ) - GetWindowWidth( window ))/2;
            var winY = (GetWindowHeight( window.opener ) - GetWindowHeight( window ))/2;
            if (winX < 0)  winX = 0;
            if (winY < 0)  winY = 0;

            window.moveTo(winX,winY);


            /*
            if (GetWindowWidth( window.opener ) >= GetWindowWidth( window ) &&
                GetWindowHeight( window.opener ) >= GetWindowHeight( window ))
            {
                var winX = (GetWindowWidth( window.opener ) - GetWindowWidth( window ))/2;
                var winY = (GetWindowHeight( window.opener ) - GetWindowHeight( window ))/2;
                window.moveTo(winX,winY);
            }
            */
        }
    }
}


function ImageWin(URL)
{
    window.open(URL,'ImageWin'+Math.round(Math.random()*10000),'width=200,height=200,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=1');
}


/**
 * Reads the width of browser window content area
 *
 * @returns Returns browser window content area width.
 * @type int
 */
function GetWindowWidth( win )
{
    var height = 0;

    if (typeof( win.innerWidth ) == 'number')
    {
        // FF, Opera
        height = win.innerWidth;
    }
    else if (win.document.documentElement && (win.document.documentElement.clientWidth || win.document.documentElement.clientHeight))
    {
        // IE 6+ in 'standards compliant mode'
        height = win.document.documentElement.clientWidth;
    }
    else if (win.document.body && (win.document.body.clientWidth || win.document.body.clientHeight))
    {
        // IE 5-6 quirks
        height = win.document.body.clientWidth;
    }

    return height;
};


/**
 * Reads the height of browser window content area
 *
 * @returns Returns browser window content area height.
 * @type int
 */
function GetWindowHeight( win )
{
    var height = 0;

    if (typeof( win.innerWidth ) == 'number')
    {
        // FF, Opera
        height = win.innerHeight;
    }
    else if (win.document.documentElement && (win.document.documentElement.clientWidth || win.document.documentElement.clientHeight))
    {
        // IE 6+ in 'standards compliant mode'
        height = win.document.documentElement.clientHeight;
    }
    else if (win.document.body && (win.document.body.clientWidth || win.document.body.clientHeight))
    {
        // IE 5-6 quirks
        height = win.document.body.clientHeight;
    }

    return height;
};

