var counter = 0;
var forward = true; 
var to;
 
function test() {
    if(counter == 4) forward=false;
    else if(counter == 0) forward=true; 
    
    if(forward) {
        $(".carousel .wrapper").animate({left: "-=673px"}, 600, "easeOutCubic" );
        $(".carousel .wrapper1").animate({top: "-=253px"}, 600, "easeOutCubic" );
        counter++;
    } else if(!forward) {
        $(".carousel .wrapper").animate({left: "+=673px"}, 600, "easeOutCubic" );
        $(".carousel .wrapper1").animate({top: "+=253px"}, 600, "easeOutCubic" );
        counter--;
    }
    to = setTimeout("test()",5000)
}

$(document).ready(function () {
    to = setTimeout("test()",5000); 
    $(".arrow_left").click(function() {
        clearTimeout(to);
        //$(".logo").append(($(".wrapper:animated").size()));
        if($(".carousel .wrapper").position().left < 0 && $(".wrapper:animated").size() == 0) {
            $(".carousel .wrapper").animate({left: "+=673px"}, 600, "easeOutCubic" );
            $(".carousel .wrapper1").animate({top: "+=253px"}, 600, "easeOutCubic" );
        }
    }); 
    $(".arrow_right").click(function() {
        clearTimeout(to);
        if($(".carousel .wrapper").position().left > -2692 && $(".wrapper:animated").size() == 0) {
            $(".carousel .wrapper").animate({left: "-=673px"}, 600, "easeOutCubic" );
            $(".carousel .wrapper1").animate({top: "-=253px"}, 600, "easeOutCubic" );
        }
    }); 
});