// JavaScript Document
(function($) {
	$.fn.BNmodal = function(command, params) {
		if (command == 'set')// Sets the id to be shown as modalwindow
			return this.each(function() {
				$(this).css("z-index","102").css({display:"none", position:"absolute"}).css(params).addClass("mbn-sl-app");
			});
		else if (command == 'unset')// Removes the id as modalwindow but keeps it hidden
			return this.each(function() {
				$(this).removeClass("mbn-sl-app").css({display: "none"});
			});
		else
			return this;
	}
	$.BNmodal = function(command) {
		if (command == 'show') { // Adds and animates modal cover
			found = 0;
			$(".mbn-sl-cover").each(function() { found = 1; });
			if (!found) { // Won't show if already there
				$("body").append('<div class="mbn-sl-cover"></div>');
				$(".mbn-sl-cover").css("z-index","101").css({position: "absolute", left: 0, top: 0, height:"100%", width:"100%", opacity:"0.75", background:"#000",margin:0, padding:0}).fadeIn("fast",function() { $(".mbn-sl-app").fadeIn("fast"); });
			}
		} else if (command == 'hide') // Removes the modal cover and removes it from DOM
			$(".mbn-sl-app").fadeOut("fast",function() { $(".mbn-sl-cover").fadeOut("fast",function() { $(this).remove(); }); });
	}
})(jQuery);
