var cycleTime = 2000;
var animTime = 300;
var infoBoxAnimTime = 500;
var infoBoxes, carousel, imgContainer, nextBtn, prevBtn, timer, imgWidth, inProgress;

function moveLeft() {
    currLeft = 0;
    newLeft = currLeft - imgWidth;
    imgContainer.animate({
        left: newLeft
    }, animTime, function () {
        $(this).find("li:first").appendTo(this);
        $(this).css("left", currLeft);
    });
}

function moveRight() {
    currLeft = 0;
    imgContainer.find("li:last").prependTo(imgContainer);
    imgContainer.css("left", currLeft - imgWidth);

    newLeft = currLeft;
	//alert(newLeft);
	
    imgContainer.animate({
        left: newLeft
    }, animTime, function () {
    });
}
function startTimer() {
    return timer = setInterval(moveLeft, cycleTime);
}
function restartTimer() {
    clearInterval(timer);
    return startTimer();
}
$(function () {
    // Private
    carousel = $("#cus_carousel");
    imgContainer = $("ul", carousel);
    nextBtn = $(".next");
    prevBtn = $(".prev");
    timer = null;
    imgWidth = 129;

    prevBtn.click(function (e) {
        e.preventDefault();
        e.stopPropagation();
        moveRight();
    });

    nextBtn.click(function (e) {
        e.preventDefault();
        e.stopPropagation();
        moveLeft();
    });
	
    imgContainer.css("left");
});
