<?php
if(!strlen($pathtoroot))
{
  $path=dirname(realpath(__FILE__));
  if(strlen($path))
  {
    /* determine the OS type for path parsing */
    $pos = strpos($path,":");
    if ($pos === false)
    {
      $gOS_TYPE="unix";
      $pathchar = "/";
    }
    else
    {
      $gOS_TYPE="win";
      $pathchar="\\";
    }
    $p = $path.$pathchar;
    /*Start looking for the root flag file */
    while(!strlen($pathtoroot) && strlen($p))
    {
      $sub = substr($p,strlen($pathchar)*-1);
      if($sub==$pathchar)
      {
        $filename = $p."root.flg";
      }
      else
        $filename = $p.$pathchar."root.flg";
      if(file_exists($filename))
      {
        $pathtoroot = $p;
      }
      else
      {
        $parent = realpath($p.$pathchar."..".$pathchar);
	if($parent!=$p)
	{
	  $p = $parent;
	}
	else
	  $p = "";
      }
    }
    if(!strlen($pathtoroot))
      $pathtoroot = ".".$pathchar;
  }
  else
  {
    $pathtoroot = ".".$pathchar;
  }
}
$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
  $pathtoroot = $pathtoroot.$pathchar;
}

require_once($pathtoroot."kernel/startup.php");

$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");


$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
    $admin = "admin";

$localURL=$rootURL."/";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images";

$pathtolocal = $pathtoroot;

$envar = "env=" . BuildEnv();

//include section data; create Section hash

//main In-portal sections
//require_once ($pathtoroot."admin/include/navmenu.php"); 

//All modules
/*if(!isset($SysData))
	$SysData=new SystemConfiguration();

$ModuleList=$SysData->GetModuleList();*/
//$sections = array();

//foreach($mod_prefix as $key => $value)
//{	
//    $mod = $pathtoroot . $value . "admin/include/navmenu.php";	 
//    include_once($mod);
//}
include_once($pathtoroot.$admin."/include/sections.php");

$ServerName = $objConfig->Get("Site_Name");
$rootLink = $adminURL."/subitems.php?env=".BuildEnv()."&section=in-portal:root";
$charset = GetRegionalOption('Charset');
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="<?php echo $adminURL."/include/style.css"; ?>">
<meta http-equiv="content-type" content="text/html;charset=<?php echo $charset; ?>">
<script src="ua.js"></script>
<script src="ftiens4.js"></script>
<script language="javascript">
// Decide if the names are links or just the icons
USETEXTLINKS = 1  //replace 0 with 1 for hyperlinks

// Decide if the tree is to start all open or just showing the root folders
STARTALLOPEN = 0 //replace 0 with 1 to show the whole tree

var foldersTree = gFld('In-Portal','<?php echo $rootLink; ?>');

foldersTree.desc = '<?php echo $ServerName; ?>';
foldersTree.iconSrc='<?php echo $adminURL."/icons/icon24_site.gif"; ?>';

function credits(url)
{
	var width = 200;
	var height = 200;
	var screen_x = (screen.availWidth-width)/2;
	var screen_y = (screen.availHeight-height)/2;
	window.open(url, 'credits', 'width=280,height=520,left='+screen_x+',top='+screen_y);	
}

<?php 
	$objSections->BuildTree('in-portal:site', 'foldersTree');
	$title = "In-Portal v ".$kernel_version."&nbsp;&nbsp;";
?>

</script>



</head>
<body topmargin="0" marginheight="0" marginwidth="0" marginheight="0" bgcolor="#DCEBF6">

<table cellpadding="0" cellspacing="0" border="0" width="100%">
<!--<tr><td colspan="2" bgcolor="black"><img alt="" width="1" height="1" src="images/spacer.gif"></td></tr>-->
	<tr>
    <td background="../images/menu_bar.gif" align="left" class="tree_head" width="80%"> <!-- 60000 -->
      &nbsp;<a class="tree_head_credits" href="javascript:credits('<?php echo $rootURL.$admin."/help/credits.php?env=".BuildEnv();?>&destform=popup');"><?php echo $title; ?></a>
    </td>
    <td background="../images/menu_bar.gif" align="right" class="tree_head" width="20%"> <!-- 40000 -->
  		<FORM style="display:inline" name="lang_select" method="POST" action="<?php echo $rootURL.$admin."/index.php?env=".BuildEnv(); ?>" TARGET="main_frame">
  			<SELECT NAME="langselect" style="width: 62px; border: 0px; background-color: #FFFFFF; font-size: 9px; color: black" onchange="document.lang_select.submit()">
  			<!-- width: 52px; font-size: 8.5px; -->
				<?php
				 	$objLanguages->Query_Item("SELECT * FROM ".$objLanguages->SourceTable." WHERE Enabled=1");
				 	foreach($objLanguages->Items as $l)
				 	{
				 		$selected = "";
				 		if($l->Get("LanguageId")==$m_var_list["lang"])
				 		  $selected = " SELECTED";
				 		echo "<OPTION onclick=\"this.form.submit();\" value=\"".$l->Get("LanguageId")."\" $selected>".$l->Get("LocalName")."</OPTION>\n";
				 	}
				?>
			</SELECT>
			<input type=hidden name="Action" value="m_lang_select">
			</FORM>      
    </td>
    <td background="../images/menu_bar.gif"><img alt="" height="21" width="1" src="../images/spacer.gif"></td>
	</tr>
</table>

<table cellpadding="5" cellspacing="0" border="0">
	<tr>
		<td>
			<script>
			  initializeDocument();
			</script>
		</td>
	</tr>
</table>

</body>
</html>