﻿  var currentState = 1;
         var currentLeft = 11;
         var transitionAmount = 507;
         var timeOut;
         
         animateToTarget = function() {
            
            $(".bulletActive").attr("class","bulletInactive");
            $("#Bullet"+currentState).attr("class","bulletActive");
            $("#AnimationContainer").animate({left:(""+currentLeft+"px")},1000);
            if(currentState == 1)
            {
                $("#LeftArrow").attr("class","inactive arrow");
            }
            else
            {
                $("#LeftArrow").attr("class","arrow");
            }
            
            if(currentState == 4)
            {
                $("#RightArrow").attr("class","inactive arrow");
            }
            else
            {
                $("#RightArrow").attr("class","arrow");
            }
         }
         
         arrowRight = function (cto) {
            if(currentState == 4)
            {
                return false;
            }
            clearTimeout(timeOut);
            currentState++;
            currentLeft = currentLeft - transitionAmount;
            animateToTarget();
            return false;
         }
         
         arrowLeft = function () {
            if(currentState == 1)
            {
                return false;
            }
            clearTimeout(timeOut);
            currentState--;
            currentLeft = currentLeft + transitionAmount;
            animateToTarget();
            return false;
         }
         
         onTimeout = function(){
            if(currentState == 4)
            {
                return false;
            }
            currentState++;
            currentLeft = currentLeft - transitionAmount;
            animateToTarget();
            timeOut = setTimeout("onTimeout()",10000);
         }
         
         $(document).ready(function() {
            var currentState = 1;
            $("#LeftArrow").click(arrowLeft);
            $("#RightArrow").click(arrowRight);
            $(".highlight").bind("mouseenter", function(){clearTimeout(timeOut)});
            timeOut = setTimeout("onTimeout()",10000);
         })
