/**
 *
 * igénybejelentés oldalakhoz tartozó funkciók
 */

var g=1;


loadEventBinding( window, function() {
	switch ( document.body.id ) {
		case 'igenybejelento_2.1' :
		case 'igenybejelento_2.2' :
			proform.initForm( 'frm_main' );
			proform.addGroup( { id : 'group-client-data', 
								elements : [ 'client_name', 'client_address', 'client_id', 'contract_number', 'registration_number', 'discharge_date' ],
								processor : function( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.client_name.value == '', [oT.client_name] ) );
									//aReturn.push( proform.condition.warning( oT.client_name.value != '' && oT.client_name.value.match(/\d+/), [oT.client_name] ) );
									aReturn.push( proform.condition.required( oT.client_id.value == '', [oT.client_id] ) );
									aReturn.push( proform.condition.warning( ( oT.client_id.value != '' && oT.client_id.value.length != 6 ) || ( oT.client_id.value != '' && !proform.condition.checkFormat( 'number', oT.client_id.value ) ), [oT.client_id], ['A partnerazonosító kötelezően 6 karakter hosszú!'] ) );
									aReturn.push( proform.condition.required( oT.contract_number.value == '', [oT.contract_number] ) );
									aReturn.push( proform.condition.warning( oT.contract_number.value != '' && !oT.contract_number.value.match(/^[^\W^\d]{3}\d{7}$/), [oT.contract_number], ['A megadott szerződésszám formátuma nem megfelelő!'] ) );
									aReturn.push( proform.condition.required( oT.registration_number.value == '', [oT.registration_number] ) );
									aReturn.push( proform.condition.warning( oT.registration_number.value != '' && oT.registration_number.value.length != 6, [oT.registration_number], ['Kötelezően 6 karakter hosszú!'] ) );
									aReturn.push( proform.condition.required( oT.discharge_date.value == '', [oT.discharge_date] ) );
									aReturn.push( proform.condition.warning( oT.discharge_date.value != '' && !proform.condition.checkFormat( 'date', oT.discharge_date.value, oT.discharge_date.className ), [oT.discharge_date], ['A megadott dátum formátuma nem megfelelő! A helyes formátum: éééé.hh.nn.'] ) );
									aReturn.push( proform.condition.warning( (oT.discharge_date.value != '' && proform.condition.checkFormat( 'date', oT.discharge_date.value, oT.discharge_date.className )) && (oT.discharge_date.value.substr(0, 4) + oT.discharge_date.value.substr(5, 2) + oT.discharge_date.value.substr(8, 2)) <= document.frm_main.date_now.value, [oT.discharge_date], ['A megadott dátumnak nagyobbnak kell lennie a mai napnál!'] ) );
/*									document.getElementById( 'administrator-name' ).style.display = (oT.client_type_1.checked == false) ? 'none' : ( is.ie ) ? 'block' : 'table-row';
									if(oT.client_type_1.checked == false) { g = 1;}
									if(oT.client_type_1.checked == true) { g = 0;}
									if( g==1 )
										var x=true;
									else var x=false;

									proform.helper.activeForm.disableElement( x, document.getElementById( 'send_address' ) );
*/
									return proform.condition.totalize(aReturn);
								}
							} );

			proform.addGroup( { id : 'group-discharge-mode', 
								elements : [ 'discharge_mode_1', 'discharge_mode_2', 'discharge_mode_3', 'discharge_mode_4' ],
								processor : function( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.discharge_mode_1.checked == false && oT.discharge_mode_2.checked == false && oT.discharge_mode_3.checked == false && oT.discharge_mode_4.checked == false, [oT.discharge_mode_1, oT.discharge_mode_2, oT.discharge_mode_3, oT.discharge_mode_4] ) );

									return proform.condition.totalize(aReturn);
								}
							} );

			proform.addGroup( { id : 'group-contract-close', 
								elements : [ 'contract_close_1', 'contract_close_2' ],
								processor : function( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.contract_close_1.checked == false && oT.contract_close_2.checked == false, [oT.contract_close_1, oT.contract_close_2] ) );

									return proform.condition.totalize(aReturn);
								}
							} );

			proform.addGroup( { id : 'group-contract_modification_reason', 
								elements : [ 'contract_modification_reason_1', 'contract_modification_reason_2', 'contract_modification_reason_3', 'contract_modification_reason_4', 'contract_modification_reason_5', 'contract_modification_reason_text_2', 'contract_modification_reason_text_5' ],
								processor : function( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.contract_modification_reason_2.checked && oT.contract_modification_reason_text_2.value == '', [oT.contract_modification_reason_text_2] ) );
									aReturn.push( proform.condition.required( oT.contract_modification_reason_5.checked && oT.contract_modification_reason_text_5.value == '', [oT.contract_modification_reason_text_5] ) );

									return proform.condition.totalize(aReturn);
								}
							} );

			proform.addGroup( { id : 'group-send-address', 
								elements : [ 'send_email', 'send_post' ],
								processor : function( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.warning( oT.send_email.value != '' && !proform.condition.checkFormat( 'email', oT.send_email.value ), [oT.send_email], ['A megadott e-mail formátuma nem megfelelő!'] ) );
									aReturn.push( proform.condition.required( oT.send_post.value == '', [oT.send_post] ) );
									
									//alert (g);
/*									if( g==1 )
										var x=true;
									else var x=false;
									
									proform.helper.activeForm.disableElement( x, oT.send_address );
*/									//proform.helper.activeForm.disableElement( true, oT.send_address ); le van tiltva
									//proform.helper.activeForm.disableElement( false, oT.send_address ); nincs letiltva
									
									
									return proform.condition.totalize(aReturn);
								}
							} );

			proform.init();
			break;

		case 'igenybejelento_3.1' :
		case 'igenybejelento_3.2' :
			proform.initForm( 'frm_main' );
			proform.addGroup( { id : 'group-client-data', 
								elements : [ 'client_name', 'client_address', 'client_id', 'contract_number', 'registration_number' ],
								processor : function( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.client_name.value == '', [oT.client_name] ) );
									aReturn.push( proform.condition.warning( oT.client_name.value != '' && oT.client_name.value.match(/\d+/), [oT.client_name] ) );
									aReturn.push( proform.condition.required( oT.client_id.value == '', [oT.client_id] ) );
									aReturn.push( proform.condition.warning( ( oT.client_id.value != '' && oT.client_id.value.length != 6 ) || ( oT.client_id.value != '' && !proform.condition.checkFormat( 'number', oT.client_id.value ) ), [oT.client_id], ['A partnerazonosító kötelezően 6 karakter hosszú!'] ) );
									aReturn.push( proform.condition.required( oT.contract_number.value == '', [oT.contract_number] ) );
									aReturn.push( proform.condition.warning( oT.contract_number.value != '' && !oT.contract_number.value.match(/^[^\W^\d]{3}\d{7}$/), [oT.contract_number], ['A megadott szerződésszám formátuma nem megfelelő!'] ) );
									
									aReturn.push( proform.condition.warning( oT.registration_number.value != '' && oT.registration_number.value.length != 6, [oT.registration_number], ['Kötelezően 6 karakter hosszú!'] ) );
									/*aReturn.push( proform.condition.required( oT.discharge_date.value == '', [oT.discharge_date] ) );
									aReturn.push( proform.condition.warning( oT.discharge_date.value != '' && !proform.condition.checkFormat( 'date', oT.discharge_date.value, oT.discharge_date.className ), [oT.discharge_date], ['A megadott dátum formátuma nem megfelelő! A helyes formátum: éééé.hh.nn.'] ) );
									aReturn.push( proform.condition.warning( (oT.discharge_date.value != '' && proform.condition.checkFormat( 'date', oT.discharge_date.value, oT.discharge_date.className )) && (oT.discharge_date.value.substr(0, 4) + oT.discharge_date.value.substr(5, 2) + oT.discharge_date.value.substr(8, 2)) <= document.frm_main.date_now.value, [oT.discharge_date], ['A megadott dátumnak nagyobbnak kell lennie a mai napnál!'] ) );*/
/*									document.getElementById( 'administrator-name' ).style.display = (oT.client_type_1.checked == false) ? 'none' : ( is.ie ) ? 'block' : 'table-row';
*/
									return proform.condition.totalize(aReturn);
								}
							} );

			proform.addGroup( { id : 'group-send-address', 
								elements : [ 'send_email', 'send_post' ],
								processor : function( oT ) {
									var aReturn = [];
									//aReturn.push( proform.condition.warning( oT.send_phone.value != '' && !proform.condition.checkFormat( 'phone', oT.send_phone.value ), [oT.send_phone], ['A megadott telefonszám formátuma nem megfelelő!'] ) );
									aReturn.push( proform.condition.warning( oT.send_email.value != '' && !proform.condition.checkFormat( 'email', oT.send_email.value ), [oT.send_email], ['A megadott e-mail formátuma nem megfelelő!'] ) );
									aReturn.push( proform.condition.required( oT.send_post.value == '', [oT.send_post] ) );

									return proform.condition.totalize(aReturn);
								}
							} );

			proform.init();
			break;

		case 'igenybejelento_6.1' :
		case 'igenybejelento_6.2' :
			proform.initForm( 'frm_main' );
			proform.addGroup( { id : 'group-client-data', 
								elements : [ 'client_name', 'client_id', 'client_email', 'contract_number' ],
								processor : function( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.client_name.value == '', [oT.client_name] ) );
									aReturn.push( proform.condition.warning( oT.client_name.value != '' && oT.client_name.value.match(/\d+/), [oT.client_name] ) );
									aReturn.push( proform.condition.required( oT.client_id.value == '', [oT.client_id] ) );
									aReturn.push( proform.condition.warning( ( oT.client_id.value != '' && oT.client_id.value.length != 6 ) || ( oT.client_id.value != '' && !proform.condition.checkFormat( 'number', oT.client_id.value ) ), [oT.client_id], ['A partnerazonosító kötelezően 6 karakter hosszú!'] ) );
									aReturn.push( proform.condition.warning( oT.client_email.value != '' && !proform.condition.checkFormat( 'email', oT.client_email.value ), [oT.client_email], ['A megadott e-mail formátuma nem megfelelő!'] ) );
//									aReturn.push( proform.condition.warning( oT.client_phone.value != '' && !proform.condition.checkFormat( 'phone', oT.client_phone.value ), [oT.client_phone], ['A megadott telefonszám formátuma nem megfelelő!'] ) );
									aReturn.push( proform.condition.warning( oT.contract_number.value != '' && !oT.contract_number.value.match(/^[^\W^\d]{3}\d{7}$/), [oT.contract_number], ['A megadott szerződésszám formátuma nem megfelelő!'] ) );

									return proform.condition.totalize(aReturn);
								}
							} );
							
			proform.addGroup( { id : 'group-changed-data', 
								elements : [ 'changed_postcode', 'changed_town', 'changed_address', 'changed_post' ],
								processor : function( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.changed_postcode.value == '', [oT.changed_postcode] ) );
									aReturn.push( proform.condition.required( oT.changed_town.value == '', [oT.changed_town] ) );
									aReturn.push( proform.condition.required( oT.changed_address.value == '', [oT.changed_address] ) );
									aReturn.push( proform.condition.required( oT.changed_post.value == '', [oT.changed_post] ) );

									return proform.condition.totalize(aReturn);
								}
							} );

			proform.init();
			break;

		case 'igenybejelento_7.1' :
		case 'igenybejelento_7.2' :
			proform.initForm( 'frm_main' );
			proform.addGroup( { id : 'group-client-data', 
								elements : [ 'client_name', 'client_id', 'registration_number', 'client_email', 'contract_number' ],
								processor : function( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.client_name.value == '', [oT.client_name] ) );
									aReturn.push( proform.condition.warning( oT.client_name.value != '' && oT.client_name.value.match(/\d+/), [oT.client_name] ) );
									aReturn.push( proform.condition.required( oT.client_id.value == '', [oT.client_id] ) );
									aReturn.push( proform.condition.warning( ( oT.client_id.value != '' && oT.client_id.value.length != 6 ) || ( oT.client_id.value != '' && !proform.condition.checkFormat( 'number', oT.client_id.value ) ), [oT.client_id], ['A partnerazonosító kötelezően 6 karakter hosszú!'] ) );
									aReturn.push( proform.condition.warning( oT.contract_number.value != '' && !oT.contract_number.value.match(/^[^\W^\d]{3}\d{7}$/), [oT.contract_number], ['A megadott szerződésszám formátuma nem megfelelő!'] ) );
									aReturn.push( proform.condition.required( oT.registration_number.value == '', [oT.registration_number] ) );
									aReturn.push( proform.condition.warning( oT.registration_number.value != '' && oT.registration_number.value.length != 6, [oT.registration_number], ['Kötelezően 6 karakter hosszú!'] ) );
									aReturn.push( proform.condition.warning( oT.client_email.value != '' && !proform.condition.checkFormat( 'email', oT.client_email.value ), [oT.client_email], ['A megadott e-mail formátuma nem megfelelő!'] ) );
//									aReturn.push( proform.condition.warning( oT.client_phone.value != '' && !proform.condition.checkFormat( 'phone', oT.client_phone.value ), [oT.client_phone], ['A megadott telefonszám formátuma nem megfelelő!'] ) );

									return proform.condition.totalize(aReturn);
								}
							} );

			proform.addGroup( { id : 'group-damage-character', 
								elements : [ 'damage_character_1', 'damage_character_2', 'damage_character_post' ],
								processor : function( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.damage_character_1.checked == false && oT.damage_character_2.checked == false, [oT.damage_character_1, oT.damage_character_2] ) );
									document.getElementById( 'complete-1' ).style.display = (oT.damage_character_1.checked == false) ? 'none' : 'block';
									document.getElementById( 'complete-2' ).style.display = (oT.damage_character_2.checked == false) ? 'none' : 'block';
									aReturn.push( proform.condition.required( oT.damage_character_post.value == '', [oT.damage_character_post] ) );
									return proform.condition.totalize(aReturn);
								}
							} );

			proform.init();
			break;

	};
} );
