<?php
##############################################################
##In-portal                                    				##
##############################################################
##                   In-portal                     			##
##             Intechnic Corporation               			##
##          All Rights Reserved, 1998-2002            		##
##                                           				##
## No portion of this code may be copied, reproduced or  	##
##    otherwise redistributed without proper written     	##
##   consent of Intechnic Corporation.  Violation will      ##
##    result in revocation of the license and support    	##
##  privileges along maximum prosecution allowed by law. 	##
##############################################################

define('IS_POPUP', 1);

$b_header_addon = "<DIV style='position:relative; z-Index: 1; background-color: #ffffff; padding-top:1px;'><div style='z-Index:1; position:relative'>";

// new startup: begin
define('REL_PATH', 'admin');
$relation_level = count( explode('/', REL_PATH) );
define('FULL_PATH', realpath(dirname(__FILE__) . str_repeat('/..', $relation_level) ) );
require_once FULL_PATH.'/kernel/startup.php';
// new startup: end

$destform = $_GET["destform"];
$destfield = $_GET["destfield"];

RegisterEnv("destform",$destform);
RegisterEnv("destfield",$destfield);
RegisterEnv("source",$_GET["source"]);

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

$m_var_list_update["cat"] = 0;
//$homeURL = $_SERVER["PHP_SELF"]."?".$envar;
$homeURL = "javascript:AdminCatNav('".$_SERVER["PHP_SELF"]."?env=".BuildEnv()."');";


if( $GLOBALS['debuglevel'] ) echo $homeURL."<br>\n";
unset($m_var_list_update["cat"]);

if($objCatList->CurrentCategoryID()>0)
{
  $c = $objCatList->CurrentCat();
  $upURL = $c->Admin_Parent_Link();
}
else
  $upURL = $_SERVER["PHP_SELF"]."?".$envar;



//admin only util

$pathtolocal = $pathtoroot."kernel/";
require_once ($pathtoroot.$admin."/include/elements.php");
//require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/browse/toolbar.php");

$m = GetModuleArray();
foreach($m as $key=>$value)
{
    $path = $pathtoroot.$value."admin/include/parser.php";
    if(file_exists($path))
    {
      //echo "<!-- $path -->";
      @include_once($path);
    }
}

//Set Section
$section = 'in-portal:catselect';

//Set Environment Variable

//echo $objCatList->ItemsOnClipboard()." Categories on the clipboard<br>\n";
//echo $objTopicList->ItemsOnClipboard()." Topics on the clipboard<br>\n";
//echo $objLinkList->ItemsOnClipboard()." Links on the clipboard<br>\n";
//echo $objArticleList->ItemsOnClipboard()." Articles on the clipboard<br>\n";

$SearchType = $objSession->GetVariable("SearchType");
if(!strlen($SearchType))
  $SearchType = "Categories";
$SearchLabel = "la_SearchLabel";

/* page header */
$charset = GetRegionalOption('Charset');
print <<<END
<html>
<head>
  <title>In-portal</title>
  <meta http-equiv="content-type" content="text/html;charset=$charset">
  <meta http-equiv="Pragma" content="no-cache">
END;

  require_once($pathtoroot.$admin."/include/mainscript.php");

print <<<END
<script src="$browseURL/toolbar.js"></script>
<script src="$browseURL/checkboxes_new.js"></script>
<script language="JavaScript1.2" src="$browseURL/fw_menu.js"></script>
<script language="JavaScript1.2">
	var enableContextMenus= true;
    var doubleClickAction = 'select';
	
	function toggleTabB(tabId, atm)
	{
    	var hl = document.getElementById("hidden_line");
   		var activeTabId;

   		if (activeTab) activeTabId = activeTab.id;
   		if (activeTabId == tabId)
		{
      		var devider = document.getElementById("tabsDevider");
      		devider.style.display = "";

			unselectAll(tabId);
			var tab = document.getElementById(tabId);
			tab.active = false;
			activeTab = null;
			collapseTab = tab;
			toolbar.setTab(null);
			showTab();
   		}
   		else 
   		{   
      		if (activeTab)
      			toggleTab(tabId, true) 
      		else 
      			toggleTab(tabId, atm)
      		if (hl) hl.style.display = "none";
   		}
   		tab_hdr = document.getElementById('tab_headers');
   		if (!tab_hdr) return; 
		
		// process all module tabs
	   	var active_str = '';
   		for(var i = 0; i < tabIDs.length; i++)
   		{
      		var tabHeader;
      		TDs = tab_hdr.getElementsByTagName("TD");
   			for (var j = 0; j < TDs.length; j++)
      			if (TDs[j].getAttribute("tabHeaderOf") == tabIDs[i])
      			{
         			tabHeader = TDs[j];
         			break;
      			}
      			if (!tabHeader) continue;

      			var tab = document.getElementById(tabIDs[i]);
      			if (!tab) continue;
				active_str = (tab.active) ? "tab_active" : "tab_inactive";
				
      			if (TDs[j].getAttribute("tabHeaderOf") == tabId) {
	      			// module tab is selected
	      			SetBackground('l_' + tabId, "$imagesURL/itemtabs/" + active_str + "_l.gif");
	        		SetBackground('m_' + tabId, "$imagesURL/itemtabs/" + active_str + ".gif");
	      			SetBackground('m1_' + tabId, "$imagesURL/itemtabs/" + active_str + ".gif");
	        		SetBackground('r_' + tabId, "$imagesURL/itemtabs/" + active_str + "_r.gif");
	      		}
	      		else 
	      		{
	      			// module tab is not selected
	      			SetBackground('l_' +tabIDs[i], "$imagesURL/itemtabs/" + active_str + "_l.gif");
	        		SetBackground('m_' + tabIDs[i], "$imagesURL/itemtabs/" + active_str + ".gif");
	      			SetBackground('m1_' + tabIDs[i], "$imagesURL/itemtabs/" + active_str + ".gif");
	        		SetBackground('r_' + tabIDs[i], "$imagesURL/itemtabs/" + active_str + "_r.gif");
	      		}

				var images = tabHeader.getElementsByTagName("IMG");
				if (images.length < 1) continue;

				images[0].src = "$imagesURL/itemtabs/" + ((tab.active) ? "divider_up" : "divider_empty") + ".gif";
   		}
	}

	function toggleCategoriesB(tabHeader, instant)
	{
		var categories = document.getElementById('categories');
		if (!categories) return;
		toggleCategories(instant);
		
		var active_str = '$imagesURL'+'/itemtabs/' + (categories.active ? 'tab_active' : 'tab_inactive');
		SetBackground('l_cat', active_str + '_l.gif');
		SetBackground('m_cat', active_str + '.gif');
		SetBackground('m1_cat', active_str + '.gif');
		SetBackground('r_cat', active_str + '_r.gif');
	
	   	var images = tabHeader.getElementsByTagName("IMG");
	   	if (images.length < 1) return;
			images[0].src = '$imagesURL'+'/itemtabs/' + ((categories.active) ? "divider_up" : "divider_dn") + ".gif";
	}
