function mycarousel_initCallback(carousel)
{	
	$("#"+carousel.options.id+' .jcarousel-control a').bind('click', function() {
		carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr( "id" )));
		//carousel.stopAuto();
		return false;
	});
	
	
	$("#"+carousel.options.id+' .jcarousel-control a').hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
	
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

function mycarousel_itemVisibleInCallback(carousel,list,idx)
{
	$("#"+carousel.options.id+' .jcarousel-control').children(".selected").removeClass("selected");
	$("#"+carousel.options.id+' .jcarousel-control').children("#"+idx).addClass( "selected" );
}
/* ----------------------------------------------------------------- */
function bigcarousel_initCallback(carousel, state) {
	$('.jcarousel-control a').bind('click', function() {		
		carousel.scroll($.jcarousel.intval($(this).text()));
        return false;
    });
	
	for (var i = carousel.first; i <= carousel.last; i++) {
        // Check if the item already exists
        if (!carousel.has(i)) {
            // Add the item
            carousel.add(i, "I'm item #" + i);
        }
    }	
};
function bigcarousel_itemVisibleInCallback(carousel,list,idx){	
	$("#"+carousel.options.id+' .jcarousel-control').children(".selected").removeClass("selected");
	$("#"+carousel.options.id+' .jcarousel-control').children("#"+idx).addClass( "selected" );

	$("#"+carousel.options.id+' .jcarousel-labels').children(".selected").removeClass("selected");
	$("#"+carousel.options.id+' .jcarousel-labels').children("#label-"+idx).addClass( "selected" );

}
function bigcarousel_onBeforeAnimation(carousel){}
function bigcarousel_onAfterAnimation(carousel){}
/* ----------------------------------------------------------------- */
function graycarousel_initCallback(carousel, state) {	
	$("#"+carousel.options.id+' .jcarousel-control a').bind('click', function() {
		carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr( "id" )));
		//carousel.stopAuto();
		return false;
	});
	
	$("#"+carousel.options.id+' .jcarousel-control a').hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
	
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });	
};
/* ----------------------------------------------------------------- */

$(document).ready(function() {
	$('.big_carousel').jcarousel({
		id: "big_carousel",
		auto: 5,
		scroll:1,
		wrap: 'last',
		visible: 1,
		itemLoadCallback: {
			  onBeforeAnimation: bigcarousel_onBeforeAnimation,
			  onAfterAnimation: bigcarousel_onAfterAnimation
			},
		initCallback: bigcarousel_initCallback,
		itemVisibleInCallback:bigcarousel_itemVisibleInCallback,
		buttonNextHTML: null,
		buttonPrevHTML: null
	}); 

	$('.gray_carousel').jcarousel({
		id: $(this).attr("id"),
		auto: 5,
		scroll:1,
        wrap: 'last',
		initCallback: graycarousel_initCallback
    });
});
