
//************************************************************************************************************

var theWindow = null;

//************************************************************************************************************

function showInFrames(seite) // beim Aufruf einer Seite ohne Frames diese einschalten
{
  if (top.frames.length == 0) // keinerlei Frames im obersten Fenster gefunden
  {
    var count = 0;
    var i;
    for (i = 0; i < seite.length; i++)
    {
      if (seite.charAt(i) == '/')
      {
        count = count + 1; // Anzahl der Slashes ermitteln
      }
    }
    if (count == 0) // enthält keine Slashes
    {
      top.location.href = "index.htm?" + seite;
    }
    else if (count == 1)  // enthält nur einen Slash
    {
      top.location.href = "../index.htm?" + seite; // eine bestimmte Seite mit Frames aufrufen
    }
    else if (count == 2) // enthält zwei Slashes
    {
      top.location.href = "../../index.htm?" + seite;
    }
  }
}

function immerVorn() // Fenster soll immer den Focus behalten
{
  self.focus();
  window.setTimeout('immerVorn()', 500); //rekursiver Aufruf
}

function openBrowserWindowCenter(theImage, theWidth, theHeight, theTitle)
{
  aTitle = "Kloster Arnsburg: " + theTitle;
  aWidth = eval(theWidth) + 20;
  aHeight = eval(theHeight) + 20 + 6; //die "+ 6" nur wegen Netscape 6.x
  var x = (screen.width - aWidth) / 2;
  var y = (screen.height - aHeight) / 2;
  var features = 'screenX=' + eval(x) + ',screenY=' + eval(y) + ',scrollbars=no,resizable=no,width=' + eval(aWidth) + ',height=' + eval(aHeight);
  aWindow = window.open('', '', features);
  if (aWindow != null)
  {
    if (aWindow.opener == null)
    {
      aWindow.opener = self;
    }
  }
  aWindow.document.clear();
  aWindow.document.open();
  aWindow.document.writeln('<html>');
  aWindow.document.writeln('<head>');
  aWindow.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">');
  aWindow.document.writeln('<script type="text/javascript" language="JavaScript">');
  aWindow.document.writeln('function immerVorn() //Fenster soll immer den Focus behalten');
  aWindow.document.writeln('{');
  aWindow.document.writeln('  self.focus();');
  aWindow.document.writeln('  window.setTimeout("immerVorn()", 500); //rekursiver Aufruf');
  aWindow.document.writeln('}');
  aWindow.document.writeln('</script>');
  aWindow.document.writeln('<title>' + aTitle + '</title>');
  aWindow.document.writeln('</head>');
  aWindow.document.writeln('<body bgcolor="#000040" leftmargin="10" topmargin="10" marginwidth="10" marginheight="10" onLoad="immerVorn()">');
  aWindow.document.writeln('<p><img src="' + theImage + '" width="' + theWidth + '" height="' + theHeight + '" border="0" alt=""></p>');
  aWindow.document.writeln('</body>');
  aWindow.document.writeln('</html>');
  aWindow.document.close();
  aWindow.moveTo(x, y);
  aWindow.focus();
}

