// Pattern *support.appblade.com\/web\/agent\/filters*

window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);

function updateDockBadge() {
    window.fluid.dockBadge = $('.filter-view div.count').first().html();
    $('tr.case').find('div.status').each(function() {
        var $this = $(this);
        if ($this.hasClass('new') && $this.data('growl') == undefined) {
            var $tr = $this.parents('tr');
            $this.data('growl', 'notified');
            var title = "";
            title += $tr.find('td[dd-dragging="Customer"] .text').html();
            $($tr.find('.case-subject .icon').attr('class').split(' ')).each(function() {
                if (this.indexOf('channel-') == 0) {
                    title += ' [' + this.split('-')[1] + ']';
                }
            });
            window.fluid.showGrowlNotification({
                title: title, 
                description: $tr.find('.case-subject .text').html(), 
                priority: 1, 
                sticky: false
            });
        }                 
    });
};