// JavaScript Document
var articleIndex = 0;
var videoIndex = 0;

$(document).ready(function(){
	var articleCount = $("#article-items > .article-item").length;
	var videoCount = $("#video-items > .video-item").length;
	
	$('.article-item:eq(0)').show();
	$('.video-item:eq(0)').show();
	
	$('#article-prev').click(function(e){
		e.preventDefault();
		
		// If the user isn't on the first item, then hide the current item,
		// decrement the counter, and show the item related to the counter.
		if (articleIndex > 0)
		{
			// Hide the existing item
			$('.article-item:eq(' + articleIndex + ')').hide(500);
			articleIndex --;
			
			$('.article-item:eq(' + articleIndex + ')').show(500);
		}
	});
	
	$('#article-next').click(function(e){
		e.preventDefault();
		
		// If the user isn't on the first item, then hide the current item,
		// decrement the counter, and show the item related to the counter.
		if (articleIndex < articleCount - 1)
		{
			// Hide the existing item
			$('.article-item:eq(' + articleIndex + ')').hide(500);
			articleIndex ++;
			
			$('.article-item:eq(' + articleIndex + ')').show(500);
		}
	});
	
	$('#video-prev').click(function(e){
		e.preventDefault();
		
		// If the user isn't on the first item, then hide the current item,
		// decrement the counter, and show the item related to the counter.
		if (videoIndex > 0)
		{
			// Hide the existing item
			$('.video-item:eq(' + videoIndex + ')').hide(500);
			videoIndex --;
			
			$('.video-item:eq(' + videoIndex + ')').show(500);
		}
	});
	
	$('#video-next').click(function(e){
		e.preventDefault();
		
		// If the user isn't on the first item, then hide the current item,
		// decrement the counter, and show the item related to the counter.
		if (videoIndex < videoCount - 1)
		{
			// Hide the existing item
			$('.video-item:eq(' + videoIndex + ')').hide(500);
			videoIndex ++;
			
			$('.video-item:eq(' + videoIndex + ')').show(500);
		}
	});
});