<?php
if( isset($_SESSION['menus']) )
	$arr_menus = $_SESSION['menus'];
else
{
	if( $arr_menus = $obj_class_admin->get_root_menus($_SESSION['admin_level']) )
	{
		if( $arr_sub_menus = $obj_class_admin->get_sub_menus($_SESSION['admin_level']) )
		{
			$uint_root_menu_id_cached = 0;

			foreach( $arr_sub_menus as $arr_row )
			{
				if( $uint_root_menu_id_cached != $arr_row['ParentId'] || !isset($uint_index) )
				{
					if( false !== ( $uint_index = in_2d_array($arr_row['ParentId'], $arr_menus, 'MenuId') ) )
						$uint_root_menu_id_cached = $arr_row['ParentId'];
					else
						continue;
				}

				if( !isset($arr_menus[$uint_index]['SubMenu']) )
					$arr_menus[$uint_index]['SubMenu'] = array();

				array_push($arr_menus[$uint_index]['SubMenu'], $arr_row);
			}
		}
	}

	$_SESSION['menus'] = $arr_menus;
}
?>
<ul id="menu">
<?
if( $arr_menus )
{
	foreach( $arr_menus as $arr_row )
	{
		echo('<li class="menu_item" onmouseover="this.className=\'menu_item active\';" onmouseout="this.className=\'menu_item\';">' . ( $arr_row['FileName'] != '#' ? '<a href="' . $arr_row['FileName'] . '">' : '' ) . $arr_row['Name'] . ( $arr_row['FileName'] != '#' ? '</a>' : '' ));

		if( isset($arr_row['SubMenu']) && $arr_row['SubMenu'] )
		{
			echo('<ul class="sub_menu">' . "\n");
			
			foreach( $arr_row['SubMenu'] as $arr_sub_row )
				echo('<li onmouseover="this.className=\'active\';" onmouseout="this.className=\'\';">' . ( $arr_sub_row['FileName'] != '#' ? '<a href="' . $arr_sub_row['FileName'] . '">' : '' ) . $arr_sub_row['Name'] . ( $arr_sub_row['FileName'] != '#' ? '</a>' : '' ) . "</li>\n");

			echo('</ul>');
		}

		echo("</li>\n");
	}
}
?>
</ul>
