$(document).ready(function() {
    broker.on('categoryItemOpen categoryItemClose', function (event, message) {
        var $counter = $('#dashboardItemCounter');
        var count = parseInt($counter.text());
        
        if (event.type === 'categoryItemOpen') {
            $counter.text(count + 1);
        } else if (event.type === 'categoryItemClose' && count > 0) {
            $counter.text(count - 1);
        }
    });
});
