var perpage = 10;
var currentPage = 1;

$(function() {		
	if(typeof(window.location.hash) != "undefined" && window.location.hash != "") {
		toPage(window.location.hash.replace("#page", ""));
	} else {
		toPage(1);	
	}	
});

function toPage(p) {
	window.scrollTo(0, 0);
	currentPage = p;
	var start = p == 1 ? 1 : perpage * (currentPage - 1) + 1;
	var end = p == 1 ? 1 + perpage : (start + perpage + 1);
	$(".paginator tr:not(.visible) td").hide();
	$(".paginator tr").slice(start, end).children().show();
	var pages = Math.ceil($(".paginator tr").length / perpage);
	$("#bottommenu2").html("");
	for(var i = 1; i <= pages; i++) {
		if(i == currentPage) {
			$('<li>[' +i+ ']</li>').appendTo($("#bottommenu2"));
		} else {
			$('<li><a href="#page' + i + '">[' +i+ ']</a></li>')
				.click(function() {
					toPage($("#bottommenu2 li").index($(this)) + 1); 
				})
				.appendTo($("#bottommenu2"));
		}
	}
}

