$(document).ready(initMenu);
var valeurRecherche;
function initMenu() {
    valeurRecherche = $("#recherche")[0].value;
    
    if($('#apprehender')){
        $('#apprehender').menu({
            content: $('#apprehender').next().html(),
            showSpeed: 100,
            width: 400,
            flyOut:true,
            positionOpts: {
                posX: 'left', 
                posY: 'bottom',
                offsetX: 0,
                offsetY: 0,
                directionH: 'right',
                directionV: 'down', 
                detectH: false, // do horizontal collision detection  
                detectV: false, // do vertical collision detection
                linkToFront: false
            }
        });
    }
    if($('#agir')){
        $('#agir').menu({
            content: $('#agir').next().html(),
            showSpeed: 100,
            width: 350,
            flyOut:true,
            positionOpts: {
                posX: 'left', 
                posY: 'bottom',
                offsetX: 0,
                offsetY: 0,
                directionH: 'right',
                directionV: 'down', 
                detectH: false, // do horizontal collision detection  
                detectV: false, // do vertical collision detection
                linkToFront: false
            }
        });
    }
    if($('#mediatheque')){
        $('#mediatheque').menu({
            content: $('#mediatheque').next().html(),
            showSpeed: 100,
            width: 240,
            flyOut:true
        });
    }
    if($('#etudesLongues')){
        $('#etudesLongues').menu({
            content: $('#etudesLongues').next().html(),
            showSpeed: 100,
            width: 250,
            flyOut:true
        });
    }
    if($('#etudesConsises')){
        $('#etudesConsises').menu({
            content: $('#etudesConsises').next().html(),
            showSpeed: 100,
            width: 275,
            flyOut:true
        });
    }
    if($('#activites')){
        $('#activites').menu({
            content: $('#activites').next().html(),
            showSpeed: 100,
            width: 370,
            flyOut:true
        });
    }
    if($('#savoirs')){
        $('#savoirs').menu({
            content: $('#savoirs').next().html(),
            showSpeed: 100,
            width: 275,
            flyOut:true
        });
    }
    if($('#outils')){
        $('#outils').menu({
            content: $('#outils').next().html(),
            showSpeed: 100,
            width: 230,
            flyOut:true,
            positionOpts: {
                posX: 'left', 
                posY: 'bottom',
                offsetX: 0,
                offsetY: 0,
                directionH: 'left',
                directionV: 'down', 
                detectH: false, // do horizontal collision detection  
                detectV: false, // do vertical collision detection
                linkToFront: false
            }
        });
    }
	$("#recherche").focus(focusRecherche);
    $("#recherche").blur(blurRecherche);
    function focusRecherche(){
	var rech = $("#recherche")[0];
	if(rech.value == valeurRecherche)
		rech.value = "";
    }
    function blurRecherche(){
    	var rech = $("#recherche")[0];
    	if(rech.value.length == 0) 
    		rech.value = valeurRecherche;
    }
}
