generalize pagination function to be used as a "class"
generalize currentpage - span and next/prev - buttons