﻿function popupImage(imageURL, imageTitle) {
    // Set autoclose true to have the window close automatically
    // Set autoclose false to allow multiple popup windows
    var AutoClose = true;

    if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
        var isNN = (navigator.appName == "Netscape") ? 1 : 0;
        var isIE = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
    }

    var optNN = 'scrollbars=no,width=50,height=50,left=100,top=100,toolbar=no,location=no';
    var optIE = 'scrollbars=no,width=150,height=100,left=100,top=100,toolbar=no,location=no';

    if (isNN) { imgWin = window.open('about:blank', '', optNN); }
    if (isIE) { imgWin = window.open('about:blank', '', optIE); }

    with (imgWin.document) {
        //	writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"');
        //	writeln('"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n');

        writeln('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">');
        writeln('<head>');
        writeln('<meta http-equiv="content-type" content="text/html charset=iso-8859-1" />');
        writeln('<title>' + imageTitle + '</title>');
        writeln('<style><!--body{margin:0px;}--></style>');

        writeln('<script>');
        writeln('var isNN,isIE;');
        writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
        writeln('isNN=(navigator.appName=="Netscape")?1:0;');
        writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
        writeln('function reSizeToImage(){');
        writeln('if (isIE){');
        writeln('window.resizeTo(300,300);');
        writeln('width=300-(document.body.clientWidth-document.images[0].width);');
        writeln('height=300-(document.body.clientHeight-document.images[0].height);');
        writeln('window.resizeTo(width,height);}');
        writeln('if (isNN){');
        writeln('window.innerWidth=document.images["myImage"].width;');
        writeln('window.innerHeight=document.images["myImage"].height;}}');
        writeln('</script>');
        writeln('</head>');

        if (!AutoClose)
            writeln('<body style="background:#ffffff;" scroll="no" onload="reSizeToImage(); self.focus();">')
        else
            writeln('<body style="background:#ffffff;" scroll="no" onload="reSizeToImage(); self.focus();" onblur="self.close();">');

        writeln('<img name="myImage" src="' + imageURL + '" style="display:block;" />');
        writeln('</body>');
        writeln('</html>');
        close();
    }
}
