
//Diese JavaScript-Datei enthält alle für die Website benötigten
//JavaScript-Funktionen, wie z.B. die Roll-Over-Effekte für das
//Hauptmenü usw.

var theWindow = null;

//************************************************************************************************************

function showSchlossFrames()
{
  parent['kopf'].location.href = 'kopf_schloss.htm';
  parent['menue'].location.href = 'menue_schloss.htm';
}

//************************************************************************************************************

function MM_preloadImages()
{
  var d = document;
  if (d.images)
  {
    if (!d.MM_p)
    {
      d.MM_p = new Array();
    }
    var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
    for (i = 0; i < a.length; i++)
    {
      if (a[i].indexOf("#") != 0)
      {
        d.MM_p[j] = new Image;
        d.MM_p[j++].src = a[i];
      }
    }
  }
}

function MM_findObj(n, d)
{
  var p, i, x;
  if (!d)
  {
    d = document;
  }
  if ((p = n.indexOf("?")) > 0 && parent.frames.length)
  {
    d = parent.frames[n.substring(p + 1)].document;
    n = n.substring(0, p);
  }
  if (!(x = d[n]) && d.all)
  {
    x = d.all[n];
  }
  for (i = 0; !x && i < d.forms.length; i++)
  {
    x = d.forms[i][n];
  }
  for (i = 0; !x && d.layers && i < d.layers.length; i++)
  {
    x = MM_findObj(n, d.layers[i].document);
  }
  if (!x && document.getElementById)
  {
    x = document.getElementById(n);
  }
  return x;
}

function MM_swapImage()
{
  var i, j = 0, x, a = MM_swapImage.arguments;
  document.MM_sr = new Array;
  for (i = 0; i < (a.length - 2); i += 3)
  {
    if ((x = MM_findObj(a[i])) != null)
    {
      document.MM_sr[j++] = x;
      if (!x.oSrc)
      {
        x.oSrc = x.src;
      }
      x.src = a[i + 2];
    }
  }
}

function MM_swapImgRestore()
{
  var i, x, a = document.MM_sr;
  for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++)
  {
    x.src = x.oSrc;
  }
}

//************************************************************************************************************

function Bildwechsel(Bildnr, Bildobjekt)
{
  window.document.images[Bildnr].src = Bildobjekt.src;
}

function showFrame(URI, frameName)
{
  parent[frameName].location.href = URI;
}

function showInFrames(param) //beim Aufruf einer Seite ohne Frames diese einschalten
{
  if (top.frames.length == 0) //keinerlei Frames im obersten Fenster gefunden
  {
    if (param.length > 0 && param.indexOf("?") > 0)
    {
      top.location.href = param; // Index-Seite mit ausgewähltem Frame aufrufen
    }
  }
  
}

function openBrowserWindowCenter(theImage, theWidth, theHeight, theText)
{
  closeBrowserWindow();
  theWidth = eval(theWidth) + 20;
  theHeight = eval(theHeight) + 20 + 60; // 60 = 15 * 4 darunter stehende Textzeilen
  var x = (screen.width - theWidth) / 2;
  var y = (screen.height - theHeight) / 2;
  var features = 'left=' + eval(x) + ',top=' + eval(y) + ',scrollbars=no,resizable=no,width=' + eval(theWidth) + ',height=' + eval(theHeight);
  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("Schloss Herborn");
  theWindow.document.writeln('</title>');
  theWindow.document.writeln('</head>');
  theWindow.document.writeln('<body bgcolor="#FFFFFF" leftmargin="10" topmargin="10" marginwidth="10" marginheight="10">');
  theWindow.document.write('<img src="');
  theWindow.document.write(theImage);
  theWindow.document.writeln('" border="0" alt=""><br>');
  theWindow.document.writeln(theText);
  theWindow.document.writeln('</body>');
  theWindow.document.writeln('</html>');
  theWindow.document.close();
  theWindow.focus();
}

function openBrowserWindow(theImage, theWidth, theHeight, theText)
{
  closeBrowserWindow();
  
  theWidth = eval(theWidth);
  theHeight = eval(theHeight) + 20;
  var x = (screen.width - theWidth) / 2;
  var y = (screen.height - theHeight) / 2;
  var features = 'left=' + eval(x) + ',top=' + eval(y) + ',location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=' + eval(theWidth) + ',height=' + eval(theHeight);
  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("Schloss Herborn");
  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('" border="0" alt=""><br>');
  theWindow.document.writeln('&nbsp;' + theText);
  theWindow.document.writeln('</body>');
  theWindow.document.writeln('</html>');
  theWindow.document.close();
  theWindow.focus();
}

function closeBrowserWindow()
{
  if (theWindow != null)
  {
    theWindow.close();
    theWindow = null;
  }
}

function showPicture(theId)
{
  document.getElementById(theId).style.display = 'inline';
}

function hidePicture(theId)
{
  document.getElementById(theId).style.display = 'none';
}

//************************************************************************************************************

var
  theText = "";

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
    }
  }
}
