function mycarousel_itemLoadCallback(carousel, state)
{
    // Since we get all URLs in one file, we simply add all items
    // at once and set the size accordingly.
    if (state != 'init')
        return;

    jQuery.get('/?alttemplate=CarouselAjax', function(data) {
        mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
    });
     
};

function mycarousel_itemAddCallback(carousel, first, last, data)
{
    // Simply add all items at once and set the size accordingly.
    var items = data.split('|');

    for (i = 0; i < items.length; i++) {
        carousel.add(i+1, mycarousel_getItemHTML(items[i]));
    }

    carousel.size(items.length);


    Cufon.replace('#mycarousel h4', { fontFamily: 'ItalianPlate' });
    Cufon.replace('#mycarousel h5', { fontFamily: 'Komika' });
	$('#mycarousel ul li').mouseover(function() {
	$(this).children('.carouseRollover').show();
});

  $('#mycarousel ul li').mouseleave(function() {
  $(this).children('.carouseRollover').hide();
});



  $('#mycarousel').mouseleave(function() {
  $('.carouseRollover').hide('fast');
});

};

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();
    });
    
};


/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(url)
{
    return url;
};

function mycarousel_itemVisibleInCallbackBeforeAnimation(carousel, item, idx, state) {
    // No animation on first load of the carousel
    if (state == 'init')
        return;

    jQuery('a', item).fadeIn('fast');
};

function mycarousel_itemVisibleOutCallbackBeforeAnimation(carousel, item, idx, state) {
    if (state == 'init')
        return;
    jQuery('a', item).fadeOut('fast');
};



jQuery(document).ready(function() {


jQuery('#newsCarousel').jcarousel({

	wrap: 'both', 
    scroll: 4,
	animation: 'fast'
}
);

jQuery('#imgCarousel').jcarousel({

	wrap: 'both', 
    scroll: 4,
	animation: 'fast'
}




);


    jQuery('#mycarousel').jcarousel({
	wrap: 'both',
	scroll: 4,
	animation: 'fast',
	
	
    itemLoadCallback: mycarousel_itemLoadCallback,
	 initCallback: mycarousel_initCallback,  
	 itemVisibleInCallback: {
            onBeforeAnimation: mycarousel_itemVisibleInCallbackBeforeAnimation
         
        },
		 itemVisibleOutCallback: {
            onBeforeAnimation: mycarousel_itemVisibleOutCallbackBeforeAnimation
        }


    });
   
});

