<?php $session = Goweb::registry('session'); ?>

<?php if (!headers_sent()) { header('Content-Type:text/html; charset=' . CHARSET); } ?>
<?php $this->loadJavascript('/media/js/prototype.js'); ?>
<?php $this->loadCss('/media/css/base.css'); ?>
<?php $this->loadCss('/media/css/cms.css'); ?>
<?php $this->loadCss('/media/css/utilizadores.css'); ?>
<?php $this->loadCss('/media/css/form.css'); ?>

<?php $config = Goweb::registry('config'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- META -->
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>" />
<meta name="copyright" content="<?php echo $config->painel->meta_copyright; ?>" />
<meta name="keywords" content="<?php echo $config->painel->meta_keywords; ?> <?php echo isset($keywords) ? $keywords : ''; ?>" />
<meta name="description" content="<?php echo $config->painel->meta_description; ?>" />
<?php echo $config->painel->meta_extra; ?>

<!-- CSS -->
<?php foreach ($this->getCss() as $css): ?>
<link rel="stylesheet" type="text/css" href="<?php echo $css; ?>" />
<?php endforeach; ?>

<!-- Javascripts -->
<?php foreach ($this->getJavascripts() as $javascript): ?>
<script type="text/javascript" src="<?php echo $javascript; ?>"></script>
<?php endforeach; ?>
<script src="/media/js/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>

<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 id="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">
                <label><?php echo $form->{$element}->label; ?></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 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 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="image" src="/media/images/ok.gif" id="submit" name="submit" value="<?php echo translate('Submeter'); ?>" />
         </td>
      </tr>
   </table>
   <?php echo $form->end(); ?>
</div>

</body>
</html>
