var aTxtWindow;
var aLegWindow;
   function LoadFrame(){
   // Funktion soll abhängig davon, ob im Frame der Inhalte bereits
   // eine Kachel des Themas geladen ist entweder die Hauptansicht
   // öffnen, oder das Frame der Inhalte nicht ändern
      OldHREF = frmContents.location.pathname;
      selfHREF = frmTopIndex.location.pathname;
        //Problem beim IE: Delimiter = "\"
        if (frmTopIndex.location.protocol == "file:"){
          if (navigator.appName == "Netscape"){
            Delimiter = '/';
          }
          else {
            Delimiter = '\\';
          }
        }
        else{
          Delimiter = '/';
        }
      //Ermitteln des Themen-Namens des Inhalt-Dokuments
      Pos = OldHREF.lastIndexOf(Delimiter);
      PageName = OldHREF.substring(Pos+1,OldHREF.length);
      DocName = OldHREF.substring(0,Pos);
      Pos = DocName.lastIndexOf(Delimiter)+1;
      SubPathName = DocName.substring(Pos,DocName.length)
      // Ermitteln des Themen-Namens des aktuellen Dokuments
      selfPos = selfHREF.lastIndexOf(Delimiter);
      selfDocName = selfHREF.substring(0,selfPos);
      selfPos = selfDocName.lastIndexOf(Delimiter)+1;
      selfSubPathName = selfDocName.substring(selfPos,selfDocName.length)
//      alert(SubPathName + "..." + selfSubPathName);

//      if (SubPathName != "thema3"){
      if (SubPathName != selfSubPathName){
        //Wenn es sich um Thema handelt, wenigstens auf den gleichen Ausschnitt gehen
        if ( SubPathName.substring(0,5) == selfSubPathName.substring(0,5) ) {
          //alert("==/" + PageName + "/" + SubPathName+ "/" + selfSubPathName);
          frmContents.location.replace(".." + Delimiter + selfSubPathName + Delimiter + PageName);
          frmLeftIndex.location.replace("index.htm");
        }
        else {
          //alert("!=/" + PageName + "/" + SubPathName+ "/" + selfSubPathName);
          frmContents.location.replace("haupt.htm");
          frmLeftIndex.location.replace("index.htm");
        }
      }
      if (!aLegWindow || aLegWindow.closed){
        // hier nichts tun
      }
      else{
           // das Legendenfenster aktualisieren
           // versuchen, auf die evtl. gewählte Lagenstatistik zu gehen
           OldHREF = aLegWindow.location.pathname;
           Pos = OldHREF.lastIndexOf(Delimiter);
           PageName = OldHREF.substring(Pos+1,OldHREF.length);
           aLegWindow.location.replace(PageName);
           aLegWindow.focus(); //funktioniert nur wenn Einstellungen es erlauben
      }
      if (!aTxtWindow || aTxtWindow.closed){
        // hier nichts tun
      }
      else{
         // das Textfenster schließen
         aTxtWindow.close();
      }
  }
   function syncCorner(){
   // Funktion soll im Eck-Fenster die Positionierung anzeigen
      OldHREF = frmContents.location.pathname;
        //Problem beim IE: Delimiter = "\"
        if (frmTopIndex.location.protocol == "file:"){
//        alert(navigator.appName);
          if (navigator.appName == "Netscape"){
            Delimiter = '/';
          }
          else {
            Delimiter = '\\';
          }
        }
        else{
          Delimiter = '/';
        }
      //Ermitteln des Themen-Namens des Inhalt-Dokuments
      Pos = OldHREF.lastIndexOf(Delimiter);
      PageName = OldHREF.substring(Pos+1,OldHREF.length);
      Pos = PageName.lastIndexOf('.');
      ChipName = PageName.substring(0,Pos);

      frmCorner.location.replace(".." + Delimiter + "marker" + Delimiter + "c" + ChipName + ".htm")
      if (!aLegWindow || aLegWindow.closed){
        // hier nichts tun
      }
      else{
           // das Legendenfenster fokussieren
           aLegWindow.focus(); //funktioniert nur wenn Einstellungen es erlauben
      }

  }
  function clearCorner(sRelDir){
    frmCorner.location.replace(sRelDir+"corner.htm");
  }
   function LoadrFrame(rNum){
        frmContents.location = "region"+rNum+".htm";
   }
   function LoadszFrame(s,z){
        frmContents.location = "r"+s+"z"+z+".htm";
   }
   function LoadhFrame(){
        frmContents.location = "haupt.htm";
   }
function LoadLegend()
{
   if (! aLegWindow || aLegWindow.closed){
     aLegWindow =  window.open("legende.htm","LegWin","width=300,height=600,resizable=yes,scrollbars=yes");
     if (! aLegWindow || aLegWindow.closed){
     }
   }
   else{
        aLegWindow.location.href = "legende.htm";
        aLegWindow.focus(); //funktioniert nur wenn Einstellungen es erlauben
   }
}
function LoadText(aTextfile)
{
   aTextName = "../../texte/" + aTextfile;
   if (! aTxtWindow || aTxtWindow.closed){
     aTxtWindow =  window.open(aTextName,"TxtWin","width=600,height=600,resizable=yes");
   }
   else{
        aTxtWindow.location.href = aTextName;
   }
}
function LoadGLStat(aFile)
{
//die Großlagenstatistik in das Legendenfenster laden
   if (! aLegWindow || aLegWindow.closed){
     aLegWindow =  window.open(aFile,"LegWin", "width=300,height=600,resizable=yes,scrollbars=yes");
   }
   else{
        aLegWindow.location.href = aFile;
        aLegWindow.focus(); //funktioniert nur wenn Einstellungen es erlauben
   }
}
function LoadMainFrame(){
  CloseWindows();
  frmContents.location.replace( "haupt.htm");
  frmTopIndex.location.replace( "dummy.htm");
  frmCorner.location.replace( "corner.htm");
}
function LoadNoTheme(sRelDir){
  CloseWindows();
  //falls man sich in einem Thema befindet muss dieses zurück gesetzt werden
  if (frmLeftIndex.location.href.search(/themen\/thema\d+\/index.htm$/) != -1){
     frmTopIndex.location.replace( sRelDir+"dummy.htm");
     frmLeftIndex.location.replace( sRelDir+"themen/index.htm");
     frmCorner.location.replace( sRelDir+"corner.htm");
  }
  else {
     frmLeftIndex.ClearPict();
  }
}
function CloseWindows(){
  if (! aLegWindow || aLegWindow.closed){
  }
  else{
       aLegWindow.close();
  }
  if (! aTxtWindow || aTxtWindow.closed){
  }
  else{
       aTxtWindow.close();
  }
}
function ClearAll(){
//Beenden der Anwendung: Alle Fenster schließen
CloseWindows();
}
