function Carousel(config) {
	
	this.parameters = { start: 0, count: 5 };
	this.last_item_count = 2;
	
	if (config.count)
		{
		this.parameters.count = config.count;
		}
	
	this.load = function() {
		var self = this;
		
		if (config.ajax_loader_html)	{
			config.container.html(config.ajax_loader_html);
		}

		if (config.ajax_loader)	{
			config.container.html(config.ajax_loader.html());
		}
		
		jQuery.getJSON(config.request_url, this.parameters, function(data) {
			var height = config.container.height();
			var width = config.container.width();
			config.container.html("<div>Chargement en cours</div>");
			self.last_item_count = data.items.length;
			
			var items = data.items;
			var nhtml = "<div style='overflow:hidden;'><div class='carousel-content' style='overflow:hidden;position:relative;'>"; 
			$j.each(items, function(index,item) {
					var id = unique_id.create();
					var giftmood = unique_id.create();
					var giftidea = unique_id.create();
					item.meta = {dom: { id: id }, mood: giftmood, idea: giftidea };
					var html = new EJS({text: data.template}).render(item);
					//var inst = target.append(html);
					nhtml += html;
				});
			nhtml += "</div></div>";
			config.container.html(nhtml);
			if (self.parameters.start == 0)	{
				config.left.css("cursor", "default" );
			} else {
				config.left.css("cursor", "pointer" );
			}
			if (self.last_item_count == self.parameters.count) {
				config.right.css("cursor", "pointer" );
			} else {
				config.right.css("cursor", "default" );
			}
			
			$j.each(items, function(index,item) {
				$j("#"+item.meta.mood).click(function() {
					window.modalw.show("/root/partial/add_gift_wish.php?id="+item.id+"&amp;backurl="+escape(window.location.href));
					return false;
				});
				$j("#"+item.meta.idea).click(function() {
					window.modalw.show("/root/partial/add_gift_idea.php?id="+item.id+"&backurl="+escape(window.location.href));
					return false;
				});

			});
		});
	}

	this.move_right = function(callback) {
		config.container.children("div").children("div.carousel-content").animate({left: config.container.width()}, 300, callback);
	};
	this.move_left = function(callback) {
		config.container.children("div").children("div.carousel-content").animate({left: -config.container.width()}, 300, callback);
	};
	
	if (config.left) {
		var self = this;
		config.left.click(function() { if (self.parameters.start>0) { self.move_right(function() { self.parameters.start -= 5; self.load(); }); }  });
	}

	if (config.right) {
		var self = this;
		config.right.click(function() { if (self.last_item_count == self.parameters.count) { self.move_left(function() { self.parameters.start += 5; self.load(); }); } });
	}

	this.load();
}
