function set_tpa(tpa_id, short) {
    if (tpa_id == 1) {
        document.getElementById('nb_participant_entreprise').style.display = 'none';
        document.getElementById('nb_participant_entreprise').value = 'Nombre de participants';
        document.getElementById('nb_participant').style.display = 'inline';
    }
    else {
        document.getElementById('nb_participant').style.display = 'none';
        document.getElementById('nb_participant').selectedIndex = 0;
        document.getElementById('nb_participant_entreprise').style.display = 'inline';
    }
    document.getElementById('recherche_ville').selectedIndex = 0;
    document.getElementById('activite').selectedIndex = 0;
    document.getElementById('thematique').selectedIndex = 0;
    document.getElementById('periode').selectedIndex = 0;
    get_infos_moteur();
}

function get_infos_moteur(short) {
    xhr = get_xhr();
    xhr.open('GET', "ajax.php?o=get_infos_moteur"+
        String.fromCharCode(38)+"TPA_ID="+(document.getElementById('rad_particulier').checked ? 1 : 2)+
        String.fromCharCode(38)+"VIL_ID="+document.getElementById('recherche_ville').options[document.getElementById('recherche_ville').selectedIndex].value+
        String.fromCharCode(38)+"ACT_ID="+document.getElementById('activite').options[document.getElementById('activite').selectedIndex].value+
        String.fromCharCode(38)+"THE_ID="+document.getElementById('thematique').options[document.getElementById('thematique').selectedIndex].value+
        String.fromCharCode(38)+"SHORT="+short, false); 
    xhr.send(null); 
    if (xhr.readyState == 4) {
        tab = xhr.responseText.split('|');
        document.getElementById('sel_ville').innerHTML = tab[0];
        document.getElementById('sel_activite').innerHTML = tab[1];
        document.getElementById('sel_thematique').innerHTML = tab[2];
    }
}

function composer_escapade(pro_id, nb, type) {
    xhr = get_xhr();
    xhr.open('GET', "ajax.php?o=composer_escapade"+String.fromCharCode(38)+"PRO_ID="+pro_id+String.fromCharCode(38)+"NB="+nb+String.fromCharCode(38)+"TYPE="+type, false); 
    xhr.send(null); 
    if (xhr.readyState == 4)
        document.getElementById('composition').innerHTML = xhr.responseText;
}

function set_resa(pro_id, tve_id, r, nb) {
    xhr = get_xhr();
    xhr.open('GET', "ajax.php?o=set_resa"+String.fromCharCode(38)+"PRO_ID="+pro_id+String.fromCharCode(38)+"TVE_ID="+tve_id+String.fromCharCode(38)+"R="+r+String.fromCharCode(38)+"NB="+nb, false); 
    xhr.send(null); 
    if (xhr.readyState == 4)
        composer_escapade(pro_id, nb, 'cur');
}

function go(etape) {
    xhr = get_xhr();
    xhr.open('GET', "ajax.php?o=panier_check_config", false); 
    xhr.send(null); 
    if (xhr.readyState == 4) {
        if (xhr.responseText == '1')
            window.location.href = "panier.php?ETAPE="+etape;
        else
            alert("Toutes vos escapades doivent être configurées pour passer à l'étape suivante.");
    }
}

var sousmenu = null;

function checkHover() {
	if (sousmenu) {
		sousmenu.find('ul').fadeOut('fast');	
	} //if
} //checkHover

$(document).ready(function() {
	$('.menu > li').hover(function() {
		if (sousmenu) {
			sousmenu.find('ul').fadeOut('fast');
			sousmenu = null;
		} //if
		
		$(this).find('ul').fadeIn('fast');
	}, function() {
		sousmenu = $(this);
		setTimeout(
			"checkHover()",
			0); // si vous souhaitez retarder la disparition, c'est ici
	});
});

