/*-----------------------------------------------------------------------------
	Author Spotlight
-----------------------------------------------------------------------------*/
	
	$(document).ready(function() {
	/*-------------------------------------------------------------------------
		
	-------------------------------------------------------------------------*/
		
		var toggleSlides = function(direction) {
			var active = $('#cta-authorspotlight li.active');
			
			if (direction == 'prev') {
				var next = active.prev(':last');
			} else {
				var next = active.next(':first');
			}
			
			if (next.length == 0) return;
			
			active
				.fadeOut()
				.removeClass('active');
				
			next
				.fadeIn()
				.addClass('active');
				
			toggleArrows();
		}
		
		var toggleArrows = function() {
			var active = $('#cta-authorspotlight li.active');
			
			// Hide the prev arrow:
			if (active.prev().length == 0) {
				$('#cta-authorspotlight .prev').fadeOut();
				
			} else {
				$('#cta-authorspotlight .prev').fadeIn();
			}
			
			// Hide the next arrow:
			if (active.next().length == 0) {
				$('#cta-authorspotlight .next').fadeOut();
				
			} else {
				$('#cta-authorspotlight .next').fadeIn();
			}
			
			$('#cta-authorspotlight').focus();
		}
		
		// Hide all authors, except the first:
		$('#cta-authorspotlight li').hide();
		$('#cta-authorspotlight li:first').show().addClass('active');
		
		// Add prev next links:
		//$('#cta-authorspotlight').append('<a style="display: none;" class="next" href="#">Next</a>');
		//$('#cta-authorspotlight').append('<a style="display: none;" class="prev" href="#">Previous</a>');
		
		// Give next slide focus:
		$('#cta-authorspotlight .next').click(function() {
			toggleSlides('next');
			
			return false;
		});
		
		// Give prev slide focus:
		$('#cta-authorspotlight .prev').click(function() {
			toggleSlides('prev');
			
			return false;
		});
		
		toggleArrows();
	});
	
/*---------------------------------------------------------------------------*/