include('http://'+servername+'/includes/js/jquery/newsticker.js');

$(document).ready(function() {
        $(".paging").show();
        $(".paging a:first").addClass("active");

        //Get size of the image, how many images there are, then determin the size of the image reel.
        var imageWidth = $(".window").width();
        var imageSum = $(".image_reel img").size();
        var imageReelWidth = imageWidth * imageSum;

        //Adjust the image reel to its new size
        $(".image_reel").css({'width' : imageReelWidth});



        //Paging  and Slider Function
        rotate = function(){
                var triggerID = $active.attr("rel") - 1; //Get number of times to slide
                //Determines the distance the image reel needs to slide
                var image_reelPosition = triggerID * imageWidth;

                $(".paging a").removeClass('active'); //Remove all active class
                $(".paging a img").removeClass('imgactive');

                $active.addClass('active');
                $(".paging a.active img").addClass('imgactive');

                $(".image_reel").clearQueue();
                $(".image_reel").fadeOut("slow");
                $(".image_reel").animate({ left: -image_reelPosition }, 0 );
                $(".image_reel").fadeIn("slow");

        };


        //Rotation  and Timing Event
        rotateSwitch = function(){

                //Set timer - this will repeat itself every 7 seconds
                play = setInterval(function(){

                        //Move to the next paging
                        $active = $('.paging a.active').next();

                        //If paging reaches the end...
                        if ( $active.length === 0) {

                                //go back to first
                                $active = $('.paging a:first');
                        }
                        rotate(); //Trigger the paging and slider function
                }, 8000); //Timer speed in milliseconds (7 seconds)
        };



        rotateSwitch(); //Run function on launch



        //On Click
        $(".paging a").click(function() {
                $active = $(this); //Activate the clicked paging
                //Reset Timer
                clearInterval(play); //Stop the rotation
                rotate(); //Trigger rotation immediately
                rotateSwitch(); // Resume rotation timer
                return false; //Prevent browser jump to link anchor
        });

                $('#newsticker').list_ticker({
                        speed:6000,
                        effect:'fade'
                });

});

