$(init);

var bFermer=false; var cFermer = new Array();

function init() {
	main_menu_off_tout();
	
	$('#mainmenu dt').attr('id', 'mainmenu_dt_' + Math.floor(Math.random()*10000));
	$('#mainmenu dt').hover ( main_menu_on, do_main_menu_off ); 
	
	$('#mainmenu dd').hover( 
		function(){ bFermer = false; }, 
		do_main_menu_off
	);
	
	$('#recherche').click(
		function(){ if ( $(this).val() == 'Recherche' ) $(this).val(''); }
	);
	
	
}

function main_menu_on() {	
	main_menu_off_tout();
	
	var ss_menu_id = $(this).parent().children('dd').attr('id');
	
		if ( cFermer[ss_menu_id] ) clearTimeout(cFermer[ss_menu_id]);
	
	if ( ss_menu_id == 'smenu1' && $.browser.msie ) {
		$('#f_choix_vehicule').css('width','80px');
	}	
	
	$(this).children('a').css('margin-top', '1px');
	$(this).parent().children('dd').css('display','block');
	$(this).children('a span').css('color', '#1E508F');	
}

function do_main_menu_off() { //dt ou dd
	bFermer = true;	
	
	if ( $(this).is('dt') ) {
		var id = $(this).parent().children('dd').attr('id');		
	}
	else {
		var id = $(this).attr('id');
	}
		
	cFermer[id] = setTimeout('main_menu_off("' + id + '")',200);	
}	

function main_menu_off(id) {
	if ( bFermer ){		
		if ($('#'+id).attr('id') == 'smenu1' && $.browser.msie ) {
			$('#f_choix_vehicule').css('width','140px');
		}		
		
		$('#'+id).parent().children('dt').children('a').css('margin-top', '0');
		$('#'+id).css('display','none');			
		$('#'+id).parent().children('dt').children('a span').css('color', '#1E508F');		
	}
}

function main_menu_off_tout() {
	$('#mainmenu dd').css('display','none');
	$('#mainmenu dt').children('a').css('margin-top', '0');
	$('#mainmenu dt').children('a span').css('color','#1E508F');
}
