// class PD..UI.MessageStack

PD.Web.UI.MessageStack = Class.extend({

    error: function (message) {

        $.notify.clear("error");

        $.notify.add({
            inline: true,
            html: this.getElement(message),
            contentCss: {
                backgroundColor: "#990000",
                border: "1px solid #990000",
                padding: "0px"
            },
            category: "error"
        }, 3000);

    },

    success: function (message) {

        $.notify.clear("success");

        $.notify.add({
            inline: true,
            html: this.getElement(message, "OK.PNG"),
            contentCss: {
                backgroundColor: "#006000",
                border: "1px solid #006000",
                padding: "0px"
            },
            category: "success"
        }, 3000);

    },

    action: function (message, icon) {

        $.notify.clear("action");

        $.notify.add({
            inline: true,
            html: this.getElement(message, icon),
            contentCss: {
                backgroundColor: "#1E211F",
                border: "1px solid #1E211F",
                padding: "0px"
            },
            category: "action"
        }, 3000);

    },

    exception: function (message) {

        $.notify.clear("exception");

        $.notify.add({
            inline: true,
            html: this.getElement(message, "error.png"),
            contentCss: {
                backgroundColor: "#990000",
                border: "1px solid #990000",
                padding: "0px"
            },
            category: "exception"
        });

    },

    getElement: function (message, icon) {

        var $span = $("<span></span>");

        if (icon) {
            icon = icon.indexOf("~") === 0 ? icon : "~/application/icons/32x32/" + icon;
            $span.css({
                backgroundImage: "url(" + PD.Path.resolve(icon) + ")"
            });
            $span.addClass("notification-box-w-icon");
        }
        else {
            $span.addClass("notification-box");
        }

        $span.html(message);

        return $span.wrap("<div/>").parent().html();

    }

});

PD.messageStack = new PD.Web.UI.MessageStack();
