(function ($) {

    $(document).ready(function () {

        $("#main-menu").meanmenu({
            meanScreenWidth: "960",
            meanRevealPositionDistance: "0px"
        });

        $(".submenu-desktop >li >a.mean-expand").click(function () {
            if ($(this).hasClass("mean-clicked")) {
                $(this).parent().css('background-color', '$carmine');
            }
            else {
                $(this).parent().removeAttr('style');
            }
        });

        $(window).resize(function () {

            // On window resize, check if mobile nav has closed
            if (!$(".meanmenu-reveal").hasClass("meanclose")) {

                // Enable page scrolling
                $('body').removeAttr('style');
            }

            // ITBS-858 - commented this out as it exists elsewhere
            //$(".searchInputMobile").autocomplete({

            //    maxResults: 5,
            //    delay: 0,
            //    source: function (request, response) {

            //        $.post("/desktopmodules/eastlinksearch/api/search/GetSearchSuggest", { searchQuery: request.term, maxReturnedResults: 5 }, function (data) {

            //            var suggestions = jQuery.parseJSON(data);
            //            response(suggestions.results);

            //        })

            //    },

            //    select: function (event, ui) {
            //        $parent = $(this).closest('.search-container');
            //        $parent.find(".searchInput").val(ui.item.value);
            //        doSearch($parent);
            //        return false;

            //    },

            //    messages: { noResults: '', results: function () { } }

            //});


        });

        $(document).on("elCloseMobileNav", function (e) {

            // Enable page scrolling
            $('body').removeAttr('style');

            // Remove scrolling within navigation
            $('.mean-nav .grid').removeAttr('style');

        });


        $(document).on("elOpenMobileNav", function (e) {

            // Disable page scrolling
            $('body').css('overflow-y', 'hidden');
            $('.mean-nav .grid').css('-webkit-overflow-scrolling', 'touch');

            // Setup scrolling within nav menu
            $('.mean-nav .grid').css('overflow-y', 'auto');
            $('.mean-nav .grid').css('overflow-x', 'hidden');
            $('.mean-nav .grid').css('height', 'calc(100vh)');
            $('.mean-nav .grid').css('margin', '0px');
            $('.mean-container .mean-nav ul').css('margin-bottom', '100px');
            $('.hide').css('display', 'none');
            $('.show').css('display', 'block');
        });

    });
})(jQuery);