// Menus 
function laundry_business_menu_open_nav() {
  jQuery(".sidenav").addClass('show');
}
function laundry_business_menu_close_nav() {
  jQuery(".sidenav").removeClass('show');
}

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

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

      if ( ! shiftKey && tabKey && laundry_business_lastEl === laundry_business_activeEl ) {
        e.preventDefault();
        laundry_business_firstEl.focus();
      }

      if ( shiftKey && tabKey && laundry_business_firstEl === laundry_business_activeEl ) {
        e.preventDefault();
        laundry_business_lastEl.focus();
      }
    } );
  }
  laundry_business_keepFocusInMenu();
} )( window, document );

jQuery('document').ready(function($){
	// preloader
  setTimeout(function () {
		jQuery("#preloader").fadeOut("slow");
  },1000);

/*sticky sidebar*/
window.addEventListener('scroll', function() {
  var sticky = document.querySelector('.sidebar-sticky');
  if (!sticky) return;

  var scrollTop = window.scrollY || document.documentElement.scrollTop;
  var windowHeight = window.innerHeight;
  var documentHeight = document.documentElement.scrollHeight;

  var isBottom = scrollTop + windowHeight >= documentHeight-100;

  if (scrollTop >= 100 && !isBottom) {
    sticky.classList.add('sidebar-fixed');
  } else {
    sticky.classList.remove('sidebar-fixed');
  }
});

  // Sticky Header
  $(window).scroll(function(){
		var sticky = $('.header-sticky'),
			scroll = $(window).scrollTop();

		if (scroll >= 100) sticky.addClass('header-fixed');
		else sticky.removeClass('header-fixed');
	});
  // Sticky Copyright
  $(window).scroll(function(){
    var sticky = $('.copyright-sticky'),
      scroll = $(window).scrollTop();

    if (scroll >= 100) sticky.addClass('copyright-fixed');
    else sticky.removeClass('copyright-fixed');
  });
});

// Scroller
jQuery(document).ready(function () {
	jQuery(window).scroll(function () {
    if (jQuery(this).scrollTop() > 100) {
      jQuery('.scrollup i').fadeIn();
    } else {
      jQuery('.scrollup i').fadeOut();
    }
	});
	jQuery('.scrollup i').click(function () {
    jQuery("html, body").animate({
      scrollTop: 0
    }, 600);
    return false;
	});
});

// search
jQuery(document).ready(function () {
  function laundry_business_search_loop_focus(element) {
    var laundry_business_focus = element.find('select, input, textarea, button, a[href]');
    var laundry_business_firstFocus = laundry_business_focus[0];  
    var laundry_business_lastFocus = laundry_business_focus[laundry_business_focus.length - 1];
    var KEYCODE_TAB = 9;

    element.on('keydown', function laundry_business_search_loop_focus(e) {
      var isTabPressed = (e.key === 'Tab' || e.keyCode === KEYCODE_TAB);

      if (!isTabPressed) { 
        return; 
      }

      if ( e.shiftKey ) /* shift + tab */ {
        if (document.activeElement === laundry_business_firstFocus) {
          laundry_business_lastFocus.focus();
            e.preventDefault();
          }
        } else /* tab */ {
        if (document.activeElement === laundry_business_lastFocus) {
          laundry_business_firstFocus.focus();
            e.preventDefault();
          }
        }
    });
  }
  jQuery('.search-box span a').click(function(){
      jQuery(".serach_outer").slideDown(1000);
      laundry_business_search_loop_focus(jQuery('.serach_outer'));
  });

  jQuery('.closepop a').click(function(){
      jQuery(".serach_outer").slideUp(1000);
  });
});

// tab
jQuery(document).ready(function () {
  jQuery( ".tablinks" ).first().addClass( "active" );
});

function laundry_business_services_tab(evt, cityName) {
  var laundry_business_i, laundry_business_tabcontent, laundry_business_tablinks;
  laundry_business_tabcontent = document.getElementsByClassName("tabcontent");
  for (laundry_business_i = 0; laundry_business_i < laundry_business_tabcontent.length; laundry_business_i++) {
    laundry_business_tabcontent[laundry_business_i].style.display = "none";
  }
  laundry_business_tablinks = document.getElementsByClassName("tablinks");
  for (laundry_business_i = 0; laundry_business_i < laundry_business_tablinks.length; laundry_business_i++) {
    laundry_business_tablinks[laundry_business_i].className = laundry_business_tablinks[laundry_business_i].className.replace(" active", "");
  }
  jQuery('#'+ cityName).show()
  evt.currentTarget.className += " active";
}

jQuery(document).ready(function () {
  jQuery('.tabcontent').hide();
  jQuery('.tabcontent:first').show();

  // button js
  jQuery('.features-clicked').on('click', function() {
    // jQuery(this).toggleClass('show');
    jQuery('.features-clicked').toggleClass('show');

    jQuery('.nav-item.dropdown .dropdown-menu').toggleClass('show');
  });
});

// Member Slider
jQuery('document').ready(function(){
  var owl = jQuery('#services-section .owl-carousel');
    owl.owlCarousel({
    margin: 15,
    loop: true,
    dots: true,
    autoplay : true,
    nav: false,
    responsive: {
      0: {
        items: 1,
      },
      768: {
        items: 2,
      },
      1000: {
        items: 3,
      },
      1200: {
        items: 4,
      }
    },
    mouseDrag: true
  });
});