function slideShow(){

	// Sets the first link and image randomly on load
	//var randomNumber = Math.floor(Math.random()*4) // gets number between 0 and 3
	//randomNumber = randomNumber + 1; // makes it so the number is between 1 and 4
	var randomNumber = 5;
	var startingLink = '#link' + randomNumber;
	var startingSlide = '#slide' + randomNumber;
	$(startingLink).addClass('active');
	$(startingSlide).show();

	// Handles the onclick function for the numbers
	$('.slide-nav li a').click(function(){

		// Stop the cycle
		clearInterval(cycle);

		$('.slide-show li').fadeOut('slow');
		$('.slide-nav li a').removeClass('active');
		$(this).addClass('active');

		// get id of clicked link
		var currentId = $(this).attr('id');
		currentId = currentId.substring(4);

		var showSlide = '#slide' + currentId;
		$(showSlide).fadeIn('slow');

	});


	// Handles the onclick function for the next button
	$('#btn-next').click(function(){

		// Stop the cycle
		clearInterval(cycle);	

		// Get the current active selection
		var currentActive = $('.active').attr('id');
		currentActive = currentActive.substring(4);
		currentActive = parseInt(currentActive);
		var nextActive = currentActive + 1;

		
		// If it's at the end, it starts over
		if (currentActive > totalLinks){
			currentActive = 1;
		} 
		
		var showSlide = '#slide' + currentActive;
		$(showSlide).fadeIn('slow');

		var activeLink = '#link' + currentActive;

		// Remove class of the current active
		$('.slide-nav li a').removeClass('active');
		// Set class of new active
		$(activeLink).addClass('active');

	});

	// Handles the onclick function for the previous
	$('#btn-previous').click(function(){
		
		// Stop the cycle
		clearInterval(cycle);

		// fade out the other slides first
		$('.slide-show li').fadeOut('slow');

		// Get the current active selection
		var currentActive = $('.active').attr('id');
		currentActive = currentActive.substring(4);
		currentActive = parseInt(currentActive);
		var nextActive = currentActive - 1;
		
		// If it's at the beginning, it goes to the end
		if (nextActive == 0){
			nextActive = totalLinks;
		} 
		
		var showSlide = '#slide' + nextActive;
		$(showSlide).fadeIn('slow');

		var activeLink = '#link' + nextActive;

		// Remove class of the current active
		$('.slide-nav li a').removeClass('active');
		// Set class of new active
		$(activeLink).addClass('active');

	});
};

var cycle = setInterval("cycleSlides()", 8000);
function cycleSlides(){
	// fade out the other slides first
	$('.slide-show li').fadeOut('slow');

	// Get the current active selection
	var currentActive = $('.active').attr('id');
	currentActive = currentActive.substring(4);
	currentActive = parseInt(currentActive);
	var nextActive = currentActive + 1;
	
	
	// If it's at the end, it starts over
	if (nextActive > totalLinks){
		nextActive = 1;
	} 
	
	var showSlide = '#slide' + nextActive;
	$(showSlide).fadeIn('slow');

	var activeLink = '#link' + nextActive;

	// Remove class of the current active
	$('.slide-nav li a').removeClass('active');
	// Set class of new active
	$(activeLink).addClass('active');					
}

