(function () {

    var notify = $.connection.notifyHub;

    notify.client.send = function (title, message, img, url, id) {
        $('.notifications').append('<li><a href="/Notifications/Readed?id=' + id + '&link=' + url + '"><h4><img src=' + img + ' />' + title + '</h4><p>' + message + '</p></a></li>');
        var x = setTimeout(function () { $('.notifications li').first().remove(); }, 15000)
        $('.get-notifications-panel .badge').removeClass("hidden");
        var notiCount = parseInt($('.get-notifications-panel').text(),10);
        $('.get-notifications-panel .badge').text(++notiCount);
        notifyapi(title, message, img, url);
    }

    notify.client.connect = function (message) {
        console.log(message);
    }

    $.connection.hub.start()
        .done(function () {
            notify.server.connect('SignalR Connected!');            
        })
        .fail(function () {
            console.log('Error connecting to SignalR');
        });
})()