const state = {};

function initSlideshow(id) {
  state[id] = 0;
}

function changeSlide(id, dir) {
  const slides = document.querySelectorAll(`#${id} .slide`);
  const dots = document.querySelectorAll(`#${id}-dots .dot`);
  slides[state[id]].classList.remove('active');
  dots[state[id]].classList.remove('active');
  state[id] = (state[id] + dir + slides.length) % slides.length;
  slides[state[id]].classList.add('active');
  dots[state[id]].classList.add('active');
}

function goToSlide(id, index) {
  const slides = document.querySelectorAll(`#${id} .slide`);
  const dots = document.querySelectorAll(`#${id}-dots .dot`);
  slides[state[id]].classList.remove('active');
  dots[state[id]].classList.remove('active');
  state[id] = index;
  slides[state[id]].classList.add('active');
  dots[state[id]].classList.add('active');
}

initSlideshow('farn');
initSlideshow('moos');


document.addEventListener("DOMContentLoaded", () => {
    const toggle = document.getElementById("dark-mode-toggle");

    // Gespeicherten Zustand wiederherstellen
    if (localStorage.getItem("darkMode") === "true") {
        document.body.classList.add("dark");
    }

    // Beim Klick umschalten und speichern
    toggle.addEventListener("click", () => {
        document.body.classList.toggle("dark");
        const isDark = document.body.classList.contains("dark");
        localStorage.setItem("darkMode", isDark);
    });
});

// Begruessung nach Tageszeit
const stunde = new Date().getHours();
let text;
let klasse;

if (stunde < 10) {
  text = "Guten Morgen!";
  klasse = "morgen";
} else if (stunde < 18) {
  text = "Hallo, schön dass du da bist!";
  klasse = "tag";
} else {
  text = "Guten Abend!";
  klasse = "abend";
}

const el = document.getElementById("begruessung");
el.textContent = text;
el.classList.add(klasse);