jQuery(document).ready(function() {
	jQuery('li.dropdown').find('.fa-plus').each(function(){
		jQuery(this).on('click', function(){
			if( jQuery(window).width() < 767) {
				jQuery(this).parent().next().slideToggle();
			}
			return false;
		});
	});
});

jQuery(document).ready(function () {	
	jQuery(window).scroll(function () {
		if (jQuery(this).scrollTop() > 150) {
			jQuery('.enigma_scrollup').fadeIn();
			jQuery('.menu').addClass('sticky-header');
		} else {
			jQuery('.enigma_scrollup').fadeOut();
			jQuery('.menu').removeClass('sticky-header');
		}
	});
	
	jQuery('.enigma_scrollup').click(function () {
		jQuery("html, body").animate({
			scrollTop: 0
		}, 600);
		return false;
	});
});	

jQuery.browser = {};
(function () {
	jQuery.browser.msie = false;
	jQuery.browser.version = 0;
	if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
		jQuery.browser.msie = true;
		jQuery.browser.version = RegExp.$1;
	}
})();
			
jQuery(document).ready(function() {
    jQuery(".navbar-right").accessibleDropDown();
});

jQuery.fn.accessibleDropDown = function () {
    var el = jQuery(this);

    /* Make dropdown menus keyboard accessible */
    jQuery("a", el).focus(function() {
        jQuery(this).parents("li").addClass("force-show");
    }).blur(function() {
        jQuery(this).parents("li").removeClass("force-show");
    });
}
jQuery(window).resize(function() {location.reload();});
var $hamburgerMenuBtn,
$slideNav,
$closeBtn,
$main;

// focus management variables
var $focusableInNav,
$firstFocusableElement,
$lastFocusableElement;

jQuery(document).ready(function() {
if( jQuery(window).width() < 767) {
$hamburgerMenuBtn = jQuery("#hamburger-menu"),
$slideNav = jQuery("#slide-nav"),
$closeBtn = jQuery("#close"),
$main = jQuery("main"),
$focusableInNav = jQuery('#slide-nav button, #slide-nav [href], #slide-nav input, #slide-nav select, #slide-nav textarea, #slide-nav [tabindex]:not([tabindex="-1"])');
if ($focusableInNav.length) {
$firstFocusableElement = $focusableInNav.first();
$lastFocusableElement = $focusableInNav.last();
}
addEventListeners();
}
});

function addEventListeners() {
$hamburgerMenuBtn.click(openNav);
$closeBtn.click(closeNav);
$slideNav.on("keyup", closeNav);
$firstFocusableElement.on("keydown", moveFocusToBottom);
$lastFocusableElement.on("keydown", moveFocusToTop);
}

function openNav() {
$slideNav.addClass("visible active");
setTimeout(function() {
$firstFocusableElement.focus()
}, 1);
$main.attr("aria-hidden", "true");
$hamburgerMenuBtn.attr("aria-hidden", "true");
}

function closeNav(e) {
if (e.type === "keyup" && e.key !== "Escape") {
return;
}

$slideNav.removeClass("active");
$main.removeAttr("aria-hidden");
$hamburgerMenuBtn.removeAttr("aria-hidden");
setTimeout(function() {
$hamburgerMenuBtn.focus()
}, 1);
setTimeout(function() {
$slideNav.removeClass("visible")
}, 501);
}

function moveFocusToTop(e) {
if (e.key === "Tab" && !e.shiftKey) {
e.preventDefault();
$firstFocusableElement.focus();
}
}

function moveFocusToBottom(e) {
if (e.key === "Tab" && e.shiftKey) {
e.preventDefault();
$lastFocusableElement.focus()
}
} 