</script>  
  <link rel="stylesheet" type="text/css" href="$browseURL/checkboxes.css">
  <link rel="stylesheet" type="text/css" href="$cssURL/style.css">
  <link rel="stylesheet" type="text/css" href="$browseURL/toolbar.css">
END;
int_SectionHeader();
?>
</div>
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
  <tbody>
   <tr>
   <td>
       <div name="toolBar" id="mainToolBar">
          <tb:button action="select" title="<?php echo admin_language("la_ToolTip_Select"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
          <tb:button action="stop" title="<?php echo admin_language("la_ToolTip_Cancel"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
          <tb:separator ImagePath="<?php echo $imagesURL."/toolbar/";?>">         
        
          <tb:button action="upcat" title="<?php echo admin_language("la_ToolTip_Up"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
          <tb:button action="homecat" title="<?php echo admin_language("la_ToolTip_Home"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
          <tb:separator ImagePath="<?php echo $imagesURL."/toolbar/";?>">
          <tb:button action="view" title="<?php echo admin_language("la_ToolTip_View"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
       </div>
   </td>
   </tr>
  </tbody>
</table>
<table cellspacing="0" cellpadding="0" width="100%" bgcolor="#e0e0da" border="0" class="tableborder_full_a">
   <tbody>
    <tr>
     <td><img height="15" src="<?php echo $imagesURL; ?>/arrow.gif" width="15" align="middle" border="0">
          <span class="navbar"><?php print m_navbar( Array('admin' => 1) ); ?></span>
       </td>
      <td align="right">
          <FORM METHOD="POST" ACTION="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>" NAME="admin_search" ID="admin_search"><INPUT ID="SearchScope" NAME="SearchScope" type="hidden" VALUE="<?php echo $objSession->GetVariable("SearchScope"); ?>"><INPUT ID="SearchType" NAME="SearchType" TYPE="hidden" VALUE="<?php echo $objSession->GetVariable("SearchType"); ?>"><INPUT ID="NewSearch" NAME="NewSearch" TYPE="hidden" VALUE="0"><INPUT TYPE="HIDDEN" NAME="Action" value="m_Exec_Search">
          <table cellspacing="0" cellpadding="0"><tr>
          <td><?php echo admin_language($SearchLabel); ?>&nbsp;</td>
          <td><input ID="SearchWord" type="text" name="SearchWord" size="10" style="border-width: 1; border-style: solid; border-color: #999999"></td>
          <td><img action="search_b" src="<?php echo $imagesURL."/toolbar/";?>/icon16_search.gif" title="<?php echo admin_language("la_ToolTip_Search"); ?>" align="absMiddle" onclick="this.action = this.getAttribute('action'); actionHandler(this);" src="<?php echo $imagesURL."/toolbar/";?>/arrow16.gif" onmouseover="this.src='<?php echo $imagesURL."/toolbar/";?>/icon16_search_f2.gif'" onmouseout="this.src='<?php echo $imagesURL."/toolbar/";?>/icon16_search.gif'" style="cursor:hand" width="22" width="22"><img action="search_a" title="<?php echo admin_language("la_ToolTip_Search"); ?>" align="absMiddle" onclick="this.action = this.getAttribute('action'); actionHandler(this);" src="<?php echo $imagesURL."/toolbar/";?>/arrow16.gif" onmouseover="this.src='<?php echo $imagesURL."/toolbar/";?>/arrow16_f2.gif'" onmouseout="this.src='<?php echo $imagesURL."/toolbar/";?>/arrow16.gif'" style="cursor:hand">
          <img action="search_c" src="<?php echo $imagesURL."/toolbar/";?>/icon16_search_reset.gif" title="<?php echo admin_language("la_ToolTip_Search"); ?>" align="absMiddle" onclick="this.action = this.getAttribute('action'); actionHandler(this);" onmouseover="this.src='<?php echo $imagesURL."/toolbar/";?>/icon16_search_reset_f2.gif'" onmouseout="this.src='<?php echo $imagesURL."/toolbar/";?>/icon16_search_reset.gif'" style="cursor:hand" width="22" width="22">&nbsp;
          </td>
          </tr></table>
          </FORM>
          <!--tb:button action="search_b" title="<?php echo admin_language("la_ToolTip_Search"); ?>" align="right" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
          <tb:button action="search_a" title="<?php echo admin_language("la_ToolTip_Search"); ?>" align="right" ImagePath="<?php echo $imagesURL."/toolbar/";?>"-->
      </td>
    </tr>
  </tbody>
