

/**
	@name :
	@description : 
*/

var Layer = new Class({
	options : {
		showCloseCross : true
	},
	initialize : function(over,content,options) {
		this.over = over;
		this.content = content;
		this.closer = new Element('div',{id:'closer'}).setText(Locale.Close).addEvent('click',function() {
			this.hide()
		}.bind(this));
		this.container = new Element('div').setStyles({
			'opacity':'0',
			'position':'absolute',
			'background':'#fff',
			'z-index':'10001',
			'padding':'15px',
			'top':'0'/*,
			'border':'1px solid rgb(172,189,0)'*/
		})
		.addClass('popsConfig')
		.injectInside(document.body);	

		this.background = this.container.clone().setStyles({
			'background':'#ddd',
			'z-index':'10000',
			'padding':0
		})
		.removeClass('popsConfig')
		.injectInside(document.body);

		this.container.adopt($$(this.closer,content));
		this.setOptions(options);
		
		if(this.options.showCloseCross) {
			this.closer.setStyle('display','block')
		} else {
			this.closer.setStyle('display','none')
		}
	},
	show : function() {
		var coordinates = this.getBackgroundSize();

		$$(this.content).filterByTag('iframe').setStyle('display','block');

		this.posX = window.getScrollLeft()+window.getWidth()/2 - this.container.getSize().size.x/2;
		this.posY = window.getScrollTop()+window.getHeight()/2 - this.container.getSize().size.y/2;

		this.background.setStyles(coordinates).effect('opacity').start(0.7);
		this.container.setStyles({'left':this.posX,'top':this.posY}).effect('opacity').start(1);
	},
	hide : function() {
		this.background.effect('opacity').start(0);
		this.container.effect('opacity').start(0);
		//this.fireEvent('onHide');
	},
	getTopOffset : function() {
		return (this.over == window) ? getScrollTop() : 0;
	},
	getBackgroundSize : function() {
		var coordinates = {};
		if(this.over == window) {
			coordinates.width = window.getScrollWidth();
			coordinates.height = window.getScrollHeight();
			coordinates.top = 0;
			coordinates.left = 0;
		} else {
			coordinates = this.over.getCoordinates();
		}
		return coordinates;
	}
});
Layer.implement(new Options,new Events);


