<?php 
$session = Goweb::registry('session');
$this->loadJavascript('/admin/media/js/ajax_helper.js');
$this->loadJavascript('/media/js/goweb_ajax.js');
$this->loadJavascript('/admin/media/js/utils.js');
$this->loadJavascript('/admin/media/js/prototype.js');
$this->loadJavascript('/admin/media/js/scriptaculous/scriptaculous.js');
$this->loadJavascript('/admin/media/js/scriptaculous/effects.js');
$this->loadJavascript('/admin/media/js/modalbox.js'); 
$this->loadCss('/admin/media/css/base.css');
$this->headScript()->appendScript("var baseUrl = '" . $baseUrl . "';\n");
$this->headScript()->appendScript("var langSM = '" . $session->lang . "';\n");
$config = Goweb::registry('config'); ?>
<?php echo $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo $session->lang; ?>" xml:lang="<?php echo $session->lang; ?>">
<head>
<?php $this->headMeta()->appendHttpEquiv('Content-Type',
                                   'text/html; charset=' . CHARSET)
                 ->appendHttpEquiv('Content-Language', 'pt-PT');
$this->headMeta()->appendHttpEquiv("X-UA-Compatible","IE=8");
// setting the site in the title; possibly in the layout script:
//$this->headTitle('Goweb - Sitemanager 4.0');
if (isset($title)) $this->headTitle(html_entity_decode($title, ENT_NOQUOTES, CHARSET));
if (isset($section_title)) $this->headTitle(html_entity_decode($section_title, ENT_NOQUOTES, CHARSET));
if (isset($action)) $this->headTitle(html_entity_decode($action, ENT_NOQUOTES, CHARSET));

// setting a separator string for segments:
$this->headTitle()->setSeparator(' | ');
?>
<?php foreach ($this->getCss() as $css): ?>
<?php $this->headLink()->appendStylesheet($baseUrl . $css) ?>
<?php endforeach; ?>
<?php foreach ($this->getJavascripts() as $javascript): ?>
<?php $this->headScript()->appendFile($baseUrl . $javascript)?>
<?php endforeach; ?>
<?php echo $this->headMeta() ?>
<?php echo $this->headTitle() ?>
<?php echo $this->headLink() ?>
<?php echo $this->headScript() ?>


