var SkapalonPopup = new Class({
	Implements: [Options, Events],
	options: {
		width: 300,
		height: 'auto'
	},
	initialize: function(element,options){
		this.setOptions(options);
		this.content = element;
		
		this.Create();
	},
	Create: function(){
		
		this.backDrop = new Element('div',{
			'class': 'backdrop',
			'styles': {
				'position': 'absolute',
				'z-index': 90,
				'bottom': 0,
				'right': 0,
				'top': 0,
				'left': 0,
				'opacity': '0.6',
				'background-color': '#000',
				'display': 'none'
			}
		}).inject( $('Disillserversideform1') );
		
		this.popup_wrap = new Element('div', {
			'class': 'popup-wrap',
			'styles': {
				'position': 'absolute',
				'z-index': 100,
				'top': 0,
				'left': 0,
				'width': this.options.width,
				'height': this.options.height,
				'opacity': 0,
				'display': 'none'
			}
		}).inject( $('Disillserversideform1') );
		
		this.close = new Element('div', {
			'class': 'close',
			'html': '',
			styles: {
				'position': 'absolute',
				'right': 30,
				'top': 30,
				'height': 19,
				'width': 19,
				'background-image':'url(/img/sprite-inline-icons.png)',
				'background-position':'0px -1308px',
				'cursor': 'pointer'
			}
		}).inject( this.popup_wrap );
		
		this.close.addEvent('click', (function(){
			this.Hide();
		}).bind(this));
		
		this.backDrop.addEvent('click', (function(){
			this.Hide();
		}).bind(this));
		
		this.content.inject( this.popup_wrap );
		this.content.setStyle('display', 'block');
	},
	Show: function(){
		
		this.popup_wrap.setStyles({'display':'block'});
		this.backDrop.setStyles({'display':'block'});
		this.Position();
		this.popup_wrap.fade('in');
		
	},
	Hide: function(){
		
		//this.Position();
		this.popup_wrap.fade('out');
		this.popup_wrap.setStyles({'display':'none'});
		this.backDrop.setStyles({'display':'none'});
		
	},
	Position: function(){
		var WinSize = window.getSize();
		var WinScroll = window.getScroll();
		var PopSize = this.popup_wrap.getSize();
		var windowWidth = window.getScrollSize().x;
		var windowHeight = window.getScrollSize().y;
		
		this.backDrop.setStyles({'width':windowWidth,'height':windowHeight})
		
		this.popup_wrap.setStyles({
			'top': ( ( document.getSize().y / 2 ) - (PopSize.y / 2 ) ),
			//'left': (WinSize.x / 2) - ( PopSize.x / 2 )
			'left': 249
		});
		
		
	}
});
