

$(document).ready(function() 
{
	var fadeDuration = 2000;	
	
	$(".textSlider li").hide();
	$(".textSlider li:first").addClass("active");
	//$(".textSlider li.active").fadeIn(fadeDuration);
	$(".textSlider li.active").show();
	
	
	
	$(".pager li:first").addClass("active");
	$(".pager li.active a").css('background-position', 'bottom');

	//$(".pager > li.active").next().css('border', '1px dashed red');
	//$activeDot = $(".pager > li.active").next()
	//$activeDot.css('border', '1px dashed red');
	//$activeDot.addClass("active");
	//$(".pager li.active a").css('background-position', 'bottom');
	//$(".pager > li.active").next().css('background-position', 'top right');
	

	
	rotate = function()
	{//Paging  and Slider Function
		$(".textSlider li").hide();
		$(".textSlider li.active").removeClass('active'); //Remove all active class
		$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		$(".textSlider li.active").fadeIn(fadeDuration);
		
		$(".pager li.active a").css('background-position', 'top');
		$(".pager li").removeClass('active'); //Remove all active class
		$activeDot.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		$(".pager li.active a").css('background-position', 'bottom');
		
	}; 


	
	rotateSwitch = function()
	{//Rotation  and Timing Event
		play = setInterval(function()
		{ //Set timer - this will repeat itself
			$active = $('.textSlider li.active').next(); //Move to the next paging
			$activeDot = $(".pager > li.active").next()
			
			if ( $active.length == 0) 
			{ //If paging reaches the end...
				$active = $('.textSlider li:first'); //go back to first
				$activeDot = $(".pager li:first").addClass("active");
			}
			
			rotate(); //Trigger the paging and slider function
		}, 5000);//Timer speed in milliseconds (1000 = 1 second)
	};
	
	//textSlide Hover
	$(".textSlider li").hover(function() 
		{
			clearInterval(play); //Stop the animation
		}, function() {
			rotateSwitch(); //Resume rotation timer
	});
	
	
	rotateSwitch(); //Run function on launch
});	

