<%@ page errorPage="errorPage.jsp" language="java" session="true" contentType="text/html;charset=ISO-8859-2"%>
<%@ page import="com.etixpert.evolution.gui.servlets.*"%>
<%@ page pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ include file="header.jsp" %>
<%
    response.setContentType("text/html; charset=iso-8859-2");
    request.setCharacterEncoding("ISO-8859-2");

	//first call

%>
<SCRIPT LANGUAGE="JavaScript">
<!-- JavaScript code hiding

	function simpleLink(origLink) {
		parent.mainFrame.location = origLink;
	}


	function link(origLink){
		if (top.mainFrame.document.forms.length == 0) {
			simpleLink(origLink);
			return;
		}
		else {
			if (top.mainFrame.document.forms[0].saveState == null) {
				simpleLink(origLink); 
				return;
			}
			top.mainFrame.document.forms[0].saveState.value = top.mainFrame.self.location.pathname;
			top.mainFrame.document.forms[0].link.value = origLink;
			top.mainFrame.document.forms[0].submit();
		}
	}
		
// -->
</SCRIPT>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
	<link rel="StyleSheet" href="dtree.css" type="text/css" />
	<script type="text/javascript" src="dtree.js"></script>

</head>
<body>
&nbsp;<fmt:message key="NAV_MENU_USER"/>:&nbsp;<%=session.getAttribute("USER_LOGGED_LASTNAME")%><br>
&nbsp;<fmt:message key="NAV_MENU_USER_ID"/>:&nbsp;<%=session.getAttribute("USER_LOGGED_ID")%><br><br>
<div class="dtree">
	<script type="text/javascript">
		<!--
		d = new dTree('d');
		//d.add(0,-1,'Evolution');

		<%
			org.apache.log4j.Logger log = MainControl.logger;
			
			
			List list = GUIRightsHelper.getNavigationMenus(session);
			
			
			for (int i=0; i<list.size(); i++) {
				Menu menu = (Menu)list.get(i);
				int pos = menu.getPos();
				String descr = menu.getName(pageContext);
				Menu parent = menu.getParent();
				int type = menu.getType();
				
				String link = menu.getLink(session);
				int id = menu.getId();
				
				String strParentPos = "-1";
				
				if (parent!=null) strParentPos = String.valueOf(parent.getPos());
				String strPos = String.valueOf(pos);
				
				if (type == Menu.FOLDER || type == Menu.ROOT) {
				%>
					d.add(<%=strPos%>,<%=strParentPos%>,'<%=descr%>');
				<%
				} else if (type == Menu.LINK) {
					
				%>
					d.add(<%=strPos%>, <%=strParentPos%>,'<%=descr%>', '<%=link%>', '', '<%=id==12000?"_top":"mainFrame"%>');
				<%				
				
				}
			}
		%>
		
		
		
		
		
		

		document.write(d);

		//-->
	</script>
</div>
</body>
</html>