$(document).ready(function() {
    $('#slideshow-container').cycle({
        fx: 'fade',
        timeout: 5000,
        delay: 500,
        sync: true,
        before: updatePager
    });

    $("#slideshow-subnav ul li").click(function(e) {
        $("#slideshow-container").cycle(parseInt($(this).data('slide')) - 1);
        $("#slideshow-container").cycle("pause");
    });

    function updatePager()
    {
        $("#slideshow-subnav ul li").removeClass("active");
        $("#slideshow-subnav ul li[data-slide='" + $(this).data("slide") + "']").switchClass(null, "active", 500);
    }

    /*var hasmoved = false;
    function doAnimate() { $("#banner").animate({ width: '213px' }, 'slow', moveLeft); }
    function moveLeft()  { $("#banner").animate({ right: '125px' }, 'slow', moveRight); }
    function moveRight() { if(!hasmoved) { $("#banner").animate({ right: '75px' }, 'slow', moveLeft); } hasmoved = true; }

    doAnimate();*/

    $(function() {
        var zIndexNumber = 1000;
        $('div').each(function() {
            $(this).css('zIndex', zIndexNumber);
            zIndexNumber -= 10;
        });
    });


    function animateDown()
    {
        $("a#logistica").css("zIndex", "100000");
        $("a#logistica").animate({
            top: "0px"
        }, 1500, 'easeOutBounce');
    }

    function animateUp()
    {
        $("a#logistica").animate({
                top: "-175px"
            },
            1500,
            '',
            function() {
                $("a#logistica").css("zIndex", "0");
        });
    }

    function setAnimate()
    {
        animateDown();
        setTimeout(animateUp, 5000);
    }

    $("a#logistica").show();
    $("a#logistica").css("zIndex", "100000");
    setAnimate();
    $("a#logistica").hoverIntent(animateDown, animateUp);
});
