/**
 *  JavaScript utilisé pour l'alimentation de menus <select> de localisation Pays/Département/Ville/Ville principale
 */



/**
 *  Récupération des informations de localisation
 *  @param    string    localisation_type          Valeurs : "departement", "ville", "ville_principale"
 *  @param    string    localisation_id            Identifiant du département, ville ou ville principale
 *  @param    string    localisation_type_ville    Valeurs : "ville", "ville_principale", "both" (si deux <select> ville + ville_principale)
 */
function getLocalisation(localisation_type, localisation_id, localisation_type_ville)
{
    $.post(
        '/script/ajax/localisation/getLocalisation',
        { localisation_type: localisation_type, localisation_id: localisation_id, localisation_type_ville: localisation_type_ville },
        function(data){ $('#' + localisation_type + 's').html(data); }
    );
}



/**
 *  Modification de l'état du champ ville pendant la recherche des villes
 */
function onChangeDepartement(select_ville)
{
    $(select_ville).html('Chargement...');
}



/**
 *  Modification du libellé "Département" selon le type de pays sélectionné
 */
function onChangePays(select_departement, select_ville, label_departement, pays_id)
{
    $(select_departement).html('Chargement...');

    switch(pays_id)
    {
        case '2':
            $('#'+label_departement).html('Province :');
            $('#'+select_ville).html('- Choisir une province -');
            break;

        case '3':
            $('#'+label_departement).html('Canton :');
            $('#'+select_ville).html('- Choisir un canton -');
            break;

        case '4':
            $('#'+label_departement).html('R&eacute;gion :');
            $('#'+select_ville).html('- Choisir une r&eacute;gion -');
            break;

        case '5':
            $('#'+label_departement).html('District :');
            $('#'+select_ville).html('- Choisir un district -');
            break;

        case '6':
            $('#'+label_departement).html('Gouvernorat :');
            $('#'+select_ville).html('- Choisir un gouvernorat -');
            break;

        case '7':
            $('#'+label_departement).html('R&eacute;gion :');
            $('#'+select_ville).html('- Choisir une r&eacute;gion -');
            break;

        case '8':
            $('#'+label_departement).html('Wilaya :');
            $('#'+select_ville).html('- Choisir une wilaya -');
            break;

        default:
            $('#'+label_departement).html('D&eacute;partement :');
            $('#'+select_ville).html('- Choisir un d&eacute;partement -');
    }
}

