﻿function verifSelection(nb)
{
    if (nb == 0)
    {
        alert('Veuillez sélectionner au moins un minicv');
        return false;
    }
    
    return true;
}

function updateRegion()
{
    var idCountry = document.getElementById('recherche_country').value;
    var ChoiceRegion = document.getElementById('recherche_region');

    // vide la liste des régions
    while(ChoiceRegion.options.length > 0)
    {
        ChoiceRegion.options[0] = null;
    }    // while
    
    /* remplir la liste des régions avec le contenu json */
    ChoiceRegion.options[ChoiceRegion.options.length] = new Option('-- Choisissez une région --', '');
    ChoiceRegion.disabled = true;
    for(i in lstDepts[idCountry].region)
    {
        if (lstDepts[idCountry].region[i].length != 0)
        {
            ChoiceRegion.disabled = false;
            ChoiceRegion.options[ChoiceRegion.options.length] = new Option(lstDepts[idCountry].region[i].libelle,i);
        }
    }    // for
    
    updateDepartment();
}

function updateDepartment()
{
    var idCountry = document.getElementById('recherche_country').value;
    var idRegion = document.getElementById('recherche_region').value;
    
    var ChoiceDepartment = document.getElementById('recherche_department');
    
    // vide la liste des régions
    while(ChoiceDepartment.options.length > 0)
    {
        ChoiceDepartment.options[0] = null;
    }
    
    /* remplir la liste des régions avec le contenu json */
    ChoiceDepartment.options[ChoiceDepartment.options.length] = new Option('-- Choisissez un département --', '');
    ChoiceDepartment.disabled = true;
    if (idRegion) {
        for(i in lstDepts[idCountry].region[idRegion].department)
        {
            if (lstDepts[idCountry].region[idRegion].department[i].length != 0)
            {
                ChoiceDepartment.disabled = false;
                ChoiceDepartment.options[ChoiceDepartment.options.length] = new Option(lstDepts[idCountry].region[idRegion].department[i],i);
            }
        }
    }
}

function initForm()
{
    $("#recherche_position").autocomplete(listPosition, {
        width: 320,
        minChars: 1,
        max: 10,
        highlight: false,
        multiple: true,
        multipleSeparator: " ",
        scroll: true,
        scrollHeight: 300
    });
    
}

function collapse(id)
{
    var elem = document.getElementById(id);
    if (elem.style.display == 'block')
    {
        elem.style.display = 'none';
    }  
    else
    {
        elem.style.display = 'block';
    }
}

