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

document.querySelector('.back-to-top a').onclick = function(event) {
  event.preventDefault();
  window.scrollTo({top: 0, behavior: 'smooth'});
};

// Property Slider
jQuery(document).ready(function() {
  var owl = jQuery('.property-section .js-es-listings');
  owl.find('p:empty').remove();
  owl.addClass('owl-carousel');
  owl.owlCarousel({
    loop: true,
    margin: 15,
    autoplay: true,
    nav: true,
    dots: true,
    responsive: {
      0: {
        items: 1,
      },
      768: {
        items: 2,
      },
      1200: {
        items: 3,
      }
    },
  });
  setTimeout(function() {
    var controls = jQuery('<div class="custom-controls"></div>');
    controls.append(owl.find('.owl-prev'));
    controls.append(owl.find('.owl-dots'));
    controls.append(owl.find('.owl-next'));
    owl.append(controls);
    owl.find('.owl-nav').hide();
  }, 100);
});

// Property Static Slider
jQuery(document).ready(function() {
  var owl = jQuery('.property-section .owl-carousel');
  owl.owlCarousel({
    loop: true,
    margin: 15,
    autoplay: true,
    nav: true,
    dots: true,
    responsive: {
      0: { items: 1 },
      768: { items: 2 },
      1200: { items: 3 }
    },
  });
  setTimeout(function() {
    var controls = jQuery('<div class="custom-controls"></div>');

    controls.append(owl.find('.owl-prev').detach());
    controls.append(owl.find('.owl-dots').detach());
    controls.append(owl.find('.owl-next').detach());

    owl.append(controls);
  }, 200);
});

// Remove tags
jQuery(document).ready(function($) {
  $('.property-section .property-boxes meta[itemprop="name"], \
    .property-section .property-boxes meta[itemprop="image"], \
    .property-section .property-boxes br').remove();
});