$(document).ready(function(){
// Closes any open mega menu
// Expands dropdown when user hovers nav bar item
$(".dropdown").mouseover(function() {
$('.open').removeClass('open');
$(this).toggleClass('open');
});
// When mouse leaves close mega menu
$(".dropdown").mouseout(function() {
$('.open').removeClass('open');
});
// When main nav-bar link is hovered
// Remove any triangles on page and add to hovered element
$('.dropdown-toggle').mouseover(function(){
if ($(this).hasClass('mega-active')) return;
$('.mega-active').removeClass('mega-active');
$(this).addClass('mega-active');
});
// If mouse leaves .nav or any of it's children
// Remove triangle
$('.nav').mouseleave(function(){
$('.mega-active').removeClass('mega-active');
});
//Remove any triangles from page if mouse enters nav link with no dropdown
$('.no-dropdown').mouseenter(function(){
$('.mega-active').removeClass('mega-active');
});
// If any link within mega-dropdown is clicked
// Remove triangle and menu
// $(".mega-dropdown-menu a").click(function(){
// $('.mega-active').removeClass('mega-active');
// $('.open').removeClass('open');
// });
// If any nav bar link is clicked
// Remove triangle and menu
// $(".dropdown-toggle").click(function(){
// $('.mega-active').removeClass('mega-active');
// });
});