function addOnloadFunc (newOnloadFunc)
{
  var oldOnloadFunc = window.onload;
  
  if (typeof oldOnloadFunc!='function') 
  {
    window.onload = function()
    { 
      newOnloadFunc(); 
    }
  } 
  else 
  {
    window.onload = function() 
    {
      if (oldOnloadFunc) // IE 7 soll ansonsten angeblich einen Runtime-Error produzieren
      oldOnloadFunc();
      newOnloadFunc();
    }
  }
}
/* Hängt eine Funktion an den Onload-Handler der Webseite an - Syntax:
1. addOnloadFunc(function(){...});   (Zeilenumbrüche im Function-Code sind erlaubt!)
2. addOnloadFunc(funcVariable);
Die angehängten Funktionen werden in der Reihenfolge des Anhängens ausgeführt. */

if (document.getElementById)
{
  function getElementsByClassName(obj, klassenName)
  {
    var elements=obj.getElementsByTagName('*');
    var elementsLength=elements.length;

    klassenName=klassenName.replace(/\s+/g, ' ').replace(/\s+$/, '').replace(/^\s+/, '').split(' ');
    var klassenNameLength=klassenName.length;

    var result=new Array();

    for (var x=0; x<elementsLength; x++)
    if (elements[x].className)
    {
      var klassen=elements[x].className.replace(/\s+/g, ' ').replace(/\s+$/, '').replace(/^\s+/, '').split(' ');
      var klassenLength=klassen.length;

      var found=0;
      for (var y=0; y<klassenLength; y++)
      {
        for (var z=0; z<klassenNameLength; z++)
        if (klassen[y]==klassenName[z])
        { 
          found++;
          break; 
        }
        if (found==klassenNameLength)
        {
          result[result.length]=elements[x];
          break;
        }
      }
    }
    return result;
  }
  /* muss laut HTML-5-Spezifikation case-sensitiv arbeiten und mehrerere, durch Leerzeichen
  getrennte Klassennamen im Parameter "klassenName" berücksichtigen, sowie Zeilenumbrüche 
  in Element.className in Leerzeichen umwandeln */


  /* Netscape ab 7, MSIE ab 6 (Mac: 5) */
  if (!document.getElementsByClassName)
  {
    document.getElementsByClassName=function(klassenName)
    { return getElementsByClassName(this, klassenName); }
  }


  /* MSIE 5,6,7 und andere Browser, die das "Element"-Objekt noch nicht kennen */
  function installGetElementsByClassName(elementObj)
  {
    if (typeof Element!='undefined') return;

    if (elementObj!=null)
    elementObj.getElementsByClassName=function(klassenName)
    { return getElementsByClassName(this, klassenName); }

    var allElements=document.getElementsByTagName('*');
    var allElementsLength=allElements.length;
    for (var x=0; x<allElementsLength; x++)
    allElements[x].getElementsByClassName=function(klassenName)
    { return getElementsByClassName(this, klassenName); }
  }
  /* kann während des Seitenaufbaus aufgerufen werden, um wenigstens die schon geladenen 
     HTML-Elemente mit der Methode "getElementsByClassName" nachzurüsten. - Wenn im
     Parameter "elementObj" ein "Element"-Objekt übergeben wird, wird nur dieses Element
     nachgerüstet - dies *muss* immer unmittelbar nach dem Erzeugen eines neuen Elements 
     mit "createNode" oder "innerHTML" erfolgen. */


  if (typeof Element!='undefined') /* Netscape ab 7, MSIE 8, Firefox+Safari bis 2, Camino bis 1 */
  {
    if (!Element.prototype.getElementsByClassName)
    {
      Element.prototype.getElementsByClassName=function(klassenName)
      { return getElementsByClassName(this, klassenName); }
    }
  }
  else /* MSIE 5,6,7 */
  {
    addOnloadFunc(installGetElementsByClassName);
  }
}
window.viewportHeight=function()
{
  var de=document.documentElement;
  return window.innerHeight || self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
}

window.viewportWidth=function()
{
  var de = document.documentElement;
  return window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
}

