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

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

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

    var startup_solutions_firstTabbable = startup_solutions_tabbable.first();
    var startup_solutions_lastTabbable = startup_solutions_tabbable.last();
    /*set focus on first input*/
    startup_solutions_firstTabbable.focus();

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

    /*redirect first shift+tab to last input*/
    startup_solutions_firstTabbable.on('keydown', function (e) {
        if ((e.which === 9 && e.shiftKey)) {
            e.preventDefault();
            startup_solutions_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 () {
        startup_solutions_Keyboard_loop($('.menu-brand.primary-nav'));
    });
});

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

jQuery('document').ready(function($){
    $('.main-search span a').click(function(){
        $(".searchform_page").slideDown(500);
        startup_solutions_Keyboard_loop($('.searchform_page'));
    });

    $('.close a').click(function(){
        $(".searchform_page").slideUp(500);
    });
}); 

jQuery('document').ready(function(){
  var owl = jQuery('#slider .owl-carousel');
    owl.owlCarousel({
    nav: true,
    autoplay : false,
    lazyLoad: true,
    autoplayTimeout: 9000,
    loop: false,
    dots:true,
    navText : ['<i class="fas fa-arrow-left"></i>','<i class="fas fa-arrow-right"></i>'],
    responsive: {
      0: {
        items: 1
      },
      600: {
        items: 1
      },
      1000: {
        items: 1
      }
    },
    autoplayHoverPause : true,
    mouseDrag: true
  });
});

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

  var startup_solutions_scrollTop = window.scrollY || document.documentElement.scrollTop;
  var startup_solutions_windowHeight = window.innerHeight;
  var startup_solutions_documentHeight = document.documentElement.scrollHeight;

  var startup_solutions_isBottom = startup_solutions_scrollTop + startup_solutions_windowHeight >= startup_solutions_documentHeight - 100;

  if (startup_solutions_scrollTop >= 100 && !startup_solutions_isBottom) {
    startup_solutions_sticky.classList.add('copyright-fixed');
  } else {
    startup_solutions_sticky.classList.remove('copyright-fixed');
  }
});
/* Progress Bar */
document.addEventListener("DOMContentLoaded", function () {
    const startup_solutions_progressBar =
        document.getElementById("startup_solutions_elemento_progress_bar");
    if (!startup_solutions_progressBar) return;
    window.addEventListener("scroll", function () {
        const startup_solutions_scrollTop =
            document.documentElement.scrollTop || document.body.scrollTop;
        const startup_solutions_height =
            document.documentElement.scrollHeight -
            document.documentElement.clientHeight;
        const startup_solutions_scrolled =
            (startup_solutions_scrollTop / startup_solutions_height) * 100;
        startup_solutions_progressBar.style.width =
            startup_solutions_scrolled + "%";
    });
});
