(function($) {
    $.notifier = function(message) { notify(message); }

    function notify(message) {
        var instance = $(document.getElementById('divNoticeContainer'));
        var html = jQuery.notifier.settings.noticeTemplate;
        html = html.replace('%message%', message);

        var notice = $(html).hide().fadeIn(jQuery.notifier.settings.noticeFadeTimeout);

        $.notifier.settings.noticeDisplay(notice);
        instance.append(notice);

        if ($.notifier.settings.displayTimeout > 0) {
            setTimeout(function() {
                jQuery.notifier.settings.noticeRemove(notice, function() {
                    notice.remove();
                });
            }, jQuery.notifier.settings.displayTimeout);
        }
    };

    $.notifier.settings = {
        noticeTemplate: '<div class="b-notif">%message%</div>',
        noticeDisplay: function(notice) {
            notice.fadeIn(jQuery.notifier.settings.noticeFadeTimeout);
        },
        noticeRemove: function(notice, callback) {
            notice.animate({ opacity: '0', height: '0px' }, { duration: jQuery.notifier.settings.noticeFadeTimeout, complete: callback });
        },
        noticeFadeTimeout: 'slow',
        displayTimeout: 3000
    };
})(jQuery);

//function pageLoad(sender, args) {
//    if (args.get_isPartialLoad()) {
//        completeNotify();
//    }
//}

function completeNotify() {
    var inputs = $("input[id*=hCommandStatusMessage]");
    for (var i = 0; i < inputs.length; i++) {
        var message = inputs[i].value;
        if (message) {
            $.notifier(message);
            inputs[i].value = '';
        }
    }
}

