if($('#choix_mini')){


var content="";
for(i=0;i<29;i++)
	content=content+"<option value='"+i+"'>"+i+"</option>";
	
$('#choix_mini select').each(function(i){
		
	$(this).html(content);
	
});


$('#choix_mini select').change(changechoix28);


} //endif #choix

function changechoix28(){
	
	var total=0;
	var options="";
	var resteSpecials=3;
	$('#choix_mini select').each(function(i){
		
		valcookies=$(this).val();
		if(valcookies>0){
			total=total+parseInt(valcookies);
			options=options+parseInt(valcookies)+"*"+$(this).prev().html()+";";
		}
	});
	var diff=28-parseInt(total);
	//on repasse sur les select pour refaire les maximums..
	$('#choix_mini select').each(function(i){
		
		valselect=$(this).val();
		
		if(diff>0){
			valmax=parseInt(valselect)+parseInt(diff);
		}
		else{
			valmax=valselect;
		}
		
		var content="";
		for(i=0;i<=valmax;i++){
			if(valselect==i && valselect>0)
				content=content+"<option value='"+i+"' selected>"+i+"</option>";
			else
				content=content+"<option value='"+i+"'>"+i+"</option>";
		}
		$(this).html(content);
	});
	
	
	
	if(total<=28){
		content="Vous avez choisi "+total+" mini Cookies";
	}
	if(total>28){
		content="Vous avez choisi "+total+" mini Cookies<br /><p style='color:#922; font-weight:bold;'>Il y a trop de mini cookies ! veuillez en sélectionner 28.</p>";
		options="Trop de mini cookies";
	}
	if(total==1){
		content="Vous avez choisi 1 Cookie";
	}
	//alert(content);
	$('#nb_cookies').html(content);
	//alert(options);
	$('#cookies_choisis').val(options);
	
	if(total==28){	
		$('#notsendPanier').hide();
		$('#sendPanier').fadeIn();
		$('#mess_panier').html("");
	}
	else{
		$('#sendPanier').hide();
		$('#notsendPanier').fadeIn();
		$('#mess_panier').html("Sélectionnez encore "+diff+" mini cookies pour ajouter cette boite à votre panier.");
	}
	
}

