<%
	def totalPage = uicomponent.getAvailablePage();
	def currentPage = uicomponent.getCurrentPage();
%>

<div class="UIPageIterator">
<% if(totalPage > 1) {%> 
	<% if(currentPage + 10 <= totalPage) {%>        
	<a href="<%=uicomponent.event("ShowPage","${currentPage + 10}")%>" class="Icon NextTopPageIcon" title="<%=_ctx.appRes("UIPageIterator.label.nextTenPages")%>"></a>
	  	<% } else if(currentPage + 1 <= totalPage) { %>
	<a class="Icon DisableNextTopPageIcon" title="<%=_ctx.appRes("UIPageIterator.label.nextTenPages")%>"><span></span></a>
	<% } else {%>
	<a class="Icon DisableNextTopPageIcon" title="<%=_ctx.appRes("UIPageIterator.label.nextTenPages")%>"><span></span></a>
	<% }%>	
	<% if(currentPage +1 <= totalPage) { %>
	<a href="<%=uicomponent.event("ShowPage","${currentPage + 1}")%>" class="Icon NextPageIcon" title="<%=_ctx.appRes("UIPageIterator.label.next")%>"></a>
	<% } else { %>
	<a class="Icon DisableNextPageIcon" title="<%=_ctx.appRes("UIPageIterator.label.next")%>"><span></span></a>
	<%}%>
	
  <%
  int min = 1;
  int max = totalPage;
  if(totalPage > 5 && currentPage > 2){
    min = currentPage - 2;
    max = currentPage + 3;
    if (max > totalPage) max = totalPage;
  } else if( totalPage > 5 && currentPage < 3 ){
    min = 1;
    max = 6;
  }
	for( i = max ; i >= min; i--) { %>
	  <%  if( i == currentPage) { %>
	  <a href="<%=uicomponent.event("ShowPage","$i")%>" class="Number PageSelected"><%=i%></a>
	  <%  } else { %>
	  <a href="<%=uicomponent.event("ShowPage","$i")%>" class="Number"><%=i%></a>
	  <%  } %> 
	<%}%>

	<%if( currentPage - 1 > 0 ){%>        
	<a href="<%=uicomponent.event("ShowPage","${currentPage - 1}")%>" class="Icon LastPageIcon" title="<%=_ctx.appRes("UIPageIterator.label.previous")%>"></a>
	<% } else {%>
	<a class="Icon DisableLastPageIcon" title="<%=_ctx.appRes("UIPageIterator.label.previous")%>"><span></span></a>
	<%}%>
	<%if(currentPage > 10) { %>
	<a href="<%=uicomponent.event("ShowPage","${currentPage -10}")%>" class="Icon LastTopPageIcon" title="<%=_ctx.appRes("UIPageIterator.label.backTenPages")%>"></a>
	<% }else { %>
	<a class="Icon DisableLastTopPageIcon" title="<%=_ctx.appRes("UIPageIterator.label.backTenPages")%>"></a>        
	<%}%>
	
	<a class="TotalPages"><strong><%=uicomponent.getFrom() + 1%> - <%=uicomponent.getTo()%></strong>
	  	  <%
	  	    def txtInfor = _ctx.appRes("UIQueryResultPageIterator.label.of-about") ;
	  	    def intNumberOfNodes = uicomponent.getEstimateNumberOfNodes() ;
	  	    if(uicomponent.isEndOfIterator()) {
	  	      txtInfor = _ctx.appRes("UIQueryResultPageIterator.label.of") ;
	  	      intNumberOfNodes = uicomponent.getRealNumberOfNodes() ;
	  	    }
	  	  %>
	  	<%=txtInfor%>
	  	<strong><%=intNumberOfNodes%></strong>
	</a>
	<a class="PagesTotalNumber"><%=_ctx.appRes("UIQueryResultPageIterator.label.results")%></a>
	<div class="ClearRight"><span></span></div>
<%}%>	
</div>