<!--[if IE]>
<script type="text/javascript" src="<?php echo $baseUrl?>/media/js/ie.js"></script>
<![endif]--> 
<!--[if lt IE 7]>
<script type="text/javascript" src="<?php echo $baseUrl?>/media/js/DD_belatedPNG_0.0.7a-min.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
DD_belatedPNG.fix('img');
/* ]]> */
</script>
<![endif]--> 
</head>
<body>
<div id="cabecalho" style="z-index:100;">
   <table border="0" cellspacing="0" cellpadding="0" width="100%" id="imgtopo">
      <tr>
         <td width="20%">&nbsp;</td>
         <td width="60%" valign="top" align="center">
            <div id="menus">
               <table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                     <td width="6"><div id="imgesq" class="imgleft">&nbsp;</div></td>
                     <td class="menutopbg">
                        <div class="label" onclick="location='<?php echo $this->link('/dashboard')?>';" onmouseover="this.className='label_hover'; $('imgesq').className='imglefthover';" onmouseout="this.className='label'; $('imgesq').className='imgleft'"><?php echo $this->img('/admin/media/images/ico_inicio.gif', array('title' => translateAdmin('In&iacute;cio'), 'alt' => translateAdmin('In&iacute;cio'), 'border' => 0)); ?><br /><?php echo translateAdmin('In&iacute;cio');?></div>
                     </td>
                     <td class="menutopbg">
                        <div class="label" onclick="location='<?php echo $this->link('/cms/')?>';" onmouseover="this.className='label_hover'" onmouseout="this.className='label'"><?php echo $this->img('/admin/media/images/ico_site.gif', array('title' => translateAdmin('Site'), 'alt' => translateAdmin('Site'),  'border' => 0)); ?><br /><?php echo translateAdmin('Site');?></div>
                     </td>
                     <?php if (count($session->modulos_menu)>0): ?>
                     <td class="menutopbg">
                        <div id="modulos_menu" class="label" onmouseover="$('submenu').style.left='-12px';$('submenu').style.visibility='visible';$('submenu').style.overflow='visible';this.className='label_hover';" onmouseout="this.className='label';$('submenu').style.visibility='hidden';">
                           <div id="interno_relativo" style="position:relative;left:0px;top:0px;z-index:101;">
                              <div style="z-index:102;">
                                 <table cellpadding="0" cellspacing="0" border="0">
                                    <tr>
                                       <td align="center"><?php echo $this->img('/admin/media/images/ico_modulos.gif', array('title' => translateAdmin('M&oacute;dulos'), 'alt' => translateAdmin('M&oacute;dulos'), 'border' => 0)); ?></td>
                                    </tr>
                                    <tr>
                                       <td align="center"><?php echo translateAdmin('M&oacute;dulos');?></td>
                                    </tr>
                                 </table>
                              </div>
                              <div id="submenu" style="position:absolute;left:0px;width:1px;height:1px;top:38px;visibility:hidden;overflow:hidden;z-index:110;">
                                 <table cellpadding="0" cellspacing="0" border="0">
                                    <tr>
                                       <td onmouseover="$('submenu').style.visibility='visible';" onmouseout="$('submenu').style.visibility='hidden';" height="2"></td>
                                    </tr>
                                    <?php foreach ((array) $session->modulos_menu as $modulo => $titulo) : ?>
                                    <tr>
                                       <td class="menu" onclick="location='<?php echo $this->link("/{$modulo}/list/section/{$modulo}/"); ?>';" onmouseover="$('modulos_menu').className='label_hover';this.className='menu_hover';$('submenu').style.visibility='visible'" onmouseout="$('modulos_menu').className='label';this.className='menu';$('submenu').style.visibility='hidden'">
                                          <table cellpadding="0" cellspacing="5" border="0">
                                             <tr>
                                                <td><?php echo $this->img('/admin/media/images/' . $modulo . '.gif', array('title' => $modulo, 'alt' => $modulo, 'border' => 0)); ?></td>
                                                <td>&nbsp;</td>
                                                <td><?php echo $titulo; ?></td>
                                                <td>&nbsp;</td>
                                             </tr>
                                          </table>
                                       </td>
                                    </tr>
                                    <?php endforeach; ?>
                                 </table>
                              </div>
                           </div>
                        </div>
                     </td>
                     <?php endif; ?>
                     <?php if ($hasPainel || ($session->__get('modulos') && array_key_exists('Painel',$session->modulos))): ?>
                     <td class="menutopbg" align="center">
                        <div class="label" onclick="location='<?php echo $this->link('/painel/edit/'); ?>';" onmouseover="this.className='label_hover'" onmouseout="this.className='label'"><?php echo $this->img('/admin/media/images/ico_pcontrol.gif', array('title' => translateAdmin('Painel'), 'alt' => translateAdmin('Painel'), 'border' =>0));?><br /><?php echo translateAdmin('Painel');?></div>
                     </td>
                     <?php endif; ?>
                     <?php if ($session->utilizador['perfil']['superuser'] > 0): ?>
                     <td class="menutopbg" align="center">
                        <div class="label" onclick="location='<?php echo $this->link('/painel_goweb/'); ?>';" onmouseover="this.className='label_hover'" onmouseout="this.className='label'"><?php echo $this->img('/admin/media/images/go.png', array('title' => translateAdmin('Goweb'), 'alt' => translateAdmin('Goweb'), 'border' =>0));?><br /><?php echo translateAdmin('Goweb');?></div>
                     </td>
                     <?php endif; ?>
                     <td class="menutopbg">
                        <div class="labeldir" onclick="location='<?php echo $this->link('/auth/logout/'); ?>';" onmouseover="this.className='label_hover_dir'; $('imgdir').className='imgrighthover'" onmouseout="this.className='labeldir'; $('imgdir').className='imgright'"><?php echo $this->img('/admin/media/images/ico_sair.gif', array('title' => translateAdmin('Sair'), 'alt' => translateAdmin('Sair'), 'border' => 0)); ?><br /><?php echo translateAdmin('Sair');?></div>
                     </td>
                     <td width="6"><div id="imgdir" class="imgright">&nbsp;</div></td>
                  </tr>
               </table>
            </div>
         </td>
         <td width="20%" id="txttopo">&nbsp;</td>
      </tr>
   </table>
</div>



