/* funktionen.js (c) A. Kirschbaum 06.2011 */
/* ------------------------------------------------------------------------*/

var menusel = 1;    /* Gewählter Menüeintrag           */
var menun = 7;      /* Anzahl Menüeinträge             */

var bildzustand = 0;  /* Flag fuer Bild-Dia-Schau                    */
var wartezustand = 0; /* Flag fuer Warten auf vollstaendiges Laden   */
var wartezeit = 200;  /* Pruefenintervall [1/1000s] fuer Ladezustand */
var bildzeit = 6000;  /* Intervall fuer Bildwechsel                  */

/* ------------------------------------------------------------------------*/

/* Bild austauschen                                     */
/* bildname = CSS-id-Bezeichner fuer dieses Bild        */
/* bildnr   = Austauschbild-Index aus Array 'bild'      */
/* pause    = 0=Ohne ueberblendung, 1=Mit ueberblednung */

function tauschebild(bildname,bildnr,pause)
{ if(document.getElementById)
  { bildobj = document.getElementById(bildname);
    if(pause&&bildobj.filters)
      bildobj.filters.blendTrans.Apply();
    bildobj.src = bild[bildnr].src;
    if(pause&&bildobj.filters)
      bildobj.filters.blendTrans.Play();
  }
}

/* ------------------------------------------------------------------------*/

/* Folgebild fuer Bild mit CSS-id-Bezeichner 'bildbez' aufrufen          */
/* unter Austausch der Bildunterschrift mit dem id-Bezeichner "bildtext" */
/* Bildunterschriften im Array 'bildtexte'                               */
/* Bilderanzahl in 'bilder', aktueller Index in 'bildix'                 */
/* pause = 0=Ohne ueberblendung, 1=Mit ueberblednung                     */

function naechstesbild(pause)
{ bildix = bildix+1;
  if(bildix >= bilder)
    bildix = 0;
  tauschebild(bildbez,bildix,pause);
}

/* ------------------------------------------------------------------------*/

/* Bildlauffunktion (s. naechstesbild() ) starten bzw. anhalten */
/* Es wird gewartet bis 'bild[0]' vollstaendig geladen ist      */
/* Wartezustand wird unter 'wartezustand' festgehalten          */
/* Bildzustand wird unter 'bildzustand' festgehalten            */

function startstopbilder()
{ if(document.images)
    if(bildzustand != 0)
    { window.clearInterval(bildstatus);
      bildzustand = 0;
    }
    else
      if(bild[0].complete != true)
      { if(wartezustand == 0)
        { wartestatus = window.setInterval("startstopbilder()",wartezeit);
          wartezustand = 1;
        }
      }
      else
      { if(wartezustand == 1)
        { window.clearInterval(wartestatus);
          wartezustand = 0;
        }
        bildstatus = window.setInterval("naechstesbild(1)",bildzeit);
        bildzustand = 1;
      }
}

/* ------------------------------------------------------------------------*/

/* Wechseln           */
/* id = Auswahlnr 1.. */

function wechsel(id)
{ var bildobj;

  if(document.getElementById)
  { bildobj = eval(document.getElementById("b"+menusel));
    bildobj.style.display = "none";
    bildobj = eval(document.getElementById("a"+menusel));
    bildobj.style.borderTopColor = "#fff";
    bildobj.style.borderBottomColor = "#fff";
    bildobj.style.backgroundImage = "url()";
    bildobj = eval(document.getElementById("b"+id));
    bildobj.style.display = "inline";
    bildobj = eval(document.getElementById("a"+id));
    bildobj.style.borderTopColor = "#666";
    bildobj.style.borderBottomColor = "#666";
    bildobj.style.backgroundImage = "url(images/auswahl.jpg)";
    menusel = id;
  }
}


