(function(C) { C.fn.pager = function(D) { var E = C.extend({}, C.fn.pager.defaults, D); return this.each(function() { C(this).empty().append(B(parseInt(D.pagenumber), parseInt(D.pagecount), D.buttonClickCallback)); C(".pages li").mouseover(function() { document.body.style.cursor = "pointer" }).mouseout(function() { document.body.style.cursor = "auto" }) }) }; function B(E, J, G) { var K = C('<ul class="pages"></ul>'); K.append(A("first", E, J, G)).append(A("prev", E, J, G)); var H = 1; var F = 9; if (E > 4) { H = E - 4; F = E + 4 } if (F > J) { H = J - 8; F = J } if (H < 1) { H = 1 } for (var I = H; I <= F; I++) { var D = C('<li class="page-number">' + (I) + "</li>"); I == E ? D.addClass("pgCurrent") : D.click(function() { G(this.firstChild.data) }); D.appendTo(K) } K.append(A("next", E, J, G)).append(A("last", E, J, G)); return K } function A(H, D, G, F) { var E = C('<li class="pgNext">' + H + "</li>"); var I = 1; switch (H) { case "first": I = 1; break; case "prev": I = D - 1; break; case "next": I = D + 1; break; case "last": I = G; break } if (H == "first" || H == "prev") { D <= 1 ? E.addClass("pgEmpty") : E.click(function() { F(I) }) } else { D >= G ? E.addClass("pgEmpty") : E.click(function() { F(I) }) } return E } C.fn.pager.defaults = { pagenumber: 1, pagecount: 1} })(jQuery);