(function($){
	
	var $backgroundOverlay = $('<div id="modalBackground" style="position: absolute; z-index: 9000; overflow: hidden; top: 0; left: 0; height: 100%; width: 100%; filter: alpha(opacity=0); -moz-opacity:0; opacity:0; display: none;"></div>');
	var $modalContent = $('<div id="modalContent" style="display: none; position: absolute; z-index: 9001; overflow: hidden;"><div id="modalContentPadding"></div></div>');
	
	$(document).ready(function(){
		$('body').prepend($modalContent);
		$('body').prepend($backgroundOverlay);
	});
	
	$.extend({
		
		lightmodal: function(content){
			
			$backgroundOverlay.css('display', 'block');
			$backgroundOverlay.css('width', $('body').width() + 'px');
			$backgroundOverlay.css('height', $(document).height() + 'px');
			$('#modalContentPadding').hide();
			$('#modalContentPadding').html(content);
			$backgroundOverlay.fadeTo('slow', 0.5, function(){
				
				var modalWidth = 750;
				var modalHeight = 600;

				$modalContent.css('width', modalWidth + 'px');
				$modalContent.css('height', '0px');
				
				$modalContent.css('top', ($(window).scrollTop() + $(window).height() / 2 - modalHeight / 2) + 'px');
				$modalContent.css('left', ($(window).scrollLeft() + $(window).width() / 2 - modalWidth / 2) + 'px');
				$modalContent.css('overflow', 'hidden');
				
				$modalContent.show();
				
				$modalContent.animate({ height: modalHeight }, 1000, function(){
					$('#modalContentPadding').fadeIn();
				});
				
			});
			
			$backgroundOverlay.click(function(){
				$.close_lightmodal();
			});
		},
		
		close_lightmodal: function()
		{
			$modalContent.fadeOut('slow', function(){
				$('#modalContentPadding').html('');
				$backgroundOverlay.fadeOut('slow');	
			});
		}
		
	});
	
})(jQuery);

