<?php
   include_once('sample_tab_session.php');
   if (!function_exists("NM_is_utf8"))
   {
       include_once("sample_tab_nmutf8.php");
   }
   session_start();

//----- 
   if (!empty($_POST))
   {
       foreach ($_POST as $nmgp_var => $nmgp_val)
       {
            $$nmgp_var = $nmgp_val;
       }
   }
   if (isset($_SESSION['session_sec_aplicacao']["Veratex_____sample_tab"]))
   {
      unset($_SESSION['session_sec_aplicacao']["Veratex_____sample_tab"]);
   }

   if (isset($_SESSION['session_sec_aplicacao']) && empty($_SESSION['session_sec_aplicacao']))
   {
      unset($_SESSION['session_sec_aplicacao']);
      unset($_SESSION['session_sec_usuario']);
   }
   if (isset($_SESSION['scriptcase']['sc_aba_iframe']['sample_tab']))
   {
       unset($_SESSION['scriptcase']['sc_aba_iframe']['sample_tab']);
   }
   $fecha_janela = false;
   if (isset($_SESSION['sc_session'][$script_case_init]['sample_tab']['sc_outra_jan']) && $_SESSION['sc_session'][$script_case_init]['sample_tab']['sc_outra_jan'])
   {
       $fecha_janela = true;
   }
   $fecha_modal = false;
   if (isset($script_case_init) && isset($_SESSION['sc_session'][$script_case_init]['sample_tab']['aba_saida']) && $_SESSION['sc_session'][$script_case_init]['sample_tab']['aba_saida'] == "modal")
   {
       unset($_SESSION['sc_session'][$script_case_init]['sample_tab']['aba_saida']);
       $fecha_modal = true;
   }
   nm_limpa_arr_session();
?>
<HTML>
<HEAD>
<TITLE></TITLE>
 <META http-equiv="Content-Type" content="text/html; charset=<?php echo $_SESSION['scriptcase']['charset_html'] ?>" />
</HEAD>
<BODY>
<?php
   if ($fecha_modal)
   {
?>
<SCRIPT LANGUAGE="Javascript">
   self.parent.tb_remove();
</SCRIPT>
</BODY>
</HTML>
<?php
   }
   elseif ($fecha_janela)
   {
?>
<SCRIPT LANGUAGE="Javascript">
   window.close();
</SCRIPT>
</BODY>
</HTML>
<?php
   }
   elseif (empty($saida_aba))
   {
?>
<SCRIPT LANGUAGE="Javascript">
  history.back();
</SCRIPT>
</BODY>
</HTML>
<?php
   }
   else
   {
?>
<form name="fsai" action="<?php echo $saida_aba; ?>"
                  method="post"
                  target="_self">
<input type=hidden name="script_case_init" value="<?php  echo NM_encode_input($script_case_init); ?>"> 
<input type=hidden name="script_case_session" value="<?php  echo NM_encode_input(session_id()); ?>"> 
</form>
<SCRIPT LANGUAGE="Javascript">
   nm_ver_saida = "<?php echo $saida_aba; ?>";
   nm_ver_saida = nm_ver_saida.toLowerCase();
   if (nm_ver_saida.substr(0, 4) != ".php" && (nm_ver_saida.substr(0, 7) == "http://" || nm_ver_saida.substr(0, 8) == "https://" || nm_ver_saida.substr(0, 3) == "../")) 
   { 
       window.location = ("<?php echo $saida_aba; ?>"); 
   } 
   else 
   { 
       document.fsai.submit();
   } 
</SCRIPT>
</BODY>
</HTML>
<?php
   }
   function nm_limpa_arr_session()
   {
      global $script_case_init;
      $achou = false;
      if (!isset($_SESSION['sc_session'][$script_case_init]))
      {
          return;
      }
      foreach ($_SESSION['sc_session'][$script_case_init] as $nome_apl => $resto)
      {
          if ($nome_apl == 'sample_tab' || $achou)
          {
              unset($_SESSION['sc_session'][$script_case_init][$nome_apl]);
              $achou = true;
          }
      }
      if (empty($_SESSION['sc_session'][$script_case_init]))
      {
          unset($_SESSION['sc_session'][$script_case_init]);
      }
   }
?>
