<?
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();

///// preenche antes

$nodes[1]= new HTML_TreeNode(array('text' => 'Home', 'icon' => 'folder.gif'));
$menu->addItem($nodes[1] );
$parentNode=&$nodes[1];
//$nodes[$row['id']]=&$parentNode->addItem(new HTML_TreeNode(array('text' => 'Notícias', 'link' => 'main.php?tipo=destaque&idCat=1N&tipoD=noticia', 'folder.gif')));
//$nodes[$row['id']]=&$parentNode->addItem(new HTML_TreeNode(array('text' => 'Calculadoras', 'link' => 'main.php?tipo=destaque&idCat=1C&tipoD=calculadora', 'folder.gif')));
//$nodes[$row['id']]=&$parentNode->addItem(new HTML_TreeNode(array('text' => 'Saiba +', 'link' => 'main.php?tipo=destaque&idCat=1S&tipoD=saibaMais', 'folder.gif')));
//$nodes[$row['id']]=&$parentNode->addItem(new HTML_TreeNode(array('text' => 'Guias Praticos', 'link' => 'main.php?tipo=destaque&idCat=1G&tipoD=guiaPratico', 'folder.gif')));

$nodes[0]= new HTML_TreeNode(array('text' => 'Areas', 'link' => 'main.php?tipo=destaque&idCat=0&tipoD=guiaPratico', 'icon' => 'folder.gif'));
$menu->addItem($nodes[0] );
//// adultos
filhos(0);

/*
$nodes[2]= new HTML_TreeNode(array('text' => 'Direita', 'icon' => 'folder.gif'));
$menu->addItem($nodes[2] );
$parentNode=&$nodes[2];
$nodes[$row['id']]=&$parentNode->addItem(new HTML_TreeNode(array('text' => 'Calculadoras', 'link' => 'main.php?tipo=destaque&idCat=3C&tipoD=calculadora', 'folder.gif')));
$nodes[$row['id']]=&$parentNode->addItem(new HTML_TreeNode(array('text' => 'Guias Praticos', 'link' => 'main.php?tipo=destaque&idCat=3G&tipoD=guiaPratico', 'folder.gif')));
*/

$treeMenu = &new HTML_TreeMenu_DHTML($menu, array('images' => 'images/menu','linkTarget'=>'main', 'defaultClass' => 'treeMenuDefault'));
	
$treeMenu->printMenu();
	    
function filhos($id=0){
	global $menu, $nodes, $tipo;
	$d= new dbElemento;


	
	$sql = "select * from categoria where idPai=$id  order by ordem";
	$lista =  $d->get( $sql );
	
	if ($lista){
		foreach($lista as $row	){
			

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

			//if ($row['idPai']==6){
			//	$parentNode1=&$nodes[$row['id']];
			//	$nodes[$row['id']+1000]=&$parentNode1->addItem(new HTML_TreeNode(array('text' => "Noticias", 'link' => 'main.php?tipo=destaque&idCat='.$row['id'] .'N&tipoD=noticia', 'folder.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>
