// Copyright Thomas Schoch, Essen, Germany

var picOnscreen = false  // a picture is displayed on the screen
var w                    // handle for opened picture window

function photo(url, width) {

    // close open window if present
    if (picOnscreen == true) {
        if (!w.closed) w.close()
        picOnscreen = false;
    }

    // calculate centered position dependent on screen resolution
    if (screen.Width <= 800) {
        var wwidth  = screen.Width - 10
        var wheight = screen.Height - 25
        var mleft = 0
        var mtop  = 0
    } else {
        if (!width || width < 600) width = 600
        var wwidth = width + 260
        var wheight = 450 + 230                  // orig was 450 + 270
        var mleft = (screen.Width - wwidth) / 2
        var mtop  = 5
    }

    // on dynamically created urls (they don't end with ".html")
    // append "&w=1" (window opened by javascript) to the url.
    if (! /\.html$/.test(url)) {
	url = url + '&w=1'
    }

    // open separate window
    w = window.open(url,'',' \
    screenY=' + mtop + ',screenX=' + mleft + ', \
    top=' + mtop + ',left=' + mleft + ', \
    width=' + wwidth + ',height=' + wheight + ', \
    resizable=no,scrollbars=no,scrolling=no,menubar=no,status=no,statusbar=no');

    picOnscreen = true
}

function loadcss(path) {

    // load appropriate style sheet depending on the screen resolution
    if (screen.availHeight < 715)
        var css = path + "_lores.css"
    else
        var css = path + "_hires.css"
    document.writeln("<link rel=\"stylesheet\" href=\"" +
    css + "\" type=\"text/css\">");

    // document.writeln("<span style='font-size:7pt'>" + screen.availWidth + " x " + screen.availHeight + "</span>\n");
}
