(function($){
	$.fn.rendezvous = function()
	{
		this.each(function(){

			var boxes = $(this).find('.fieldset_checkbox');
            for (var i=0; i<boxes.length; i++) {
                var box = boxes[i];
                $(box).click(box_click);
                if (!$(box).attr('checked')) {
                    $('div#fieldset_'+box.name).hide(0);
                }
            }
            
            $('#id_location').change(function(){
                if ($(this).val() == 'bulles') {
                    $('#fieldset_complete_carosserie').hide(0);
                } else {
                    $('#fieldset_complete_carosserie').show(0);                
                }
            });

            function box_click(event) {
                if ($(this).attr('checked')) {
                    $('div#fieldset_'+this.name).fadeIn(500);
                } else {
                    $('div#fieldset_'+this.name).hide(0);
                }
                for (var i=0; i<boxes.length; i++) {
                	var box = boxes[i];
                	if (box != this) {
                		console.log(box);
                		$(box).attr('checked', '');
                		$('div#fieldset_'+box.name).hide(0);
                	}
                }
            }

		})

	}
})(jQuery);
