function slide_home(){
    var $ = jQuery,
        current = 0,
        $itens = $("#destaque .slide .reel .item"),
        $reel = $("#destaque .slide .reel"),

        itensWidth = 646,
        itemSum = $itens.size(),

        reelWidth = itensWidth * itemSum;

        

    if(itemSum < 2){
        $reel.css({
            'width' : itensWidth
        });
        return;
    }

    $reel.css({
        'width' : reelWidth
    });

    var rotate = function(c){

        if(c == -itemSum){
            c = 0;
            current = 0;
        }
        if(c > 0){
            c = 0;
            current = 0;
        }

        $reel.animate({
            left: c * itensWidth
        }, 700);

        current = c;
    };

    function next(){
        rotate(--current);
        return false;
    }

    function preview(){
        rotate(++current);
        return false;
    }

    setInterval(function(){
        rotate(--current);
    }, 10000);
}

(function($){

    $(document).ready(function(){
        slide_home();
    });

})(jQuery);
