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');
