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

<div class="UIPageIterator" id="$uicomponent.id">
<% 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")%>"></a>
  <% } else {%>
  <a class="Icon DisableNextTopPageIcon" title="<%=_ctx.appRes("UIPageIterator.label.nextTenPages")%>"></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")%>"></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")%>"></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>       
  <%}%>
<%}%> 
</div>