var workpages = 0, worksize = 0, workcurrent = 0;
var newspages = 0, newssize = 0, newscurrent = 0;
var thoughtpages = 0, thoughtsize = 0, thoughtcurrent = 0;

$(document).ready(function()
{
    workpages = ($('.workpage').size()) - 1;
	worksize = (workpages - 1) * 10;
	
	if (workpages > 0)
	{
		$('#workdisplay0 span').html( '1 - ' + $('#workpage0 .searchitem').size() );
		$('#workpage0').fadeIn();
		$('#workbar').show();
		
		$("#workbar #next").click(function()
		{
			$('#workpage'+workcurrent).hide();
			if (workcurrent == workpages) { workcurrent = 0; }
			else { workcurrent = workcurrent + 1; }
			$('#workdisplay'+workcurrent+' span').html( ((workcurrent*10)+1) + " - " + ((workcurrent*10) + $('#workpage'+workcurrent+' .searchitem').size()) );
			$('#workpage'+workcurrent+'').fadeIn();
		});
		$("#workbar #prev").click(function()
		{
			$('#workpage'+workcurrent).hide();
			if (workcurrent == 0) { workcurrent = workpages; }
			else { workcurrent = workcurrent - 1; }
			$('#workdisplay'+workcurrent+' span').html( ((workcurrent*10)+1) + " - " + ((workcurrent*10) + $('#workpage'+workcurrent+' .searchitem').size()) );
			$('#workpage'+workcurrent+'').fadeIn();
		});
	}
	else 
	{
		$('#workdisplay0 span').html( '1 - ' + $('#workpage0 .searchitem').size() );
		$('#workpage0').fadeIn();
	}
	
	newspages = ($('.newspage').size()) - 1;
	newssize = (newspages - 1) * 10;
	
	if (newspages > 0)
	{
		$('#newsdisplay0 span').html( '1 - ' + $('#newspage0 .searchitem').size() );
		$('#newspage0').fadeIn();
		$('#newsbar').show();
		
		$("#newsbar #next").click(function()
		{
			$('#newspage'+newscurrent).hide();
			if (newscurrent == newspages) { newscurrent = 0; }
			else { newscurrent = newscurrent + 1; }
			$('#newsdisplay'+newscurrent+' span').html( ((newscurrent*10)+1) + " - " + ((newscurrent*10) + $('#newspage'+newscurrent+' .searchitem').size()) );
			$('#newspage'+newscurrent+'').fadeIn();
		});
		$("#newsbar #prev").click(function()
		{
			$('#newspage'+newscurrent).hide();
			if (newscurrent == 0) { newscurrent = newspages; }
			else { newscurrent = newscurrent - 1; }
			$('#newsdisplay'+newscurrent+' span').html( ((newscurrent*10)+1) + " - " + ((newscurrent*10) + $('#newspage'+newscurrent+' .searchitem').size()) );
			$('#newspage'+newscurrent+'').fadeIn();
		});
	}
	else 
	{
		$('#newsdisplay0 span').html( '1 - ' + $('#newspage0 .searchitem').size() );
		$('#newspage0').fadeIn();
	}
	
	thoughtpages = ($('.thoughtpage').size()) - 1;
	thoughtsize = (thoughtpages - 1) * 10;

	if (thoughtpages > 0)
	{
		$('#thoughtdisplay0 span').html( '1 - ' + $('#thoughtpage0 .searchitem').size() );
		$('#thoughtpage0').fadeIn();
		$('#thoughtbar').show();
		
		$("#thoughtbar #next").click(function()
		{
			$('#thoughtpage'+thoughtcurrent).hide();
			if (thoughtcurrent == thoughtpages) { thoughtcurrent = 0; }
			else { thoughtcurrent = thoughtcurrent + 1; }
			$('#thoughtdisplay'+thoughtcurrent+' span').html( ((thoughtcurrent*10)+1) + " - " + ((thoughtcurrent*10) + $('#thoughtpage'+thoughtcurrent+' .searchitem').size()) );
			$('#thoughtpage'+thoughtcurrent+'').fadeIn();
		});
		$("#thoughtbar #prev").click(function()
		{
			$('#thoughtpage'+thoughtcurrent).hide();
			if (thoughtcurrent == 0) { thoughtcurrent = thoughtpages; }
			else { thoughtcurrent = thoughtcurrent - 1; }
			$('#thoughtdisplay'+thoughtcurrent+' span').html( ((thoughtcurrent*10)+1) + " - " + ((thoughtcurrent*10) + $('#thoughtpage'+thoughtcurrent+' .searchitem').size()) );
			$('#thoughtpage'+thoughtcurrent+'').fadeIn();
		});
	}
	else 
	{
		$('#thoughtdisplay0 span').html( '1 - ' + $('#thoughtpage0 .searchitem').size() );
		$('#thoughtpage0').fadeIn();
	}
	
});
