$(document).ready(function() { 
	$('table.tablesorter').each(function() { 
		var aktStranka = 0;
		var pocetNaStrance = 5;
		var $tabulka = $(this);

		var strankuj = function() { 
			$tabulka.find('tbody tr').hide() 
			.slice(aktStranka * pocetNaStrance, 
				(aktStranka + 1) * pocetNaStrance) 
			.show(); 
		};
		strankuj();

		var pocetRadku = $tabulka.find('tbody tr').length;
		var pocetStranek = Math.ceil(pocetRadku / pocetNaStrance); 
		var $ovladac = $('<div class="ovladac"></div>');

		for (var stranka = 0; stranka < pocetStranek; stranka++) { 
			$('<span class="cislo"></span>').text(stranka + 1) 
			.bind('click', {novaStranka: stranka}, function(event) { 
				aktStranka = event.data['novaStranka']; 
				strankuj();
				$(this).addClass('aktOdkaz')
				.siblings().removeClass('aktOdkaz');
			}).appendTo($ovladac);
		}

		$ovladac.insertBefore($tabulka)
		.find('span.cislo:first').addClass('aktOdkaz');
	});
});