<div id="page">
<%
p_head = '|&lt;&lt;先頭ページへ'
p_prev = '&lt;前へ'
p_next = '次へ&gt;'
p_tail = '末尾ページへ&gt;&gt;|'

wsiz = 10
w1 = 5
w2 = 5

# 全ページ数
pcnt = found / rows + ( ( found % rows ) == 0 ? 0 : 1 )

# 現在のページ番号
cpag = start / rows + 1

# ウィンドウ開始・終了（ページ番号）
wbgn = cpag - w1
wend = cpag + w2
if wbgn < 1 then
  wbgn = 1
  wend = wbgn + wsiz
  if wend > pcnt + 1 then
    wend = pcnt + 1;
  end
end
if wend > pcnt + 1 then
  wend = pcnt + 1
  wbgn = wend - wsiz
  if wbgn < 1 then
    wbgn = 1
  end
end
%>
<% if pcnt > 1 %>
  <strong>Page</strong>：
  <% if cpag > 1 %>
    <%=link_to "#{p_head}", {:query=>query,:filters=>filters.join('/'),:start=>0,:rows=>rows}%>&nbsp;&nbsp;&nbsp;
    <%=link_to "#{p_prev}", {:query=>query,:filters=>filters.join('/'),:start=>"#{(cpag-2)*rows}",:rows=>rows}%>&nbsp;&nbsp;&nbsp;
  <% end %>
  &nbsp;
  <% (wbgn..wend-1).each do |i| %>
    <% if i == cpag then %>
      <%=i%>&nbsp;&nbsp;
    <% else %>
      <%=link_to i,{:query=>query,:filters=>filters.join('/'),:start=>"#{(i-1)*rows}",:rows=>rows}%>&nbsp;&nbsp;
    <% end %>
  <% end %>
  &nbsp;
  <% if cpag < pcnt %>
    <%=link_to "#{p_next}", {:query=>query,:filters=>filters.join('/'),:start=>"#{cpag*rows}",:rows=>rows}%>&nbsp;&nbsp;&nbsp;
    <%=link_to "#{p_tail}", {:query=>query,:filters=>filters.join('/'),:start=>"#{(pcnt-1)*rows}",:rows=>rows}%>
  <% end %>
<% end %>
</div>
