$(document).ready(function() {
                $(".checkbox").click(function()
                {
                    $(this).parents('.opt-matiere-color').each(function()
                    {
                        $(this).toggleClass("opt-matiere-color-selected");
                    });
                    var total = 0;
                    
                    $("input[@type=checkbox]:checked").each(function(){ // read that each is like for loop
                        total++;
                    });
                    var value_echantillon_array = '|';
                    $('.checkbox:checked').each(function(){
                            var value_echantillon = '';
                            //alert("value = " + $(this).val());
                            value_echantillon = $(this).val();
                            value_echantillon_array += value_echantillon;
                            value_echantillon_array += '|';
                            //alert(value_echantillon);
                        });
                    //alert(value_echantillon_array);
                    //document.getElementById('result_echantillon').value = '';
                    //var value_echantillon = $("#par_matiere_lightbox_form").serialize();
                    //alert(value_echantillon);
                    document.getElementById('result_echantillon').value = value_echantillon_array;
                    if (total > 4 )
                    {
                        $(".checkbox").not(':checked').each(function(){
                            $(this).parents('.choix').hide("normal");
                        });
                        $("#init_buttons_a").fadeOut("slow");
                        $("#init_buttons2_a").fadeOut("slow");
                        $("#init_buttons_a").fadeIn("slow");
                        $("#init_buttons2_a").fadeIn("slow");

                    }
                    else
                    {
                        $(".checkbox").not(':checked').each(function(){

                                $(this).parents('.choix').show("normal");

                            });
                    }
	            });

           	});
