<%
  import org.exoplatform.faq.service.FileAttachment;
  import org.exoplatform.faq.service.Category;
  import org.exoplatform.faq.service.Question;
  import org.exoplatform.faq.service.Answer;
  import org.exoplatform.faq.service.Comment;
  import org.exoplatform.faq.webui.ValidatorDataInput;
  import org.exoplatform.faq.webui.FAQUtils;
  import org.exoplatform.web.application.JavascriptManager;

  String compId = uicomponent.getId(); 
  def rcontext = _ctx.getRequestContext();
  JavascriptManager jsmanager = rcontext.getJavascriptManager();
  jsmanager.addJavascript('eXo.faq.UIAnswersPortlet.initContextMenu("'+compId+'") ;') ;
  jsmanager.addJavascript("eXo.faq.UIAnswersPortlet.checkCustomView('" + uicomponent.isNotInSpace() + "', '" + _ctx.appRes("UIQuestions.label.HileLeftPanels") + "', '" + _ctx.appRes("UIQuestions.label.ShowLeftPanels") + "');");
  String cateId = uicomponent.getCategoryId();
  uicomponent.setIsModerators(); //reset permission
  boolean canEditQuestion = uicomponent.getCanEditQuestion();
  boolean isViewRootCate = uicomponent.isViewRootCate;
%>
<div class="UIQuestions" id="$uicomponent.id">
  <div class="AnswerToolbar">
	      <!--  CustomView action  -->
	        <div class="SeparatorLine" id="FAQTitlePanels" title="<%=_ctx.appRes("UIQuestions.label.HileLeftPanels")%>" onclick="eXo.faq.UIAnswersPortlet.changeCustomView('true', '<%=_ctx.appRes("UIQuestions.label.HileLeftPanels")%>', '<%=_ctx.appRes("UIQuestions.label.ShowLeftPanels")%>')">
	          	<a class="Icon FAQCustomView" id="FAQCustomView">
	              <span></span>
	            </a>
	        </div>
	      
	      <%
	      if(uicomponent.faqSetting_.isEnableAutomaticRSS()){
	        String linkRss = uicomponent.getRSSLink() ;
	      %>
	            <a class="Icon FAQRSS SeparatorLine" href="$linkRss" target="_blank"><%=_ctx.appRes("UIQuestions.action.RSS"); %></a>
	    <%
	    }
	    if(canEditQuestion) {
	    %>
	            <div class="DownArrow1Icon SeparatorLine">
	                <a class="Icon CategoryManager" onclick="eXo.faq.UIAnswersPortlet.viewTitle('FAQCategroManager');" href="javascript:void(0);"><%=_ctx.appRes("UIQuestions.action.ManageCategory"); %></a>
	            
				          
				      <!--  Begin popup menu  -->
				        <div class="UIFAQPopupCategory" id="FAQCategroManager" style="display:none;" onmouseover="eXo.faq.UIAnswersPortlet.viewTitle('FAQCategroManager')" onfocus="eXo.faq.UIAnswersPortlet.viewTitle('FAQCategroManager')" onmouseout="eXo.faq.UIAnswersPortlet.setCheckEvent(true); eXo.faq.UIAnswersPortlet.checkAction();" onblur="eXo.faq.UIAnswersPortlet.setCheckEvent(true); eXo.faq.UIAnswersPortlet.checkAction();">
				          <div class="UIRightClickPopupMenu UIContextMenuContainer">
				           
				              <%
				                String[] actionTollbar = uicomponent.getMenuCateManager();
				                for(String action in actionTollbar) {
				                  if(action.equals("DeleteCategory") && uicomponent.isCategoryHome()) continue; 
				              %>
				                  <div onmousedown="<%=uicomponent.event(action, cateId);%>" onkeydown="<%=uicomponent.event(action, cateId);%>" class="MenuItem">
				                    <a class="ItemIcon $action" href="javascript:void(0);"><%=_ctx.appRes("UIQuestions.action." + action)%></a>
				                  </div>
				              <%
				                }%>
				          
				          </div>
			          </div>
				      <!--  End popup menu  -->
		       </div>
	    <%
	    }
	    if(canEditQuestion) {
	      String[] actionTollbar = uicomponent.getActionTollbar();
	      for(String action in actionTollbar) {
	    %>
        <a class="Icon $action SeparatorLine" onclick="<%=uicomponent.event(action, cateId);%>" href="javascript:void(0);"><%=_ctx.appRes("UIQuestions.action." + action);%></a>
	    <%
	      }
	    } else {
	      if(uicomponent.isAddQuestion()) {
	    %>
        <a class="Icon SeparatorLine AddNewQuestion" onclick="<%=uicomponent.event("AddNewQuestion", cateId);%>" href="javascript:void(0);"><%=_ctx.appRes("UIQuestions.action.AddQuestion")%></a>
	    <%}
	    }%>
	  <%String currentUser = FAQUtils.getCurrentUser() ; 
	    if(currentUser != null && currentUser.trim().length() > 0) {
	      String actionSetting = uicomponent.event("Setting");
	  %>
       <a class="Icon Setting SeparatorLine" onclick="$actionSetting" href="javascript:void(0);"><%=_ctx.appRes("UIQuestions.action.Settings")%></a>
	    <% } %>
	      <!--<div onclick="eXo.faq.UIAnswersPortlet.printAll(this)">-->
        <a class="Icon Print SeparatorLine" onclick="<%=uicomponent.event("PrintAllQuestion")%>" href="javascript:void(0);"><%=_ctx.appRes("UIQuestions.action.Print")%></a>
  </div>

  <div class="AnswersContainer ViewQuestionContent">
    <div class="FAQContent">
