function fade(step,idx,idxAlt) {
  var imgs = document.getElementById("animation").getElementsByTagName("img");

  step = step || 0;

  if (idx > 0) {
    imgs[idx].style.opacity = step/100;
    imgs[idx].style.filter = "alpha(opacity=" + step + ")";
  } else {
    imgs[idxAlt].style.opacity = (100-step)/100;
    imgs[idxAlt].style.filter = "alpha(opacity=" + (100 - step) + ")";
  }

  step = step + 1;

  if (step <= 100) {
    window.setTimeout(function () { fade(step,idx,idxAlt); }, 1);
  } else {
    if (idxAlt > 0) {
      imgs[idxAlt].style.opacity = 0;
      imgs[idxAlt].style.filter = "alpha(opacity=0)";
    }
    if ( idx < (imgs.length - 1) ) {
      idx = idx + 1;
    } else {
      idx = 0;
    }
    if ( idxAlt < (imgs.length - 1) ) {
      idxAlt = idxAlt + 1;
    } else {
      idxAlt = 0;
    }
    window.setTimeout(function () { fade(0,idx,idxAlt); }, 8000);
  }
}


function animation() {
  var imgs = document.getElementById("animation").getElementsByTagName("img");
  var idx = 1;
  var idxAlt = 0;
  imgs[idxAlt].style.opacity = 1;
  imgs[idxAlt].style.filter = "alpha(opacity=100)";
  window.setTimeout(function () { fade(0,idx,idxAlt); }, 3000);
};

function chkKontaktForm () {
  if (document.kontaktForm.Name.value == "") {
    alert("Bitte Ihren Namen eingeben!");
    document.kontaktForm.Name.focus();
    return false;
  }
  if (document.kontaktForm.Strasse.value == "") {
    alert("Bitte die Strasse eingeben!");
    document.kontaktForm.Strasse.focus();
    return false;
  }
  if (document.kontaktForm.Nr.value == "") {
    alert("Bitte die Hausnummer eingeben!");
    document.kontaktForm.Nr.focus();
    return false;
  }
  if (document.kontaktForm.PLZ.value == "") {
    alert("Bitte die Postleitzahl eingeben!");
    document.kontaktForm.PLZ.focus();
    return false;
  }
  if (document.kontaktForm.Ort.value == "") {
    alert("Bitte den Wohnort eingeben!");
    document.kontaktForm.Ort.focus();
    return false;
  }
  if (document.kontaktForm.Mail.value == "") {
    alert("Bitte Ihre E-Mail-Adresse eingeben!");
    document.kontaktForm.Mail.focus();
    return false;
  }
  if (document.kontaktForm.Mail.value.indexOf("@") == -1) {
    alert("Keine E-Mail-Adresse!");
    document.kontaktForm.Mail.focus();
    return false;
  }
}
