document.addEventListener('DOMContentLoaded', function() {
var images = document.querySelectorAll('.monochrome');
if (images.length) { // Check if there are any images with the "monochrome" class
window.addEventListener('scroll', function() {
var scrollPos = window.pageYOffset;
images.forEach(function(image) {
var offset = image.offsetTop;
if (scrollPos >= offset - 250 && scrollPos <= offset + image.offsetHeight - 250)
image.style.filter = 'grayscale(0%)'; // Set the selected image to full color
else
image.style.filter = 'grayscale(100%)'; // Set the selected image to monochrome
});
});
}
});