var ERROR_BROWSER_URL = '../public/browser_error.php';
// böngésző ellenőrzés
if ( !is.bs5 || is.saf || ( is.opera7 && is.appVer < 7.5 ) || ( is.gecko && is.ns6 ) ) {
	//document.location = ERROR_BROWSER_URL;
};
// lang beállítésa
if ( is.ie ) {
	document.documentElement.className = document.documentElement.getAttribute('lang');
};


/**
 * az ellenőrzések beállítása
 */
addEvent( window, 'load', function() {
	switch( document.body.id ) {
		case 'application_phase_menu' : 
		case 'login' : 
			proform.initForm( 'form-login' );
			proform.addGroup( { id : 'group-login', 
			                    elements : [ 'email', 'password' ],
			                    processor : function ( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.email.value == '', [oT.email] ) );
									aReturn.push( proform.condition.required( oT.password.value == '', [oT.password] ) );
									aReturn.push( proform.condition.warning( oT.email.value != '' && !proform.condition.checkFormat( 'email', oT.email.value ), [oT.email], [ERROR_MESSAGE.EMAILFORMAT] ) );
									return proform.condition.totalize(aReturn);
								}
			                  } );
			proform.translateStrings( PROFORM_STRINGS );
			proform.init();
			break;
		case 'reminder' : 
			proform.initForm( 'form-reminder' );
			proform.addGroup( { id : 'group-reminder', 
			                    elements : [ 'email', 'date' ],
			                    processor : function ( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.email.value == '', [oT.email] ) );
									aReturn.push( proform.condition.required( oT.date.value == '', [oT.date] ) );
									aReturn.push( proform.condition.warning( oT.email.value != '' && !proform.condition.checkFormat( 'email', oT.email.value ), [oT.email], [ERROR_MESSAGE.EMAILFORMAT] ) );
									aReturn.push( proform.condition.warning( oT.date.value != '' && !proform.condition.checkFormat( 'date', oT.date.value, oT.date.className ), [oT.date], [ERROR_MESSAGE.DATEFORMAT] ) );
									return proform.condition.totalize(aReturn);
								}
			                  } );
			proform.translateStrings( PROFORM_STRINGS );
			proform.init();
			break;
		case 'contact' : 
			proform.initForm( 'form-contact' ); 
			proform.addGroup( { id : 'group-contact', 
						elements : [ 'email', 'subject', 'message', 'captcha', 'captcha_id', 'captcha_img' ],
						processor : function ( oT, sEventId, sFireId ) {
							var aReturn = [], oRequest;
							if ( sEventId == 'onInit' ) {
								var elButton = document.getElementById('new_captcha');
								elButton.onclick = function() {
									if ( this.status == 2 ) {
										removeClass( oT.captcha, 'xmlhttprequest-nonvisible' );
										removeClass( proform.helper.getLabel( oT.captcha, true ), 'xmlhttprequest-nonvisible' );
									oT.captcha.focus();
									}
									else {
										oRequest = new XMLHttpRequest();
										oRequest.open( 'POST', 'contact.php?action=newcaptcha', true );
										oRequest.send( );
										oRequest.onreadystatechange = function() {
											if ( oRequest.readyState == 4 ) {
												if ( oRequest.responseXML && oRequest.responseXML.documentElement &&
													 oRequest.responseXML.documentElement.getAttribute('action') == 'new_captcha' ) {
													var elsUser = oRequest.responseXML.documentElement.getElementsByTagName('captcha');
													if ( elsUser.length > 0 ) {
														oT.captcha_id.value = elsUser[0].firstChild.data;
														oT.captcha_img.src = 'captcha.php?id='+elsUser[0].firstChild.data;
														removeClass( oT.captcha, 'xmlhttprequest-nonvisible' );
														removeClass( proform.helper.getLabel( oT.captcha, true ), 'xmlhttprequest-nonvisible' );
														oT.captcha.focus();
														proform.helper.XMLHttpRequest.markUpdate( oT.captcha.parentNode );
													}
													else {
														oT.captcha.focus();
													};
												};
											};
										};
									};
									return false;
								};
							};
							aReturn.push( proform.condition.required( oT.email.value == '', [oT.email] ) );
							aReturn.push( proform.condition.required( oT.subject.value == '', [oT.subject] ) );
							aReturn.push( proform.condition.required( oT.message.value == '', [oT.message] ) );
							aReturn.push( proform.condition.required( oT.captcha.value == '', [oT.captcha] ) );
							aReturn.push( proform.condition.warning( oT.email.value != '' && !proform.condition.checkFormat( 'email', oT.email.value ), [oT.email], [ERROR_MESSAGE.EMAILFORMAT] ) );
							return proform.condition.totalize(aReturn);
						}
					  } );
			proform.translateStrings( PROFORM_STRINGS );
			proform.init();
			break;
		case 'pwd_change' : 
			proform.initForm( 'form-pwd_change' );
			proform.addGroup( { id : 'group-pwd_change', 
			                    elements : [ 'email', 'password_old', 'password_new1', 'password_new2' ],
			                    processor : function ( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.email.value == '', [oT.email] ) );
									aReturn.push( proform.condition.required( oT.password_old.value == '', [oT.password_old] ) );
									aReturn.push( proform.condition.required( oT.password_new1.value == '', [oT.password_new1] ) );
									aReturn.push( proform.condition.required( oT.password_new2.value == '', [oT.password_new2] ) );
									aReturn.push( proform.condition.warning( oT.email.value != '' && !proform.condition.checkFormat( 'email', oT.email.value ), [oT.email], [ERROR_MESSAGE.EMAILFORMAT] ) );
									aReturn.push( proform.condition.warning( oT.password_new1.value != '' && oT.password_new2.value != '' && oT.password_new1.value != oT.password_new2.value, [oT.password_new1, oT.password_new2], [ERROR_MESSAGE.PASSWORD,ERROR_MESSAGE.PASSWORD] ) );
									return proform.condition.totalize(aReturn);
								}
			                  } );
			proform.translateStrings( PROFORM_STRINGS );
			proform.init();
			break;
		case 'registration_confirm' : 
			proform.initForm( 'form-registration_confirm' );
			proform.addGroup( { id : 'group-registration_confirm', 
			                    elements : [ 'person_id', 'code', 'email', 'password1', 'password2' ],
			                    processor : function ( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.person_id.value == '', [oT.person_id] ) );
									aReturn.push( proform.condition.required( oT.code.value == '', [oT.code] ) );
									aReturn.push( proform.condition.required( oT.email.value == '', [oT.email] ) );
									aReturn.push( proform.condition.required( oT.password1.value == '', [oT.password1] ) );
									aReturn.push( proform.condition.required( oT.password2.value == '', [oT.password2] ) );
									aReturn.push( proform.condition.warning( oT.email.value != '' && !proform.condition.checkFormat( 'email', oT.email.value ), [oT.email], [ERROR_MESSAGE.EMAILFORMAT] ) );
									aReturn.push( proform.condition.warning( oT.password1.value != '' && oT.password2.value != '' && oT.password1.value != oT.password2.value, [oT.password1, oT.password2], [ERROR_MESSAGE.PASSWORD,ERROR_MESSAGE.PASSWORD] ) );
									return proform.condition.totalize(aReturn);
								}
			                  } );
			proform.translateStrings( PROFORM_STRINGS );
			proform.init();
			break;
		case 'confirm' : 
			proform.initForm( 'form-confirm' );
			proform.addGroup( { id : 'group-confirm', 
			                    elements : [ 'password' ],
			                    processor : function ( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.password.value == '', [oT.password] ) );
									return proform.condition.totalize(aReturn);
								}
			                  } );
			proform.translateStrings( PROFORM_STRINGS );
			proform.init();
			break;
		case 'addresses' : // csak teszeléshez kell
			proform.initForm( 'fAddresses' );
			proform.addGroup( {
				id: 'group_perm_address',
				elements: [ 'perm_country', 'perm_country_text', 'perm_town', 'perm_town_s', 'perm_zip', 'perm_zip_s', 'perm_address' ],
				processor: function(oT, sEventId, sFireId, oEvent){
					proform.helper.XMLHttpRequest.config = {
						updateClass: 'xmlhttprequest-update-',
						updateUnit: 5,
						updateDelayFase1: 200,
						updateDelayFase2: 50
					};
					
					var aReturn = [];
					new ZipCodes(this,oPermAddress);
					aReturn.push(proform.condition.required(oT.perm_country.isRequired && oT.perm_country.value == '000' && oT.perm_country_text.value == '', [oT.perm_country_text]));
					aReturn.push(proform.condition.required(oT.perm_country.isRequired && oT.perm_country.value == '-1', [oT.perm_country]));
					aReturn.push(proform.condition.required(oT.perm_town.isRequired && oT.perm_town.value == '', [oT.perm_town]));
					aReturn.push(proform.condition.required(oT.perm_zip.isRequired && oT.perm_zip.value == '', [oT.perm_zip]));
					aReturn.push(proform.condition.required(oT.perm_address.isRequired && oT.perm_address.value == '', [oT.perm_address]));
					return proform.condition.totalize(aReturn);
				}
			} );
			proform.init();
			break;
	};
} );	 


