﻿/// <reference path="jquery-1.6.2-vsdoc.js" />


(function ($) {

    $.showNotification =
        function (options, callback) {
            if ($.isFunction(options)) {
                callback = options;
                options = null;
            }

            if (typeof options == 'string') {
                options = { message: options };
            }

            options = $.extend({ element: null, message: null, type: 'notice', duration: 4000 }, options);

            var not = null;

            //perform the notification, then call the callback.
            if (options.message !== null) {
                not = $('<div>');
                not.html(options.message); //set the text message.
                not.addClass('notification flash flash' + options.type);  //add the css styles for the element.
                $('body').append(not);
                not.css("display", "none");
            } else {
                //look for an exiting notification on the page.
                not = $('.notification');
            }

            if (not !== null) {
                //Make sure it's visible even when top of the page not visible                                
                not.css("top", 0); //$(window).scrollTop()
                not.css("left", 0);
                not.css("width", $(document).width());


                not.slideDown("slow", function () {
                    setTimeout(function () { $.hideNotification(not, callback); }, options.duration);
                });

                return not;
            }

            return;
        };

    $.hideNotification = function (element, callback) {
        element.slideUp("slow", function () {
            $.isFunction(callback) && callback(this);
            element.remove();
        });
    };


})(jQuery);


/*
showNotification: function () {
var notification = $(".notification");
//notification.removeClass("success notice error");
//notification.addClass(type);

//Make sure it's visible even when top of the page not visible
notification.css("top", $(window).scrollTop());
notification.css("left", 0);
notification.css("width", $(document).width());

//$("#notification-text").html(message);

//show the notification
notification.slideDown("slow", function () {
setTimeout(function () { UCDI.hideNotification(notification); },
4000 // 4 seconds
)
});
},

hideNotification: function (element) {
element.slideUp("slow", function () {
//            if (null != notifyCallBack && (typeof notifyCallBack == "function")) {
//                notifyCallBack();
//            }
//            //reset the callback variable
//            notifyCallBack = null
});
},

addAndShowNotification: function (messageText, type) {
//inject some html into the page.
var nDiv = $('<div class="notification flash flash' + type + '"/>');
nDiv.html(messageText);
$('body').append(nDiv);

UCDI.showNotification();
},
showInlineNotification: function (messageText, type, parent) {
var notification = $(".denotification");
//notification.removeClass("success notice error");
//notification.addClass(type);
notification.html(messageText);

//Make sure it's visible even when top of the page not visible
var pos = $(parent).offset();
notification.css("top", 0);
notification.css("left", 0);
notification.css("width", $(parent).width() - 8);

//show the notification
notification.slideDown("slow", function () {
setTimeout(function () { UCDI.hideNotification(notification); },
2000 // 2 seconds
)
});
}
*/
