var CmooLayer_insurance = new Class({
	state: false,
	oContainer: null,
	oPopuptext: null,
	oCancelBTN: null,
	oCloseBTN: null,
	fnClose: null,
	cmoodate: null,
	initialize: function() {
		var layer = new Element('div',{'class':'mmt_layer mmt_layer_550 select-free','id':'mmt_cmoolayer_insurance_popup'});
		layer.set('html','<div class="mmt_layer_top">\
							<div class="box_head_text head_rendszeruzenet">Rendszerüzenet</div>\
						  </div>\
						  <div class="mmt_layer_bg">\
							<div class="mmt_layer_cont">\
							  Az árkalkulációhoz további adatokra van szükség!\
							  <div class="clear_5"></div>\
							  <div id="mmt_cmoolayer_insurance_popuptext"></div>\
							  <div class="clear_10"></div>\
							  <label style="float: left; width: 130px; text-align: right; padding: 0px 10px 0px 70px;">Vezetéknév :</label><input id="mmt_insurance_lastname" type="text" class="input_210 input_border" /><div class="clear_5"></div>\
							  <label style="float: left; width: 130px; text-align: right; padding: 0px 10px 0px 70px;">Keresztnév :</label><input id="mmt_insurance_firstname" type="text" class="input_210 input_border" /><div class="clear_5"></div>\
							<div class="szuletesi_datum" id="mmt_cmoolayer_insurance_naptar">\
								<label style="float: left; width: 130px; text-align: right; padding: 0px 10px 0px 70px;">Születési dátum :</label>\
								<select class="select_60 input_border"></select>\
								<select class="select_45 input_border"></select>\
								<select class="select_45 input_border"></select>\
							</div>\
							<div class="clear_5"></div>\
							  <div class="form_button">\
								<img id="mmt_cmoolayer_insurance_cancel" alt="" src="/images/button_megse.gif" style="margin-right: 15px;"/>\
								<img id="mmt_cmoolayer_insurance_close" alt="" src="/images/button_mehet_sz.gif" />\
							  </div>\
							  <div class="clear"></div>\
							 </div>\
						  </div>\
						  <div class="mmt_layer_bot"></div>\
						<!--[if lte IE 6.5]><iframe></iframe><![endif]-->').setStyle('visibility','hidden');
		layer.inject(document.getElement('BODY'));
		this.cmoodate = new CmooDateSelects('mmt_cmoolayer_insurance_naptar', [1970, 1, 1], [1900, 1, 1], _currentdate);
		this.oContainer = $('mmt_cmoolayer_insurance_popup');
		this.oPopuptext = $('mmt_cmoolayer_insurance_popuptext');
		this.oCancelBTN = $('mmt_cmoolayer_insurance_cancel');
		this.oCloseBTN = $('mmt_cmoolayer_insurance_close');
		window.addEvent('resize',(this.moveCenter).bind(this));
		window.addEvent('scroll',(this.moveCenter).bind(this));
		this.moveCenter();
	},
	isOpen: function(){ 
		return this.state;
	},
	moveCenter: function(){
		// y pozicio szamitasa, beallitasa***** CREDITS: thx Gui, Lefi :))
		// itt most fixen 550x250 az ablak merete
		ypos = window.getScroll().y + ((window.getSize().y/2)-(250/2));
		xpos = window.getScroll().x + ((window.getSize().x/2)-(550/2));
		this.oContainer.setStyle('left', xpos);
		this.oContainer.setStyle('top', ypos);
		// ************************************
	},
	open: function(){
		if (!this.isOpen()){
			this.moveCenter();
			this.state=true;
			this.oContainer.setStyle('visibility','visible');
		}
	},
	onClose: function(){
		if (this.isOpen()){
			if ($('mmt_insurance_firstname').get('value').length == 0) return;
			if ($('mmt_insurance_lastname').get('value').length == 0) return;
			this.state=false;
			this.oContainer.setStyle('visibility','hidden');
			this.fnClose();
		}
	},
	onCancel: function(){
		if (this.isOpen()){
			this.state=false;
			this.oContainer.setStyle('visibility','hidden');
		}
	},
	onEnter: function(event){
		if (event.key == 'enter') this.onClose();
	},
	pop: function(text, fnonclose){
		if (this.isOpen()) return false;
		this.fnClose = fnonclose;
		this.oPopuptext.set('html',text);
		this.oCancelBTN.removeEvents('click');
		this.oCancelBTN.addEvent('click', this.onCancel.bind(this));
		this.oCloseBTN.removeEvents('click');
		this.oCloseBTN.addEvent('click',this.onClose.bind(this));
		this.cmoodate.setDate([1970,1,1]);
		$('mmt_insurance_lastname').set('value', '');
		$('mmt_insurance_firstname').set('value', '');
		this.open();
		$('mmt_insurance_lastname').focus();
	}
});
