<?php

include("_dirinfo.php");

include (PATH_TO_ROOT."init.php");
include (PATH_TO_ROOT."webhelp/_class/class.Extjs_tree.php");
//include (PATH_TO_ROOT."_support/class.UserSession.php");

//$UserSession = new UserSession($db);

$treeName = $_POST[treeName].'Help';

?>
/*function openNewWindow(){

 myWindow=window.open("webhelp/_forms/helpToPdf.php?table=<?=$_POST[tree]?>&s=a", "PDF export", "height=300, width=500,toolbar=no,scrollbars=no,menubar=no");
 
 
 
 
}*/

<?php

$tree = new MakeTreeHelp($treeName);
$tree->SetTable($_POST[tree], DB_WARPIT_HELP);
$tree->SetRootVisible('false')
	  ->setTitle('Help')
	  ->addConfig('iconCls',"'icon-help-tab'")
	  ->addtBarItem("
	 {
          text:'FAQ',
          iconCls:'iconHelpFaq',
          handler:function()
          {
              CallScript('webhelp/_forms/forms.treeFaq.php','table=".$_POST[tree]."');
          }
       }, '->', 
        {
          xtype:'textfield',
          id: 'testFieldHelp'
      },
	  {
	      text:'Search',
	      iconCls:'RMicon_search',
	      handler:function()
	      {
	          CallScript('webhelp/_forms/forms.treeSearch.php','table=".$_POST[tree]."&s='+Ext.getCmp(\"testFieldHelp\").el.dom.value);
          }
      } 
      /*, '-', 
       {
           text:'Export',
           handler:function(){openNewWindow();}
       }*/ ")
	 ;

?>

<?php
	
	echo $tree->CreateTree();
	//echo $treeName.".on('dblclick',function(node){addTab(node.text,'webhelp/_forms/forms.helpGrid.php','id='+node.id+'&tabTitle='+node.text+'&table=".$_POST[tree]."');})";
	echo $treeName.".on('click',function(node){CallScript('webhelp/_forms/forms.helpGrid.php','id='+node.id+'&tabTitle='+node.text+'&table=".$_POST[tree]."');})";
?>



Ext.getCmp('west-panel').add(<?php echo $treeName; ?>).show();
	
