// ***  conf Variablen *** //

// neues HauptFenster: FlashBaumAnsicht
var cFTborder   = 15; // Mindestabstand des Fensters vom Bildschirmrand
// neue Fenster
var wfTimeout = 200; // delay nach dem neu geöffnetes Fenster einen Focus bekommt
var cwVonOben = 20;  // Abstand neu zu öffnender Fenster vom oberen Bildschirmrand
// Abs. Pfad
var ceiPfad  = '/portcam/';

// *** windowFeatures *** //
// Objekt zur Aufnahme/Vordefinition von Optionen der window.open()-Methode
function windowFeatures() {
    this.breite      = 500;   // Fensterhöhe
    this.hoehe       = 300;   // Fensterbreite
    this.directories = 'no';  // LinkLeiste (Personal Toolbar Folder)
    this.location    = 'no';  // AdressEingabe
    this.menubar     = 'no';  // HauptMenü
    this.scrollbars  = 'yes'; // ScrollBalken
    this.status      = 'no';  // StatusZeile (unten)
    this.toolbar     = 'no';  // WerkzeugLeiste
    this.resizable   = 'yes'; // Fenster in der Größe veränderbar?

    this.vonOben     = '0';   // Abstand der linken oberen Fensterecke von oben
    this.vonLinks    = '0';   // Abstand der linken oberen Fensterecke von links
}
// Generierung des Zeichenkette für die Optionen der window.open()-Methode
function windowFeaturesStringTogether() {
    this.ausgabe =  'width='        + this.breite;
    this.ausgabe += ',height='      + this.hoehe;
    this.ausgabe += ',directories=' + this.directories;
    this.ausgabe += ',location='    + this.location;
    this.ausgabe += ',menubar='     + this.menubar;
    this.ausgabe += ',scrollbars='  + this.scrollbars;
    this.ausgabe += ',status='      + this.status;
    this.ausgabe += ',toolbar='     + this.toolbar;
    this.ausgabe += ',resizable='   + this.resizable;

    // NN4+
    this.ausgabe += ',screenX=' + this.vonLinks;
    this.ausgabe += ',screenY=' + this.vonOben;

    // IE4+
    this.ausgabe += ',left=' + this.vonLinks;
    this.ausgabe += ',top='  + this.vonOben;
}
windowFeatures.prototype.stringTogether = windowFeaturesStringTogether;


// weitere Behandlung eines geöffneten Fensters
var aktTitel = '';
function processWindow(winHandleStr, url, winFocus) {
    if (eval(winHandleStr + ".fertig")) { // Fenster schon fertig?
        winHandle = eval(winHandleStr);

        // Inhalt des Fenster entspricht aufgerufener URL?
        if (winHandle.location.href.indexOf(url) == -1) winHandle.location.href = url;

        // Focus für das neue bzw. aktualisierte Fenster
        if (winFocus && window.focus) setTimeout(winHandleStr + ".focus()", wfTimeout);

    } else { // Fenster noch nicht fertig? -- gleich noch mal probieren
        setTimeout("processWindow(\"" + winHandleStr + "\", \"" +  url + "\", \"" + winFocus + "\")", 100);
    }
}

// generelle Funktion für die window.open()-Methode
function openWindow(winHandleStr, url, winName, optionen) {
    var oeffnen = true;
    if (eval(winHandleStr) && !eval(winHandleStr + '.closed'))
        oeffnen = false;

    // öffnen, falls nötig
    if (oeffnen) {
        optionen.stringTogether();
        eval(winHandleStr + ' = window.open("' + url + '", "' + winName + '", "' + optionen.ausgabe + '");');
    }

    // zusatzFenster weiter verarbeiten
    processWindow(winHandleStr, url, true);
}



// *** Methoden *** //

// makeExtendedInfoWindow
// Öffnen eines Fensters zur Anzeige von Zusätzlichen Informationen aus dem System
var extendedInfoWindow = null;
function makeExtendedInfoWindow(url) {
    var optionen = new windowFeatures();
    optionen.breite     = 640;
    optionen.hoehe      = 240;
    optionen.scrollbars = 'no';
    optionen.vonLinks = (window.screen.width)? Math.ceil((window.screen.width-optionen.breite)/2) : 0;
    optionen.vonOben  = cwVonOben;
	var eiFullURL = ceiPfad + url;

    openWindow('extendedInfoWindow', eiFullURL, 'extended', optionen)
    return false;
}


