jQuery(function($) {

    /* -----------------------------------------
    Preloader
    ----------------------------------------- */
    $('#preloader').delay(1000).fadeOut();
    $('#loader').delay(1000).fadeOut("slow");

    /* -----------------------------------------
    Navigation
    ----------------------------------------- */
    $('.menu-toggle').click(function() {
        $(this).toggleClass('open');
    });

    /* -----------------------------------------
    Keyboard Navigation
    ----------------------------------------- */
    $(window).on('load resize', interior_services_navigation)

    function interior_services_navigation(event) {
        if ($(window).width() < 1200) {
            $('.main-navigation').find("li").last().bind('keydown', function(e) {
                if (e.interior_services_shiftKey && e.which === 9) {
                    if ($(this).hasClass('focus')) {
                    }

                } else if (e.which === 9) {
                    e.preventDefault();
                    $('#masthead').find('.menu-toggle').focus();
                }                
            })
        } else {
            $('.main-navigation').find("li").unbind('keydown')
        }
    }

    interior_services_navigation()

    var interior_services_primary_menu_toggle = $('#masthead .menu-toggle');
    interior_services_primary_menu_toggle.on('keydown', function(e) {
        var interior_services_tabKey = e.keyCode === 9;
        var interior_services_shiftKey = e.interior_services_shiftKey;

        if (interior_services_primary_menu_toggle.hasClass('open')) {
            if (interior_services_shiftKey && interior_services_tabKey) {
                e.preventDefault();
                const $interior_services_the_last_li = $('.main-navigation').find("li").last()
                $interior_services_the_last_li.find('a').focus()
                if (!$interior_services_the_last_li.hasClass('focus')) {

                    const $interior_services_is_parent_on_top = true
                    let $interior_services_the_parent_ul = $interior_services_the_last_li.closest('ul.sub-menu')

                    let interior_services_count = 0

                    while (!!$interior_services_the_parent_ul.length) {
                        ++interior_services_count

                        const $interior_services_the_parent_li = $interior_services_the_parent_ul.closest('li')

                        if (!!$interior_services_the_parent_li.length) {
                            $interior_services_the_parent_li.addClass('focus')
                            $interior_services_the_parent_ul = $interior_services_the_parent_li.closest('ul.sub-menu')

                            // Blur the cross
                            $(this).blur()
                            $interior_services_the_last_li.addClass('focus')
                        }

                        if (!$interior_services_the_parent_ul.length) {
                            break;
                        }
                    }

                }

            };
        }
    })

    // Determine if the document is RTL
    var isRtl = $('html').attr('dir') === 'rtl';
    
  /* -----------------------------------------
  Slider Section
  ----------------------------------------- */

    jQuery(document).ready(function ($) {

    $('.banner-slider')
        .on('init afterChange', function () {
        const $interior_services_slider = $(this);
        $interior_services_slider.find('.slick-slide').removeClass('is-prev is-next');

        $interior_services_slider.find('.slick-center').prev().addClass('is-prev');
        $interior_services_slider.find('.slick-center').next().addClass('is-next');
        })
        .slick({
        centerMode: true,
        centerPadding: '300px',   
        slidesToShow: 1,
        arrows: true,
        dots: false,
        infinite: true,
        autoplay: true,
        autoplaySpeed: 4000,
        prevArrow: '<button class="slick-prev fas fa-arrow-left"></button>',
        nextArrow: '<button class="slick-next fas fa-arrow-right"></button>',
        responsive: [
            {
            breakpoint: 1400,
            settings: {
                centerPadding: '220px',
            }
            },
            {
            breakpoint: 991,
            settings: {
                centerPadding: '120px',
            }
            },
            {
            breakpoint: 768,
            settings: {
                centerPadding: '0px',
            }
            }
        ]
        });

    });

  /* -----------------------------------------
  Services Section
  ----------------------------------------- */

    $('.service-section-wrapper').slick({
        slidesToShow: 3, 
        autoplaySpeed: 3000,
        dots: false,
        arrows: false,
        autoplay: true,
        rtl: isRtl,
        responsive: [
            {
                breakpoint: 992, 
                settings: {
                    slidesToShow: 3, 
                    dots: false,
                    arrows: false
                }
            },
            {
                breakpoint: 768, 
                settings: {
                    slidesToShow: 2, 
                    dots: false,
                    arrows: false
                }
            },
            {
                breakpoint: 601, 
                settings: {
                    slidesToShow: 1, 
                    dots: false,
                    arrows: false
                }
            }
        ],
        autoplayHoverPause: false,
        mouseDrag: true
    });

    /* -----------------------------------------
    Scroll Top
    ----------------------------------------- */
    var interior_services_scrollToTopBtn = $('.interior-services-scroll-to-top');

    $(window).scroll(function() {
        if ($(window).scrollTop() > 400) {
            interior_services_scrollToTopBtn.addClass('show');
        } else {
            interior_services_scrollToTopBtn.removeClass('show');
        }
    });

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

    //search js

    $(".input").focus(function() {
        $(".form").addClass("move");
    });
    $(".input").focusout(function() {
        $(".form").removeClass("move");
        $(".input").val("");
    });

    $(".search-main .btn").click(function() {
        $(".input").toggleClass("active");
        $(".form").toggleClass("active");
    }); 
    
});

document.addEventListener('DOMContentLoaded', function() {
  const interior_services_header = document.querySelector('.sticky-header');
  if (interior_services_header) { // Check if header exists
    window.addEventListener('scroll', function() {
      if (window.scrollY > 0) {
        interior_services_header.classList.add('is-sticky');
      } else {
        interior_services_header.classList.remove('is-sticky');
      }
    });
  }
});