function openBrWindow(theURL,winName,features) {
  f1 = window.open(theURL,winName,features);
}

///////////////////////////////////////////////////////////
// Globale Definitionen
var default_width = 800;
var default_height = 500;
var rahmen_w = 8;
var rahmen_h = 70;

///////////////////////////////////////////////////////////
// showBild(a, name) - die Hauptfunktion.
function showBild(a, name)
{
    if(!a.target) a.target = "BildFenster";

    // Das Fenster öffnen
    isLoad = false;
    if(!showFenster || showFenster.closed == true)
    showFenster = popUp("", a.target, default_width, default_height);

    showFenster.document.open('text/html');
    showFenster.document.write( getHTML(a.href, name) );
    showFenster.document.close();
    showFenster.focus();
    return false;
}
///////////////////////////////////////////////////////////
// fitWin(Image, window) - wird aus dem Popup aufgerufen.
var isLoad = false;

function fitWin(i, win)
{
    if(isLoad == true) return;
    isLoad = true;

    var w = i.width;
    var h = i.height;

    if(w < 100) w = 100;
    if(h < 100) h = 100;

    var size = getWinSize(win);
    win.resizeBy((w - size.w + rahmen_w), (h - size.h + rahmen_h) );

    win.focus();
}
function setSize(w,h, win)
{
    if(!win) win = window;

    if (typeof win.innerWidth != 'undefined') win.innerWidth = w;
    else win.document.body.clientWidth = w;

    if(typeof win.innerHeight != 'undefined') win.innerHeight = h;
    else win.document.body.clientHeight = h;
}
/////////////////////////////////////////////////////////////////////
// getHTML(bild, titel, farbe)
function getHTML(src, title, bgcolor)
{
    var body = (window.opera || document.layers) ? false : true;

    if(!title) title = 'kein Titel';
    if(!bgcolor) bgcolor = '#ffe92f';
    return '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">\n' +
    '<HTML>\n<HEAD>' +
    '<TITLE>' + title + '</TITLE>\n' +
    '<link rel="stylesheet" href="../design/style.css" type="text/css">' +
    '</HEAD>\n' +
    '<body ' + (body ? 'onload=";opener.fitWin(document.images[0], self);"' : '') +
    'onblur="window.close()">\n' +
    '<img src="' + src +
    '" alt="' + title +
    '" border=1 ' + (!body ? 'onload="opener.fitWin(this, self);"' : '' ) + '>' +
    '\n<br><b>' + title +'<b><div align=center><a href=javascript:self.close()>Fenster schliessen</a></body>\n</html>\n';
}
/////////////////////////////////////////////////////////////////////
// Ein popup öffnen
function popUp(url, fname, w, h)
{
    var tmp = new Array();
    tmp[tmp.length] = 'resizable=yes';
    tmp[tmp.length] = 'scrollbars=no';
    if(w) tmp[tmp.length] = 'width=' + w;
    if(h) tmp[tmp.length] = 'height=' + h;

    return window.open(url, fname, tmp.join(','));
}

function getWinSize(w)
{
    if(!w) w = window;
    var size = {w:0, h:0};

    size.w = w.innerWidth ? w.innerWidth : w.document.body.clientWidth;
    size.h = w.innerHeight ? w.innerHeight : w.document.body.clientHeight;
    return size;
}
/////////////////////////////////////////////////////////////////////
// Alle Fenster schliessen
function closeAll()
{
    if(showFenster && !showFenster.closed) showFenster.close();
}
var showFenster = null;
/////////////////////////////////////////////////////////////////////
// ... und am schluss alle Fenster schliessen.
window.onunload = closeAll;

