$(document).ready(function(){
    $.ajax({
        url: '/csi/template/dropdowns',
        method: 'GET',
        dataType: 'json'
    }).done(function(data) {
        data.forEach(function(item) {
            $("#csiTemplateHomePageDropdown").append('<li><a href="/csi/forms/'+item.fileName+'" target="_blank">'+ item.docTitle +'</a></li>');
        });
    });

    $.ajax({
        url: '/notices/getAllActiveHierarchies',
        method: 'GET',
        dataType: 'json'
    }).done(function(data) {
        $('#publicNoticesDropDown > li:last-child').remove();
        data.forEach(function(item) {
            if (item.mainCategory.subCategoriesContainActiveNotices) {
                $('#publicNoticesDropDown').append('<li><a href="/notices/category/'+item.mainCategory.categoryId+'">'+item.mainCategory.name+'</a></li>');
            } else {
                $('#publicNoticesDropDown').append('<li><a href="/notices/display/'+item.mainCategory.categoryId+'">'+item.mainCategory.name+'</a></li>');
            }
        });
    });

    function adjustCollapseView(){
        var desktopView = $(document).width();
        if(desktopView >= "768"){
            $("li.dropdown a[data-toggle]").attr("data-toggle","");
        }else{
            $("li.dropdown a[data-toggle]").attr("data-toggle","dropdown");
        }
    }

    adjustCollapseView();

    $(window).on("resize", function(){
        adjustCollapseView();
    });


});
