# -*- encoding : utf-8 -*-
module Admin::PaginationHelper


	def per_page_link(per_page)
	  new_params = {}
	  new_params.merge!(params)
	  new_params["per_page"] = per_page
	  link_to per_page, new_params, :remote => true
	
	end
	
	def per_page_links(per_page, items)
	  to_r = ""
	 
	
	  nbrs = [5, 10, 20, 50 ]
	
	
	  max = ((items.to_i.to_f / 10).to_i*10)+10
	  nbrs << max if !nbrs.include?(max)
		nbrs_to_show = nbrs
		nbrs_to_show.delete(per_page.to_i)
		nbrs.sort.each do |nbr|
			to_r += per_page_link(nbr)
		end
	to_r += "<em>" 
	to_r += per_page.to_s
	to_r += "</em>" 
	 to_r += " lignes/pages"
	
	  raw(to_r)
	end



	
	
	
end
