// JavaScript Document

// menu top initialisation
var timeOut = setTimeout ('',0);
var lastMenu = null;
var interval = 500;
var selected = null;

function init () {
	clearTimeout(timeOut);	
	if (lastMenu) {		
		$(lastMenu).find("ul").eq(0).hide ("slow");
		if (lastMenu != selected) {
			$(lastMenu).find("a").eq(0).removeClass("selected");
		}
	}
}

$( function () {
	
	//
	$("#menuHaut > ul > li").each(function(){
		if ($(this).find("a").eq(0).attr('class') == 'selected') {
			selected = this;
		}
	});
	
    //on load
	$("#menuHaut > ul > li").hover  ( function () {
		if (lastMenu != this)
			init();
		$(this).find("ul").eq(0).show("slow");	
		$(this).find("a").eq(0).addClass("selected");
		lastMenu = this;
	}, function(){		
		$(selected).find("a").eq(0).addClass('selected');
	});
	
	$("#menuHaut > ul > li").find("a").hover  ( function () {
		clearTimeout(timeOut);
	}, function () { 
		timeOut = setTimeout ( function () {
			init ();
		}, interval );
	});	
	
	// target blank
	$('.target-blank').each(
		function()
		{
			$(this).click(
				function()
				{
					var lien = $(this).attr('href');
					window.open(lien);
					
					return false;
				}
			);			
		}
	);

	$("#print_button").click(function(){
		window.print();
	});

});