<? global $lang; ?>
<fieldset>
	<form method='POST' action='<?=$this -> _form_adress;?>' id='<?=$this -> _form_id;?>' enctype='multipart/form-data'>
	<?
	if ( is_array ( $this -> _hidden_tab ) ) foreach ( $this -> _hidden_tab as $hidden )
	{
		?><input type='hidden' name='<?=$hidden['name'];?>' value='<?=$this -> secureHTML( $hidden['value'] );?>'><?
	}
	if ( $this -> _form_key && $this -> _form_val )
	{
		?><input type='hidden' name='rw' value='db_edit_save'><?
	}
	else
	{
		?>
		<input type='hidden' name='rw' value='db_edit_add_new'>
		<input type='hidden' name='<?=base64_encode( 'time' );?>' value='<?=base64_encode( date( 'Y-m-d H:i:s' ) );?>'>
		<?
	}
	if ( is_array ( $this -> _hidden_param_tab ) ) foreach ( $this -> _hidden_param_tab as $hidden )
	{
		?><input type='hidden' name='<?=$hidden['name'];?>' value='<?=$this -> secureHTML( $hidden['value'] );?>'><?
	}
	?>
	<?
	if ( is_array( $this -> _table_edit_tab ) ) foreach ( $this -> _table_edit_tab as $tab )
	{
		?>
		<div class="edit_line" id='div_<?=$tab['tr_id'];?>'>
			<label><?=ucfirst( $tab['name'] );?>:</label>
      <div class="input">
        <?
        if ( $tab['type'] == 'label' )
        {
          ?>
          <input type='hidden' id='<?=$tab['input_id'];?>' name='<?=$tab['input_id'];?>' value='<?=$this -> secureHTML( $tab['input_value'] );?>' <?=$tab['input_action'];?>><?=$tab['input_value'];?>
          <?
        }

        if ( $tab['type'] == 'text' )
        {
          ?>
          <input type='text' id='<?=$tab['input_id'];?>' name='<?=$tab['input_id'];?>' value='<?=$this -> secureHTML( $tab['input_value'] );?>' <?=$tab['input_action'];?>>
          <?
        }

        if ( $tab['type'] == 'textarea' )
        {
          ?>
            <textarea name='<?=$tab['input_id'];?>' id='<?=$tab['input_id'];?>' cols='70' rows='5'><?=stripslashes($tab['input_value']);?></textarea>
          <?
        }

        if ( $tab['type'] == 'radio' )
        {
          foreach ( $tab['input_value'] as $key => $val )
          {
            ?>
            <input type='radio' name='<?=$tab['input_name'];?>' id="<?=$tab['input_nam'] . '_' . $val;?>" value='<?=$key;?>'
              <?
              if ( $tab['var'] == $key )
                echo 'checked';
              ?>
            ><?=$val;?>
            <?
          }
        }

        if ( $tab['type'] == 'file' )
        {
          ?>
          <input type='file' id='<?=$tab['input_id'];?>' name='<?=$tab['input_id'];?>'>
          <?
          if ( $tab['input_value'] )
          {
            ?>
            <script>
              $(document).ready(function(){
                $('#imageshow').tooltip({
                  showURL: false,
                  opacity: 1,
                  bodyHandler: function() {
                    return $('<img/>').attr('src','../<?=$tab['input_value'];?>');
                  }
                });
              });
              </script>
              <div style='display:inline; margin-left:40px; margin-top:3px;' id='imageshow'><?=$lang -> getTrans( 'T_ZDJECIE' );?></div>
            <?
          }
        }

        if ( $tab['type'] == 'combo' )
        {
          ?>
          <select name='<?=$tab['input_name'];?>' <?=$tab['input_action'];?> id='<?=$tab['input_id'];?>'>
          <?
          foreach ( $tab['input_value'] as $key => $val )
          {
            ?>
            <option value='<?=$key;?>'
            <?
            if ( isset( $tab['var'] ) && $tab['var'] == $key )
            {
              ?>selected<?
            }
            ?>><?=$val;?>
            </option><?
          }
          ?>
          </select>
          <?
        }
        ?>
			</div
    </div>
		<?
	}

	if ( isset( $this -> _password ) )
	{
		?>
    <div class="edit_line">
      <label><?=ucfirst( $lang -> getTrans( 'T_HASLO' ) );?>:</label>
      <div class="input">
				<input type='password'  style='width:200px;' name='<?=$this -> _pass_name1;?>' id='<?=$this -> _pass_name1;?>' 	<?=$this -> _pass_action;?>>
      </div>
    </div>

    <div class="edit_line">
      <label><?=ucfirst( $lang -> getTrans( 'T_HASLO_POWTORZ' ) );?>:</label>
      <div class="input">
				<input type='password'  style='width:200px;' name='<?=$this -> _pass_name2;?>' id='<?=$this -> _pass_name2;?>' <?=$this -> _pass_action2;?>>
      </div>
    </div>
		<?
	}
	?>

	<?
	if ( isset( $this -> _file_upload ) )
	{

		if ( is_array( $this -> _upload_tab ) ) foreach ( $this -> _upload_tab as $uplaod )
		{
			?><input type='hidden' name='<?=$uplaod['name'];?>' value='<?=$uplaod['value'];?>'><?
		}
	}
	if ( isset( $this -> _cancel_button ) )
	{
		?>
		<a href='<?=$this -> _cancel_adress;?>
			<?
			if ( $this -> _cancel_key && $this -> _cancel_val )
			{
				?>?<?=$this -> _cancel_key;?>=<?=$this -> _cancel_val;?><?
			}
			?>
		' class='btn'><?=$this -> _cancel_name;?></a>
		<?
	}
	?>
	</form>
</fieldset>