function Zoomer (origWidth, origHeight, zoomWidth, zoomHeight)
{
  /* zoomWidth=-1 -> Breite ergibt sich automatisch */
  /* zoomHeight=-1 -> Höhe ergibt sich automatisch */

  this.newWidth =0;
  this.newHeight=0;

  this.calcBigSize=function()
  {
    this.newWidth =zoomWidth;
    this.newHeight=zoomHeight;

    if (this.newWidth < origWidth)  this.newWidth =origWidth;
    if (this.newHeight<origHeight) this.newHeight=origHeight;

    if (origWidth>=this.newWidth && origHeight>=this.newHeight) return false; /* raus, wenn das Objekt bereits gleichgroß oder größer ist */

    /* ab hier sind beide "calc"-Funktionen identisch */
    var zoom_w= this.newWidth /origWidth; 
    var zoom_h =this.newHeight/origHeight;
  
    if         (zoom_w<zoom_h) this.newHeight=Math.min(Math.round(origHeight*zoom_w), this.newHeight); /* min(): falls das Rundungsergebnis einen Pixel größer ist als der originale Maximal-Wert */
    else if (zoom_h<zoom_w) this.newWidth =Math.min(Math.round(origWidth  *zoom_h), this.newWidth);
  
    return true;
  }


  this.calcSmallSize=function()
  {
    this.newWidth =zoomWidth;
    this.newHeight=zoomHeight;

    if (this.newWidth ==-1 || this.newWidth > origWidth)  this.newWidth =origWidth;
    if (this.newHeight==-1 || this.newHeight>origHeight) this.newHeight=origHeight;

    if (origWidth<=this.newWidth && origHeight<=this.newHeight) return false; /* raus, wenn das Objekt bereits gleichgroß oder kleiner ist */

    var zoom_w= this.newWidth /origWidth; 
    var zoom_h =this.newHeight/origHeight;
  
    if         (zoom_w<zoom_h) this.newHeight=Math.min(Math.round(origHeight*zoom_w), this.newHeight); /* min(): falls das Rundungsergebnis einen Pixel größer ist als der originale Maximal-Wert */
    else if (zoom_h<zoom_w) this.newWidth =Math.min(Math.round(origWidth  *zoom_h), this.newWidth);
  
    return true;
  }

}

function FlashMovie (instanceName, objectID)
{
  this.maxZoomFaktor=1.5; /* wenn das Movie nicht ins Browserfenster passt, wird ein kleinerer Zoomfaktor verwendet */
  this.rightMargin=20; /* in Pixel  - wird bei der Berechnung der max. Größe von der Breite des Browserfensters abgezogen*/
  this.bottomMargin=20; /* in Pixel - wird bei der Berechnung der max. Größe von der Höhe des Browserfensters abgezogen */

  var movie;
  var thisObj=this; /* in internen Methoden anstelle von "this" verwenden, da dort kein Zugriff auf  "this" möglich ist */

  var flashWindow;
  var origWidth;
  var origHeight;
  var zoomed=false; /* Aktueller Zustand des Movies: false=Originalgröße, true=gezoomt */

/* this.frameNum=function() { return movie.FrameNum; }  ginge nur mit MSIE/ActiveX */

  this.totalPages=function()
  {
    if (typeof movie.TotalFrames=='undefined')
    return 0; /* 0=ungültiger Wert=Funktion wird nicht unterstützt */
    if (typeof movie.TotalFrames=='number') 
    return movie.TotalFrames; /* MSIE mit Flash 6*/
    else
    return movie.TotalFrames(); /* mindestens ab Flash 9 */
  }

  this.nextPage=function()
  {
    movie.Forward();
    return false;
  }

  this.prevPage=function()
  {
    movie.Back();
    return false;
  }


  this.zoom=function()
  {
    var bigWidth=Math.min(Math.max(window.viewportWidth()-this.rightMargin, 0), origWidth*this.maxZoomFaktor);
    var bigHeight=Math.min(Math.max(window.viewportHeight()-this.bottomMargin, 0), origHeight*this.maxZoomFaktor);
   
    if (zoomed=!zoomed) /* Vergrößern */
    {
      var zoomer=new Zoomer (origWidth, origHeight, bigWidth, bigHeight);
      if (!zoomer.calcBigSize()) return false;
      flashWindow.style.width=zoomer.newWidth+'px';
      flashWindow.style.height=zoomer.newHeight+'px';
    }
    else /* auf Originalgröße zurücksetzen */
    {
      flashWindow.style.width=origWidth+'px';
      flashWindow.style.height=origHeight+'px';
    }

    if (this.zoomCallback) this.zoomCallback(objectID, zoomed);

    movie.width='100%';
    movie.height='100%';
    movie.Zoom(0);

    return false;
  }


  this.init=function()
  {
    if (!document.getElementById) return;
    movie=document.getElementById(objectID);
    if (!movie || movie.nodeName!='OBJECT' || typeof movie.Zoom=='undefined') return; /* !movie.Zoom: Flash-Plugin aus oder Uralt-Version (z.B. Shockwave 2) */

    flashWindow=movie.parentNode;
    origWidth=parseInt(flashWindow.style.width, 10);
    origHeight=parseInt(flashWindow.style.height, 10);

    var menu;
    if (menu=document.getElementById(objectID+'_menu'))
    menu.style.display='';

    var link;
    if (link=document.getElementById(objectID+'_zoom'))
    {
      if (link.nodeName=='A')
      link.href='javascript:void('+instanceName+'.zoom());';
      else
      link.onclick=function() { return thisObj.zoom(); };
    }

    if (link=document.getElementById(objectID+'_next'))
    {
      if (link.nodeName=='A')
      link.href='javascript:void('+instanceName+'.nextPage());';
      else
      link.onclick=function() { return thisObj.nextPage(); };
    }

    if (link=document.getElementById(objectID+'_prev'))
    {
      if (link.nodeName=='A')
      link.href='javascript:void('+instanceName+'.prevPage());';
      else
      link.onclick=function() { return thisObj.prevPage(); };
    }
  }

  addOnloadFunc(this.init);
}


