/**
 * Platform jCarousel Looping Code
 * @author Dylan
 * @published 03/01/2010
 */
(function($) {
	$.fn.jcarouselLoop = function(options) {
		settings = jQuery.extend({}, options);
		return this.each(function() {
			var images = new Array();
			$(this).find('li').each(function(){ images.push( $(this) ) });
			$(this).find('li').remove();
			$(this).data( 'images', images );
			options.itemVisibleInCallback = {onBeforeAnimation:itemVisibleInCallback}
			options.itemVisibleOutCallback = {onAfterAnimation:itemVisibleOutCallback}
			$(this).jcarousel(options);
		});
	}
	var itemVisibleInCallback = function(carousel, item, i){
		var images = $(item).parent().data( 'images');
		carousel.add(i, images[(carousel.index(i, images.length))-1].html());
	}
	var itemVisibleOutCallback = function(carousel, item, i){
		carousel.remove(i);
	}
})(jQuery);