(function($) {
	
	if(!$.maria) $.maria = {};
	
	// TODO: Add $.extend with Options and Defaults
	$.maria.Overlay = function(options) {
		
		if(!options) {
			options = {};
		}
		if (typeof(options['class']) == 'undefined') {
            options['class'] = 'Overlay';
        }
        if (typeof(options['backgroundClass']) == 'undefined') {
            options['backgroundClass'] = 'OverlayBackground';
        }
		
		if(options["class"]) {
			this.html.addClass(options["class"]);
		}
		if(options["backgroundClass"]) {
            this.background.addClass(options["backgroundClass"]);
        }
		
		if(options.id) {
			this.html.attr("id", options.id);
		}
		
	};
	
	$.maria.Overlay.prototype = {
		
		defaults: {
			
			"id": "generic",
			"class": "generic"
			
		},
		
		/**
		* @description Open the Overlay
		* @param Number Optional duration of the Open-Animation
		*/
		open: function(duration) {
			
			this.html.stop().fadeIn(duration || 300);
            this.background.stop().fadeIn(duration || 300);
            
		},
		
		/**
		* @description Close the Overlay
		* @param Number Optional duration of the Close-Animation
		*/
		close: function(duration) {
			
			this.html.stop().fadeOut(duration || 300);
            this.background.stop().fadeOut(duration || 300);
		
        },
		
		html: $("<div/>", {
			css: {
				"position": "fixed",
				"display": "none"
			},
			data: {
				"olddisplay": "inline-block"
			}
		}),
		
		background: $("<div/>", {})
        
    };
	
})(jQuery);

