document.observe(
	'dom:loaded',
	function()
	{
		
		// ---------- ONGLETS ----------
		
		// ----- VARIABLES -----
		
		var tabList = $$('#search-onglets a');
		var blocList = $$('.search-bloc');
		
		// ----- FUNCTIONS -----
		
		function onTabClick()
		{
			trace('onTabClick()');
			
			tabList.each(
				function(item)
				{
					item.removeClassName('current');
				}
			);
			
			this.addClassName('current');
			
			blocList.each(
				function(item)
				{
					item.setStyle({ 'display': 'none' });
				}
			)
			
			$(this.readAttribute('id').replace('tab','bloc')).setStyle({ 'display': 'block' });
			
			// init google map
			if(this.readAttribute('id') == 'tab-3')
			{
				initMap();
			}
		}
		
		function trace(toTrace)
		{
			if(typeof(console) != 'undefined')
			{
				console.log(toTrace);
			}
		}
		
		// ----- SCRIPT -----
		
		tabList.each(
			function(item)
			{
				Event.observe(item, 'click', onTabClick);
			}
		);
		
		tabList.first().addClassName('current');
		
		blocList.each(
			function(item)
			{
				item.setStyle({ 'display': 'none' });
			}
		)
		
		blocList.first().setStyle({ 'display': 'block' });
	}
);
