/*
// -----------------------------------------------------------------------------
// Projekt: biefer.com
// Datei: js_diashow.js
// Does: Steuert das Ersetzen eines Bildes durch andere Bilder
// -----------------------------------------------------------------------------
// Bedingungen damit diese Funktionen funktionieren:
// Funktionsaufruf diaIgnition() im Bodytag onload
// mit den Parametern Total Anzahl Bilder und Dateiendung
// Alle Bilder im Unterordner 'images' sind durchnummeriert, beginnend mit 1 (nicht 01)
// Das Urbild muss name='myPicture' haben
// Navigation vorhanden mit Aufruf
*/


// -----------------------------------------------------------------------------

// Automatische Diashow

// zuerst initialisieren von Variablen
imgtot = 10;
imgend = "gif";
i = 1;
flag="play";
// dann empfangen von Variablen
function diaIgnition(tot,end) {
  imgtot = tot;
  imgend = end;
  diaAuto(); // starten der eigentlichen diashow funktion
}


function diaAuto() {
  document.myPicture.src = "images/"+i+"."+imgend;
  if (i < imgtot) {	// solange die Variable i kleiner ist als die Bildzahl
    i += 1;	// rechne zu i 1 dazu
  } else {		// sonst, also nach dem letzten Bild
    i = 1;	// wird die Variable i wieder auf 1 gesetzt
  }
  thisPic = i; // aktuelles Bild für Manuelle Diashow
  if (flag=="play") {
    setTimeout("diaAuto()",1000); // zeitliche Verzögerung um Millisekunden
  }
}	// END Funktion 'diaAuto()'

// -----------------------------------------------------------------------------

// Stop Automatische Diashow
function stopper() {
  showhide ();
  flag="stop";
  i -= 2;
  diaAuto();
}

// Start Automatische Diashow
function starter() {
  showhide ();
  flag="play";
//  i -= 1;
  diaAuto();
}
// -----------------------------------------------------------------------------

// Manuelle Diashow
function diaManu(direction) {
	if (document.images) {
		thisPic = thisPic + direction;
		if (thisPic > imgtot) {
			thisPic = 1;
		}
		if (thisPic < 1) {
			thisPic = imgtot;
		}
		document.myPicture.src= "images/"+thisPic+"."+imgend;;
		i=thisPic; // aktuelles Bild für Automatische Diashow
	}
} // END function chgSlide()

// -----------------------------------------------------------------------------

// Verstecken-Zeigen der Manuellen Bedienung
function showhide () { // start function
  if (document.getElementById) { // start if browser knows DOM
    if (document.getElementById("pause").style.display == "inline") {
      document.getElementById("pause").style.display = "none";
      document.getElementById("play").style.display = "inline";
    }
    else if (document.getElementById("pause").style.display == "none") {
      document.getElementById("pause").style.display = "inline";
      document.getElementById("play").style.display = "none";
    }
  } // end if browser
} // end function


