<script>
document.addEventListener("DOMContentLoaded", function () {
  var images = [
    "https://reach-visuals.com/wp-content/uploads/2025/09/solomun_ade_ziggodome.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/AMLS_AL_4_1200x900.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/Video-02-05-2025-22-49-35_06813.png",
	"https://reach-visuals.com/wp-content/uploads/2025/09/ELECTRIC_FEST_LOCODICE_2016_ARUBA-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/BLUEMARLIN_UAE_2016-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/CARLCOX_TECHNIQUES_210919-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/COCOON_AUS_2014-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/COCOON_AUS_2015-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/COCOON_HERPOES_INTOTHEMAGIC_2012-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/COCOON_WOMB_2014-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/CocoonHeroes_Ageha_TOKYO_2012_1-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/CocoonHeroes_Ageha_TOKYO_2012_2-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/CocoonHeroes_Ageha_TOKYO_2013-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/COCOONHEROES_INTOTHEMAGIC_2012-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/COCOONHEROES_WEAREFSTVL_2013_ESSEX_UK-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/COCORICO_2012-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/DGTL_2016-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/DGTL_SAOPAULO_05052018_GeneratorStage_BENKOOCK-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/DGTL_SAOPAULO_05052018_GeneratorStage_LenFaki-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/DUBFIRE_1-gigapixel-cgi-3840w-scaled.jpg",
    "https://reach-visuals.com/wp-content/uploads/2025/09/DUBFIRE-2-gigapixel-cgi-3840w-scaled.jpg",
  ];

  let section = document.querySelector(".elementor-element-hero"); // jouw Hero sectie ID/class
  let lastIndex = -1; // bewaart de vorige foto index

  if (section) {
    function changeBackground() {
      let randomIndex;
      do {
        randomIndex = Math.floor(Math.random() * images.length);
      } while (randomIndex === lastIndex); // zorgt dat hij niet dezelfde kiest

      lastIndex = randomIndex;

      section.style.backgroundImage = "url('" + images[randomIndex] + "')";
      section.style.backgroundSize = "cover";
      section.style.backgroundPosition = "center";
      section.style.backgroundRepeat = "no-repeat";
    }

    changeBackground(); // eerste image direct instellen
    setInterval(changeBackground, 5000); // elke 5 sec wisselen
  }
});
</script>


