<%  
	import org.exoplatform.faq.service.Category;
	import org.exoplatform.faq.service.Question;
	import org.exoplatform.faq.webui.FAQUtils;
	import org.exoplatform.faq.service.Utils ;
	String compId = uicomponent.getId() ; 
  def rcontext = _ctx.getRequestContext() ;	
  rcontext.getJavascriptManager().addJavascript('eXo.webui.UIRightClickPopupMenu.disableContextMenu("'+compId+'") ;') ;
%>

<div class="UIMoveCategoryForm $uicomponent.id">
	<% uiform.begin() %>
	<div class="TitleMoveThreads"><%= _ctx.appRes("UIMoveFAQForm.title.chooseCategory"); %>
	  <% String linkRoot = uicomponent.event("Save", Utils.CATEGORY_HOME); %>	
	</div>
  <div class="ViewCategoryToSelect" style="margin:5px 0px 5px 0px ; padding-top:10px;">
		<div style="padding-left:20px;">
			<a href="javaScript: void(0)" ondblclick="$linkRoot">
				<img src="/faq/skin/DefaultSkin/webui/background/HomeIcon.gif"/>
			</a>
		</div>
		<div style="margin-left:30px;">
			<%
			List listCate = uicomponent.getListCate() ;
			if(listCate.size() > 0) {
				int deep = 0;
		    for(int i = 0; i < listCate.size(); i ++){
		    	try{
		    		deep = listCate.get(i - 1).getDeft() - listCate.get(i).getDeft();
		    	}catch(Exception ex){
		    		deep = 0;
		    	}
		    	for(int j = 0; j <= deep && i >0; j ++){
		    		println "</div>";
	    		}
	    		String link = uicomponent.event("Save",listCate.get(i).getCategory().getPath());    		
	    		String categoryName = listCate.get(i).getCategory().getName();
	    		String title = "" ; 
	    		if(categoryName.length() > 50) {
						title = FAQUtils.getTitle(title) ; 
						categoryName = FAQUtils.getSubString(categoryName, 50);
		    	}
		    	println "<div style=\"margin:5px 0px 5px 0px ;\">";
		    	println 	"<div class=\"Icon FAQCategoryViewMove\"><span></span></div>";
		    	println		"<div id=\"FAQCate" + i + "\" style=\"float:left\">";
		    	println 		"<a href=\"javaScript: void(0)\" onclick=\"eXo.faq.UIAnswersPortlet.treeView('FAQViewChild"+i+"')\" title=\"" + title + "\" ondblclick=\"" + link + "\">";
		    	println			"" + categoryName + "";
		    	println			"</a>";
		    	println 	"</div>";
		    	println "</div>";
		    	println "<div style=\"clear:left;\"><span></span></div>";
		    	println "<div style=\"padding-left:30px ; margin-top:10px; display:none;\" id=\"FAQViewChild" + i + "\">";
		    }
		    for(int i = 1; i <= listCate.get(listCate.size() - 1).getDeft(); i ++){
		    	println "</div>";
		    }
			}	    
	    %>	   
		</div>
	</div>
  <div class="UIAction">
      <a href="javascript:void(0);" onclick="<%=uicomponent.event("Cancel");%>" class="ActionButton LightBlueStyle"><%=_ctx.appRes("UIAnswersPortlet.action.Cancel");%></a>
    </div>
	<%uiform.end()%>
</div>
