// Popup windows for images, based on source from Chelsvig's web site and
// various JavaScript script archives.

browserName = navigator.appName; 
browserVer = parseInt(navigator.appVersion); 
if (browserName == "Netscape" && browserVer >= 3 || browserName == "Microsoft Internet Explorer" && browserVer >= 4) version = "n3";
else version = "n2"; 

function showMsg() {
    window.status='Click to see the full-size image in new window.';
    return true;
}

var newWindow = null;

function show_props(obj, name) {
    var result = "";
    for (var i in obj) {
        //result += name + "." + i + " = " + obj[i] + "\n";
        result += " " + i;
    }
    return result;
}

function makeNewWindow(Title,ImageName,width,height) { 
    windowwidth = width + 20; 
    windowheight = height + 52; 

    var LeftPosition = 0;
    var TopPosition = 0;
    if (window.screen) { // Early browsers don't know the screen object!
        LeftPosition = (window.screen.width) ? Math.floor((window.screen.width-windowwidth)/2) : 0;
        TopPosition = (window.screen.height) ? Math.floor((window.screen.height-1.1*windowheight)/2) : 0;
    }
    else { // Early browsers use h & w for the outside size.
        windowwidth += 4;
        windowheight += 7;
    }

    // store new window object in global variable 
    newWindow = window.open("","imagePopup","top="+TopPosition+",left="+LeftPosition+"screenY="+TopPosition+",screenX="+LeftPosition+",width=" + windowwidth + ",height=" + windowheight) 

    if (newWindow != null) { 

    // assemble content for new window 
    var newContent = "<HTML><HEAD>"
    newContent += "<BODY BGCOLOR=\"#000000\" TEXT=\"#FF0000\"><form><center>"
    newContent += "<img src=\"" + ImageName + "\" " + width + " " + height
    newContent += " alt=\"" + Title + "\" align=top>"
    newContent += "<font face=\"Arial, Helvetica\" size=2><p></p>"
    newContent += "<input type='button' value='Close This Window' onclick='self.close()'></FORM></center>"
    newContent += "</BODY></HTML>"

    //write content to the new window 
    newWindow.document.write(newContent)
    newWindow.document.close()
    }
}

function makeNewWindow2(Title,ImageName) {
    // A version that figures out the image size, but doesn't work for IE
    // because MICROSOFT SUCKS!!!!!
    var img = new Image();
    img.src = ImageName;
    // window.alert(img.src+"\n w, h = "+img.width+" "+img.height);
    window.alert(show_props(img,"img"));
    if (img.src) { // NS requires that we use img.src b/4 w & h get set....
        width = parseInt(img.width);
        height = parseInt(img.height);
        windowwidth = width + 20; 
        windowheight = height + 52;
    }

    var LeftPosition = 0;
    var TopPosition = 0;
    if (window.screen) { // Early browsers don't know the screen object!
        LeftPosition = (window.screen.width) ? Math.floor((window.screen.width-windowwidth)/2) : 0;
        TopPosition = (window.screen.height) ? Math.floor((window.screen.height-1.1*windowheight)/2) : 0;
    }
    else { // Early browsers use h & w for the outside size.
        windowwidth += 4;
        windowheight += 7;
    }

    // store new window object in global variable 
    newWindow = window.open("","imagePopup","top="+TopPosition+",left="+LeftPosition+"screenY="+TopPosition+",screenX="+LeftPosition+",width=" + windowwidth + ",height=" + windowheight+",resizable=1") 

    if (newWindow != null) { 

    // assemble content for new window 
    var newContent = "<HTML><HEAD>"
    newContent += "<BODY BGCOLOR=\"#000000\" TEXT=\"#FF0000\"><form><center>"
    newContent += "<img src=\"" + ImageName + "\" " + width + " " + height
    newContent += " alt=\"" + Title + "\" align=top>"
    newContent += "<font face=\"Arial, Helvetica\" size=2><p></p>"
    newContent += "<input type='button' value='Close This Window' onclick='self.close()'></FORM></center>"
    newContent += width + " " + height;
    newContent += "</BODY></HTML>"

    //write content to the new window 
    newWindow.document.write(newContent)
    newWindow.document.close()
    }
}

