﻿// JScript File    
    var secs
    var timerID = null
    var timerRunning = false
    var delay = 1000
    
    //Length Each image stays on the screen in Seconds
    var imgLength = 12;
    
    //Enter Image urls
    //links[0] = "/LeadershipInstitute/";
    //links[1] = "/communities/";
    //links[2] = "/Membership/VolunteerConnect/";
    //links[3] = "/Education/";
    
    //_________________________________________________________________________

    InitializeTimer();

    function showImage(X)
    {
        var textArea = document.getElementById("RotatorInfo");
        var MainArea = document.getElementById("mainRotator");
        MainArea.style.display = "none";
        textArea.style.display = "none";
        
        MainArea.innerHTML = "<a href='" + links[X] + "'><img src='" + gallery[X].src + "' style='border:0px;' /></a>";
        textArea.innerHTML = Text[X];
        
        Effect.Appear("mainRotator", {queue: 'end'});
        Effect.Appear('RotatorInfo', {queue: 'end'});
    }
    
    function goToImage(X)
    {
        StopTheClock();
        
        showImage(X);
    }

    function InitializeTimer()
    {
        secs = imgLength;
        
        showImage(counter);
        if(total > 1)
        {
            StopTheClock()
            StartTheTimer()
        }
    }
    function StopTheClock()
    {
        if(timerRunning)
            clearTimeout(timerID)
        timerRunning = false
    }
    function StartTheTimer()
    {
        if (secs==0)
        {
            secs = imgLength;
            counter++;
            if(counter == total)
            {
                counter = 0;
            }
            showImage(counter);
            StartTheTimer();
        }
        else
        {
            secs = secs - 1
            timerRunning = true
            timerID = self.setTimeout("StartTheTimer()", delay)
        }
    }
