$(function() {
    $('#carousel .itm').each(function() {
        $(this).data('orig_left', $(this).css('left'));
        $(this).data('max_right', 950 - $(this).width());
    });
    $('body').not('#IE').find( '#carousel h3' ).each(function() {
        $(this).text( $(this).text().split( 'O' ).join( '0' ) );
    });
    $('#carousel .large img').reflect({
        opacity: 0.3
    });
    $('#carousel').carouFredSel({
        items: 1,
        auto: {
            pauseDuration: 5000
        },
        scroll: {
            duration: 600,
            pauseOnHover: true,
            onBefore: function( oI, nI ) {
                $($('.itm', oI).get().reverse()).stop().each(function(i) {
                    $(this).delay(80*i).animate({
                        left: 20
                    }, 400);
                });
                $('.itm', nI).stop().each(function() {
                    $(this).css({
                        left: $(this).data('max_right')
                    });
                }).delay(200).each(function(i) {
                    $(this).delay(80*i).animate({
                        left: $(this).data('orig_left')
                    }, 400);
                });
            }
        },
        prev: {
            button: '#header a.prev',
            onBefore: function( oI, nI ) {
                $($('.itm', oI).get().reverse()).stop().each(function(i) {
                    $(this).delay(80*i).animate({
                        left: $(this).data('max_right')
                    }, 400);
                });
                $($('.itm', nI).get().reverse()).stop().css({
                    left: 20
                }).delay(200).each(function(i) {
                    $(this).delay(80*i).animate({
                        left: $(this).data('orig_left')
                    }, 400);
                });
            }
        },
        next: {
            button: '#header a.next'
        }
    });
});
