var animationTime = 300;
var animationStep = 3000;
var currentRun = 0;
var animationTimer = null;

function timeAnimation()
{
    animationTimer = window.setTimeout("animation()", animationStep);
}
function animation()
{
    $("#customerSliderWrapper").mousedown(function() {
        if (animationTimer == null) {
            timeAnimation();
        } else {
            window.clearTimeout(animationTimer);
            animationTimer = null;
        }
    });
    $("#customerSliderWrapper").animate({
        // Entferne bei jedem 5. Lauf einen Pixel, damit Übergang nahtlos
        "left": "-=" + (imageWidth - ((currentRun % 5 == 0) ? 1 : 0)) + "px"
    }, {
        duration: animationTime,
        easing: "linear",
        step: function(now, fx) {
            if (currentRun == anzahlReferenzen) {
                // Reset slider position
                setTimeout("resetSlider()", animationStep);
                currentRun = 0;
            }
        },
        complete: function() {
            timeAnimation();
        }
    });
    currentRun++;
}

function resetSlider()
{
    $('#customerSliderWrapper').css("left", "0px");
}

$(document).ready(timeAnimation);