</table>
<br>
 <!-- CATEGORY DIVIDER -->

<?php
    $OrderBy = $objCatList->QueryOrderByClause(TRUE,TRUE,TRUE);   
    $objCatList->Clear();
    if($SearchType=="categories" || $SearchType="all")
    {
      $list = $objSession->GetVariable("SearchWord");
      $SearchQuery = $objCatList->AdminSearchWhereClause($list);
      if(strlen($SearchQuery))
      {
        $SearchQuery = " (".$SearchQuery.") ";
        if(strlen($CatScopeClause))
            $SearchQuery .= " AND ".$CatScopeClause;
        $objCatList->LoadCategories($SearchQuery.$CategoryFilter,$OrderBy);
      }
      else
        $objCatList->LoadCategories("ParentId=".$objCatList->CurrentCategoryID()." ".$CategoryFilter,$OrderBy);
    }
    else
      $objCatList->LoadCategories("ParentId=".$objCatList->CurrentCategoryID()." ".$CategoryFilter,$OrderBy);
?>
<table cellspacing="0" cellpadding="0" width="100%" border="0">
	<tbody>
	<tr>
		<td width="138" height="20" nowrap="nowrap" class="active_tab" onclick="toggleCategoriesB(this)" id="cats_tab">
			<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tr>
          		<td id="l_cat" background="<?php echo $imagesURL; ?>/itemtabs/tab_active_l.gif" class="left_tab">
          			<img src="<?php echo $imagesURL; ?>/itemtabs/divider_up.gif" width="20" height="20" border="0" align="absmiddle">
					</td>
          		<td id="m_cat" nowrap background="<?php echo $imagesURL; ?>/itemtabs/tab_active.gif" class="tab_class">
             		<?php echo admin_language("la_ItemTab_Categories"); ?>:&nbsp;
					</td>
             	<td id="m1_cat" align="right" valign="top" background="<?php echo $imagesURL; ?>/itemtabs/tab_active.gif" class="tab_class">
						<span class="cats_stats">(<?php echo $objCatList->QueryItemCount; ?>)</span>&nbsp;
					</td>
					<td id="r_cat" background="<?php echo $imagesURL; ?>/itemtabs/tab_active_r.gif" class="right_tab">
						<img src="<?php echo $imagesURL; ?>/spacer.gif" width="21" height="20">
					</td>
				</tr>
			</table>
		</td>
		<td>&nbsp;</td>
	</tr>
  	</tbody>
</table>

<div class="divider" style="" id="categoriesDevider"><img width=1 height=1 src="images/spacer.gif"></div>
</DIV>
<DIV style="background-color: #ffffff; position: relative; padding-top: 1px; top: -1px; z-Index:0" id="firstContainer">
  <DIV style="background-color: #ffffff; position: relative; padding-top: 1px; top: -1px; z-Index: 2" id="secondContainer">
    <!-- CATEGORY OUTPUT START -->
    <div id="categories" tabtitle="Categories">
      <form id="categories_form" name="categories_form" action="" method="post">
        <input type="hidden" name="Action">
        <?php print adListSubCats($objCatList->CurrentCategoryID(),"cat_select_element.tpl"); ?>
      </form>
    </div>
    <BR>
    <!-- CATEGORY OUTPUT END -->
  </DIV>
  <form method="post" action="cat_select.php?env=<?php echo BuildEnv(); ?>" name="viewmenu">
    <input type="hidden" name="fieldname" value="">
    <input type="hidden" name="varvalue" value="">
    <input type="hidden" name="varvalue2" value="">
    <input type="hidden" name="Action" value="">
  </form>
</DIV>
<!-- END CODE-->
<script language="JavaScript">
<?php
  //if($_GET["Selector"]=="radio")
    echo "  var single_select = true;";
?>    
   InitPage();
</script>

<?php int_footer(); ?>