$(function(){
	var items = $('#boxes .box'), from = 0, n = Math.max(3, parseInt(Math.max($('#menu').height(), $('#content').height()) / 140, 10));
	if(items.length > n) {
		$('#boxes-nav').show();
		function showFrom(a) {
			if(a < 0 || a >= items.length) {
				return;
			}
			items.hide().removeClass('fst').slice(a, a + n).show().slice(0, 1).addClass('fst');
			from = a;
		}
		$('#boxes-nav .prev').click(function() {
			showFrom(from - n);
			return false;
		});
		$('#boxes-nav .next').click(function() {
			showFrom(from + n);
			return false;
		});
		showFrom(0);
	}
});