// this array consists of the id attributes of the divs we wish to alternate between
var divs_to_fade = new Array('box-1', 'box-2', 'box-3', 'box-4');

var i = 0;

// the number of milliseconds between swaps.  Default is five seconds.
var wait = 6000;

// the function that performs the fade
function swapFadeIn() {
	i++;
	if (i == divs_to_fade.length)
		i = 0;
	$('#'+divs_to_fade[i]).fadeIn();
}

function swapFadeOut() {
	$('#'+divs_to_fade[i]).fadeOut();
        swapFadeIn();
}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

$(document).ready(function(){
	setInterval('swapFadeOut()',wait);
	//setInterval('swapFadeIn()', wait);

        $('#eventcarousel').jcarousel({
        auto: 6,
        scroll: 1, 
        wrap: 'circular',
        buttonNextHTML: null,
        buttonPrevHTML: null, 
        initCallback: mycarousel_initCallback
    });
});
