function Carousel(carouselObject, carouselCallback) {
	this.object = carouselObject;
	this.ul = jQuery(this.object).children().first();
	this.moving = false;
	this.itemWidth = 60;
	this.itemHeight = 90;
	this.itemMargin = 10;
	this.itemsToScroll = 4;
	this.scrollSpeed = 2000;
	this.callback = carouselCallback;

	this.scrollSize = function() {
		return this.itemsToScroll * (this.itemWidth + this.itemMargin);
	}

	this.itemCount = function() {
		return jQuery(this.object).children("ul").children().size();
	}

	this.move_left = function() {
		if (!this.moving) {
			this.moving = true;

			var carousel = this;

			jQuery(this.ul).animate( {
				left : "-=" + carousel.scrollSize()
			}, carousel.scrollSpeed, function() {
				jQuery(this).animate( {
					left : "+=" + carousel.scrollSize()
				}, 0);
				for ( var i = 0; i < carousel.itemsToScroll; i++) {
					var item = jQuery(carousel.ul).children("li").first();
					var itemCopy = jQuery(item).clone();
					jQuery(carousel.ul).append(itemCopy);
					jQuery(itemCopy).each(carousel.callback);
					jQuery(item).remove();
				}
				carousel.moving = false;
			});
		}
	}

	this.move_right = function() {
		if (!this.moving) {
			this.moving = true;

			var carousel = this;

			jQuery(this.ul).animate( {
				left : "+=" + carousel.scrollSize()
			}, carousel.scrollSpeed, function() {
				jQuery(this).animate( {
					left : "-=" + carousel.scrollSize()
				}, 0);
				for ( var i = 0; i < carousel.itemsToScroll; i++) {
					var item = jQuery(carousel.ul).children("li").last();
					var itemCopy = jQuery(item).clone();
					jQuery(carousel.ul).prepend(itemCopy);
					jQuery(itemCopy).each(carousel.callback);
					jQuery(item).remove();
				}
				carousel.moving = false;
			});
		}
	}

	var itemsDisplayed = Math.round((jQuery(this.object).width() / (this.itemWidth + this.itemMargin)) + 0.5);

	var itemCount = jQuery(this.ul).children("li").size();

	while (itemCount < itemsDisplayed + this.itemsToScroll + this.itemsToScroll) {
		// Add extra items if we don't have enough
		for ( var i = 0; i < itemCount; i++) {
			var item = jQuery(this.ul).children("li").get(i);
			jQuery(this.ul).append(jQuery(item).clone());
		}
		itemCount = jQuery(this.ul).children("li").size();
	}
	var width = itemCount * (this.itemWidth + this.itemMargin);

	jQuery(this.ul).children("li").css( {
		width : this.itemWidth,
		height : this.itemHeight,
		"margin-right" : this.itemMargin
	});
	jQuery(this.ul).css( {
		width : width,
		height : this.itemHeight
	});

	jQuery(this.ul).animate(
		{left : '-=' + this.scrollSize()},
		0
	);
	
	for ( var i = 0; i < this.itemsToScroll; i++) {
		var lastItem = jQuery(this.ul).children("li").last();
		jQuery(this.ul).prepend(jQuery(lastItem).clone());
		jQuery(lastItem).remove();
	}
	
	jQuery(this.ul).children("li").each(this.callback);
}
