<?
include_once ("db/dbElemento.class.php");

require_once('include/treemenu/TreeMenu.php');

$icon         = 'folder.gif';
$expandedIcon = 'folder-expanded.gif';

$menu  = new HTML_TreeMenu();
$nodes=array();

filhos(0);

$treeMenu = &new HTML_TreeMenu_DHTML($menu, array('images' => 'images/menu','linkTarget'=>'main', 'defaultClass' => 'treeMenuDefault'));

$treeMenu->printMenu();


function filhos($id=0){
	global $menu, $nodes;
	$d= new dbElemento;
	$sql = "select * from categoria where idPai=$id order by ordem";
	$lista =  $d->get( $sql );

	if ($lista){
		foreach($lista as $row){

			if ($id==0){
			
			$nodes[$row['id']]= new HTML_TreeNode(array('text' => $row['categoria'], 'link' => 'main.php?tipo='.$row['tipo1'].'&idCat='.$row['id'], 'icon' => $row['tipo1'].'.gif'));
			
			$menu->addItem($nodes[$row['id']] );

			} else {
			$parentNode=&$nodes[$row['idPai']];
			$nodes[$row['id']]=&$parentNode->addItem(new HTML_TreeNode(array('text' => $row['categoria'], 'link' => 'main.php?tipo='.$row['tipo1'].'&idCat='.$row['id'], 'icon' => $row['tipo1'].'.gif')));
			
			}

			filhos($row['id']);

		}
	}


}


?>
    <style type="text/css">
        body {
            font-family: Georgia;
            font-size: 10pt;
        }
        
        .treeMenuDefault {


        }
        
        .treeMenuBold {
            font-weight: bold;
        }
		A{
			text-decoration:none;
			color:black;
		}
    </style>