﻿function ShowAlert() {
    var self = this;
    self.AlertCount = 0;

    self.UpdateCounts2 = function (first) {
        self.FirstRun = first;
        $.getJSON(self.GetAlertCountsUrl2, self.ProcessCounts2);
    }
     self.ProcessCounts2 = function (messageCounts) {
        $("#AlertCount12").html(messageCounts.TotalPendingCount);
        $("#headerAlerts12 .AlertCount12").html(messageCounts.TotalPendingCount);
        if (messageCounts.TotalPendingCount > 0) {
             self.Blink(messageCounts);    }
        else {
            $("#AlertLink12").removeClass("NewAlerts12");
        }
        self.StartTimer();
    }
    self.Blink = function (messageCounts) {
        if (self.AlertCount != messageCounts.AlertCount && self.FirstRun != true) {
            self.AlertCount = messageCounts.AlertCount;
                }
    }

    self.StartTimer = function () {
        setTimeout(self.UpdateCounts, 10000);
    }


}


