var BodyOverlay = new Class({
	Implements: [Options],
	options : {
		background: '#000',
		opacity: .6,
		zIndex: 10,
		duration: 0,
		transition: "linear",
		onClick: $empty
	},
	initialize: function(options){
		this.setOptions(options);
		this.createOverlay();
		this.overlay.setStyles({opacity:0});
		this.position();
		window.addEvent('resize', this.position.bind(this));
	},
	createOverlay : function()
	{
		this.overlay = new Element('div').setStyles({
			position: 'absolute',
			left: '0px',
			top: '0px',
			width: '100%',
			zIndex: this.options.zIndex,
			background : this.options.background});
		this.overlay.addEvent('click', function(e){this.options.onClick(e);}.bind(this));
	},
	position: function(){ 
		var height = window.getScrollHeight()+'px'; 
		this.overlay.setStyles({top: '0px', height: height}); 
	},
	show: function(){
		this.overlay.injectInside(document.body);
		this.overlay.set("morph", {duration:this.options.duration, transition:this.options.transition});
		this.overlay.morph({opacity:this.options.opacity});
	},
	hide: function(){
		this.overlay.set("morph", {onComplete:function(){this.overlay = this.overlay.dispose()}.bind(this),duration:this.options.duration, transition:this.options.transition});
		this.overlay.morph({opacity:0});
	}
});