// Scroll to Top
window.onscroll = function() {
  const dropshipping_shop_button = document.querySelector('.scroll-top-box');
  if (dropshipping_shop_button) {
    if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
      dropshipping_shop_button.style.display = "block";
    } else {
      dropshipping_shop_button.style.display = "none";
    }
  }
};

const scrollTopLink = document.querySelector('.scroll-top-box a');
if (scrollTopLink) {
  scrollTopLink.onclick = function(event) {
    event.preventDefault();
    window.scrollTo({ top: 0, behavior: 'smooth' });
  };
}


// our services
jQuery(document).ready(function() {
  jQuery('.our-location .owl-carousel').owlCarousel({
    loop: true,
    margin: 0,
    nav: true,
    dots: false,
    rtl: false,
    responsive: {
    0: { 
      items: 1 
    },
    600: { 
      items: 2 
    },
    1000: { 
      items: 2
    },
    1200: { 
      items: 3 
    }
  },
    autoplay: false,
  });
});

// latest blog
jQuery(document).ready(function() {
  jQuery('.our-blog-section .owl-carousel').owlCarousel({
    loop: true,
    margin: 20,
    nav: true,
    dots: false,
    rtl: false,
    responsive: {
    0: { 
      items: 1 
    },
    600: { 
      items: 2 
    },
    1000: { 
      items: 2
    },
    1200: { 
      items: 3 
    }
  },
    autoplay: false,
  });
});

// form js
document.addEventListener("DOMContentLoaded", function() {
    // For Start Date
    let startDateInput = document.querySelector("input[name='mphb_check_in_date']");
    if (startDateInput) {
        startDateInput.setAttribute("placeholder", "Start Date");
    }
    // For Return Date
    let endDateInput = document.querySelector("input[name='mphb_check_out_date']");
    if (endDateInput) {
        endDateInput.setAttribute("placeholder", "Return Date");
    }
    // For Person
    let personSelect = document.querySelector("select[name='mphb_adults']");
    if (personSelect) {
        let firstOption = personSelect.querySelector("option[value='0']");
        if(!firstOption){
            firstOption = document.createElement("option");
            firstOption.value = "0";
            firstOption.textContent = "Person";
            firstOption.disabled = true;
            firstOption.selected = true;
            personSelect.insertBefore(firstOption, personSelect.firstChild);
        } else {
            firstOption.textContent = "Person";
            firstOption.disabled = true;
        }
    }
    // For Children
    let childrenInput = document.querySelector("select[name='mphb_children'], input[name='mphb_children']");
    if (childrenInput) {
        if(childrenInput.tagName === "SELECT"){
            let firstOption = childrenInput.querySelector("option[value='0']");
            if(firstOption){
                firstOption.textContent = "Children";
                firstOption.disabled = true;
            }
        } else {
            childrenInput.setAttribute("placeholder", "Children");
        }
    }
});
