
/**************************************************************

	Script		: Overlay
	Version		: 1.2
	Authors		: Samuel birch
	Desc		: Covers the window with a semi-transparent layer.
	Licence		: Open Source MIT Licence

**************************************************************/

var Overlay = new Class({
	Implements : [Options , Events],
	options: {
		colour: '#e2e2e2',
		opacity: 0.65,
		zIndex: 100
	
		
	},

	initialize: function(options){
		this.setOptions(options);
		this.container = new Element('div',{
			'id' : 'OverlayContainer',
			'styles':{
				'position': 'absolute',
				'left': '0px',
				'top': '0px',
				'width': '100%',
				'opacity':0,
				'z-index': this.options.zIndex,
				'background-color': this.options.colour,
				'overflow':'hidden'
			}
		});
		this.container.inject(document.body,'top');
	
		this.iframe = new Element('iframe',{
			id: 'OverlayIframe',
			name: 'OverlayIframe',
			src: 'javascript:void(0);',
			frameborder: 1,
			scrolling: 'no',
			styles:{
				position: 'absolute',
				top: 0,
				left: 0,
				width: '100%',
				height: '100%',
				filter: 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)',
				opacity: 0,
				zIndex: 1,
				'overflow-x':'hidden'
			}
		});
		this.iframe.inject(this.container);
	
		this.overlay = new Element('div',{
			id : 'Overlay',
			styles :{
				position: 'absolute',
				left: '0px',
				top: '0px',
				width: '100%',
				height: '10%',
				zIndex: 2,
				background: this.options.colour,
				'overflow':'hidden'	
			}
		});
		//this.overlay.inject(this.container);
	
		this.container.addEvent('click', function(){
		
		}.bind(this));	
		
		
		
		//this.position();
		
		//window.addEvent('resize', this.position.bind(this));
	},
	
	
	show: function(){
		var h = window.getScrollHeight()+'px'; 
		this.container.setStyles({top: '0px', height: h}); 
		if(!Browser.Engine.trident){
			this.container.set('opacity', { duration: 100 }).tween('opacity', 0, this.options.opacity);
		}else{
			var myFx = new Fx.Tween(this.container,{ duration: '300'});
			myFx.start('opacity',0,this.options.opacity);		
		}		
		
	
	},
	
	hide: function(){
		this.container.set('opacity', { duration: 100 }).tween('opacity', this.options.opacity, 0);
	}	

	
});


/*************************************************************/

