function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, mycarousel_itemList.length);
    carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

/**
 * Item html creation helper.
 */

function mycarousel_getItemHTML(item)
{
    return '<img src="' + item.urltexte + '" id="texte_diapo" /><img src="' + item.url + '" width="950" height="235" alt="' + item.title + '" />';
};

function mycarousel_initCallback(carousel)
{
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
	if($('#wrap').length>0)
	{
		$('#wrap')[0].innerHTML='<ul id="mycarousel" class="jcarousel-skin-ie7"></ul>';
		jQuery('#mycarousel').jcarousel({
			wrap: 'circular',
			auto: 4,
			animation:3000,
			scroll:1,
			easing:'linear',
			initCallback: mycarousel_initCallback,
			itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
			itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
		});
	}
});

