function adventure_tourism_openNav() {
  jQuery(".sidenav").addClass('show');
}
function adventure_tourism_closeNav() {
  jQuery(".sidenav").removeClass('show');
}

function adventure_tourism_openSidebar() {
  jQuery(".header-widgets").addClass('show');
}
function adventure_tourism_closeSidebar() {
  jQuery(".header-widgets").removeClass('show');
}

( function( window, document ) {
  function adventure_tourism_keepFocusInMenu() {
    document.addEventListener( 'keydown', function( e ) {
      const adventure_tourism_nav = document.querySelector( '.sidenav' );

      if ( ! adventure_tourism_nav || ! adventure_tourism_nav.classList.contains( 'show' ) ) {
        return;
      }
      const elements = [...adventure_tourism_nav.querySelectorAll( 'input, a, button' )],
        adventure_tourism_lastEl = elements[ elements.length - 1 ],
        adventure_tourism_firstEl = elements[0],
        adventure_tourism_activeEl = document.activeElement,
        tabKey = e.keyCode === 9,
        shiftKey = e.shiftKey;

      if ( ! shiftKey && tabKey && adventure_tourism_lastEl === adventure_tourism_activeEl ) {
        e.preventDefault();
        adventure_tourism_firstEl.focus();
      }

      if ( shiftKey && tabKey && adventure_tourism_firstEl === adventure_tourism_activeEl ) {
        e.preventDefault();
        adventure_tourism_lastEl.focus();
      }
    } );
  }
  adventure_tourism_keepFocusInMenu();

  function adventure_tourism_keepFocusInSidebar() {
    document.addEventListener( 'keydown', function( e ) {
      const adventure_tourism_nav = document.querySelector( '.header-widgets ' );

      if ( ! adventure_tourism_nav || ! adventure_tourism_nav.classList.contains( 'show' ) ) {
        return;
      }
      const elements = [...adventure_tourism_nav.querySelectorAll( 'input, a, button' )],
        adventure_tourism_lastEl = elements[ elements.length - 1 ],
        adventure_tourism_firstEl = elements[0],
        adventure_tourism_activeEl = document.activeElement,
        tabKey = e.keyCode === 9,
        shiftKey = e.shiftKey;

      if ( ! shiftKey && tabKey && adventure_tourism_lastEl === adventure_tourism_activeEl ) {
        e.preventDefault();
        adventure_tourism_firstEl.focus();
      }

      if ( shiftKey && tabKey && adventure_tourism_firstEl === adventure_tourism_activeEl ) {
        e.preventDefault();
        adventure_tourism_lastEl.focus();
      }
    } );
  }
  adventure_tourism_keepFocusInSidebar();
} )( window, document );

var adventure_tourism_btn = jQuery('#button');

jQuery(window).scroll(function() {
  if (jQuery(window).scrollTop() > 300) {
    adventure_tourism_btn.addClass('show');
  } else {
    adventure_tourism_btn.removeClass('show');
  }
});

adventure_tourism_btn.on('click', function(e) {
  e.preventDefault();
  jQuery('html, body').animate({scrollTop:0}, '300');
});

jQuery(document).ready(function() {
    var owl = jQuery('#top-slider .owl-carousel');
    owl.owlCarousel({
    margin: 0,
    nav:true,
    autoplay : true,
    lazyLoad: true,
    autoplayTimeout: 5000,
    loop: false,
    dots: true,
    navText : ['<i class="fas fa-arrow-up" aria-hidden="true"></i>','<i class="fas fa-arrow-down" aria-hidden="true"></i>'],
    responsive: {
      0: {
        items: 1
      },
      576: {
        margin: 0,
        items: 1
      },
      768: {
        items: 1
      },
      1000: {
        items: 1
      },
      1200: {
        items: 1
      }
    },
    autoplayHoverPause : false,
    mouseDrag: true
  });
})

window.addEventListener('load', (event) => {
  jQuery(".loading").delay(2000).fadeOut("slow");
});

jQuery("#top-slider .slider-inner-box h3").html(function(){
  var words = jQuery(this).text().trim().split(" ");

    words[1] = `<b>${words[1]}</b>`;
    words[2] = `<b>${words[2]}</b>`;

  return words.join(" ");
});

jQuery(".categorie-heading h3.main-heading").html(function(){
  var words = jQuery(this).text().trim().split(" ");

  if (words.length > 0) words[0] = `<b>${words[0]}</b>`;
  if (words.length > 1) words[1] = `<b>${words[1]}</b>`;
  if (words.length > 5) words[5] = `<b>${words[5]}</b>`;

  return words.join(" ");
});

jQuery('.header-search-wrapper .search-main').click(function(){
  jQuery('.search-form-main').toggleClass('active-search');
  jQuery('.search-form-main .search-field').focus();
});


jQuery(window).scroll(function() {
  var data_sticky = jQuery('.bottom-header').attr('data-sticky');

  if (data_sticky == "true") {
    if (jQuery(this).scrollTop() > 1){
      jQuery('.bottom-header').addClass("stick_header");
    } else {
      jQuery('.bottom-header').removeClass("stick_header");
    }
  }
});