function openBrowserWindow(theImage, imageWidth, imageHeight, aTitle)
{
    closeBrowserWindow(); // eventuell das alte Fenster schließen

    imageWidth = eval(imageWidth); // eindeutig als Wert interpretieren
    imageHeight = eval(imageHeight);
    var windowWidth = eval(imageWidth) + 25; // 25 Pixel größer wegen der Scroller
    var windowHeight = eval(imageHeight) + 25;
    if (windowWidth > screen.width - 40) {
        windowWidth = screen.width - 40;
    }
    if (windowHeight > screen.height - 130) {
        windowHeight = screen.height - 130; // die Kopfzeile des Fenster wird mit berücksichtigt
    }
    var x = (screen.width - windowWidth) / 2 - 4; // muss noch minimal versetzt werden
    var y = (screen.height - windowHeight) / 2 - 50;
    var features = 'left=' + eval(x) + ',top=' + eval(y) + ',location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=' + eval(windowWidth) + ',height=' + eval(windowHeight);
    theWindow = window.open('', '', features);
    if (theWindow != null) {
        if (theWindow.opener == null) {
            theWindow.opener = self;
        }
    }
    theWindow.document.clear();
    theWindow.document.open();
    theWindow.document.writeln('<html>');
    theWindow.document.writeln('<head>');
    theWindow.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">');
    theWindow.document.writeln('<style type="text/css">');
    theWindow.document.writeln('body');
    theWindow.document.writeln('{');
    theWindow.document.writeln('  background-color:#FFFFFF;font-family:"Trebuchet MS",Tahoma,Geneva,Arial,Helvetica,sans-serif;color:#202020;font-weight:normal;font-size:14px;');
    theWindow.document.writeln('}');
    theWindow.document.writeln('</style>');
    theWindow.document.write('<title>');
    theWindow.document.write("Kloster Arnsburg - " + aTitle);
    theWindow.document.writeln('</title>');
    theWindow.document.writeln('</head>');
    theWindow.document.writeln('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
    theWindow.document.write('<img src="');
    theWindow.document.write(theImage);
    theWindow.document.writeln('" width="' + imageWidth + '" height="' + imageHeight + '" border="0" alt="">');
    theWindow.document.writeln('</body>');
    theWindow.document.writeln('</html>');
    theWindow.document.close();
    theWindow.focus();
}

function closeBrowserWindow()
{
    if (theWindow != null) {
        theWindow.close();
        theWindow = null;
    }
}

//************************************************************************************************************

function zurueckDiashow()
{
  s = top.frames[2].location.href; // URL des dritten Frames (Bilddatei) holen
  s = s.substr(s.length - 6, 2);   // die beiden Zahlen des Bilddateinamens extrahieren
  if (s == "00")
  {
    s = "26"; // das letzte Bild anzeigen
  }
  else
  {
    s = String(eval(s) - 1); // Zahl um 1 erniedrigen
    if (s.length == 1)
    { 
      s = "0" + s; // bei einstelliger Zahl muss eine 0 davor
    }
  }
  top.frames[2].location.href = "images/image" + s + ".jpg"; // neues Bild im dritten Frame anzeigen
}

function weiterDiashow()
{
  s = top.frames[2].location.href;
  s = s.substr(s.length - 6, 2);
  if (s == "26")
  {
    s = "00";
  }
  else
  {
    s = String(eval(s) + 1);
    if (s.length == 1)
    { 
      s = "0" + s;
    }
  }
  top.frames[2].location.href = "images/image" + s + ".jpg";
}

function openDiashow()
{
  var theWidth = 600;
  var theHeight = 480; 
  var x = (screen.width - theWidth) / 2;
  var y = (screen.height - theHeight) / 2;
  var features = 'screenX=' + eval(x) + ',screenY=' + eval(y) + ',scrollbars=no,resizable=no,width=' + eval(theWidth) + ',height=' + eval(theHeight);
  aWindow = window.open('', '', features);
  if (aWindow != null)
  {
    if (aWindow.opener == null)
    {
      aWindow.opener = self;
    }
  }
  aWindow.document.clear();
  aWindow.document.open();
  aWindow.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">');
  aWindow.document.writeln('<html>');
  aWindow.document.writeln('<head>');
  aWindow.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">');
  aWindow.document.writeln('<bgsound src="../diashow/sounds/air.mid" loop="-1">');
  aWindow.document.writeln('<title>Kloster Arnsburg: Diashow</title>');
  aWindow.document.writeln('</head>');
  aWindow.document.writeln('<frameset rows="20,400,*" border="0" frameborder="0" framespacing="0">');
  aWindow.document.writeln('<frame name="rando" src="../diashow/rand.htm" scrolling="no" noresize marginwidth="0" marginheight="0" frameborder="0">');

  aWindow.document.writeln('<frameset cols="100,400,*" border="0" frameborder="0" framespacing="0">');
  aWindow.document.writeln('<frame name="randl" src="../diashow/rand.htm" scrolling="no" noresize marginwidth="0" marginheight="0" frameborder="0">');
  aWindow.document.writeln('<frame name="bild" src="../diashow/images/image00.jpg" scrolling="no" noresize marginwidth="0" marginheight="0" frameborder="0">');
  aWindow.document.writeln('<frame name="randr" src="../diashow/rand.htm" scrolling="no" noresize marginwidth="0" marginheight="0" frameborder="0">');
  aWindow.document.writeln('<\/frameset>');

  aWindow.document.writeln('<frame name="knoepfe" src="../diashow/knoepfe.htm" scrolling="no" noresize marginwidth="0" marginheight="0" frameborder="0">');
  aWindow.document.writeln('<noframes><body><\/body><\/noframes>');
  aWindow.document.writeln('<\/frameset>');
  aWindow.document.writeln('</html>');
  aWindow.document.close();
  aWindow.moveTo(x, y);
  aWindow.focus();
}

//************************************************************************************************************

var
  theText = "";
  theText2 = "";

function laufschrift(seed, aText)
{
  var out = "";  
  var j;  
  var cmd;
  if (aText.length > 0)
  {
    theText = aText;
  }
  if (seed >= 1000) // nur beim ersten Aufruf
  {
    seed = document.startform.lauftext.size;
  }
  if (seed > 0)
  { 
    for (j = 0; j < seed; j++)
    {
      out += " ";                            // jede Menge Leerzeichen aneinanderhängen
    }
    out += theText;                          // Leerzeichen + Text in das Textfeld schreiben
    document.startform.lauftext.value = out;
    seed = seed - 1;                         // Funktion laufschrift zeitverzögert aufrufen:
    cmd = "laufschrift(" + seed + ", '')";
    window.setTimeout(cmd, 150);
  }
  else
  {
    if (-seed < theText.length)
    {
      out = theText.substring(-seed, theText.length); // Text vorne abschneiden:
      document.startform.lauftext.value = out;
      seed = seed - 1;
      cmd = "laufschrift(" + seed + ", '')";
      window.setTimeout(cmd, 150);
    }
    else
    {
      document.startform.lauftext.value = " ";
      window.setTimeout("laufschrift(1000, '')", 150); // wieder von vorne anfangen
    }
  }
}

function laufschrift2(seed, aText)
{
  var out = "";  
  var j;  
  var cmd;
  if (aText.length > 0)
  {
    theText2 = aText;
  }
  if (seed >= 1000) // nur beim ersten Aufruf
  {
    seed = document.startform.lauftext2.size;
  }
  if (seed > 0)
  { 
    for (j = 0; j < seed; j++)
    {
      out += " ";                            // jede Menge Leerzeichen aneinanderhängen
    }
    out += theText2;                         // Leerzeichen + Text in das Textfeld schreiben
    document.startform.lauftext2.value = out;
    seed = seed - 1;                         // Funktion laufschrift zeitverzögert aufrufen:
    cmd = "laufschrift2(" + seed + ", '')";
    window.setTimeout(cmd, 150);
  }
  else
  {
    if (-seed < theText2.length)
    {
      out = theText2.substring(-seed, theText2.length); // Text vorne abschneiden:
      document.startform.lauftext2.value = out;
      seed = seed - 1;
      cmd = "laufschrift2(" + seed + ", '')";
      window.setTimeout(cmd, 150);
    }
    else
    {
      document.startform.lauftext2.value = " ";
      window.setTimeout("laufschrift2(1000, '')", 150); // wieder von vorne anfangen
    }
  }
}
