// JavaScript Document

var pageRadius = 5;

$(document).ready(function()
{
	hide_page_links();
	position_page_links();
});

function hide_page_links()
{
	var children = $('#pages a:first').parent().children()
	var index = children.index($('#pages .currentPage'));
	$('#pages a').each(function(i)
	{
		//$('#debugbox').append(i + ' ');
		if(i>= index-pageRadius && i<index+pageRadius)
		{
			//link is inside radius
		}
		else
		{
			//link is outside radius
			if($(this).hasClass('nextPage') || $(this).hasClass('prevPage'))
			{
				//item is the "Previous Page" or "Next Page" link. do nothing
			}
			else
			{
				//item is outside the radius and is not the "Previous Page" or "Next Page" link. hide it.
				$(this).css({display:'none'});
			}

		}
	});
}
function position_page_links()
{
	var contentWidth = $('#mainContent').width();
	var pageWidth = $('#pages').width();
	var left = (contentWidth-pageWidth)/2;
	$('#pages').css({left:left + 'px'})
}