<?php /* Smarty version 2.6.26, created on 2017-04-19 06:37:32
         compiled from /home3/bargaip4/public_html/gevimmo/plugins/multiField/mf_reg_js.tpl */ ?>
<?php if (@REALM == 'admin'): ?>
	<?php $this->assign('post_prefix', 'f'); ?>
<?php else: ?>
	<?php $this->assign('post_prefix', 'account'); ?>
<?php endif; ?>

<?php $_from = $this->_tpl_vars['fields']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['field']):
?>
	<?php if ($this->_tpl_vars['multi_formats'][$this->_tpl_vars['field']['Condition']]): ?>
		<?php if ($this->_tpl_vars['mf_form_key']): ?>
			var post_form_dom = 'form:has(input[value=<?php echo $this->_tpl_vars['mf_form_key']; ?>
],name=[post_form_key]) ';
		<?php else: ?>
			var post_form_dom = '';
		<?php endif; ?><?php echo '

		if( \''; ?>
<?php echo $this->_tpl_vars['field']['Key']; ?>
<?php echo '\'.indexOf(\'level\') > 0 && $(post_form_dom + \'select[name="'; ?>
<?php echo $this->_tpl_vars['post_prefix']; ?>
[<?php echo $this->_tpl_vars['field']['Key']; ?>
<?php echo ']"]\').val() == "0" )
		{
			var top_field = trim(\''; ?>
<?php echo $this->_tpl_vars['field']['Key']; ?>
<?php echo '\'.split(\'level\')[0], \'_\');
			var level = \''; ?>
<?php echo $this->_tpl_vars['field']['Key']; ?>
<?php echo '\'.split(\'level\')[1];
			var prev_level = level-1;
			var prev_field = level > 1 ? top_field + \'_level\' + prev_level : top_field;

			if( !$(post_form_dom + \'select[name="'; ?>
<?php echo $this->_tpl_vars['post_prefix']; ?>
['+prev_field+']"]').val() || $(post_form_dom + 'select[name="<?php echo $this->_tpl_vars['post_prefix']; ?>
<?php echo '[\'+prev_field+\']"]\').val() == "0" )
			{
				$(post_form_dom + \'select[name="'; ?>
<?php echo $this->_tpl_vars['post_prefix']; ?>
[<?php echo $this->_tpl_vars['field']['Key']; ?>
<?php echo ']"]\').attr(\'disabled\', \'disabled\').addClass(\'disabled\');
			}
		}
		
		$(post_form_dom + \'select[name="'; ?>
<?php echo $this->_tpl_vars['post_prefix']; ?>
[<?php echo $this->_tpl_vars['field']['Key']; ?>
<?php echo ']"]\').change(function(){
			'; ?>

			var top_field = trim('<?php echo $this->_tpl_vars['field']['Key']; ?>
'.split('level')[0], '_');
			var level = parseInt('<?php echo $this->_tpl_vars['field']['Key']; ?>
'.split('level')[1]) ? parseInt('<?php echo $this->_tpl_vars['field']['Key']; ?>
'.split('level')[1]) : 0;

			<?php echo '			
			if( $(this).val() == "0" )
			{
				if( level > 1 )
				{
					var prev_field = top_field +\'_level\'+(level-1);
				}
				else
				{
					var prev_field = top_field;
				}
				var prev_val = $(post_form_dom + \'select[name="'; ?>
<?php echo $this->_tpl_vars['post_prefix']; ?>
<?php echo '[\'+ prev_field +\']"]\').val();

				'; ?>

				$('#<?php echo $this->_tpl_vars['mf_form_prefix']; ?>
'+top_field+'_lastsel').val( prev_field );
				$('#<?php echo $this->_tpl_vars['mf_form_prefix']; ?>
'+top_field+'_val').val( prev_val );
				<?php echo '
			}else
			{
				'; ?>

				$('#<?php echo $this->_tpl_vars['mf_form_prefix']; ?>
'+top_field+'_lastsel').val('<?php echo $this->_tpl_vars['field']['Key']; ?>
');
				$('#<?php echo $this->_tpl_vars['mf_form_prefix']; ?>
'+top_field+'_val').val( $(this).val() );
				<?php echo '
			}
			
			if( $(this).val() != "0" && $(this).val() && $(post_form_dom + \'select[name="'; ?>
<?php echo $this->_tpl_vars['post_prefix']; ?>
<?php echo '[\'+top_field+\'_level\'+(level+1)+\']"]\').length > 0 )
			{
				xajax_mfGetNext( $(this).val(), $(this).attr(\'name\'), \''; ?>
<?php echo $this->_tpl_vars['mf_form_key']; ?>
<?php echo '\', $(\'.'; ?>
<?php echo $this->_tpl_vars['mf_form_prefix']; ?>
<?php echo $this->_tpl_vars['field']['Key']; ?>
<?php echo '_mf\').length, \'account\' );
			}
		});
		
		if( \''; ?>
<?php echo $this->_tpl_vars['field']['Key']; ?>
<?php echo '\'.indexOf(\'level\') < 0 || \''; ?>
<?php echo $this->_tpl_vars['field']['Key']; ?>
<?php echo '\'.indexOf(\'level\') == false)
		{
			'; ?>
	
			xajax_mfBuild( $('#<?php echo $this->_tpl_vars['mf_form_prefix']; ?>
<?php echo $this->_tpl_vars['field']['Key']; ?>
_val').val(), $('#<?php echo $this->_tpl_vars['mf_form_prefix']; ?>
<?php echo $this->_tpl_vars['field']['Key']; ?>
_lastsel').val(), '<?php echo $this->_tpl_vars['mf_form_key']; ?>
', $('.<?php echo $this->_tpl_vars['mf_form_prefix']; ?>
<?php echo $this->_tpl_vars['field']['Key']; ?>
_mf').length, 'account' );
			<?php echo '
		}	
		'; ?>
	
	<?php endif; ?>
<?php endforeach; endif; unset($_from); ?>
