jQuery(function($){
	"use strict";
	jQuery('.main-menu-navigation > ul').superfish({
		delay:       500,
		animation:   {opacity:'show',height:'show'},  
		speed:       'fast'
	});
});

function swimming_pool_cleaning_menu_open() {
	jQuery(".menu-brand.primary-nav").addClass('show');
}
function swimming_pool_cleaning_menu_close() {
	jQuery(".menu-brand.primary-nav").removeClass('show');
}

var swimming_pool_cleaning_Keyboard_loop = function (elem) {
    var swimming_pool_cleaning_tabbable = elem.find('select, input, textarea, button, a').filter(':visible');

    var swimming_pool_cleaning_firstTabbable = swimming_pool_cleaning_tabbable.first();
    var swimming_pool_cleaning_lastTabbable = swimming_pool_cleaning_tabbable.last();
    /*set focus on first input*/
    swimming_pool_cleaning_firstTabbable.focus();

    /*redirect last tab to first input*/
    swimming_pool_cleaning_lastTabbable.on('keydown', function (e) {
        if ((e.which === 9 && !e.shiftKey)) {
            e.preventDefault();
            swimming_pool_cleaning_firstTabbable.focus();
        }
    });

    /*redirect first shift+tab to last input*/
    swimming_pool_cleaning_firstTabbable.on('keydown', function (e) {
        if ((e.which === 9 && e.shiftKey)) {
            e.preventDefault();
            swimming_pool_cleaning_lastTabbable.focus();
        }
    });

    /* allow escape key to close insiders div */
    elem.on('keyup', function (e) {
        if (e.keyCode === 27) {
            elem.hide();
        }
        ;
    });
};

// scroll
jQuery(document).ready(function () {
	jQuery(window).scroll(function () {
	    if (jQuery(this).scrollTop() > 0) {
	        jQuery('#scrollbutton').fadeIn();
	    } else {
	        jQuery('#scrollbutton').fadeOut();
	    }
	});
	jQuery(window).on("scroll", function () {
	   document.getElementById("scrollbutton").style.display = "block";
	});
	jQuery('#scrollbutton').click(function () {
	    jQuery("html, body").animate({
	        scrollTop: 0
	    }, 600);
	    return false;
	});
});

jQuery(function($){
	$('.mobiletoggle').click(function () {
        swimming_pool_cleaning_Keyboard_loop($('.menu-brand.primary-nav'));
    });
});

// preloader
jQuery(function($){
    setTimeout(function(){
        $(".frame").delay(1000).fadeOut("slow");
    });
});

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

  var swimming_pool_cleaning_scrollTop = window.scrollY || document.documentElement.scrollTop;
  var swimming_pool_cleaning_windowHeight = window.innerHeight;
  var swimming_pool_cleaning_documentHeight = document.documentElement.scrollHeight;

  var swimming_pool_cleaning_isBottom = swimming_pool_cleaning_scrollTop + swimming_pool_cleaning_windowHeight >= swimming_pool_cleaning_documentHeight - 100;

  if (swimming_pool_cleaning_scrollTop >= 100 && !swimming_pool_cleaning_isBottom) {
    swimming_pool_cleaning_sticky.classList.add('copyright-fixed');
  } else {
    swimming_pool_cleaning_sticky.classList.remove('copyright-fixed');
  }
});
/* Progress Bar */
document.addEventListener("DOMContentLoaded", function () {
    const swimming_pool_cleaning_progressBar =
        document.getElementById("swimming_pool_cleaning_elemento_progress_bar");
    if (!swimming_pool_cleaning_progressBar) return;
    window.addEventListener("scroll", function () {
        const swimming_pool_cleaning_scrollTop =
            document.documentElement.scrollTop || document.body.scrollTop;
        const swimming_pool_cleaning_height =
            document.documentElement.scrollHeight -
            document.documentElement.clientHeight;
        const swimming_pool_cleaning_scrolled =
            (swimming_pool_cleaning_scrollTop / swimming_pool_cleaning_height) * 100;
        swimming_pool_cleaning_progressBar.style.width =
            swimming_pool_cleaning_scrolled + "%";
    });
});