if(typeof(ComposantsController) == 'undefined')
    ComposantsController = new Object();

Object.extend(ComposantsController,
{
    init: function()
	{
		if($('alpha_A')) {
			ComposantsController.resetListing();
			
			$('alpha_A').show();
			$('A').addClassName('selected');

			$$('h2.section_alpha').invoke('hide');

			$$('.ma_section_alpha a').each(function(a) {
				Event.observe(a, 'click', ComposantsController.selectAlpha.bindAsEventListener(this, a));
			});
		}

		new Ajax.Autocompleter("sectionSearch", "sectionSearchListing", "/composants/search.phtml", {
			 paramName: "section",
			 indicator: 'indicator1',
			 minChars: 1
        });
	},

	resetListing: function()
	{
        $$('.alpha_list').invoke('hide');
		$$('.ma_section_alpha a').invoke('removeClassName', 'selected');
	},

	selectAlpha: function(e, a)
    {
		ComposantsController.resetListing();
        $('alpha_' + a.id).show();
		a.addClassName('selected');
        Event.stop(e);		
    }
});

Event.observe(window, "load", ComposantsController.init.bind(this));