<!--  View question  -->
      <%
        String[] questionActions = uicomponent.getActionQuestion();
        
        Question[] listQuestion = uicomponent.getListQuestion();
        String questionContent = new String();
        int questionIndex = new Date().getTime() ;
        
        String linkQuestion = "" ;
        
        for(question in listQuestion) {
          String qId = question.getPath();
          linkQuestion=uicomponent.event("OpenQuestion", qId);
          String questionIcon = "" ;
          String colorViewQuestion = "";
          if(!question.isActivated() || !question.isApproved()) colorViewQuestion = "gray";
          if(question.getAnswers() != null && question.getAnswers().length > 0) {
            questionIcon = "Question" ;
          } else {
            questionIcon = "NotResponse" ;
          }
          
          if(!uicomponent.getQuestionView().equals(qId)){
            questionContent = question.getQuestion();
      %>
            <div class="QuestionContainer ClearFix oncontextmenu" id="$qId">
      
<!-- style for Questions -->
              <div class="NormalQuest ClearFix">
                <div class="LeftCon ClearFix">
                  <a class="BoxNum">
                    <p><%= uicomponent.getVoteScore(question); %></p>
                    <h4><%= _ctx.appRes("UIQuestions.label.score"); %></h4>
                  </a>
                  <a class="BoxNum">
                    <p><%= question.getNumberOfPublicAnswers(); %></p>
                    <h4><%= _ctx.appRes("UIQuestions.label.answers"); %></h4>
                  </a>
                </div>
                <div class="RightCon">
                <%
                String titleQuestion = "" ;
                if(questionContent.length() > 140) {
                  titleQuestion = questionContent ;
                  questionContent = FAQUtils.getSubString(questionContent, 140);
                }
                %>
                	<h5 class="QuestionContextMenu" id="UIContextPopupMenu$questionIndex">
	                  <a class="Questions" href="$linkQuestion">$questionContent</a>
                	</h5>
                  <div class="ClearFix">
	                  <%if(!question.isApproved()) {%>
	                  <div class="WarningCon"><p class="Warning"><%=_ctx.appRes("UIQuestions.label.QuestionIsNotApproved")%></p></div>                  
	                  <%}%>
	                  <%
	                  String authorOfLastAct = question.getAuthorOfLastActivity();
	                  if (authorOfLastAct != null && !authorOfLastAct.isEmpty()) {%>
                                  
                    <p class="Name"><span><%=_ctx.appRes("UIQuestions.label.By");%>&nbsp;</span>
                    <a title="<%=_ctx.appRes("UIQuestionsInfo.title.ViewUserProfile")%>" href="<%=uicomponent.event("ViewUserProfile", authorOfLastAct)%>"><%= FAQUtils.getFullName(authorOfLastAct);%></a> | <%= uicomponent.calculateTimeMessageOfLastActivity(question.getTimeOfLastActivity());%></p>
                    <% } %>
                  </div>
                </div>
              </div>

					<!-- End new style for Questions -->
 
              
                  <!-- action of this question -->
                  <div class="UIFAQPopupCategory" id="UIPopupMenu$questionIndex" style="display:none;">
                    <div class="UIRightClickPopupMenu UIContextMenuContainer">                         
                              <%
                                String iconView = "" ;
                                for(viewAction in questionActions) {      
                                  if(viewAction.equals("CommentQuestion") && !question.isApproved() && !uicomponent.canEditQuestion) continue ;                           
                                  if(!viewAction.equals("MoveQuestion") && !viewAction.equals("ResponseQuestion"))
                                    iconView = viewAction.replace("Question", "");
                                  else
                                    iconView = viewAction ;
                                  String linkView = "";
                                  
                                  String lockFunction = "" ;
                                  if(viewAction.equals("SendQuestion") && (!question.isApproved() || !question.isActivated())) {
                                    if(canEditQuestion){
                                      linkView = uicomponent.event(viewAction, qId+"/true");
                                    } else {
                                      linkView = "javaScript:alert('" + _ctx.appRes("UIQuestions.label.CanSendToFriend") + "');" ;
                                      lockFunction = "LockFunction" ;
                                    }
                                  } else {
                                    linkView = uicomponent.event(viewAction, qId);
                                  }
                                  String itemLabelView = _ctx.appRes("UIQuestions.action." + viewAction);
                              %>
                                  <div class="MenuItem $lockFunction">
                                    <a class="ItemIcon $iconView" href="$linkView">$itemLabelView</a>
                                  </div>                                
                              <%}%>
                              
                               
                              <%if(uicomponent.currentUser_ != null) {
                                  if(!canEditQuestion && uicomponent.currentUser_.equals(question.getAuthor())){
                                    String itemLabelView = _ctx.appRes("UIQuestions.action.EditQuestion");
                                    String linkView = uicomponent.event("EditQuestion", qId);
                                  %>  
                                    <div class="MenuItem">
                                      <a class="ItemIcon Edit" href="$linkView">$itemLabelView</a>
                                    </div>
                                  <%  
                                  }
                                  if(uicomponent.isDiscussForum()) {
                                    String pathDiscuss = question.getTopicIdDiscuss();
                                    if(pathDiscuss == null || pathDiscuss.length() <= 0){
                              %>
                                    <div class="MenuItem">
                                      <div title="<%=_ctx.appRes("UIQuestions.title.DiscussForum");%>">
                                        <a class="ItemIcon DiscussForum" href="javascript:void(0);" onclick="<%=uicomponent.event("DiscussForum", question.getPath())%>"><%= _ctx.appRes("UIQuestions.title.DiscussForum"); %></a>
                                      </div>
                                    </div>
                              <%  
                                    } 
                                  }
                                } 
                                if(uicomponent.isDiscussForum()) {
                                  String topicIdDiscuss = question.getTopicIdDiscuss();
                                  if(topicIdDiscuss != null && topicIdDiscuss.length() > 0){
                                    String link = FAQUtils.getLinkDiscuss(topicIdDiscuss);
                                    if(uicomponent.discussId != null && uicomponent.discussId.length() > 0){
                                      if(topicIdDiscuss.equals(uicomponent.discussId)) {
                                        jsmanager.addJavascript("eXo.faq.UIAnswersPortlet.openDiscussLink('"+link+"');");
                                        uicomponent.discussId = "";
                                      }
                                    }
                              %>
                                    <div class="MenuItem">
                                      <a class="ItemIcon DiscussForum" onmousedown="window.open('$link'); return false;" onkeydown="window.open('$link'); return false;" style="display:block"><%= _ctx.appRes("UIQuestions.title.DiscussForum"); %></a>
                                    </div>
                              <%  } 
                                } 
                              %>
                    </div>
                  </div>

                  <!-- finish action of this question -->
                  
     
            </div>
            
        <!--  View Question which is selected  -->

        <%} else {
            String[] listQuestLanguage = uicomponent.getQuestionLangauges(question.getPath());
            questionContent = uicomponent.getQuestionContent();
            String responseBy = "..." ;
            String date = "..." ;
          %>          
            <div class="QuestionSelect">
                  
                    <div class="QuestionContainer ClearFix" id="$qId">
                      
                        <% if(uicomponent.viewAuthorInfor || uicomponent.faqSetting_.isEnableViewAvatar()){ %>
                          <div class="ImgProfile">
                            <%
                              if(uicomponent.faqSetting_.isEnableViewAvatar()) {
                            %> 
                            <img class="FAQAvatar" src="<%=uicomponent.getAvatarUrl(question.getAuthor())%>" alt="<%=_ctx.appRes("UISettingForm.label.Avatar")%>"/>
                            <%}%>
                            <!--  view author's infor  -->
                            <%
                              if(uicomponent.viewAuthorInfor){
                                String email = question.getEmail();
                                
                            %>
                              <div class="AuthorInfor">
                                <a title="<%=_ctx.appRes("UIQuestionsInfo.title.ViewUserProfile")%>" href="<%=uicomponent.event("ViewUserProfile", question.getAuthor())%>">
                                  <span class="UserName"><%=FAQUtils.getFullName(question.getAuthor())%></span>
                                </a>
                                <span title="$email"><%=FAQUtils.getSubString(email, 20)%></span>
                              </div>
                            <%}%>
                          </div>
                        <%}%>
                        
                        <div class="ActionQuestion">
                            <!-- Action -->
                            <div class="IconContainer ClearFix">
                               
                                                               
                                <!-- action Discuss -->
                              <%
                                if(uicomponent.currentUser_ != null) {                                            
                                  if(uicomponent.isDiscussForum()) {
                                    String topicIdDiscuss = question.getTopicIdDiscuss();
                                    if(topicIdDiscuss == null || topicIdDiscuss.length() <= 0){
                              %>
                                
                                  <a class="DiscussForum" href="javascript:void(0);" onclick="<%=uicomponent.event("DiscussForum", question.getPath())%>" title="<%=_ctx.appRes("UIQuestions.title.DiscussForum");%>">
                                    <span></span>
                                  </a>
                                  
                              <%    } else {
                                    String link = FAQUtils.getLinkDiscuss(topicIdDiscuss);
                                    if(uicomponent.discussId != null && uicomponent.discussId.length() > 0){
                                      if(topicIdDiscuss.equals(uicomponent.discussId)) {
                                        jsmanager.addJavascript("eXo.faq.UIAnswersPortlet.openDiscussLink('"+link+"');");
                                        uicomponent.discussId = "";
                                      }
                                    }
                              %>
                              
                                
                                  <a class="MenuItem DiscussForum" onclick="window.open('$link'); return false;" title="<%= _ctx.appRes("UIQuestions.title.DiscussForum"); %>">
                                    <span></span>
                                  </a>
                                
                              <%    }
                                  }
                                } %>
                              
                                <!-- action send mail for frend -->
                                
                                  <%
                                  String SendToFriend = "SendToFriend";
                                  if((!question.isApproved() || !question.isActivated())){
                                    if(canEditQuestion) {
                                      link = uicomponent.event("SendQuestion",qId+"/true");
                                    } else {
                                      link = "javaScript:alert('" + _ctx.appRes("UIQuestions.label.CanSendToFriend") + "');" ;
                                      SendToFriend = "LockSendToFriend" ;
                                    }
                                  } else {
                                    link = uicomponent.event("SendQuestion",qId);
                                  }
                                  %>
                                  <a class="$SendToFriend" href="$link" title="<%=_ctx.appRes("UIQuestions.action.SendQuestion")%>">
                                    <span></span>
                                  </a>
                                
                              <%if(uicomponent.currentUser_ != null) {
                                  if(canEditQuestion || uicomponent.currentUser_.equals(question.getAuthor())){
                              %>
                               
                                  <a class="MoveQuestion" onclick="<%=uicomponent.event("MoveQuestion", qId);%>" title="<%=_ctx.appRes("UIQuestions.action.MoveQuestion")%>">
                                    <span></span>
                                  </a>
                                
                                  <a class="Delete" onclick="<%=uicomponent.event("DeleteQuestion", qId);%>" title="<%=_ctx.appRes("UIQuestions.action.DeleteQuestion")%>">
                                    <span></span>
                                  </a>
                               
                                  <a class="Edit" onclick="<%=uicomponent.event("EditQuestion", qId);%>" title="<%=_ctx.appRes("UIQuestions.action.EditQuestion")%>">
                                    <span></span>
                                  </a>
                              <%  }
                                } 
                              %>  
                                
                                <!-- action print question -->
                                
                                  <a class="PrintScrintFAQ" onclick="javaScript:eXo.faq.UIAnswersPortlet.printPreview(this);"
                                      title="<%=_ctx.appRes("UIQuestions.action.PrintQuestion")%>">
                                    <span></span>
                                  </a>
                                
                                
                                <!-- Action back page -->
                                <%
                                String backPath = uicomponent.getBackPath() ;
                                if(backPath != null && backPath.trim().length() > 0) {
                                  String link = uicomponent.event("ViewQuestion",backPath);
                                %>
                                  
                                    <a class="BackPageFAq" onclick="$link" title="<%=_ctx.appRes("UIQuestions.action.Back")%>">
                                      <span></span>
                                    </a>
                                  
                                <%}%>
                             
                            </div>
                                
	                        <!-- action translation question -->
	                        <div class="LanguageContainer">
	                          <%
	                            int countLanguage = 2;
	                            for(String quesLanguage in listQuestLanguage) {
	                              String linkView = uicomponent.event("ChangeLanguage", quesLanguage);
	                              String color = "#914ab6";
	                              if(quesLanguage.equals(uicomponent.language_)){
	                                continue;
	                              }
	                          %>
	                              <a href="$linkView">$quesLanguage</a>
	                          <%  if(countLanguage < listQuestLanguage.length){%>
	                                 |
	                            <%} else {%>
	                                <span></span>
	                            <%}
	                              countLanguage ++;
	                            }
	                          %>
	                        </div>
                            
                            <%
                            if(uicomponent.faqSetting_.isEnanbleVotesAndComments()){
                            %>
	                        
                          <!--  Vote result  -->
                          <div class="VoteResult">
                                <% 
                                int markVote =(Integer) question.getMarkVote();
                                double sodu = question.getMarkVote() - markVote;
                                %>
                                <div class="RatingInfoContainer ClearFix">
                                  <%
                                    if(uicomponent.currentUser_ == null || 
                                        (uicomponent.currentUser_ != null && !uicomponent.canVote(question))){
                                        onclick = "javaScrip:void(0);";
                                        titleMark = "";
                                        if(uicomponent.currentUser_ != null && question.isApproved() || uicomponent.canEditQuestion) {
                                          onclick = uicomponent.event("UnVoteQuestion",question.getPath());
                                          titleMark = _ctx.appRes("UIQuestions.action.UnVoteQuestion");
                                        }
                                    %>
                                      <div class="ClearFix" onclick="$onclick" title="$titleMark">
                                        <%
                                        for(int mark = 0; mark < 5; mark ++){
                                          if(mark < markVote){%>
                                            <div class="OverVote"><span></span></div>
                                        <%} else if (mark > markVote){%>
                                            <div class="RatedVote"><span></span></div>
                                        <%} else{
                                            if(sodu < 0.3){%>
                                              <div class="RatedVote"><span></span></div>
                                          <%} else if (sodu > 0.7){%>
                                              <div class="OverVote"><span></span></div>
                                          <%} else {%>
                                              <div class="HaftVote"><span></span></div>
                                          <%}
                                          }
                                        }%>
                                      </div>
                                  <% } else { %>
                                      <div id="faqVoteSpace" class="faqVoteSpace" onmouseover="eXo.faq.UIAnswersPortlet.viewTitle('faqVoteQuestion');eXo.faq.UIAnswersPortlet.hiddenTitle('faqMarkVoteSpace'); "  
                                                              onmouseout="eXo.faq.UIAnswersPortlet.viewTitle('faqMarkVoteSpace');eXo.faq.UIAnswersPortlet.hiddenTitle('faqVoteQuestion');">
                                        <div id="faqMarkVoteSpace" style="display:block;">
                                        <%String classNameForStar = "";
                                          for(int mark = 0; mark < 5; mark ++){
                                            if(mark < markVote){
                                              classNameForStar = "OverVote";
                                              
                                            } else if (mark > markVote){
                                              classNameForStar = "RatedVote";
                                            } else{
                                              if(sodu < 0.3){
                                                classNameForStar = "RatedVote";
                                              } else if (sodu > 0.7){
                                                classNameForStar = "OverVote";
                                              } else {
                                                classNameForStar = "HaftVote";
                                              }
                                            }%>
                                            <div class="$classNameForStar"><span></span></div>
                                        <%}%>
                                        </div>
                                        
                                          <%
                                          if (question.isApproved() || uicomponent.canEditQuestion) {
                                          %>
                                          <div id="faqVoteQuestion" style="display:none;" onmouseout="eXo.faq.UIAnswersPortlet.changeStarForVoteQuestion('-1', 'FAQHomeStarVote')" title="<%=_ctx.appRes("UIQuestions.action.VoteQuestion")%>">
                                          <%
                                            for(int i = 0; i < 5; i ++) {
                                              number = String.valueOf(i+1);
                                              onclick = uicomponent.event("VoteQuestion", number);
                                            %>
                                              <div id="FAQHomeStarVote$i" class="RatedVote" onmouseover="eXo.faq.UIAnswersPortlet.changeStarForVoteQuestion('$i', 'FAQHomeStarVote')" onclick="$onclick" title=""><span></span></div>
                                          <%}%>
                                          </div>
                                          <%}%>
                                          
                                        
                                      </div>
                                  <%}
                                    %>
                                </div>
                                <%
                                String markView = question.getMarkVote() + "";
                                if(markView.length() <= 4){
                                %>
                                  <p class="Result"><strong>$markView</strong></p>
                                <%
                                } else {
                                %>
                                  <div><strong><%=markView.substring(0, 4)%></strong></div>
                                <%}%>
                          </div>
                              
                            <%
                            }
                            %>
                            
                          </div>
                         
                          <div class="QuestionContent">
                              <div class="LeftQuestionContainer oncontextmenu">
                                <div onmousedown="eXo.webui.UIRightClickPopupMenu.clickRightMouse(event, this, 'UIPopupQuestion$questionIndex', '', null, null)" onkeydown="eXo.webui.UIRightClickPopupMenu.clickRightMouse(event, this, 'UIPopupQuestion$questionIndex', '', null, null)">
                                 	<!-- question content -->
	                                    <a class="QuestionName" href="<%=uicomponent.event("CloseQuestion")%>" style="color:$colorViewQuestion;">
	                                      $questionContent
	                                    </a> 
                                </div>
                                
                                <!-- action of this question -->
                                <div class="UIFAQPopupCategory" id="UIPopupQuestion$questionIndex" style="display:none;">
                                  <div class="UIRightClickPopupMenu UIContextMenuContainer">
              
                                            <%
                                              String iconView = "" ;
                                              for(viewAction in questionActions) {
                                                if(viewAction.equals("CommentQuestion") && !question.isApproved() && !uicomponent.canEditQuestion) continue ;
                                                if(!viewAction.equals("MoveQuestion") && !viewAction.equals("ResponseQuestion"))
                                                  iconView = viewAction.replace("Question", "");
                                                else
                                                  iconView = viewAction ;
                                                String linkView = "";
                                                String lockFunction = "" ;
                                                if(viewAction.equals("SendQuestion") && (!question.isApproved() || !question.isActivated())) {
                                                  if(canEditQuestion){
                                                    linkView = uicomponent.event(viewAction, qId+"/true");
                                                  } else {
                                                    linkView = "javaScript:alert('" + _ctx.appRes("UIQuestions.label.CanSendToFriend")+"');" ;
                                                    lockFunction = "LockFunction" ;
                                                  }
                                                } else {
                                                  linkView = uicomponent.event(viewAction, qId);
                                                }
                                                String itemLabelView = _ctx.appRes("UIQuestions.action." + viewAction); 
                                                      
                                            %>

                                                <div class="MenuItem $lockFunction" onmousedown="$linkView" onkeydown="$linkView">
                                                  <a class="ItemIcon $iconView" href="$linkView" > $itemLabelView</a>
                                                </div>
                                            <%
                                              }
                                            %>                                                    
                                            <%if(!canEditQuestion && uicomponent.currentUser_ != null && uicomponent.currentUser_.equals(question.getAuthor())){
                                                String itemLabelView = _ctx.appRes("UIQuestions.action.EditQuestion");
                                                String linkView = uicomponent.event("EditQuestion", qId);                                       
                                            %>
                                              <div class="MenuItem" onmousedown="$linkView" onkeydown="$linkView">
                                                <a class="ItemIcon Edit" href="$linkView">$itemLabelView</a>
                                              </div>
                                            <%}%>
                                  </div>
                                </div>
                                <!-- finish action of this question -->
                                
                                  <!--  view Detail  -->
                                <div class="UIDetailContainer">
                                  <%
                                    String questionDetail = uicomponent.render(uicomponent.getQuestionDetail());
                                  %>
                                      $questionDetail
                                </div>
                                <p class="QuestionDateTime"><%=FAQUtils.getLongDateFormat(question.getCreatedDate())%>&nbsp;*</p>
                                  <!--  view bottom  -->
                                <%
                                if(uicomponent.currentUser_ != null){
                                %>
                                  <div class="QuestionAction">
                                   <%
                                    if(question.isApproved() || uicomponent.canEditQuestion){
                                   %>
                                      <a href="<%=uicomponent.event("ResponseQuestion", question.getPath());%>" class="ResponseQuestion"><%=_ctx.appRes("UIQuestions.action.AddAnswerQuestion");%></a>
                                      <%}
                                    if((uicomponent.faqSetting_.isEnanbleVotesAndComments() && question.isApproved())){
                                    %>
                                      <span>| </span><a href="<%=uicomponent.event("CommentQuestion", question.getPath() + "/new")%>" class="Comment"><%=_ctx.appRes("UIQuestions.action.AddCommentQuestion")%></a>
                                      <%}%>
                                    </div>
                                  <%}%>
                              </div>
                            </div>
                                   
                    </div>
                    
                    <!--  View response content  -->
                    <% 
                    Answer[] answers = uicomponent.getPageListAnswer(question.getPath());
                    String classResponsse = "";
                    if(answers != null && answers.length > 0)classResponsse = "ResponseExternal";
                    %>
                    <div class="ResponseContent">
                    
                      <!--  View attachment files  -->
                      <%if(!question.getAttachMent().isEmpty()) {%>
                          <div class="AttachmentContent ClearFix">
                            <%
                              for(FileAttachment fileAttachment :question.getAttachMent()){
                                String fileName = fileAttachment.getName();
                                long fileSize = fileAttachment.getSize();
                                String size = uicomponent.convertSize(fileSize);
                                String fileType = fileAttachment.getMimeType();
                                String fileWorkSpace = fileAttachment.getWorkspace();
                                ValidatorDataInput validate = new ValidatorDataInput();
                                String linkImage = FAQUtils.getFileSource(fileAttachment);
                                String typeFileIcon = fileAttachment.getMimeType().substring((fileAttachment.getMimeType().indexOf("/")+1));
                                if(validate.isImage(fileName)) {
                                  String attLink = uicomponent.getImageUrl(fileAttachment.getPath());
                              %>
                                  <div class="FileAttachment" id="divId${fileName}">
                                    <div class="Image ClearFix">
                                      <div onclick="eXo.faq.UIAnswersPortlet.showPicture('$attLink');">
                                        <img id="imgView${fileName}" src="$attLink" width="100px" height="100px" alt="$fileName" class="AttachmentFile"/>
                                      </div>
                                    </div>
                                    
                                    <div class="LabelBox ClearFix">

                                        <div class="AttachmentLabel">
                                          <%
                                            String downloadAtt = uicomponent.event("DownloadAttach");
                                          if(fileName.length() > 60){
                                          %>
                                            <a class="AttachmentLabel" title="$fileName" onclick="ajaxRedirect('$linkImage'); if(eXo.core.Browser.browserType === 'ie') {$downloadAtt ; } return false;" href="javaScript:void(0);">
                                              <span><%=FAQUtils.getSubString(fileName, 60);%></span>
                                            </a>
                                          <%}else{%>
                                            <a class="AttachmentLabel" onclick="ajaxRedirect('$linkImage'); if(eXo.core.Browser.browserType === 'ie') {$downloadAtt ; } return false;" href="javaScript:void(0);">
                                              <span>$fileName</span>
                                            </a>
                                          <%}%>
                                        </div>
                                        <div class="SizeLabel">
                                          <span>&nbsp;- </span><span>$size</span>
                                        </div>
                                      
                                    </div>
                                  </div>
                              <%} else { %>
                                  <div class="LabelBox ClearFix">
                                    <div class="AttachmentIcon FileAttachmentIcon">
                                    <%
                                    if(fileName.length() > 60){
                                    %>
                                      <a title="$fileName" class="AttachmentLabel" onclick="if(eXo.core.Browser.browserType === 'ie') {<%=uicomponent.event("DownloadAttach");%>; } ajaxRedirect('$linkImage'); return false;" href="javaScript:void(0);">
                                        <%=FAQUtils.getSubString(fileName, 60);%>
                                      </a>
                                    <%}else{%>
                                      <a class="AttachmentLabel" onclick="if(eXo.core.Browser.browserType === 'ie') {<%=uicomponent.event("DownloadAttach");%>; } ajaxRedirect('$linkImage'); return false;" href="javaScript:void(0);">
                                        $fileName
                                      </a>
                                    <%}%>
                                    </div>
                                    <div class="SizeLabel">&nbsp;-&nbsp;<span>$size</span></div>
                                    
                                  </div>
                              <%}
                              }%>
                            
                          </div>
                      <%}%>
                      
                      <!--  view relation question  -->
                      <%
                        List questionRelation = question.getRelations();
                        if(!questionRelation.isEmpty()){
                          Map<String, String> mapQuestionRelation = uicomponent.getQuestionRelation(questionRelation);
                          if(mapQuestionRelation.size() > 0) {
                            String linkRelaQues = "" ;
                            String relationContent = "" ;
                            String relationId = "";
                        %>
                          <div class="RelationContent">
                            <h4><%=_ctx.appRes("UIQuestions.label.RelatedQuestion")%>:</h4>
                        <%
                            for (Map.Entry<String, String> entry : mapQuestionRelation.entrySet()) {
                              relationId = entry.getKey();
                              relationContent = entry.getValue();
                              linkRelaQues = uicomponent.event("ViewQuestion", relationId + uicomponent.OBJECT_LANGUAGE + uicomponent.language_+ uicomponent.OBJECT_RELATION);
                              if(relationContent != null && relationContent.trim().length() > 0) {
                        %>
                                <p>
                                  <a href="$linkRelaQues"> - $relationContent</a><br/>
                                </p>
                        <%    }
                            }
                        %>
                            </div>
                        <%}%>
                      <%}%>
                    
                      
                      <!--  Question's answers  -->
                      <div class="ResponseContainer">
                        <div class="TitleResponseContent ClearFix">
                            <h5 class="TxtTitle">
                              <%=_ctx.appRes("UIQuestions.label.Answers")%>
                            </h5>
                            <%if(uicomponent.faqSetting_.isEnanbleVotesAndComments()){%>
                                <!-- action Sort answer by vote -->
                              <p class="IconTitle">
                                <a class="SortAnswer DisablePrint" href="<%=uicomponent.event("SortAnswer")%>" title="<%=_ctx.appRes("UIQuestions.action.SortAnswerByVote")%>">
                                  Sort by Rate
                                </a>
                              </p>
                            <%}%>
                        </div>
                        
                        <!-- View all answer for this question -->
                        <div class="Response $classResponsse" id="SetWidthContent">
                          <div>
                          <%
                          if(answers != null && answers.length > 0){
                            String actionAnswer = "";
                            int i = 0;
                            String owner = "";
                            for(Answer answer in answers) {
                              res = uicomponent.render(answer);
                              if(!uicomponent.canEditQuestion && (!answer.getApprovedAnswers() || !answer.getActivateAnswers())){
                                continue;
                              }
                              date = FAQUtils.getLongDateFormat(answer.getDateResponse());
                              owner = answer.getResponseBy();
                              responseBy = FAQUtils.getScreenName(owner, answer.getFullName());
                              String userProfile = uicomponent.event("ViewUserProfile", owner);
                            %>
                            <div class="ResponseItemContainer ClearFix">
                                  <!--  View user who answered quesetion  -->
                                  <div class="ImgItemContainer">
                                    <%
                                    if(uicomponent.faqSetting_.isEnableViewAvatar()) {
                                    %> 
                                      <img class="FAQAvatar" src="<%=uicomponent.getAvatarUrl(owner);%>" alt="<%=_ctx.appRes("UISettingForm.label.Avatar")%>"/>
                                   
                                    <%}%>
                                  </div>
                                  
                                  <div class="IconContainer ClearFix">
                                  <% if(uicomponent.canEditQuestion || owner.equals(uicomponent.currentUser_)){%>
                                    
                                    <a class="ItemIcon DeleteAnswer" href="<%=uicomponent.event("DeleteAnswer", "" + answer.getId())%>" title="<%=_ctx.appRes("UIQuestionsInfo.title.DeleteAnswer")%>">
                                      <span></span>
                                    </a>
                                    
                                    <%if(uicomponent.canEditQuestion) { %>
                                    
                                    <%
                                      actionAnswer = uicomponent.event("ChangeStatusAnswer", answer.getId() + "/Approve");
                                      if(answer.getApprovedAnswers()) {
                                      %>
                                        <a class="ItemIcon ApprovedQuestion" href="$actionAnswer" title="<%=_ctx.appRes("UIQuestionsInfo.title.UnApprove")%>">
                                        	<span></span>
                                        </a>
                                      <%} else {
                                      %>
                                        <a class="ItemIcon UnApprovedQuestion" href="$actionAnswer" title="<%=_ctx.appRes("UIQuestionsInfo.title.Approve")%>">
                                          <span></span>
                                        </a>
                                      <%}%>
                                    
                                    
                                      <%
                                        actionAnswer = uicomponent.event("ChangeStatusAnswer", answer.getId() + "/Activate");
                                        if(answer.getActivateAnswers()) {
                                      %>
                                        <a class="ItemIcon ActivateQuestion" href="$actionAnswer" title="<%=_ctx.appRes("UIQuestionsInfo.title.UnActivated")%>">
                                          <span></span>
                                        </a>
                                      <%} else {
                                      %>
                                        <a class="ItemIcon DeActivateQuestion" href="$actionAnswer" title="<%=_ctx.appRes("UIQuestionsInfo.title.Activate")%>">
                                          <span></span>
                                        </a>
                                      <%}%>
                                    
                                    <%} %>
                                    
                                      <a class="ItemIcon Edit" title="<%=_ctx.appRes("UIQuestions.action.EditAnswer")%>" href="<%=uicomponent.event("EditAnswer", answer.getId())%>">
                                            <span></span>
                                      </a>
                                    
                                  <%}%>
                           				 </div>
                                  
                                  <div class="ResponseItemContainerRight ClearFix">
                                    
                                      <%
                                      if(answer.getApprovedAnswers() && answer.getActivateAnswers()){
                                      %>
                                      <div class="AnswerContent ClearFix">
	                                      <a class="AuthorInfor" title="<%=_ctx.appRes("UIQuestionsInfo.title.ViewUserProfile")%>" href="<%=uicomponent.event("ViewUserProfile", owner)%>" ><span class="UserName">$responseBy</span></a> 
	                                      $res
                                      </div>
                                      <%
                                      } else {
                                      %>
                                    	<div class="AnswerContent ClearFix">
	                                      <a class="AuthorInfor" title="<%=_ctx.appRes("UIQuestionsInfo.title.ViewUserProfile")%>" href="<%=uicomponent.event("ViewUserProfile", owner)%>" ><span class="UserName">$responseBy</span></a> 
	                                      $res
                                      </div>
                                      <%} %>
                                      <div class="Date">$date</div>
                                    
                                    
                                    <!--  View mark vote answer  -->
                                    <div class="VoteAnswerContainer ClearFix">
                                      <%
                                      if(uicomponent.faqSetting_.isEnanbleVotesAndComments()){
                                          String userVoteUpAnswer = "javaScript:alert('" + _ctx.appRes("UIQuestions.alert.LoginBeforVote") + "')";
                                          String userVotedownAnswer = "javaScript:alert('" + _ctx.appRes("UIQuestions.alert.LoginBeforVote") + "')";
                                          if(uicomponent.currentUser_ != null){
                                            userVoteUpAnswer = uicomponent.event("VoteAnswer", answer.getPath() + "/up");
                                            userVotedownAnswer = uicomponent.event("VoteAnswer", answer.getPath() + "/down");
                                          }
                                          String idVote = "FAQVoteAnswerUp" + i;
                                        %>
                      
                                              <a class="VoteAnswerUp" href="$userVoteUpAnswer" title="+1" id="$idVote" onmouseover="eXo.faq.UIAnswersPortlet.voteAnswerUpDown('$idVote', 'true')" onfocus="eXo.faq.UIAnswersPortlet.voteAnswerUpDown('$idVote', 'true')" onmouseout="eXo.faq.UIAnswersPortlet.voteAnswerUpDown('$idVote', null)" onblur="eXo.faq.UIAnswersPortlet.voteAnswerUpDown('$idVote', null)">
                                                <span></span>
                                              </a>
                                           
                                          <%
                                            idVote = "FAQVoteAnswerDown" + i;
                                            ++i;
                                          %>
      
                                              <a class="VoteAnswerDown" href="$userVotedownAnswer" title="-1" id="$idVote" onmouseover="eXo.faq.UIAnswersPortlet.voteAnswerUpDown('$idVote', 'true')" onfocus="eXo.faq.UIAnswersPortlet.voteAnswerUpDown('$idVote', 'true')" onmouseout="eXo.faq.UIAnswersPortlet.voteAnswerUpDown('$idVote', null)" onblur="eXo.faq.UIAnswersPortlet.voteAnswerUpDown('$idVote', null)">
                                                <span></span>
                                              </a>
                                           
                                            <div class="TextVoteAnswer">

                                              <%=answer.getMarkVotes()%>
                                            </div>
                                            
                                        <%
                                        }%>
                                        
                                    </div>
                                    
                                  </div>
                            
                          <%}
                            if(uicomponent.getChildById(uicomponent.ANSWER_ITER + question.getId())!= null){
                          %>
                              <div style="overflow:auto" class="ClearFix">
                                <% uicomponent.renderChild(uicomponent.ANSWER_ITER + question.getId()) %>
                               
                              </div>  
                        <%  }
                          } else { %>
                        <div class="NotResponse">
                          <%=_ctx.appRes("UIQuestions.label.QuestionNotYetAnswered")%>
                        </div>
                        <%}%>
                          </div>
                        </div>
                        <!-- finish View all answer for this question -->
                        
                        <!--  View question's commnets  -->
                        <%
                        if(uicomponent.faqSetting_.isEnanbleVotesAndComments()){
                          boolean canEditComment = false;
                          Comment[] comments = uicomponent.getPageListComment(question.getPath());
                          String classComment = "";
                          if(comments.length > 0) {
                            classComment = "CommentExternal";
                        %>
                            <h5 class="TitleCommentContent">
                              <%=_ctx.appRes("UIQuestions.label.Comments")%>
                            </h5>
                        <% } %>
                          
                          <div class="Response $classComment">
                          <%
                            int commentCount = 0;
                            for(Comment comment in comments){
                              String owner = comment.getCommentBy();
                              if(uicomponent.currentUser_.equals(comment.getCommentBy())) canEditComment = true;
                              else canEditComment = false;
                          %>
                                <div class="ResponseItemContainer ClearFix">
                                    
	                                <div class="ImgItemContainer">
	                                <!--  View user who comment for quesetion  -->
	                                      <%
	                                      if(uicomponent.faqSetting_.isEnableViewAvatar()) {
	                                      %>
	                                        <img class="FAQAvatar" src="<%=uicomponent.getAvatarUrl(owner);%>" alt="<%=_ctx.appRes("UISettingForm.label.Avatar")%>"/>
	                                   
	                                      <%}%>
	                                </div>
                                        
                                    <div class="IconContainer ClearFix">
                                        <a class="ItemIcon Delete" title="<%=_ctx.appRes("UIQuestions.action.DeleteComment")%>" href="<%=uicomponent.event("DeleteComment", comment.getId())%>">
                                       		<span></span>
                                        </a>
                                      
                                        <a class="ItemIcon Edit" title="<%=_ctx.appRes("UIQuestions.action.EditComment")%>" href="<%=uicomponent.event("CommentQuestion", question.getPath() + "/" + comment.getId())%>">
                                          <span></span>
                                        </a>
	                                    <%
	                                    if(canEditComment){
	                                      if (uicomponent.faqSetting_.isCanEdit()){%>
                                          <a class="ItemIcon CommentToAnswer" title="<%=_ctx.appRes("UIQuestions.action.CommentToAnswer")%>" href="<%=uicomponent.event("CommentToAnswer", comment.getId())%>">
                                               <span></span>
                                          </a>
	                                    <%}%>
                                      
	                                  <%} else if (uicomponent.faqSetting_.isCanEdit()){%>
	                                      
	                                        <a class="ItemIcon CommentToAnswer" title="<%=_ctx.appRes("UIQuestions.action.CommentToAnswer")%>" href="<%=uicomponent.event("CommentToAnswer", comment.getId())%>">
	                                          <span></span>
	                                        </a>
	                                      
	                                      
	                                        <a class="ItemIcon Delete" title="<%=_ctx.appRes("UIQuestions.action.DeleteComment")%>" href="<%=uicomponent.event("DeleteComment", comment.getId())%>">
	                                           <span></span>
	                                        </a>
	                                      
	                                  <%}%>
                                  </div>
	                                <div class="ResponseItemContainerRight">
	                                  <%
	                                    String commentDetail = uicomponent.render(comment);
	                                  %>
	                                  <div class="CommentContent ClearFix">
	                                    <a class="AuthorInfor" title="<%=_ctx.appRes("UIQuestionsInfo.title.ViewUserProfile")%>" href="<%=uicomponent.event("ViewUserProfile", owner)%>">
	                                      <span class="UserName"><%=FAQUtils.getScreenName(owner, comment.getFullName())%></span>
	                                    </a>$commentDetail</div>
	                                  <div class="Date"><%=FAQUtils.getLongDateFormat(comment.getDateComment());%></div>
	                                </div>
                                  
                                </div>
                          <%}
                            if(uicomponent.getChildById(uicomponent.COMMENT_ITER + question.getId())!= null){
                          %>
                            <div class="ClearFix">
                              <% uicomponent.renderChild(uicomponent.COMMENT_ITER + question.getId()) %>
                              
                            </div>                            
                            <%}%> 
                          </div>
                        <%}%>
                          
                        </div>
                      </div>
            </div>
    <%    }
          questionIndex = new Date().getTime() ;
        }
    %>
    
      <!-- Print function -->
      
          <div class="PrintAction" title="<%=_ctx.appRes("UIQuestions.action.ClosePrintQuestion")%>"><%=_ctx.appRes("UIQuestions.action.Print")%></div>
      
    </div>
    <%
      if(uicomponent.getQuestionView() != null && uicomponent.getQuestionView().trim().length() > 0) {
        String divId = uicomponent.getQuestionView();
        jsmanager.addJavascript("eXo.faq.UIAnswersPortlet.jumToQuestion('"+divId+"');");
      }
    %>
  </div>
  
  <div>
    <%uicomponent.renderChild(uicomponent.OBJECT_ITERATOR);%>
  </div>

	<!-- End View category -->
</div>