$(document).ready(function()
{
	/*-------------------------------------------    
  		Featured Ghale
	-------------------------------------------*/
	$('div.coda').each(function()
	{
		// scope the coda
		var $coda = $(this);
		
		// hide extras
		$coda.find('ul.featured > li:gt(4)').hide();
		
		// store page
		$coda.attr('page', '1');
		
		// make the previous work
		$coda.find('a.previous').click(function()
		{
			var page = parseInt($coda.attr('page'))-1;
			if (page == 0) { return false; }
			
			$coda.attr('page', page);
			$coda.find('ul.featured > li').show();
			$coda.find('ul.featured > li:gt('+((page*5)-1)+')').hide();
			
			$coda.find('ul.featured > li:eq('+((page*5)-5)+')').addClass('first');
			$coda.find('ul.featured > li:lt('+((page*5)-5)+')').hide();
			return false;
		});
		
		// make the next work
		$coda.find('a.next').click(function()
		{
			var page = parseInt($coda.attr('page'))+1;
			
			var num = $coda.find('ul.featured > li').size();
			var spillover = num%5;
			var maxPage = Math.floor(num/5)+(spillover!=0?1:0);
			
			if (page > maxPage) { return false; }
			
			$coda.attr('page', page);
			$coda.find('ul.featured > li').show();
			$coda.find('ul.featured > li:gt('+((page*5)-1)+')').hide();
			
			$coda.find('ul.featured > li:eq('+((page*5)-5)+')').addClass('first');
			$coda.find('ul.featured > li:lt('+((page*5)-5)+')').hide();
			return false;
		});
	});

	
});