<div id="sublinks" style="z-index:1;">

    <div id="linksFlags">
        <div id="flags" style="z-index:1;">
            <?php if (is_array($session->langs)): ?>
                <?php 
                
                    $redirect_url = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
                    $redirect_url = str_replace($baseUrl, '', $redirect_url);
                    $redirect_url = str_replace('/admin', '', $redirect_url);
                    $redirect_url = str_replace('save', 'edit', $redirect_url);
                ?>
                <?php foreach ((array) $session->langs as $l): ?>
                <?php if ($l == $session->lang): ?>
                <div style="padding-right:5px; float:left;z-index:1;" class="selectedFlag"><a href="<?php echo $this->link($redirect_url, 'lang=' . $l); ?>"><?php echo $this->img('/admin/media/images/flag-' . strtoupper($l) . '.gif', array('alt' => 'flag-' . strtoupper($l), 'title' => 'flag-' . strtoupper($l), 'width' => 16, 'border' => 0, 'style' => 'padding:2px; margin:0; background-color:#A5E600;'));?></a></div>
                <?php else: ?>
                <div style="padding-right:5px; float:left;z-index:1;" class="disabledFlag"><a href="<?php echo $this->link($redirect_url, 'lang=' . $l); ?>?lang=<?php echo $l?>"><?php echo $this->img('/admin/media/images/flag-' . strtoupper($l) . '.gif', array('alt' => 'flag-' . strtoupper($l), 'title' => 'flag-' . strtoupper($l), 'width' => 16, 'border' => 0,  'style' => 'filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity: 0.5;'));?></a></div>
                <?php endif; ?>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
        <div id="welcomeUser_idioma"><?php echo translateAdmin('Escolha o seu idioma');?>&nbsp;:</div>
        <div id="welcomeUser"><label><?php echo translateAdmin('Bem-Vindo');?></label>, <?php echo $session->utilizador['nome']; ?></div>
    </div>
    
 	<div id="linksdomodulobg" style="z-index:1;">
    	<div style="float:left"><?php echo $this->img('/admin/media/images/corner_modulo.png', array('alt' => '', 'title' => '', 'width' => 5, 'border' => 0 ));?></div>
        <div id="modulos" style="z-index:1;">  	
        	<div id="imgmodulos" style="z-index:1;"></div>
            <?php if (isset($section_title)) : ?>
            <div style="padding:3px 3px 0px 3px; z-index:1; float:left;"><?php echo $section_title; ?></div>
            <?php else : ?>
            <div style="padding:3px 3px 0px 3px; z-index:1; float:left;"><?php echo translateAdmin('M&oacute;dulos Instalados');?></div>
            <?php endif; ?>
        </div>
        <div id="links_modulo_palavras" style="z-index:1;">
            <?php foreach($sections as $s): ?>
                <div class="palavra">
                <a href="<?php echo $this->link($s['link']); ?>"><?php echo translateAdmin($s['title']); ?></a>
                <?//= $this->img('/admin/media/images/divlinksmod.gif', array('alt' => 'divlinksmod', 'title' => 'divlinksmod', 'align' => 'middle', 'hspace' => 8)); ?>
                </div>
            <?php endforeach; ?>
        </div>
       
	</div>
    
</div>


<?php if (isset($message) || isset($error)): ?>
<div id="messages">
    
    <?php if (isset($error)): ?>
   	<div id="messageError">
        <div id="error" style="display:none;">
            <div class="img"><?php echo $this->img('/admin/media/images/msg_erro.png', array('alt' => '', 'title' => '', 'width' => 24, 'height' => 24, 'border' => 0,));?></div>
            <div class="msg"><?php echo $error; ?></div>
    	</div>
    </div>
    <script type="text/javascript">
    /* <![CDATA[ */
    new Effect.toggle("error", "appear");
    /* ]]> */
    </script>
    <?php endif?>
    
    <?php if (isset($message)): ?>
    <div id="messageSuccess">
    	<div id="success" style="display:none;">
            <div class="img"><?php echo $this->img('/admin/media/images/msg_sucesso.png', array('alt' => '', 'title' => '', 'width' => 24, 'height' => 24, 'border' => 0,));?></div>
            <div class="msg"><?php echo $message; ?></div>
        </div>
    </div>  
    <script type="text/javascript">
    /* <![CDATA[ */
    new Effect.toggle("success", "appear");
    /* ]]> */
    </script>
    <?php endif; ?>  
</div>

<script type="text/javascript">
/* <![CDATA[ */
setTimeout("new Effect.Fade('messages', { duration: 3 });", 5000);
/* ]]> */
</script>
<?php endif; ?>

<!-- Content -->
<div id="content" style="z-index:1;"><?php echo $output; ?></div>
<!-- END Content -->				

<!--<div id="footer"></div>-->

<script type="text/javascript">
/* <![CDATA[ */
if (Prototype.Browser.IE){
	//$('links_modulo_palavras').immediateDescendants().last().addClassName('palavra_last');
	$$('#links_modulo_palavras div.palavra:last-child').invoke('addClassName','palavra_last');
}
/* ]]> */
</script>
</body>
</html>
