  // Variablen für das popup-Fenster:
  var BildID = 0;
  var BildName = "";
  var BildBreite = 0;
  var BildHoehe = 0;
  var BildText = "";
  var BildPfad = "";
  var PdfName = "";
  var DocName = "";
  var Pdf_aktiv = "";
  var Doc_aktiv = "";

  var FensterBreite = 0;
  var FensterHoehe = 0;
  var altBreite = 0;
  var altHoehe = 0;

  var Popup = false;  // Popup-Fenster vorhanden?

function Bild(_BildID,_BildName,_Breite,_Hoehe,_BildText,_BildPfad,_PdfName,_DocName,_Pdf_aktiv,_Doc_aktiv) {

   if (!top.FensterOK) return;

   // Variablen zwischenspeichern:
   // BildID merken für Popup (JS):
   BildID = _BildID;       // BildID
   BildName = _BildName;   // Bildname (quelle)
   BildBreite = _Breite;   // Bildbreite
   BildHoehe = _Hoehe;     // Bildhöhe
   BildText = _BildText;   //
   BildPfad = _BildPfad;   //
   PdfName = _PdfName;     //
   DocName = _DocName;     //
   Pdf_aktiv = _Pdf_aktiv;     //
   Doc_aktiv = _Doc_aktiv;     //

   // alert("BildID = " + BildID);
   /*
   if (BildBreite > 500) {
      FensterBreite = 520;
      FensterHoehe = 600;
   }
   else {
      FensterBreite = 300;
      FensterHoehe = 300;
   }
   */

   FensterBreite = Math.max(parseInt(BildBreite) + 30, 530);
   FensterHoehe = parseInt(BildHoehe) + 120 + 120;
   // alert(FensterHoehe);

   // Problem: wenn neues Bild größer ist und noch nicht geladen war,
   // entsteht kurz ein Scrollbalken -> erst Fenster vergrößern !!!
   // if (Popup && FensterHoehe > altHoehe) PopupFenster.close();     // -> noch keine Lösung gefunden !!!
   // window.resizeTo(FensterBreite, FensterHoehe);

   // if(PopupFenster.closed == true) alert("Fenster wurde geschlossen");
   PopupFenster = window.open("../Material/popup.html", "PopupFenster", "resizable=yes, dependent=no, width=" + FensterBreite + ", height=" + FensterHoehe );     // scrollbars=yes,
   if (PopupFenster.opener == null) PopupFenster.opener = self;

   Popup = true;
   PopupFenster.focus();
}

// HauptFenster: haupt.php body.onLoad="menu(228)"
function menu(id) {
	if (!frameCheck()) return;

   top.FensterOK = true;  // PopupFenster für Bild() freigeben

	// Titelzeile des Browsers setzen (FF):
	top.document.title = document.title;
	// IE: auch <title>...</title> !!!
   // document.title.innerHTML = title;  // für IE ?

   // tree0 sollte den entsprechenden Node öffnen:
   if (!top.LinkesFenster.tree0) return;
   // t = window.CTrees.tree0;  // ???
   t = top.LinkesFenster.tree0;

   // url = "../Material/haupt.php?InhaltID=" + id;
   url = "../Grundschule/" + id + ".html";
   node = t.nodeByURL(url);
   if (node) {
      nr = node.index;
      // if (nr == top.nodeNr) return;
      while (node) {
         if (node.hasChildren() && !node.expanded) t.expandNode(node.index, false, true);
         node = node.getParent();
      }
      t.selectNode(nr);
   }
}

function frameCheck() {
	// 1. wird die Seite in einem Frameset aufgerufen?
	if (parent.frames.length > 0) {
		// 2. prüfen ob es auch dein Frameset ist:
		if(top.frames[0].name == "OberesFenster") return true; // alles OK
	}
	// wenn nicht:
	// Adresse der Seite merken:
	var adr = this.location.href;
	// http://www.grundschulmaterial-online.de/Grundschule/228.html
	// InhaltID bestimmen:
	var InhaltID = adr.substring(adr.lastIndexOf("/") + 1, adr.length - 5);
	// window.status = "Adresse: " + adr;  // http://www.grundschulmaterial-online.de/Grundschule/228.html
	// window.status = "InhaltID = " + InhaltID;  // 228 (OK)
	// Frameset laden und InhaltID übergeben:
	top.location.href = "http://grundschulmaterial-online.de/index.php?InhaltID=" + InhaltID;
	return false;
}
