<%  
  def totalPage = uicomponent.getAvailablePage();
  def currentPage = uicomponent.getCurrentPage();
  def maxPageSize = uicomponent.getItemsPerPage();
  def int[] maxItemPerPageList = uicomponent.getMaxItemPerPageList(); 
%>
<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="PagesTotalNumber"><%=totalPage%></a>
  <a class="TotalPages"><%=_ctx.appRes("UIPageIterator.label.totalPage")%>:</a>
  <% if (uicomponent.isUseMaxSizeSetting()) { %>
  <a class="TotalPages" style="float:left; display:block;"><%=_ctx.appRes("UIPageIterator.label.maxPageSize")%>:&nbsp;</a>
  <select class="selectbox" onchange="window.location.href=this.options[this.selectedIndex].value; return false;">
  <% for (maxItemPerPage in maxItemPerPageList) {
    if (maxPageSize == maxItemPerPage) {
  %>
    <option value="<%=uicomponent.event("ChangeMaxSizePage","$maxItemPerPage")%>" selected>$maxItemPerPage</option>
  <% } else { %>
    <option value="<%=uicomponent.event("ChangeMaxSizePage","$maxItemPerPage")%>">$maxItemPerPage</option>
  <% } 
  } %>
  </select>
  <% } %>
  <div class="ClearRight"><span></span></div>
<%} else {%>
  <% if (uicomponent.isUseMaxSizeSetting()) { %>
  <a class="TotalPages" style="float:left; display:block;"><%=_ctx.appRes("UIPageIterator.label.maxPageSize")%>:&nbsp;</a>
  <select class="selectbox" onchange="window.location.href=this.options[this.selectedIndex].value; return false;">
  <% for (maxItemPerPage in maxItemPerPageList) {
    if (maxPageSize == maxItemPerPage) {
  %>
    <option value="<%=uicomponent.event("ChangeMaxSizePage","$maxItemPerPage")%>" selected>$maxItemPerPage</option>
  <% } else { %>
    <option value="<%=uicomponent.event("ChangeMaxSizePage","$maxItemPerPage")%>">$maxItemPerPage</option>
  <% } 
  } %>
  </select>
  <div class="ClearLeft"><span></span></div>
  <% } else {%>
  <div class="ClearRight"><span></span></div>
  <% } %>
  <%}%> 
</div>