<%
  /**
   * Created by The eXo Platform SAS
   * Author : eXoPlatform
   *          chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com
   * Jun 27, 2009  
   */
   
  /**
   * Render sub categories
   */
  public void renderChild(def categoryUri, def categories, int level) {
    def categoryPath = categories.get(level);
    def subcategories = uicomponent.getSubcategories(categoryPath);
    for (subcategory in subcategories) {
      def subcategoryName = subcategory.getName();
      def subcategoryTitle = uicomponent.getTitle(subcategory);
      def margin = 16 * (level - 1) + "px";
      def selectedClass = "";
      if (categoryUri.equals("/" + categoryPath + "/" + subcategoryName)) selectedClass = "SubCategorySelected";
      def categoryLink = uicomponent.renderCategoryLink(subcategory);
      %><a class="CategoryLabel $selectedClass" href="$categoryLink" rel="tooltip" data-placement="bottom" title="$subcategoryTitle">$subcategoryTitle</a>&nbsp;|&nbsp;<%      
      if (subcategory.hasNodes() && (categoryUri+"/").startsWith("/" + categoryPath + "/" + subcategoryName + "/"))       
        renderChild(categoryUri, categories, level + 1);
    }
  }
  
%>
<style>
#ACMEBody {
  padding: 10px;
}
</style>

<div id="$uicomponent.id" class="SimpleHorizontal">
  <div class="CategoriesContainer">
    <div class="TitleBarL">
      <div class="TitleBarR">
        <div class="TitleBarM">
          <div class="NewContent">
            <%
              def categoryUri = uicomponent.resolveCategoryPathByUri(_ctx.getRequestContext());
              def categories = uicomponent.getCategoriesByUri(categoryUri);
              def rootCategory = categories.get(0);
              def subcategories = uicomponent.getSubcategories(rootCategory);
              for (subcategory in subcategories) {
                def subcategoryName = subcategory.getName();
                def subcategoryTitle = uicomponent.getTitle(subcategory);
                def categoryLink = uicomponent.renderCategoryLink(subcategory);
                %><a class="CategoryLabel" href="$categoryLink" rel="tooltip" data-placement="bottom" title="$subcategoryTitle">$subcategoryTitle</a>&nbsp;|&nbsp;<%
                if ((categoryUri+"/").startsWith("/" + subcategoryName + "/")) renderChild(categoryUri, categories, 1);
              }
            %>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>