<%
	import org.exoplatform.webui.core.UIRightClickPopupMenu;
	
	def selected = uicomponent.getSelected();
	def sibling = uicomponent.getSibbling();
	def children = uicomponent.getChildren();	
	String id = uicomponent.getParent().getId();												  
	UIRightClickPopupMenu uiPopupMenu = uicomponent.getUIRightClickPopupMenu();
	
	def rcontext = _ctx.getRequestContext();
	def jsMan = rcontext.getJavascriptManager(); 
	jsMan.require("SHARED/webui-ext", "webuiExt")
		  .addScripts("webuiExt.UITree.init('$id', '$uicomponent.expandIcon','$uicomponent.colapseIcon',${uiPopupMenu != null});");
	
	if(uiPopupMenu != null){
		uicomponent.renderUIComponent(uiPopupMenu); 
	}	
%>
<div class="uiTrees scrollArea">
	<div class="treeContainer jsContainer">
		
			<div class="homeNode clearfix">
				<a class="actionIcon pull-left" href="javascript:void(0);" onclick="<%=uicomponent.getActionLink();%>" rel="tooltip" title="<%=_ctx.appRes("UITree.tooltip.UpLevel")%>" style="display: block;">
				  <i class="uiIconUpLevel uiIconLightGray"></i>
				  <span class="skipHidden"><%=_ctx.appRes("UITree.tooltip.UpLevel")%></span>
				</a>
			</div>
			
			<ul class="nodeGroup">
				<%
				int count=0;
				for(object in sibling) {
				%>
				<li class="node">
					<% 
					String objId = String.valueOf(uicomponent.getId(object));
					String actionLink = uicomponent.event("ChangeNode", objId);
					%>
					<%=uicomponent.renderNode(object);%>											
					<%	
						if(uicomponent.isSelected(object)){%>
						<ul class = "childrenContainer nodeGroup" actionLink="$actionLink">
						<%	
						int countChild=0;
						for(child in children) {				
						 %>
						 		<li class="node">
									<%=uicomponent.renderNode(child);%>
								</li>
							<%countChild++;}	%>								
						</ul>					
					<%}%>							 
					</li>
				<%count++;}%>
			</ul>
			
	</div>	
</div>