$(document).ready(function() {

	//Set Default State of each portfolio piece
		$(".paging div:first").addClass("active");
		$(".dots div:first").addClass("active");
	
	//Get size of images, how many there are, then determin the size of the image reel.
	var imageWidth = $(".complete").width();
	var imageSum = $(".image_reel img").size();
	var imageReelWidth = 2400;
	
	//Adjust the image reel to its new size
	$(".image_reel").css({'width' : 2400});
	
	//Paging + Slider Function
	rotate = function(){	
		var triggerID = $active.attr("biolifesolutions") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * 800; //Determines the distance the image reel needs to slide

		$(".paging div").removeClass('active'); //Remove all active class
		$(".dots div").removeClass('active'); //Remove all active class

		$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
		//Slider Animation
		$(".image_reel").animate({ 
			left: -image_reelPosition
		}, 400 );
		
	}; 
	
		
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			$active = $('.paging div.active, .dots div.active').next();
			if ( $active.length === 0) { //If paging reaches the end...
				$active = $('.paging div:first, .dots div.active'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, 700000000); //Timer speed in milliseconds
		};
	
	rotateSwitch(); //Run function on launch
	
	//On Hover
	$(".image_reel").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	

	$(".uno").click(function() {	
		$active = $(".dos, .two") //Activate the clicked paging
		clearInterval(play);
		rotate(); 
		rotateSwitch(); 
	});	

		$(".dos").click(function() {	
		$active = $(".tres, .three") //Activate the clicked paging
		clearInterval(play);
		rotate(); 
		rotateSwitch(); 
	});	

		$(".tres").click(function() {	
		$active = $(".uno, .one") 
		clearInterval(play);
		rotate(); 
		rotateSwitch(); 
	});	

		$(".one").click(function() {	
		$active = $(".uno, .one") 
		clearInterval(play);
		rotate(); 
		rotateSwitch(); 
	});	

		$(".two").click(function() {	
		$active = $(".dos, .two") //Activate the clicked paging
		clearInterval(play);
		rotate(); 
		rotateSwitch(); 
	});	

		$(".three").click(function() {	
		$active = $(".tres, .three") 
		clearInterval(play);
		rotate(); 
		rotateSwitch(); 
	});	


});



