function ModalElement(options) 
{
	// INI: Private properties
	var _options = {
		bgColor	: options ? options.bgColor : '#000',
		opacity	: options ? options.opacity : '0.8',
		fixed	: options && options.fixed ? options.fixed : false
	};
	var _element = null;
	var _originalCss = {};
	
	var _background = $('<div id="ModalElementBackground" />');
	var _this = this;
	// END: Private properties
	
// INI: Public methods
	// Show Any element in modal mode
	this.showElement = function(elementSelector) {
		this.hide(function(){
			if (!$(elementSelector).length) {
				return;
			}
			// Resize background
			_background.css({
				top	   :0,
				left   :0,
				margin :0,
				padding:0,
				width  :$(window).width() + 'px',
				height : $(document).height() > $(window).height() ? $(document).height() : $(window).height() + 'px',
				display: 'none'
			});
			// Get the element to set modal
			
			_element = $( $(elementSelector).get(0) );
			
			var top  = ($(window).height() / 4) - ($(_element).height() / 4);
			var left = ($(window).width() / 2) - (_element.width()/2);
			// Get the original css basic properties
			_originalCss.display  = _element.css('display');
			_originalCss.position = _element.css('position');
			_originalCss.top  	  = _element.css('top');
			_originalCss.left  	  = _element.css('left');
			_originalCss.width 	  = _element.css('width');
			_originalCss.height   = _element.css('height');
			// Replace the original element
			_element.after( $('<div id="AuxiliarElement" />').css(_originalCss) );
			// Set the new css position in 
			_element.css({
				position : _options.fixed ? 'fixed' : 'absolute',
				//position:'absolute',
				top		 : top,
				left	 : left,
				zIndex	 : 100
			});
			// Move the element to center
			$('body').append(_element);
			
			// Show element in modal mode
			_background.fadeIn('fast',function(){ _element.fadeIn('fast'); });
			
			//_background.show();
			//_element.show();
			
		});	
	};
	
	//
	this.hide = function(callback) {
		if (_element) {
			_element.fadeOut('fast',function(){
				$('#AuxiliarElement').replaceWith(_element.css(_originalCss));
				_background.fadeOut(callback || function(){});
			});
		}
		else if(callback) {
			callback();
		}
	};
	
// INI: Public methods

// Constructor
	(function(){
		// setup background element
		_background
			.css({
				opacity	   : _options.opacity,
				position   : 'absolute',
				background : _options.bgColor,
				top		   : 0,
				left	   : 0,
				display	   : 'none'
			})
			.click(function(){
				_this.hide();
			});
		// append background element to body
		$('body').append(_background);
	}());
}



