$(document).ready(function() {
	//Show the paging and activate its first link

$(".paging2").show();
$(".paging2 a:first").addClass("active");

//Get size of the image, how many images there are, then determin the size of the image reel.

var imageWidthAlt = $(".window2").width();

var imageSumAlt = $(".image_reel2 img").size();
var imageReelWidthAlt = imageWidthAlt * imageSumAlt;

//Adjust the image reel to its new size

$(".image_reel2").css({'width' : imageReelWidthAlt});

//Paging  and Slider Function
rotateAlt = function(){
    var triggerIDAlt = $active.attr("rel") - 1; //Get number of times to slide
    var image_reelPositionAlt = triggerIDAlt * imageWidthAlt; //Determines the distance the image reel needs to slide

  
	 $(".paging2 a").removeClass('active'); //Remove all active class
    $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitchAlt function)


   
	//Slider Animation
    $(".image_reel2").animate({
        right: -image_reelPositionAlt
    }, 500 );

}; 

//Rotation  and Timing Event

rotateSwitchAlt = function(){
    play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
        $active = $('.paging2 a.active').next(); //Move to the next paging
        if ( $active.length === 0) { //If paging reaches the end...
            $active = $('.paging2 a:first'); //go back to first
        }
        rotateAlt(); //Trigger the paging and slider function
    }, 7000); //Timer speed in milliseconds (7 seconds)
};

rotateSwitchAlt(); //Run function on launch

//On Hover
$(".image_reel2 a").hover(function() {
    clearInterval(play); //Stop the rotation
}, function() {
    rotateSwitchAlt(); //Resume rotation timer
});	

//On Click


$(".paging2 a").click(function() {
    $active = $(this); //Activate the clicked paging
    //Reset Timer
    clearInterval(play); //Stop the rotation
    rotateAlt(); //Trigger rotation immediately
    rotateSwitchAlt(); // Resume rotation timer
    return false; //Prevent browser jump to link anchor
});


});