FlashMovie.prototype.zoomCallback=function(objectID, zoomed)
{
  var texteRechts=document.getElementsByClassName('content_right');
  if (texteRechts.length>0)
  texteRechts[0].style.visibility=zoomed ? 'hidden' : 'visible';

  var zoomLink=document.getElementById(objectID+'_zoom');
  if (zoomLink) zoomLink.innerHTML=zoomed ? '[verkleinern]' : '[vergrößern]';
}
function PicViewer(instanceName, changeMode, picWindowId, picWindowWidth, picWindowHeight)
{
  var MSIE=navigator.userAgent.indexOf('MSIE')>-1 && !window.opera;
  var MacMSIE=MSIE && navigator.userAgent.indexOf('Mac')>-1;
  if (MacMSIE) changeMode=''; /* Bilder ohne Effekt wechseln */

/* --------------------------------------- öffentliche Variablen ------------------------------------------ */

  this.disabledPrevLink='';   /* z.B. '<span>zurück</span>' */
  this.disabledNextLink='';
  this.prevLink='';           /* z.B. '<a rel="prev">zurück</a>' - Achtung, ohne "href"! */
  this.nextLink='';

  this.currentPageIndex=0;    /* falls die Bildgalerie auch ohne Javascript mittels <a>-Links seitenweise 
                                 geblättert werden kann bzw. direkt auf eine der Bildseiten verlinkt wird,
                                 muss hier der Index dieser Seite eingesetzt werden - Zählung beginnt mit 0 */
  this.lastPicIsUplink=false; /* auf true setzen, wenn beim Anklicken des letzten Bildes zum übergeordneten 
                                 Ordner (d.h., zur Übersichtsseite) gewechselt werden soll, genauer gesagt: 
                                 zur URL eines im Dokument enthaltenen <a rel="up">-Links */
  this.pause=1;
  this.step=20;

/* --------------------------------------  globale Hilfsvariablen ----------------------------------------- */

  var upLink=false;
  var pageNumber=false;
  var picWindow=false;
  var imgWrapperLink=false;

  var picTimer;
  var phase=1;

  var thisObj=this;           /* in internen Methoden anstelle von "this" verwenden, da dort kein Zugriff auf 
                                 "this" möglich ist */

/* ----------------------------------- Bild zur Bilderliste hinzufügen ------------------------------------ */

  var picList=new Array();

  function picListItem (src, text, klasse)
  {
    this.src=src;                           /* URL der Grafik-Datei */
    this.text=text!=null ? text : '';       /* optional: Bild-Unterschrift */
    this.klasse=klasse!=null ? klasse : ''; /* optional: Klasse, die im IMG-Tag eingefügt werden soll - dadurch 
                                               kann z.B. ein "border" gesetzt werden o.ä. */
  }

  this.addPic=function (src, text, klasse)
  {
    picList[picList.length]=new picListItem (src, text, klasse);
  }

/* Hier noch eine Funktion oder this.variable einsetzen, die den "Basepath" aufnimmt, 
   damit die Pfade in picList weniger Speicherplatz und Ladezeit in Ansprich nehmen */

/* ------------------------------------------ Slider-Funktionen ------------------------------------------- */

  var picMarginLeft=0;
  var picSlider=false;
  var picFrame=false;

  function clonePicFrame()
  {
    var nextFrame=picFrame.cloneNode(true);
    var img=nextFrame.getElementsByTagName('img');
    if (img.length>0) 
    {
      img=img[0];
      img.src=picList[thisObj.currentPageIndex].src;
      img.style.height='auto';
      img.style.width='auto';
      img.className=picList[thisObj.currentPageIndex].klasse;

      var imgText=nextFrame.getElementsByClassName(picWindowId+'_text');
      if (imgText.length>0)
      {
        imgText=imgText[0];
        imgText.innerHTML=picList[thisObj.currentPageIndex].text;
      }

      imgWrapperLink=nextFrame.getElementsByClassName(picWindowId+'_link');
      if (imgWrapperLink.length>0)
      {
        imgWrapperLink=imgWrapperLink[0];
        imgWrapperLink.tmpHref='javascript:void('+instanceName+'.nextPic());';
      }
    }
    phase=2;
    return nextFrame;
  }


  function endSlide()
  {
    clearInterval(picTimer);
    void (picSlider.removeChild(picFrame));
    picSlider.style.marginLeft='0px';
    picFrame=picSlider.firstChild;
    phase=1;
  }


  function slideNext()
  {
    if (phase==1)
    {
      picSlider.appendChild(clonePicFrame());
      picMarginLeft=0;
    }
    picMarginLeft-=thisObj.step;
    picSlider.style.marginLeft=picMarginLeft+'px';
    if (picMarginLeft<=0-picWindowWidth) endSlide();
  }


  function slidePrev()
  {
    if (phase==1)
    {
      picSlider.insertBefore(clonePicFrame(), picSlider.firstChild);
      picMarginLeft=0-picWindowWidth;
    }
    picMarginLeft+=thisObj.step;
    picSlider.style.marginLeft=picMarginLeft+'px';
    if (picMarginLeft>=0) endSlide();
  }


  this.slideNewPic=function(direction)
  {
    switch (direction)
    {
      case 'next' : slideNext(); break;
      case 'prev' : slidePrev(); break;
   /* case 'up'/'down' ... */  
    }
  }

/* ----------------------------------------- Fading-Funktion --------------------------------------------- */

  var curPic=false;
  var picText=false;
  var picOpacity=100;

  function MSIEfadeNewPic()
  {
    picWindow.style.visibility='hidden';
    picWindow.style.filter='blendTrans(Duration=0.8)'; /* Einblendzeit in Sekunden */
    picWindow.filters.blendTrans.Apply();
    picWindow.style.visibility='visible';
    picWindow.filters.blendTrans.Play();
    setNewPic();
  }

  this.fadeNewPic = function()
  {
    if (phase==1)
    {
      picOpacity-=this.step;
      picWindow.style.opacity=picOpacity/100;
      if (picOpacity<=0)
      {
        setNewPic();
        phase=2;
      }
    }
    else if (phase==2)
    {
      picOpacity+=this.step;
      picWindow.style.opacity=picOpacity/100;
      if (picOpacity>=100)
      {
        clearInterval(picTimer);
        phase=1;
        picOpacity=100;
      }
    }
  }

/* -------------------- Bildwechsel ohne Effekt und Hilfsfunktion für Fading-Funktion -------------------- */

  function setNewPic()
  {
    if (curPic)
    {
      curPic.src=picList[thisObj.currentPageIndex].src;
      if (MacMSIE)
      {
        curPic.height='';
        curPic.width='';
      }
      curPic.style.height='auto';
      curPic.style.width='auto';
      curPic.className=picList[thisObj.currentPageIndex].klasse;
    }
    if (picText) picText.innerHTML=picList[thisObj.currentPageIndex].text;
  }

/* -------------------------------------- Navigations-Funktionen ----------------------------------------- */

  function preLoad()
  {
    if (thisObj.currentPageIndex+1<picList.length)
    {
      var nextPic=new Image(); 
      nextPic.src=picList[thisObj.currentPageIndex+1].src;
    }
    if (thisObj.currentPageIndex>0)
    { 
      var prevPic=new Image(); 
      prevPic.src=picList[thisObj.currentPageIndex-1].src;
    }
  }


  function changePic(direction)
  {
    if (!changeMode)
    setNewPic();
    else
    if (changeMode=='slide')
    picTimer=setInterval(instanceName+'.slideNewPic("'+direction+'")', thisObj.pause);
    else
    if (MSIE)
    MSIEfadeNewPic();
    else
 /* if (changeMode=='fade') */
    picTimer=setInterval(instanceName+'.fadeNewPic()', thisObj.pause);
  
    if (pageNumber) pageNumber.innerHTML=thisObj.currentPageIndex+1;
    preLoad();
  }


  this.nextPic = function()
  {
    if (thisObj.currentPageIndex+1>=picList.length)
    {
      if (upLink) document.location.href=upLink;
      return false;
    }

    if (thisObj.currentPageIndex==0)
    {
      var prevL=document.getElementById(picWindowId+'_prev');
      if (prevL) prevL.innerHTML=thisObj.prevLink;
    }

    thisObj.currentPageIndex++;

    if (thisObj.currentPageIndex+1>=picList.length)
    {
      var nextL=document.getElementById(picWindowId+'_next');
      if (nextL) nextL.innerHTML=thisObj.disabledNextLink;
      if (imgWrapperLink) 
      {
         if (thisObj.lastPicIsUplink) 
         {
           if (upLink) imgWrapperLink.href=upLink; 
         }
         else imgWrapperLink.removeAttribute('href');
      }
    }

    changePic('next');
    return false; /* falls in onload-Attribut eingebunden */
  }


  this.prevPic = function()
  {
    if (thisObj.currentPageIndex<=0) return false;

    thisObj.currentPageIndex--;

    if (thisObj.currentPageIndex<=0)
    {
      var prevL=document.getElementById(picWindowId+'_prev');
      if (prevL) prevL.innerHTML=thisObj.disabledPrevLink;
    }

    if (thisObj.currentPageIndex<picList.length)
    {
      var nextL=document.getElementById(picWindowId+'_next');
      if (nextL) nextL.innerHTML=thisObj.nextLink;
      if (imgWrapperLink) imgWrapperLink.setAttribute('href', imgWrapperLink.tmpHref);
    }

    changePic('prev');
    return false;
  }


  this.init = function()
  {
    if (!Image || !document.getElementById) return;

    picWindow=document.getElementById(picWindowId);
    if (!picWindow) return;
    picWindow.style.width=picWindowWidth+'px';
    picWindow.style.height=picWindowHeight+'px';

    pageNumber=document.getElementById(picWindowId+'_pagenumber');

    thisObj.prevLink=thisObj.prevLink.replace(/<a /i, '<a href="javascript:void('+instanceName+'.prevPic())"');
    thisObj.nextLink=thisObj.nextLink.replace(/<a /i, '<a href="javascript:void('+instanceName+'.nextPic())"');

    switch (changeMode)
    {
      case 'slide' : picWindow.style.overflow='hidden';
                     picWindow.innerHTML='<div><div>'+picWindow.innerHTML+'<\/div><\/div>';

                     picSlider=picWindow.firstChild;
                     picSlider.style.width=(picWindowWidth*2+10)+'px'; /* 10 Pixel Reserve */
                     picSlider.style.height=picWindowHeight+'px';

                     picFrame=picSlider.firstChild;
                     installGetElementsByClassName(picFrame); /* MSIE 5,6,7 - da picFrame nachträglich mit innerHTML erzeugt wurde */
                     picFrame.style.width=picWindowWidth+'px';
                     picFrame.style.height=picWindowHeight+'px';
                     picFrame.style.cssFloat='left';
                     if (MSIE) /* MSIE inkl. MSIE 8 RC 1 unterstützt cssFloat nicht */
                     picFrame.style.styleFloat='left';
                     picFrame.style.overflow='hidden';

                     break;

      case 'fade'  :
      default      : var img=picWindow.getElementsByTagName('img');
                     if (img.length>0) curPic=img[0]; else return;
                     var imgText=picWindow.getElementsByClassName(picWindowId+'_text');
                     if (imgText.length>0) picText=imgText[0];
                     break;
    }

    if (thisObj.lastPicIsUplink)
    for (var x=0; x<document.links.length; x++)
    if (document.links[x].rel.toLowerCase()=='up')
    {
      upLink=document.links[x].href;
      break;
    }

    var prevL=document.getElementById(picWindowId+'_prev');
    if (prevL)
    {
      prevL=prevL.getElementsByTagName('a');
      if (prevL.length>0)
      prevL[0].href='javascript:void('+instanceName+'.prevPic());';
    }

    var nextL=document.getElementById(picWindowId+'_next');
    if (nextL)
    {
      nextL=nextL.getElementsByTagName('a');
      if (nextL.length>0)
      nextL[0].href='javascript:void('+instanceName+'.nextPic());';
    }
 
    imgWrapperLink=picWindow.getElementsByClassName(picWindowId+'_link');
    if (imgWrapperLink.length>0)
    {
      imgWrapperLink=imgWrapperLink[0];
      imgWrapperLink.tmpHref='javascript:void('+instanceName+'.nextPic());';
      if (thisObj.currentPageIndex+1>=picList.length)
      {
        if (thisObj.lastPicIsUplink) 
        {
          if (upLink) imgWrapperLink.href=upLink; 
        }
        else imgWrapperLink.removeAttribute('href');
      }
      else
      imgWrapperLink.href=imgWrapperLink.tmpHref;
    }

    preLoad();
  }

  addOnloadFunc(this.init);
}

