// ŪTF-8
var newPazinojums = new Class({
	options : { pazinojums : false},
	initialize : function(options) {
		this.setOptions(options); this._build(); this._center(); this._events(); this._esc();
	},
	_build : function() {
		this.Hover = new Element('div',{
			'class' : 'alert-hover',
			'styles' : {'opacity' : 0.5}
		}).inject(document.body);
		this.Back = new Element('div',{
			'class' : 'alert-back',
			'styles' : {'opacity' : 0.75}
		}).inject(this.Hover,'after');
		this.Holder = new Element('div',{
			'class' : 'alert-holder'
		}).inject(this.Hover,'after');
		new Element('p',{
			'class' : 'alert-message',
			'html' : this.options.pazinojums
		}).inject(this.Holder);
		this.Ok = new Element('input',{
			'id' : 'alert-labi',
			'type' : 'button',
			'value' : 'Labi'
		}).inject(this.Holder);
	},
	_center : function () {
		var box = document.getSize();
		var scr = document.getScroll();
		var hol = this.Holder.getSize();
		var con = $('container').getSize();
		con.y = (con.y.toInt() >= box.y.toInt()) ? con.y.toInt() : box.y.toInt();
		this.Hover.setStyles({
			'width' : box.x.toInt(),
			'height' : con.y.toInt()
		});
		this.Back.setStyles({
			'left' : (scr.x + (box.x - hol.x) / 2).toInt() + 'px',
			'top' : (scr.y + (box.y - hol.y) / 2).toInt() + 'px',
			'width' : hol.x,
			'height' : hol.y
		});
		this.Holder.setStyles({
			'left' : (scr.x + (box.x - hol.x) / 2).toInt() + 'px',
			'top' : (scr.y + (box.y - hol.y) / 2).toInt() + 'px'
		});
	},
	_events : function() {
		var hov = this.Hover;
		var bac = this.Back;
		var hol = this.Holder;
		this.Ok.addEvent('click', function() {
			hov.destroy();
			bac.destroy();
			hol.destroy();
		});
	},
	_esc : function() {
		hov = this.Hover;
		bac = this.Back;
		hol = this.Holder;
		window.addEvent('keydown', function(e) {
			if (e.key == 'esc') {
				hov.destroy();
				bac.destroy();
				hol.destroy();
			} 
		});
	}
});
newPazinojums.implement(new Options, new Events);
// laižam vaļā
window.addEvent('domready', function(){
	if ($chk($('pazinojums'))) {
		new newPazinojums({pazinojums : $('pazinojums').value});
	}
});