var hincrease = 0;
hincrease = 42;

var versionIE = -1;
if (navigator.appName == 'Microsoft Internet Explorer')
{
  var ua = navigator.userAgent;
  var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
  if (re.exec(ua) != null)
    versionIE = parseFloat( RegExp.$1 );
}

if (versionIE >= 7)
    hincrease=82;

function popupwindow(url, width, height, left, top) {
    if ((navigator.appName.indexOf('Netscape') != -1)
    && (parseInt(navigator.appVersion) <= 4))
        seedpopup(url, width, height, left, top);
    else {
        /* following needed when clicking on Prev/Next */
        if (window.name == "popupwindow") {
            window.focus();
            window.resizeTo(width, height+hincrease);
        }

        window.open(url, "popupwindow", 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',resizable=0');
    }
}

function seedpopup(url, width, height, left, top) {
    /* With Netscape 4.7, a window opened with window.open cannot
       be resized.  This opens a seed window which closes the
       original popupwindow, opens a newly redimensioned one,
       then closes itself. */

    var windowseed = window.open("", "popupseed", "width=10,height=10,left=15,top=15");

    windowseed.document.writeln('<html><head><title></title></head>');
    windowseed.document.writeln('<script language="JavaScript" type="text/javascript">');
    windowseed.document.writeln('<!-- ');
    windowseed.document.writeln('function loadpopup() {');
    windowseed.document.writeln('var windowpopup = window.open("", "popupwindow", "width=10,height=10,left=15,top=15");');
    windowseed.document.writeln('windowpopup.close();');
    windowseed.document.writeln('window.open("' + url + '", "popupwindow", "width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',resizable=0");');
    windowseed.document.writeln('window.close(); }');
    windowseed.document.writeln('    // Stop hiding --></script>');

    /* setTimeout is required for IE and Netscape 6.2.  Without it, 
       closing popupwindow also closes popupseed */
    windowseed.document.writeln('<body bgcolor="#000000" onload="setTimeout(\'loadpopup();\',0);">');

    windowseed.document.writeln('</body></html>');
    windowseed.document.close();
}

function focusresize(width, height) {
    /* needed when clicking to enlarge another photo from parent page */
    if (window.name == "popupwindow") {
        window.focus();
        window.resizeTo(width, height+hincrease);
    }
}