/* HTML-Code-Schema:

<div id="referenzgrafik">
  <a href="2.htm" class="referenzgrafik_link"><img src="bild.jpg"></a>
  <div class="referenzgrafik_text">Startseite</div>
</div>

<span id="referenzgrafik_prev"><span>&lt;&lt;&lt;</span></span>
<a href="up.htm" rel="up">zur Übersicht</a>
<span id="referenzgrafik_next"><a href="2.htm">&gt;&gt;&gt;</a></span>

Seite <span id="referenzgrafik_pagenumber">1</span> von 3

*/
/* für Masken "Textseite" und "Ordner mit Text" */

var pause=10;
var step=3;

var fadeBlock, t;
var opacity=0;

var p=navigator.userAgent.indexOf('MSIE');
var isMSIElte8 = p>-1 && !window.opera && parseInt(navigator.userAgent.substr(p+5), 10)<=8;

function fadeFunc()
{
  opacity+=step;
  fadeBlock.style.opacity=opacity/100;
  if (opacity>=100)
  clearInterval(t);
}

function fadeIn()
{
  if (!document.getElementById) return;
  fadeBlock=document.getElementById('fadeblock');
  if (!fadeBlock) return;

  if (typeof picViewer!='undefined')
  {
     step=7; 
     pause=2;
  }

  if (isMSIElte8)
  {
    fadeBlock.style.filter='blendTrans(Duration=0.8)'; /* Einblendzeit in Sekunden */
    fadeBlock.filters.blendTrans.Apply();
    fadeBlock.style.visibility='visible';
    fadeBlock.filters.blendTrans.Play();
  }
  else
  t=window.setInterval('fadeFunc()', pause);
}

document.writeln('<style type="text/css">');
if (isMSIElte8)
document.writeln('#fadeblock { visibility: hidden; height: 1%; }');
else
document.writeln('#fadeblock { opacity: 0; }');
document.write('<\/style>');

addOnloadFunc(fadeIn);
