<?php $this->loadCss('/media/css/form.css'); ?>
<?php if ($form):?>
<div id="form_view">
   <?php echo $form->start(); ?>
   <table border="0" cellpadding="3" cellspacing="0">
      <?php foreach ($form->getElementsNames() as $element): ?>
          <?php if ($form->{$element}->type == 'separator') : ?>
          <tr>
             <td colspan="2">
                <div class="separator">
                   <?php if ($form->{$element}->label != '<label></label>'): ?>
                   <?php echo $form->{$element}->label; ?>
                   <?php endif; ?>             
                   <?php echo $form->{$element}->input; ?>
                </div>
             </td>
          </tr>
          <?php else : ?>
		  <?php if ($form->{$element}->getErrorMessage()): ?>
		  <tr>
		  	<td>&nbsp;</td>
			<td>
                <div class="error_message"><?php echo $form->{$element}->getErrorMessage(); ?></div></td>
		  </tr>
		  <?php endif; ?>
          <tr>
             <td valign="top">
                <?php echo $form->{$element}->label; ?>
             </td>
             <td>
                <?php if (is_array($form->{$element}->input)): ?>
                <table border="0" cellpadding="3" cellspacing="0">
                   <?php foreach ($form->{$element}->input as $label => $input): ?>
                   <?php $cleanLabel = str_replace("<label>", "", $label);?>
                   <?php $cleanLabel = str_replace("<label>", "", $cleanLabel);?>
                   <?php $cleanLabel = str_replace("\n", "", $cleanLabel);?>
                   
                   <?php if (is_array($form->{$element}->value)) : ?>
                        
                       <?php if (in_array(trim($cleanLabel), $form->{$element}->value)) : ?>
                       <?php $input = str_replace('" value="', '" checked="checked" value="', $input); ?>
                       <tr>
                          <td id="radio"><?php echo $input; ?></td>
                          <td><?php echo $label; ?></td>
                       </tr>
                       <?php else : ?>
                       <tr>
                          <td id="radio"><?php echo $input; ?></td>
                          <td><?php echo $label; ?></td>
                       </tr>
                       <?php endif; ?>
                        
                   <?php else : ?>
                       <?php if (trim($form->{$element}->value) == trim($cleanLabel)) : ?>
                       <?php $input = str_replace('" value="', '" checked="checked" value="', $input); ?>
                       <tr>
                          <td id="radio"><?php echo $input; ?></td>
                          <td><?php echo $label; ?></td>
                       </tr>
                       <?php else : ?>
                       <tr>
                          <td id="radio"><?php echo $input; ?></td>
                          <td><?php echo $label; ?></td>
                       </tr>
                       <?php endif; ?>
                   <?php endif; ?>
                   
                   
                   <?php endforeach; ?>
                </table>
                <?php else: ?>
                <?php echo $form->{$element}->input; ?>
		  <?php if ($form->{$element}->getErrorMessage()): ?>
                <span class="error_message"></span>
		  <?php endif; ?>
                <?php endif; ?> 
             </td>
          </tr>
          <?php endif; ?>
      <?php endforeach; ?>
      <tr>
         <td>&nbsp;</td>
         <td>
           <input type="submit" name="submit" value="<?php echo translate('Submeter'); ?>" />
         </td>
      </tr>
   </table>
    <?php echo $form->getJsValidate()?>
   <?php echo $form->end(); ?>
</div>
<?php endif;?>