$(document).ready(function() {

    $('#carousel li').each(function(i){
        $('<li><a href="#">'+(i+1)+'</a></li>').appendTo('#carousel-control');
    });
    
    /*
    Note:
    Everything that's commented pertains to the flash/javascript animation transition.
    Do not delete, in case you ever want this functionality back.
    */

	/*
    var delay = 20;
    setTimeout(function(){
        revealSlideshow();
    }, (delay*1000));
	*/

    var jcarousel;
    $('#carousel').jcarousel({
		wrap: 'circular',
		visible: 1,
		scroll: 1,
		auto: 5,
		initCallback: function(carousel){
            jcarousel = carousel;
            $('#carousel-control a').bind('click', function() {
                carousel.scroll($.jcarousel.intval($(this).text()));
                return false;
            });
            //carousel.stopAuto();
		},
        itemVisibleInCallback: {
            onBeforeAnimation: function(carousel, item, idx, state){
                idx = ((idx - 1) % $('#carousel-control a').length);
                $('#carousel-caption').html($('#carousel img:eq('+idx+')').attr('title'));
                $('#carousel-control a').removeClass('current');
                $('#carousel-control a:eq('+idx+')').addClass('current');
            }
        },
		buttonPrevHTML: 'null',
		buttonNextHTML: 'null'
    });
    
	/*
    $('.flash-skip').click(function(){
        revealSlideshow();
    });
    
    function revealSlideshow() {
        $('#flash_content').fadeOut('slow');
        jcarousel.startAuto();
    }
	*/

});

