/*
 *	Drop down notification box
 */ 
function Notification(B) {
    this.$bar = jQuery('<div class="notification-bar"></div>');
    this.$barContainer = jQuery('<div class="notification-bar-container"></div>');
    this.$barContents = jQuery('<div class="notification-bar-contents"></div>');
    this.$barBackground = jQuery('<div class="notification-bar-bkg"></div>');
    this.$message = jQuery('<div class="message"></div>');
    this.$bar.hide();
    this.$barBackground.hide();
    var A = this;
    this.$bar.click(function(C) {
        A.removeAfterEvent(C)
    });
    this.className = B
}


Notification.SLIDE_SPEED_IN_MS = 300;
Notification.prototype.remove = function() {
    var A = this;
    this.slideUp(function() {
        A.$bar.remove();
        A.$barBackground.remove();
        window.clearTimeout(A.timeout)
    })
};
Notification.prototype.removeAfterEvent = function(B) {
    var A = $(B.target);
    if (A.get(0).nodeName.toLowerCase() == "a" && A.hasParent(this.$message)) {
        return
    }
    this.remove()
};
Notification.prototype.setMessage = function(A) {
    this.msg = A;
    return this
};
Notification.prototype.show = function() {
    this.$message.addClass(this.className).html(this.msg);
    this.$barContainer.append(this.$barBackground).append(this.$bar.append(this.$barContents.append(this.$message)));
    jQuery("#notifications").append(this.$barContainer);
    this.$barBackground.height(this.$bar.height());
    this.showBar();
    if (this.onShow) {
        this.onShow()
    }
    return this
};
Notification.prototype.removeInMilliseconds = function() {
    var A = this;
    this.timeout = window.setTimeout(function() {
        A.remove()
    },
    A.timeoutInMilliseconds)
};
Notification.prototype.showBar = function() {
    this.$bar.show();
    this.$barBackground.show()
};
Notification.prototype.onShow = function() {
    this.removeInMilliseconds()
};
Notification.prototype.slideUp = function(A) {
    this.$bar.slideUp(Notification.SLIDE_SPEED_IN_MS);
    this.$barBackground.slideUp(Notification.SLIDE_SPEED_IN_MS, A)
};
function ShortNotification() {
    Notification.call(this, "message-info");
    this.timeoutInMilliseconds = 3000
}
jQuery.inherits(ShortNotification, Notification);
ShortNotification.prototype.showBar = function() {
    this.$bar.slideDown(Notification.SLIDE_SPEED_IN_MS);
    this.$barBackground.slideDown(Notification.SLIDE_SPEED_IN_MS)
};
function InfoNotification() {
    Notification.call(this, "message-info");
    this.timeoutInMilliseconds = 6000
}
jQuery.inherits(InfoNotification, Notification);
InfoNotification.prototype.showBar = function() {
    this.$bar.slideDown(Notification.SLIDE_SPEED_IN_MS);
    this.$barBackground.slideDown(Notification.SLIDE_SPEED_IN_MS)
};
function ProgressNotification() {
    Notification.call(this, "message-progress");
    this.timeoutInMilliseconds = 1000
}
jQuery.inherits(ProgressNotification, Notification);
ProgressNotification.prototype.setProgressMessage = function(A) {
    return this.setMessage(A)
};
ProgressNotification.prototype.setCompletedMessage = function(A) {
    this.completedMsg = A;
    return this
};
ProgressNotification.prototype.onShow = function() {};
ProgressNotification.prototype.cancel = function() {
    this.timeoutInMilliseconds = 0;
    this.removeInMilliseconds()
};
ProgressNotification.prototype.done = function() {
    this.$message.addClass("message-progress-done").removeClass(this.className).html(this.completedMsg);
    this.removeInMilliseconds()
};
function ErrorNotification() {
    Notification.call(this, "message-error");
    this.timeoutInMilliseconds = 8000
}
jQuery.inherits(ErrorNotification, Notification);
