// var verticarouselHeight = 0;
$(function(){
	//$("#verticarousel").height(0);
	verticarouselHeight = $("#verticarousel li:first").outerHeight();
	
	$("#verticarousel span, #verticarousel h3").wrap("<div>");
	
	$("#verticarousel div div").each(function(){
		$(this).css("width", $(this).width()+"px");
		$(this).css("display", "block");
	});
	if($("#verticarousel li").length > 1){
		scrollContent();
	}
	$("#verticarousel li").click(function(){
		window.location.href = $(".green-button", $(this)).attr("href");
	});
	
	
	
	var image = new Image();
	image.src = $("#verticarousel img:last").attr('src');
	if (image.complete)        
	  imageLoaded();        
	else        
	  image.onload = imageLoaded;
	
});

function imageLoaded(){
	var nbLi = $("#verticarousel li").length;
	$("#verticarousel li").each(function(i){
		$("div:first", $(this)).css("left",$(".verticarousel-produit", $(this)).width()+5);
		// if(i+1 == nbLi){
			// $("#verticarousel").height(verticarouselHeight);
		// }
	});
}

function scrollContent(){
	setTimeout(function() {
		var re = /px/;
		$("#verticarousel li:first").slideUp("normal", function(){
			$(this).appendTo("#verticarousel").show();
			scrollContent();
		});
	}, 5000 );
}
