function verenrldap()
{
    if ((window.document.enrldap.id.value == "") || (window.document.enrldap.temens.value == ""))
    {
        alert("Il manque des paramètres.");
        return false;
    }
    else
    {
        if (window.document.enrldap.penrl.value == "")
        {
            alert("Vous devez entrer votre mot de passe ldap");
            return false;
        }
        else
        {
            if (confirm("Voulez vous vraiment modifier les droits d'accès à l'application de l'utilisateur " + window.document.enrldap.id.value + " ?"))
            {
                window.document.enrldap.trens.value = "1";
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}

function Redir_action()
{
    window.document.infoactions.action = "vnens_actions.jsp";
    window.document.infoactions.submit();
}

function Redir_activ()
{
    window.document.infoactiv.action = "vnens_activ.jsp";
    window.document.infoactiv.submit();
}


function Gr_reportidens(iens)
{
    window.opener.document.infoelp.idensrech.value = iens;
    window.opener.document.infoelp.aff.value = "1";
    window.opener.document.infoelp.submit();
    window.close();
}

function Gr_apoidens(iens)
{
    window.opener.document.infoelp.idensrech.value = iens;
    window.opener.document.infoelp.aff.value = "1";
    window.opener.document.infoelp.submit();
    window.close();
}

function Gr_apoensint(idens)
{
    window.opener.document.gestensinterne.idensrech.value = idens;
    window.opener.document.gestensinterne.action = "ensint.jsp";
    window.opener.document.gestensinterne.submit();
    window.close();
}

function Gr_idensext(iens)
{
    window.opener.document.gestensext.idensrech.value = iens;
    window.opener.document.gestensext.submit();
    window.close();
}

function Gr_retournaction()
{
    window.document.infoelp.action = "voeux_ens.jsp";
    window.document.infoelp.trait.value = "1";
}

function Gr_retournactiv()
{
    window.document.infoelp.action = "voeux_ens.jsp";
    window.document.infoelp.trait.value = "1";
}

function Gr_vens()
{
    window.document.modvaction.action = 'voeux_ens.jsp';
}

function Gr_velp()
{
    window.document.modvaction.action = 'voeux_action.jsp';
}

function Gr_vensact()
{
    window.document.modvactiv.action = 'voeux_ens.jsp';
}

function Gr_Verifaction(tot, actuel)
{
    var pos = -1;
    var souschaine = ".";
    pos = window.document.modvaction.nbhvoeu.value.indexOf(souschaine, -1);
    if (pos >= 0)
    {
        alert("Le nombre d'heures doit être entier.");
        return false;
    }
    else
    {
        if (window.document.modvaction.nbhvoeu.value == "")
        {
            alert("Le nombre d'heures voulues n'est pas renseigné.");
            return false;
        }
        else
        {
            if (window.document.modvaction.nbhvoeu.value == actuel)
            {
                alert("Votre voeu est déjà de " + actuel + " heure(s).");
                return false;
            }
            else
            {
                if (isNaN(window.document.modvaction.nbhvoeu.value))
                {
                    alert("Veuillez entrer un nombre.");
                    return false;
                }
                else
                {
                    if ((window.document.modvaction.nbhvoeu.value > tot) || (window.document.modvaction.nbhvoeu.value < 0))
                    {
                        alert("Le nombres d'heures souhaitées doit étre compris entre 0 et le nombre total d'heures de l'action.");
                        return false;
                    }
                    else
                    {
                        if (window.document.modvaction.nbhvoeu.value == 0)
                        {
                            if (confirm("Voulez vous vraiment supprimer ce voeu?"))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            if (confirm("Voulez vous vraiment modifier ce voeu?"))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }

                    }
                }
            }
        }
    }
}


function testchps()
{
//en dev (local), la pass n'est pas demande
/*var adresseIP=java.net.InetAddress.getLocalHost();
var adip=adresseIP.getHostAddress();
if (adip=="127.0.0.1") return true;*/
    if ((window.document.connect.username.value == ("Identifiant")) || (window.document.connect.username.value == ("")) || (window.document.connect.pwd.value == ("password")) || (window.document.connect.pwd.value == ("")))
    {
        alert("L'identifiant et le mot de passe doivent être renseignés");
        return false;
    }
    else
    {
        return true;
    }
}

function Gr_ControleId()
{
    if (isNaN(window.document.infoelp.idensrech.value))
    {
        alert("L'identifiant grille est numérique");
        return false;
    }
    else
    {
        if ((window.document.infoelp.idensrech.value == null) || (window.document.infoelp.idensrech.value == ""))
        {
            alert("Identifiant non renseigné.");
            return false;
        }
        else
        {
            return true;
        }
    }
}

function Gr_vaction(act, nelp)
{
    window.document.infoactions.na.value = act;
    window.document.infoactions.ne.value = nelp;
    window.document.infoactions.submit();
}

function Gr_vactiv(act)
{
    window.document.infoactiv.na.value = act;
    window.document.infoactiv.submit();
}

function Gr_VensActions(maxh, henr)
{
    var pos = -1;
    var souschaine = ".";
    pos = window.document.modvaction.nbhvoeu.value.indexOf(souschaine, -1);
    var nbhvoeu = window.document.modvaction.nbhvoeu.value;
    if ((isNaN(nbhvoeu)) || (nbhvoeu == ""))  {
            alert("Vous devez entrer un nombre d'heures.");
            return false;
     }
    if (window.document.modvaction.etdemi.checked) {
        nbhvoeu =parseFloat(nbhvoeu) + 0.5;
    }
    
    if (pos >= 0)
    {
        alert("Le nombre d'heures doit être entier.");
        return false;
    }
    else
    {
        if ((isNaN(nbhvoeu)) || (nbhvoeu == ""))
        {
            alert("Vous devez entrer un nombre d'heures.");
            return false;
        }
        else
        {
            if ((nbhvoeu > maxh) || (nbhvoeu < 0))
            {
                alert("Le nombre d'heures voulues ne doit pas étre négatif ou depasser le nombre maximum d'heures de l'action.");
                return false;
            }
            else
            {
                if (nbhvoeu == henr)
                {
                    alert("Le voeu est dejà de " + henr + " heures.");
                    return false;
                }
                else
                {
                    if (nbhvoeu == 0)
                    {
                        if (confirm("Voulez vous vraiment supprimer ce voeu?"))
                        {
                            window.document.modvaction.tr.value = 2;
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else
                    {
                        if (confirm("Voulez vous vraiment modifier ce voeu?"))
                        {
                            window.document.modvaction.tr.value = 1;
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
        }
    }
}


function Gr_VensActiv(maxh, henr)
{
    var pos = -1;
    var souschaine = ".";
    pos = window.document.modvactiv.nbhvoeu.value.indexOf(souschaine, -1);
    if (pos >= 0)
    {
        alert("Le nombre d'heures doit étre entier.");
        return false;
    }
    else
    {
                
        if ((isNaN(window.document.modvactiv.nbhvoeu.value)) || (window.document.modvactiv.nbhvoeu.value == ""))
        {
            alert("Vous devez entrer un nombre d'heures.");
            return false;
        }
        else
        {
            var nbhr = window.document.modvactiv.nbhvoeu.value;
            if (window.document.modvactiv.etdemi.checked){
                nbhr = (0.5+parseInt(nbhr));
            }
            if ((nbhr > maxh) || (nbhr < 0))
            {
                alert("Le nombre d'heures voulues ne doit pas être négatif ou depasser le nombre maximum d'heures de l'action.");
                return false;
            }
            else
            {
                if (nbhr == henr)
                {
                    alert("Le voeu est dejà de " + henr + " heures.");
                    return false;
                }
                else
                {
                    if (nbhr == 0)
                    {
                        if (confirm("Voulez vous vraiment supprimer ce voeu?"))
                        {
                            window.document.modvactiv.tr.value = 2;
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else
                    {
                        if (confirm("Voulez vous vraiment modifier ce voeu?"))
                        {
                            window.document.modvactiv.tr.value = 1;
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
        }
    }
}


function Gr_vnactionens()
{
    if (window.document.infoelp.codelp.value == "")
    {
        alert("Le code ELP doit être renseigné.");
        return false;
    }
    else
    {
        window.document.infoelp.aff.value = "1";
        return true;
    }
}

function Gr_vnactivens()
{
    if (window.document.infoelp.codetp.value == "")
    {
        alert("Le code Etape doit être renseigné.");
        return false;
    }
    else
    {
        return true;
    }
}

function Gr_nactionens(max)
{
    var pos = -1;
    var souschaine = ".";
    pos = window.document.infoelp.nbhvoeux.value.indexOf(souschaine, -1);
    if (pos >= 0)
    {
        alert("Le nombre d'heures doit étre entier.");
        return false;
    }
    else
    {
        if ((isNaN(window.document.infoelp.nbhvoeux.value)) || (window.document.infoelp.nbhvoeux.value == ""))
        {
            alert("Vous devez entrer un nombre d'heures.");
            return false;
        }
        else
        {
            if ((window.document.infoelp.nbhvoeux.value > max) || (window.document.infoelp.nbhvoeux.value <= 0))
            {
                alert("Le nombre d'heures voulues ne doit pas étre négatif ou depasser le nombre maximum d'heures de l'action.");
                return false;
            }
            else
            {
                if ((window.document.infoelp.codelp.value == "") || (window.document.infoelp.codelp.value == null) || (window.document.infoelp.codaction.value == "") || (window.document.infoelp.codaction.value == null))
                {
                    alert("Code ELP ou Action non renseigné.");
                    return false;
                }
                else
                {
                    if ((window.document.infoelp.idensrech.value == "") || (window.document.infoelp.idensrech.value == null))
                    {
                        alert("Vous n'avez pas selectionné d'enseignant.");
                        return false;
                    }
                    else
                    {
                        if (confirm("Voulez vous vraiment enregistrer ce voeu?"))
                        {
                            window.document.infoelp.tr.value = "1";
                            window.document.infoelp.action = "vnens_actions.jsp";
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
        }
    }
}

function Gr_nactivens(maxhactiv)
{
    var pos = -1;
    var souschaine = ".";
    pos = window.document.infoelp.nbhvoeux.value.indexOf(souschaine, -1);
    if (pos >= 0)
    {
        alert("Le nombre d'heures doit être entier.");
        return false;
    }
    else
    {
        if ((isNaN(window.document.infoelp.nbhvoeux.value)) || (window.document.infoelp.nbhvoeux.value == ""))
        {
            alert("Vous devez entrer un nombre d'heures.");
            return false;
        }
        else
        {
            if ((window.document.infoelp.nbhvoeux.value > maxhactiv) || ((window.document.infoelp.nbhvoeux.value <= 0)&&(!window.document.infoelp.etdemi.checked)))
            {
                alert("Le nombre d'heures voulues ne doit pas être négatif ou depasser le nombre maximum d'heures de l'activité.");
                return false;
            }
            else
            {
                if ((window.document.infoelp.codactiv.value == "") || (window.document.infoelp.codactiv.value == null))
                {
                    alert("Activité non renseigné.");
                    return false;
                }
                else
                {
                    if ((window.document.infoelp.idensrech.value == "")||(window.document.infoelp.idensrech.value==null))
                    {
                        alert("Enseignant non renseigné.");
                        return false;
                    }
                    else
                    {

                        if (confirm("Voulez vous vraiment enregistrer ce voeu?"))
                        {                            
                            window.document.infoelp.tr.value = "1";
                            window.document.infoelp.aff.value = "3";
                            window.document.infoelp.action = "vnens_activ.jsp";
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
        }

    }

}


function Gr_affdetails()
{
    window.document.infoelp.codaction.value = window.document.infoelp.codactionn.value;
    window.document.infoelp.aff.value = "2";
    window.document.infoelp.submit();
}

function Gr_affactivdetails()
{
    window.document.infoelp.codactiv.value = window.document.infoelp.codactivv.value;
    if ((window.document.infoelp.codvrsvet)&&(window.document.infoelp.codvrsvett))
        window.document.infoelp.codvrsvet.value = window.document.infoelp.codvrsvett.value;
    if ((window.document.infoelp.codDfd)&&(window.document.infoelp.pubDomaine)){
        window.document.infoelp.codDfd.value = window.document.infoelp.pubDomaine.value;
        if (window.document.infoelp.codDfd.value!=""){
            window.document.infoelp.rechByDom.value="O";
        }
    }
    window.document.infoelp.aff.value = "3";
    window.document.infoelp.submit();
}

function Gr_affactiv()
{
    window.document.infoelp.aff.value = "2";
    if ((window.document.infoelp.codvrsvet)&&(window.document.infoelp.codvrsvett))
        window.document.infoelp.codvrsvet.value = window.document.infoelp.codvrsvett.value;
    if ((window.document.infoelp.codDfd)&&(window.document.infoelp.pubDomaine))
        window.document.infoelp.codDfd.value = window.document.infoelp.pubDomaine.value;
    if ((window.document.infoelp.codCmp)&&(window.document.infoelp.pubCmp))
        window.document.infoelp.codCmp.value = window.document.infoelp.pubCmp.value;
    window.document.infoelp.submit();
}

function Affidiv()
{
    window.document.getElementById("nvoeu").style.visibility = "visible";
}

function Affichaction(idaction)
{
    window.document.infoelp.numaction.value = idaction;
    window.document.infoelp.action = "voeux_action.jsp";
}

function Affichactiv(idactiv, codetp, codvrs)
{
    window.document.infoelp.aff.value = "3";
    window.document.infoelp.codactiv.value = idactiv;
    window.document.infoelp.codetp.value = codetp;
    window.document.infoelp.codvrsvet.value = codvrs;
    window.document.infoelp.action = "gr_activoeux.jsp";
}

function Gr_retourelp()
{
    window.document.infaction.action = "voeux_elp.jsp";
}

function Gr_retourelpact()
{
    window.document.infoelp.action = "voeux_elp.jsp";
}

function Grdir_naction()
{
    window.document.infaction.idensrech.value = "";
    window.document.infaction.aff.value = "2";
    window.document.infaction.action = "vnens_actions.jsp";
}

function Grdir_action(ens)
{
    window.document.infaction.idensrech.value = ens;
    window.document.infaction.action = "vens_actions.jsp";
}

function Gr_elpverrou()
{
    window.document.infoelp.trverrou.value = "1";
}

function Gr_suprvoeu()
{
    if (confirm("Voulez vous vraiment supprimer tout les voeux de cette action?"))
    {
        window.document.infaction.suprv.value = "1";
        return true;
    }
    else
    {
        return false;
    }
}

function verifapo()
{
    var pos = -1;
    var souschaine = ".";
    pos = window.document.recherchens.codapo.value.indexOf(souschaine, -1);
    if (pos >= 0)
    {
        alert("Le code est un entier.");
        return false;
    }
    else
    {
        if (isNaN(window.document.recherchens.codapo.value))
        {
            alert("Le code doit étre numerique.");
            return false;
        }
        else
        {
            return true;
        }
    }
}

function Gr_Suppraction(maxv)
{
    if (maxv > 0)
    {
        alert("Cette action fais l'objet de " + maxv + " voeu(x) que vous devez supprimer avant de pouvoir supprimer cette action.");
    }
    else
    {
        if (window.document.infoelp.codaction.value == "")
        {
            return false;
        }
        else {
            if (confirm("Voulez vous vraiment supprimer cette action?"))
            {
                window.document.infoelp.supra.value = "2";
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}

function Gr_Supraction(maxhv)
{
    if (maxhv > 0)
    {
        alert("Les actions de cette ELP font l'objet de " + maxhv + " heure(s) de voeux. Vous devez supprimer les voeux existants avant de supprimer ces actions.");
        return false;
    }
    else
    {
        if (confirm("Voulez vous vraiment supprimer les actions de cette ELP?"))
        {
            window.document.infoelp.supra.value = "1";
            return true;
        }
        else
        {
            return false;
        }
    }
}

function Gr_codelp()
{
    if (window.document.infoelp.codelp.value == "")
    {
        alert("Le code ELP n'est pas renseigné.");
        return false;
    }
    else
    {
        return true;
    }
}

function Gr_elpactions()
{
    window.document.infoelp.action = "voeux_elp.jsp";
}

function Gr_actionselp()
{
    window.document.infoelp.action = "gr_elp.jsp";
}

function Gr_modelp()
{
    var poscm = -1;
    var postd = -1;
    var postp = -1;
    var souschaine = ".";
    poscm = window.document.infoelp.gactcm.value.indexOf(souschaine, -1);
    postd = window.document.infoelp.gacttd.value.indexOf(souschaine, -1);
    postp = window.document.infoelp.gacttp.value.indexOf(souschaine, -1);
    if ((poscm >= 0) || (postd >= 0) || (postp >= 0))
    {
        alert("Les nombre de groupes doivent étre entier.");
        return false;
    }
    else
    {
        if ((isNaN(window.document.infoelp.gactcm.value)) || (isNaN(window.document.infoelp.gacttd.value)) || (isNaN(window.document.infoelp.gacttp.value)))
        {
            alert("Les nombres de groupe actuel en CM, TD, TP doivent étre des numériques.");
            return false;
        }
        else
        {
            if ((window.document.infoelp.gactcm.value == "") || (window.document.infoelp.gacttd.value == "") || (window.document.infoelp.gacttp.value == ""))
            {
                alert("Les champs concernant le nombre de groupe actuel en CM, TD, TP doivent étre renseignés.");
                return false;
            }
            else
            {
                if (confirm("Voulez vous enregistrer les changements effectués?"))
                {
                    window.document.infoelp.mod.value = "1";
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
    }
}

function Gr_nouvaction()
{
    window.document.infoelp.aff.value = "4";
    window.document.infoelp.action = "gr_actions.jsp";
}

function Gr_detaction()
{
    window.document.infaction.aff.value = "5";
    window.document.infaction.action = "gr_actions.jsp";
}

function Gr_genactelp(typgen)
{
    if (typgen == "1")
    {
        if (confirm("Voulez vous vraiment générer automatiquement en details les actions de cette ELP?"))
        {
            window.document.infoelp.mod.value = "2";
            window.document.infoelp.typegen.value = "1";
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        if (typgen == "0")
        {
            if (confirm("Voulez vous vraiment générer automatiquement en mode groupé les actions de cette ELP?"))
            {
                window.document.infoelp.mod.value = "2";
                window.document.infoelp.typegen.value = "0";
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}

function Gr_affaction()
{
    window.document.infoelp.numaction.value = window.document.infoelp.codaction.value;
    window.document.infoelp.submit();
}

function Gr_enraction()
{
    var totheurest = 0;
    var totheuresta = 0;
    var pos = -1;
    var poss = -1;
    var typaction = "";
    var souschaine = ".";
    pos = window.document.infoelp.haction.value.indexOf(souschaine, -1);
    poss = window.document.infoelp.graction.value.indexOf(souschaine, -1);


    if (window.document.infoelp.codaction.value == "")
    {

        for (i = 0; i < 3; i++)
        {
            if (window.document.infoelp.typea.checked == true)
            {
                typaction = window.document.infoelp.typea.value;
                i = 4;
            }
            else
            {
                if (window.document.infoelp.typea[i].checked == true)
                {
                    typaction = window.document.infoelp.typea[i].value;
                    i = 4;
                }
            }
        }

        if (typaction == "CM")
        {
            totheurest = parseInt(window.document.infoelp.hrestantcm.value);
            if (totheurest < (window.document.infoelp.haction.value * window.document.infoelp.graction.value))
            {
                alert("Vous ne pouvez pas enregistrer " + (window.document.infoelp.haction.value * window.document.infoelp.graction.value) + " heure(s), car il ne reste que " + totheurest + " heure(s) CM é repartir");
                return false;
            }
        }
        if (typaction == "TD")
        {
            totheurest = parseInt(window.document.infoelp.hrestanttd.value);
            if (totheurest < (window.document.infoelp.haction.value * window.document.infoelp.graction.value))
            {
                alert("Vous ne pouvez pas enregistrer " + (window.document.infoelp.haction.value * window.document.infoelp.graction.value) + " heure(s), car il ne reste que " + totheurest + " heure(s) TD é repartir");
                return false;
            }
        }
        if (typaction == "TP")
        {
            totheurest = parseInt(window.document.infoelp.hrestanttp.value);
            if (totheurest < (window.document.infoelp.haction.value * window.document.infoelp.graction.value))
            {
                alert("Vous ne pouvez pas enregistrer " + (window.document.infoelp.haction.value * window.document.infoelp.graction.value) + " heure(s), car il ne reste que " + totheurest + " heure(s) TP é repartir");
                return false;
            }
        }
    }
    else
    {
        if ((window.document.infoelp.haction.value == window.document.infoelp.hcaction.value) && (window.document.infoelp.graction.value == window.document.infoelp.grcaction.value))
        {

        }
        else
        {
            if (window.document.infoelp.typea.value == "CM")
            {
                totheurest = (parseInt(window.document.infoelp.htotalcm.value) - parseInt(window.document.infoelp.hrestantcm.value)) - (parseInt(window.document.infoelp.hcaction.value) * parseInt(window.document.infoelp.grcaction.value)) + (parseInt(window.document.infoelp.haction.value) * parseInt(window.document.infoelp.graction.value));
                if (totheurest > window.document.infoelp.htotalcm.value)
                {
                    alert("Vous ne pouvez pas enregistrer " + ((window.document.infoelp.haction.value * window.document.infoelp.graction.value) - (window.document.infoelp.hcaction.value * window.document.infoelp.grcaction.value)) + " heure(s) en plus, car il ne reste que " + window.document.infoelp.hrestantcm.value + " heure(s) CM é repartir");
                    return false;
                }
            }
            if (window.document.infoelp.typea.value == "TD")
            {
                totheurest = (parseInt(window.document.infoelp.htotaltd.value) - parseInt(window.document.infoelp.hrestanttd.value)) - (parseInt(window.document.infoelp.hcaction.value) * parseInt(window.document.infoelp.grcaction.value)) + (parseInt(window.document.infoelp.haction.value) * parseInt(window.document.infoelp.graction.value));
                if (totheurest > window.document.infoelp.htotaltd.value)
                {
                    alert("Vous ne pouvez pas enregistrer " + ((window.document.infoelp.haction.value * window.document.infoelp.graction.value) - (window.document.infoelp.hcaction.value * window.document.infoelp.grcaction.value)) + " heure(s) en plus, car il ne reste que " + window.document.infoelp.hrestanttd.value + " heure(s) TD é repartir");
                    return false;
                }
            }
            if (window.document.infoelp.typea.value == "TP")
            {
                totheurest = (parseInt(window.document.infoelp.htotaltp.value) - parseInt(window.document.infoelp.hrestanttp.value)) - (parseInt(window.document.infoelp.hcaction.value) * parseInt(window.document.infoelp.grcaction.value)) + (parseInt(window.document.infoelp.haction.value) * parseInt(window.document.infoelp.graction.value));
                if (totheurest > window.document.infoelp.htotaltp.value)
                {
                    alert("Vous ne pouvez pas enregistrer " + ((window.document.infoelp.haction.value * window.document.infoelp.graction.value) - (window.document.infoelp.hcaction.value * window.document.infoelp.grcaction.value)) + " heure(s) en plus, car il ne reste que " + window.document.infoelp.hrestanttp.value + " heure(s) TP é repartir");
                    return false;
                }
            }
        }
    }

/*
    if ((pos >= 0) || (poss >= 0))
    {
        alert("Le nombre d'heures et le nombre de groupes doivent étre entier.");
        return false;
    }
    else
    {*/
        if (window.document.infoelp.codaction.value == "n2")
        {
            alert("Aucune action selectionnée.");
            return false;
        }
        else
        {
            if (isNaN(window.document.infoelp.haction.value))
            {
                alert("Le nombre d'heures doit étre numérique.");
                return false;
            }
            else
            {
                if (isNaN(window.document.infoelp.graction.value))
                {
                    alert("Le nombre de groupe doit étre numérique.");
                    return false;
                }
                else
                {
                    if (window.document.infoelp.haction.value <= 0)
                    {
                        alert("Le nombre d'heures de l'action doit étre supérieur é 0.");
                        return false;
                    }
                    else
                    {
                        if (window.document.infoelp.codaction.value == "")
                        {
                            if (confirm("Voulez vraiment enregistrer cette action?"))
                            {
                                window.document.infoelp.aff.value = "5";
                                window.document.infoelp.mod.value = "2";
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            if (confirm("Voulez vraiment modifier cette action?"))
                            {
                                window.document.infoelp.mod.value = "3";
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                    }
                }
            }
        }
   // }
}

function Gr_actout()
{
    window.document.infoelp.aff.value = "5";
    window.document.infoelp.submit();
}

function Gr_voeuxactions()
{
    window.document.infoelp.numaction.value = window.document.infoelp.codaction.value;
    window.document.infoelp.action = "voeux_action.jsp";
}

function actl(aff)
{
    window.document.infoelp.aff.value = aff;
    if (window.document.infoelp.codDfd)
        window.document.infoelp.codDfd.value="";    
    window.document.infoelp.submit();
}

function gl()
{
    var pos = -1;
    var souschaine = ".";
    pos = window.document.infoelp.idensrech.value.indexOf(souschaine, -1);
    if (pos >= 0)
    {
        alert("Le code grille est un entier.");
        return false;
    }
    else
    {
        if (window.document.infoelp.idensrech.value == "")
        {
            alert("Le code grille doit être renseigné.");
            return false;
        }
        else
        {
            if (isNaN(window.document.infoelp.idensrech.value))
            {
                alert("Le code grille est un numérique.");
                return false;
            }
            else
            {
                window.document.infoelp.aff.value = "1";
                window.document.infoelp.submit();
            }
        }
    }
}

function Gr_enractiv()
{
    var pos = -1;
    var souschaine = ".";
    pos = window.document.infoelp.hactiv.value.indexOf(souschaine, -1);
    if (pos >= 0)
    {
        alert("Le nombre d'heures activité doit être un entier.");
        return false;
    }
    else
    {
        if (window.document.infoelp.aff.value == "4")
        {
            if ((window.document.infoelp.codelprech.value == "")&&(((window.document.infoelp.codetp.value == "")&&(window.document.infoelp.codetprech.value == "")) || (window.document.infoelp.codvrsvet.value == "")))
            {
                alert("Il manque un paramètre. Veuillez selectionner un ELP ou un code etape ainsi que la version concernée ou un domaine.");
                return false;
            }
            else
            {
                if (window.document.infoelp.comment.value.length > 400)
                {
                    alert("Le commentaire ne doit pas depassé 400 caractéres.");
                    return false;
                }
                else
                {
                    if ((window.document.infoelp.hactiv.value == "") || (window.document.infoelp.hactiv.value <= 0))
                    {
                        alert("Le nombre d'heures de l'activité doit être renseigné et être superieur à  0.");
                        return false;
                    }
                    else
                    {
                        if (isNaN(window.document.infoelp.hactiv.value))
                        {
                            alert("Le nombre d'heures de l'activité doit être un numérique");
                            return false;
                        }
                        else
                        {
                            if (window.document.infoelp.codacte.value == "")
                            {
                                alert("Le code acte est obligatoire.");
                                return false;
                            }
                            else
                            {
                                if (confirm("Voulez vous vraiment enregistrer cette activité?"))
                                {
                                    window.document.infoelp.aff.value = "2";
                                    window.document.infoelp.mod.value = "3";
                                    return true;
                                }
                                else
                                {
                                    return false;
                                }
                            }
                        }
                    }
                }
            }

        }
        else
        {            
            if ((window.document.infoelp.codelprech.value == "")&& (((window.document.infoelp.codetp.value == "")&&(window.document.infoelp.codetprech.value == "")) || (window.document.infoelp.codvrsvet.value == "")))
            {
                alert("Il manque un paramètre. Veuillez selectionner un elp ou code etape ainsi que la version concernée ou un domaine. Puis l'activité que vous voulez modifier.");
                return false;
            }
            else
            {
                if (window.document.infoelp.comment.value.length > 400)
                {
                    alert("Le commentaire ne doit pas depassé 400 caractères.");
                    return false;
                }
                else
                {
                    if ((window.document.infoelp.hactiv.value == "") || (window.document.infoelp.hactiv.value <= 0))
                    {
                        alert("Le nombre d'heures de l'activité doit être renseigné et être superieur à  0.");
                        return false;
                    }
                    else
                    {
                        if (isNaN(window.document.infoelp.hactiv.value))
                        {
                            alert("Le nombre d'heures de l'activité doit être un numérique");
                            return false;
                        }
                        else
                        {
                            if (window.document.infoelp.codacte.value == "")
                            {
                                alert("Le code acte est obligatoire.");
                                return false;
                            }
                            else
                            {
                                if (confirm("Voulez vous vraiment modifier cette activité?"))
                                {
                                    window.document.infoelp.aff.value = "3";
                                    window.document.infoelp.mod.value = "2";
                                    return true;
                                }
                                else
                                {
                                    return false;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

function Gr_ReportActe(a)
{
    var choix = a.options[a.options.selectedIndex].value;
    window.opener.document.infoelp.codacte.value = choix;
    window.close();
}

function Gr_ReportPos(p)
{
    var choix = p.options[p.options.selectedIndex].value;
    window.opener.document.gestensext.codpos.value = choix;
    window.close();
}

function gr_rempelp(numa, numelp)
{
    window.opener.document.infoelp.codelp.value = numelp;
    window.close();
}

function Gr_nouvactiv()
{   
    if (window.document.infoelp.codvrsvet.value == "vrs")
    {
        alert("Vous devez choisir la version d'Etape concernée par cette nouvelle activité, avant de cliquer sur ce bouton.");
        return false;
    }
    else
    {
        window.document.infoelp.aff.value = "4";
        return true;
    }
}

function Gr_supractiv(nbvactiv)
{
    /*if ((window.document.infoelp.codetp.value == "") || (window.document.infoelp.codvrsvet.value == "") || (window.document.infoelp.codvrsvet.value == "vrs") || (window.document.infoelp.codactiv.value == "") || (window.document.infoelp.codactiv.value == "activ"))*/
    if ((window.document.infoelp.codactiv.value == "") || (window.document.infoelp.codactiv.value == "activ"))
    {
        alert("Vous n'avez pas selectionné d'activité à  supprimer.");
        return false;
    }
    else
    {
        if (nbvactiv > 0)
        {
            alert("Vous ne pouvez pas supprimer cette activité sans supprimer les voeux qui y sont rattachés d'abord.");
            return false;
        }
        else
        {
            if (confirm("Voulez vous vraiment supprimer cette activité?"))
            {
                window.document.infoelp.aff.value = "2";
                window.document.infoelp.supra.value = "2";
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}

function Gr_vidvar()
{
    window.document.infoelp.codvrsvet.value = "vrs";
    window.document.infoelp.codactiv.value = "activ";
    window.document.infoelp.aff.value = "1";
    if (window.document.infoelp.codDfd)
        window.document.infoelp.codDfd.value="";
    /*window.document.infoelp.submit();*/
}

function Gr_voeuxactiv()
{
    window.document.infoelp.aff.value = "3";
    window.document.infoelp.action = "gr_activoeux.jsp";
}

function Gr_modactiv(){
    window.document.infoelp.aff.value = "3";
    window.document.infoelp.action = "activites.jsp";
}

function Gr_mactiv(codactiv, codetp, codvrsvet)
{
    window.document.infoelp.aff.value = "3";
    window.document.infoelp.codactiv.value = codactiv;
    window.document.infoelp.codetp.value = codetp;
    window.document.infoelp.codvrsvet.value = codvrsvet;
    window.document.infoelp.action = "activites.jsp";
    window.document.infoelp.submit();
}
function Grdir_activ(nens)
{
    
    window.document.infoelp.ne.value = nens;
    window.document.infoelp.na.value = window.document.infoelp.codactivv.value;
    window.document.infoelp.codactiv.value = window.document.infoelp.codactivv.value;
    window.document.infoelp.action = "vens_activ.jsp";
}

function Gr_nouvoeuactiv()
{
    window.document.infoelp.action = "vnens_activ.jsp";
}

function Gr_suprvactiv()
{
    if (confirm("Voulez vous vraiment supprimer tout les voeux de cette activité?"))
    {
        window.document.infoelp.supra.value = "2";
        window.document.infoelp.aff.value = "3";
        return true;
    }
    else
    {
        return false;
    }
}

function Gr_dirnouvdech()
{
    window.document.infoelp.aff.value = "4";
    window.document.infoelp.action = "gr_ndech.jsp";
}

function Gr_dirnouvpres()
{
    window.document.infoelp.aff.value = "4";
    window.document.infoelp.action = "gr_npres.jsp";
}

function Gr_dechens()
{
    window.document.infoelp.action = "decharges.jsp";
}

function Gr_presens()
{
    window.document.infoelp.action = "prestations.jsp";
}

function Gr_enrnpres()
{
    var poscm = -1;
    var postd = -1;
    var postp = -1;
    var souschaine = ".";
    poscm = window.document.infoelp.hcm.value.indexOf(souschaine, -1);
    postd = window.document.infoelp.htd.value.indexOf(souschaine, -1);
    postp = window.document.infoelp.htp.value.indexOf(souschaine, -1);
    if ((poscm >= 0) || (postd >= 0) || (postp >= 0))
    {
        alert("Les nombre d'heures doivent étre entier.");
        return false;
    }
    else
    {
        if (window.document.infoelp.idensrech.value == "")
        {
            alert("L'enseignant n'est pas renseigné.");
            return false;
        }
        else
        {
            if (window.document.infoelp.comment.value.length > 400)
            {
                alert("Le commentaire ne doit pas dépasser 400 caractéres.");
                return false;
            }
            if (window.document.infoelp.codacte.value == "")
            {
                alert("Le code acte est obligatoire.");
                return false;
            }
            else
            {
                if (window.document.infoelp.codetb.value == "")
                {
                    alert("Le code de l'établissement est obligatoire.");
                    return false;
                }
                else
                {
                    if ((window.document.infoelp.hcm.value == "0") && (window.document.infoelp.htd.value == "0") && (window.document.infoelp.htp.value == "0"))
                    {
                        alert("Il faut obligatoirement entrer, au minimum, un nombre d'heures CM, TD ou TP.");
                        return false;
                    }
                    else
                    {
                        if ((isNaN(window.document.infoelp.hcm.value)) || (window.document.infoelp.hcm.value < 0))
                        {
                            alert("Le nombre d'heures CM de la prestation doit étre numérique et supérieur ou egal é zéro.");
                            return false;
                        }
                        if ((isNaN(window.document.infoelp.htd.value)) || (window.document.infoelp.htd.value < 0))
                        {
                            alert("Le nombre d'heures TD de la prestation doit étre numérique et supérieur ou egal é zéro.");
                            return false;
                        }
                        if ((isNaN(window.document.infoelp.htp.value)) || (window.document.infoelp.htp.value < 0))
                        {
                            alert("Le nombre d'heures TP de la prestation doit étre numérique et supérieur ou egal é zéro.");
                            return false;
                        }
                        if (confirm("Voulez vous vraiment enregistrer cette nouvelle prestation pour cet enseignant ?"))
                        {
                            window.document.infoelp.mod.value = "2";
                            window.document.infoelp.action = "prestations.jsp";
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
        }
    }
}


function Gr_enrndech(toth, serv,urlRetour,mode)
{
    var totcal = 0;

    var pos = -1;
    var poss = -1;
    var posss = -1;
    var souschaine = ".";
    pos = window.document.infoelp.andeb.value.indexOf(souschaine, -1);
    poss = window.document.infoelp.anfin.value.indexOf(souschaine, -1);
    posss = window.document.infoelp.hdech.value.indexOf(souschaine, -1);
    if ((pos >= 0) || (poss >= 0) || (posss >= 0))
    {
        alert("Les années et le nombre d'heures sont des entiers.");
        return false;
    }
    else
    {
        if (window.document.infoelp.idensrech.value == "")
        {
            alert("L'enseignant n'est pas renseigné.");
            return false;
        }
        else
        {
            if ((window.document.infoelp.andeb.value == "") || (window.document.infoelp.anfin.value == ""))
            {
                alert("Les années sont obligatoire.");
                return false;
            }
            else
            {
                if ((isNaN(window.document.infoelp.andeb.value)) || (isNaN(window.document.infoelp.anfin.value)))
                {
                    alert("Les années doivent étre numérique.");
                    return false;
                }
                else
                {
                    if ((window.document.infoelp.andeb.value.length == 4) && (window.document.infoelp.anfin.value.length == 4))
                    {
                        if (window.document.infoelp.codacte.value == "")
                        {
                            alert("Le code acte est obligatoire.");
                            return false;
                        }
                        else
                        {
                            if (window.document.infoelp.hdech.value == "")
                            {
                                alert("Vous devez renseigner le nombre d'heures.");
                                return false;
                            }
                            else
                            {
                                if ((window.document.infoelp.andeb.value) > (window.document.infoelp.anfin.value))
                                {
                                    alert("L'année de fin doit étre superieure ou egale é l'année de début.");
                                    return false;
                                }
                                else
                                {
                                    if ((isNaN(window.document.infoelp.hdech.value)) || (window.document.infoelp.hdech.value <= 0))
                                    {
                                        alert("Le nombre d'heures doit étre numérique et supérieur é zéro.");
                                        return false;
                                    }
                                    else
                                    {
                                        if (window.document.infoelp.comdech.value.length > 400)
                                        {
                                            alert("Le commentaire ne doit pas depasser 400 caractéres");
                                            return false;
                                        }
                                        else
                                        {
                                            totcal = Number(toth) + Number(window.document.infoelp.hdech.value);

                                            if ((serv>0)&&(totcal > serv))
                                            {
                                                if (confirm("Le total d'heures de l'enseignant (" + totcal + " heures) sera supérieur é son service (" + serv + " heures). Voulez vous tout de méme enregistrer ?"))
                                                {
                                                    window.document.infoelp.mod.value = mode;
                                                    window.document.infoelp.action = urlRetour;
                                                    return true;
                                                }
                                                else
                                                {
                                                    return false;
                                                }

                                            }
                                            else
                                            {
                                                if (confirm("Voulez vous vraiment enregistrer ?"))
                                                {
                                                    window.document.infoelp.mod.value = mode;
                                                    window.document.infoelp.action = urlRetour;
                                                    return true;
                                                }
                                                else
                                                {
                                                    return false;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        alert("Les années doivent étre sur quatre caractéres. Exemple : 2005.");
                        return false;
                    }
                }
            }
        }
    }
}

function Gr_suprttdech()
{
    if (confirm("Voulez vous vraiment supprimer toutes les décharges de cet enseignant?"))
    {
        window.document.infoelp.supra.value = "2";
        return true;
    }
    else
    {
        return false;
    }
}

function Gr_suprttpres()
{
    if (confirm("Voulez vous vraiment supprimer toutes les prestations de cet enseignant?"))
    {
        window.document.infoelp.supra.value = "2";
        return true;
    }
    else
    {
        return false;
    }
}


function Gr_modech(numd, url)
{
    window.document.infoelp.numdech.value = numd;
    window.document.infoelp.aff.value = "5";
    window.document.infoelp.action = url ;
    window.document.infoelp.submit();
}

function Gr_modpres(numd)
{
    window.document.infoelp.numpres.value = numd;
    window.document.infoelp.aff.value = "5";
    window.document.infoelp.action = "gr_npres.jsp";
    window.document.infoelp.submit();
}

function Gr_moddech(tot, hserv,url)
{
    var totcal = 0;
    var pos = -1;
    var poss = -1;
    var posss = -1;
    var souschaine = ".";
    pos = window.document.infoelp.andeb.value.indexOf(souschaine, -1);
    poss = window.document.infoelp.anfin.value.indexOf(souschaine, -1);
    posss = window.document.infoelp.hdech.value.indexOf(souschaine, -1);
    if ((pos >= 0) || (poss >= 0) || (posss >= 0))
    {
        alert("Les années et le nombre d'heures sont des entiers.");
        return false;
    }
    else
    {
        if (window.document.infoelp.idensrech.value == "")
        {
            alert("L'enseignant n'est pas renseigné.");
            return false;
        }
        else
        {
            if (window.document.infoelp.numdech.value == "")
            {
                alert("Erreur, il n'y a pas de code .");
                return false;
            }
            else
            {
                if ((window.document.infoelp.andeb.value == "") || (window.document.infoelp.anfin.value == ""))
                {
                    alert("Les années sont obligatoire.");
                    return false;
                }
                else
                {
                    if ((isNaN(window.document.infoelp.andeb.value)) || (isNaN(window.document.infoelp.anfin.value)))
                    {
                        alert("Les années doivent étre numérique.");
                        return false;
                    }
                    else
                    {
                        if ((window.document.infoelp.andeb.value.length == 4) && (window.document.infoelp.anfin.value.length == 4))
                        {
                            if (window.document.infoelp.codacte.value == "")
                            {
                                alert("Le code acte est obligatoire.");
                                return false;
                            }
                            else
                            {
                                if (window.document.infoelp.hdech.value == "")
                                {
                                    alert("Vous devez renseigner le nombre d'heures.");
                                    return false;
                                }
                                else
                                {
                                    if ((window.document.infoelp.andeb.value) > (window.document.infoelp.anfin.value))
                                    {
                                        alert("L'année de fin doit étre superieure ou egale é l'année de début.");
                                        return false;
                                    }
                                    else
                                    {
                                        if ((isNaN(window.document.infoelp.hdech.value)) || (window.document.infoelp.hdech.value <= 0))
                                        {
                                            alert("Le nombre d'heures doit étre numérique et supérieur é zéro.");
                                            return false;
                                        }
                                        else
                                        {
                                            if (window.document.infoelp.comdech.value.length > 400)
                                            {
                                                alert("Le commentaire ne doit pas depasser 400 caractéres");
                                                return false;
                                            }
                                            else
                                            {
                                                totcal = Number(tot) + Number(window.document.infoelp.hdech.value);

                                                if ((hserv>0)&&(totcal > hserv))
                                                {
                                                    if (confirm("Avec cette modification, le total d'heures de l'enseignant (" + totcal + " heures) sera supérieur é son service (" + hserv + " heures). Voulez vous tout de méme modifier  ?"))
                                                    {
                                                        window.document.infoelp.mod.value = "3";
                                                        window.document.infoelp.action = url;
                                                        return true;
                                                    }
                                                    else
                                                    {
                                                        return false;
                                                    }

                                                }
                                                else
                                                {
                                                    if (confirm("Voulez vous vraiment modifier ?"))
                                                    {
                                                        window.document.infoelp.mod.value = "3";
                                                        window.document.infoelp.action = url;
                                                        return true;
                                                    }
                                                    else
                                                    {
                                                        return false;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            alert("Les années doivent étre sur quatre caractéres. Exemple : 2005.");
                            return false;
                        }
                    }
                }
            }
        }
    }
}

function Gr_moddpres()
{
    var poscm = -1;
    var postd = -1;
    var postp = -1;
    var souschaine = ".";
    poscm = window.document.infoelp.hcm.value.indexOf(souschaine, -1);
    postd = window.document.infoelp.htd.value.indexOf(souschaine, -1);
    postp = window.document.infoelp.htp.value.indexOf(souschaine, -1);
    if ((poscm >= 0) || (postd >= 0) || (postp >= 0))
    {
        alert("Les nombre d'heures doivent étre entier.");
        return false;
    }
    else
    {
        if (window.document.infoelp.idensrech.value == "")
        {
            alert("L'enseignant n'est pas renseigné.");
            return false;
        }
        else
        {
            if (window.document.infoelp.comment.value.length > 400)
            {
                alert("Le commentaire ne doit pas dépasser 400 caractéres.");
                return false;
            }
            if (window.document.infoelp.codacte.value == "")
            {
                alert("Le code acte est obligatoire.");
                return false;
            }
            else
            {
                if (window.document.infoelp.codetb.value == "")
                {
                    alert("Le code de l'établissement est obligatoire.");
                    return false;
                }
                else
                {
                    if ((window.document.infoelp.hcm.value == "") || (window.document.infoelp.htd.value == "") || (window.document.infoelp.htp.value == ""))
                    {
                        alert("Les heures CM, TD, TP sont obligatoire.");
                        return false;
                    }
                    else
                    {
                        if ((isNaN(window.document.infoelp.hcm.value)) || (window.document.infoelp.hcm.value < 0))
                        {
                            alert("Le nombre d'heures CM de la prestation doit étre numérique et supérieur ou egal é zéro.");
                            return false;
                        }
                        if ((isNaN(window.document.infoelp.htd.value)) || (window.document.infoelp.htd.value < 0))
                        {
                            alert("Le nombre d'heures TD de la prestation doit étre numérique et supérieur ou egal é zéro.");
                            return false;
                        }
                        if ((isNaN(window.document.infoelp.htp.value)) || (window.document.infoelp.htp.value < 0))
                        {
                            alert("Le nombre d'heures TP de la prestation doit étre numérique et supérieur ou egal é zéro.");
                            return false;
                        }
                        if (confirm("Voulez vous vraiment modifier cette prestation ?"))
                        {
                            window.document.infoelp.mod.value = "3";
                            window.document.infoelp.action = "prestations.jsp";
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
        }
    }
}

function Gr_suprdech(url)
{
    if (confirm("Voulez vous vraiment supprimer ?"))
    {
        window.document.infoelp.supra.value = "3";
        window.document.infoelp.action = url;
        return true;
    }
    else
    {
        return false;
    }
}

function Gr_suprpres()
{
    if (confirm("Voulez vous vraiment supprimer cette prestation ?"))
    {
        window.document.infoelp.supra.value = "3";
        window.document.infoelp.action = "prestations.jsp";
        return true;
    }
    else
    {
        return false;
    }
}

function Gr_idetb(idetb)
{
    /*var idetb = listetb.options[listetb.options.selectedIndex].value;*/   
    window.opener.document.infoelp.codetb.value = idetb;
    window.close();
}

function Gr_idextetb(idetb)
{
    /*var idetb = listetb.options[listetb.options.selectedIndex].value;*/
    window.opener.document.gestensext.codetb.value = idetb;
    window.close();
}

function Gr_idensint(idensint)
{
    window.opener.document.gestensinterne.idensrech.value = idensint;
    window.opener.document.gestensinterne.action = "ensint.jsp";
    window.opener.document.gestensinterne.submit();
    window.close();
}

function Gr_ensitpres()
{
    window.document.gestensinterne.action = "prestations.jsp";
}

function Gr_ensitrep()
{
    window.document.gestensinterne.action = "report_ens.jsp";
}

function Gr_ensitdech()
{
    window.document.gestensinterne.action = "decharges.jsp";
}

function connectEnsExtId(idensext){
    window.opener.document.connectEnsExt.idensrech.value = idensext;
    window.opener.document.connectEnsExt.submit();
    window.opener.focus();
    window.close();
}

function Gr_reportidensext(idensext){
    window.opener.document.gestensext.idensrech.value = idensext;
    window.opener.document.gestensext.submit();
    window.opener.focus();
    window.close();
}

function detailaction(elp, action)
{
    window.document.infoactions.action = "voeux_action.jsp";
    window.document.infoactions.numaction.value = action;
    window.document.infoactions.codelp.value = elp;
    window.document.infoactions.submit();
}

function Suppvaction()
{
    if (confirm("Voulez vous vraiment supprimer tous les voeux sur action de cet enseignant?"))
    {
        window.document.infoelp.suprvoeu.value = "1";
        window.document.infoelp.submit();
        return true;
    }
    else
    {
        return false;
    }
}

function Suppvactiv()
{
    if (confirm("Voulez vous vraiment supprimer tous les voeux sur activité de cet enseignant?"))
    {
        window.document.infoelp.suprvoeu.value = "2";
        window.document.infoelp.submit();
        return true;
    }
    else
    {
        return false;
    }
}

function verifsupext(nbvoeux)
{
    if (nbvoeux > 0)
    {
        alert("Vous devez supprimer les voeux (sur action et activité) de cet enseignant avant de pouvoir le supprimer.");
        return false;
    }
    else
    {
        if (confirm("Voulez vous vraiment supprimer cet enseignant ?"))
        {
            window.document.gestensext.trait.value = "2";
            return true;
        }
        else
        {
            return false;
        }
    }
}

function voeuxext()
{
    window.document.gestensext.action = "voeux_ens.jsp";
    window.document.gestensext.trait.value = "1";
}

function dirvens(numens)
{
    window.document.infaction.idensrech.value = numens;
    window.document.infaction.trait.value = "1";
    window.document.infaction.action = "voeux_ens.jsp";
    window.document.infaction.submit();
}


function LanceGenetat()
{
    if (window.document.genactions.niveaux.value == "0")
    {
        alert("Vous devez selectionner un niveau de generation puis les elements associes.");
        return false;
    }
    else
    {
        if (window.document.genactions.niveaux.value == "1")
        {
            if (window.document.genactions.ufr.value == "")
            {
                alert("Vous devez choisir l'UFR");
                return false;
            }
            else
            {
                window.document.genactions.action = "recapelp";
                return true;
            }
        }
        else
        {
            if (window.document.genactions.niveaux.value == "2")
            {
                if ((window.document.genactions.dip.value == "") || (window.document.genactions.vdi.value == ""))
                {
                    alert("Vous devez choisir le diplome et la version de diplome");
                    return false;
                }
                else
                {
                    window.document.genactions.action = "recapelp";
                    return true;
                }
            }
            else
            {
                if (window.document.genactions.niveaux.value == "3")
                {
                    if ((window.document.genactions.etp.value == "") || (window.document.genactions.vet.value == ""))
                    {
                        alert("Vous devez choisir l'etape et la version d'etape");
                        return false;
                    }
                    else
                    {
                        window.document.genactions.action = "recapelp";
                        return true;
                    }
                }
            }
        }
    }
}


function retirer(lt1, lt2,all)
{
    index1 = lt1.selectedIndex;
    if ((index1 == -1)&&(!all))
    {
        alert("Vous n'avez rien selectionné.");
        return false;
    }

    for (var i = lt1.length - 1; i >= 0; i--)
    {
        if ((lt1.options[i].selected)||(all))
        {
            var finded=false;
            for (var j = lt2.length - 1; j >= 0; j--)
            {
                if (lt2.options[j].text == lt1.options[i].text)
                {
                    lt2.options[j].disabled = false;
                    lt2.options[j].style.color = "menutext";
                    finded=true;
                }
            }
            if (!finded) {
                var newOpt = document.createElement('option');                                            
                newOpt.value=lt1.options[i].value;
                lt2.appendChild(newOpt); 
                newOpt.text=lt1.options[i].text;                
            }
            lt1.options[i] = null;
        }
    }    
}

function flushSelect (sct) {     
    sct.innerHTML="";    
}


function transfert(l1, l2,all)
{
    index1 = l1.selectedIndex;
    if ((index1 == -1)&&(!all))
    {
        alert("Vous n'avez rien selectionné.");
        return false;
    }

    // Supression des doublons potentiels [CB2005]
    var canbeadded;
    for (i = 0; i <= l1.length - 1; i++) {
        if ((l1.options[i].selected)||(all)) {
            if (!l1.options[i].disabled) {
                canbeadded = true;
                for (j = l2.length - 1; j >= 0; j--)
                    if (l2.options[j].text == l1.options[i].text) canbeadded = false;
                if (canbeadded) l2.options[l2.length] = new Option(l1.options[i].text, l1.options[i].value);                
                l1.options[i].disabled = true;
                l1.options[i].style.color = "graytext";
            }
            l1.options[i].selected = false;
        }
    }
}

function selectlistdest(lt)
{
    for (i = lt.length - 1; i >= 0; i--)
    {
        lt.options[i].selected = true;
    }
}

function selectlistdestt(lt,lt2){
    if (window.document.creliste.carelp.value == "")    {
        alert("Vous devez renseigner le caractére de selection");
        return false;
    } else    {
        for (var i = lt.length - 1; i >= 0; i--)        {
            lt.options[i].selected = true;
        }
        for (var j = lt2.length - 1; j >= 0; j--)        {
            lt2.options[j].selected = true;
        }
        return true;
    }
}

function enrlistetat(){
    selectlistdest(window.document.creliste.seldest);
    ind1 = window.document.creliste.seldest.selectedIndex;

    if (window.document.creliste.codliste.value == "")    {
        alert("Le code liste est obligatoire");
        return false;
    } else    {
        if (window.document.creliste.codetp.value == "")        {
            if (window.document.creliste.libliste.value == "")            {
                alert("Le libellé est obligatoire si l'étape n'est pas renseignée.");
                return false;
            } else            {
                if (ind1 == -1)                {
                    alert("Pas d'elp selectionné!")
                    return false;
                } else                {
                    if (confirm("Voulez vous vraiment enregistrer cette liste?"))                    {
                        window.document.creliste.trt.value = "1";
                        return true;
                    } else                    {
                        return false;
                    }
                }
            }
        } else        {
            if (window.document.creliste.codvrsvet == "")            {
                alert("Erreur. Veuillez reselectionner un couple Etape/Version à  partir de l'arbre.");
                return false;
            } else            {
                if (ind1 == -1)                {
                    alert("Pas d'elp selectionné!")
                    return false;
                } else                {
                    if (confirm("Voulez vous vraiment enregistrer cette liste?"))                    {
                        window.document.creliste.trt.value = "1";
                        return true;
                    } else                    {
                        return false;
                    }
                }
            }
        }
    }
}

function modlistetat()
{
    selectlistdest(window.document.creliste.seldest);
    ind1 = window.document.creliste.seldest.selectedIndex;

    if (window.document.creliste.codliste.value == "")
    {
        alert("Le code liste est obligatoire");
        return false;
    }
    else
    {
        if (window.document.creliste.codetp.value == "")
        {
            if (window.document.creliste.libliste.value == "")
            {
                alert("Le libellé est obligatoire si l'étape n'est pas renseignée.");
                return false;
            }
            else
            {
                if (ind1 == -1)
                {
                    alert("Pas d'elp selectionné!")
                    return false;
                }
                else
                {
                    if (confirm("Voulez vous vraiment modifier cette liste?"))
                    {
                        window.document.creliste.trens.value = "1";
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
        }
        else
        {
            if (window.document.creliste.codvrsvet == "")
            {
                alert("Erreur. Veuillez reselectionner un couple Etape/Version à  partir de l'arbre.");
                return false;
            }
            else
            {
                if (ind1 == -1)
                {
                    alert("Pas d'elp selectionné!")
                    return false;
                }
                else
                {
                    if (confirm("Voulez vous vraiment modifier cette liste?"))
                    {
                        window.document.creliste.trens.value = "1";
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
        }
    }
}

function changelst()
{
    window.document.creliste.traff.value = "2";
    window.document.creliste.codliste.value = window.document.creliste.codlst.value;
    window.document.creliste.submit();
}

function suprlistetat()
{
    if (confirm("Voulez vous vraiment supprimer cette liste?"))
    {
        window.document.creliste.trens.value = "3";
        return true;
    }
    else
    {
        return false;
    }

}

function GenServlisteH()
{
    if (window.document.genactionsh.idliste.value == "listv")
    {
    }
    else
    {
        window.document.genactionsh.codliste.value = window.document.genactionsh.idliste.value;
        window.document.genactionsh.submit();
    }
}

function GenServlisteV()
{
    if (window.document.genactionsv.idliste.value == "listv")
    {
    }
    else
    {
        window.document.genactionsv.codliste.value = window.document.genactionsv.idliste.value;
        window.document.genactionsv.submit();
    }
}


function CherchEnsServ()
{
    window.document.fichens.action = "gr_serv_ens.jsp";
    if (window.document.fichens.nomens.value == "")
    {
        alert("Le champs Nom est vide!");
        return false;
    }
    else
    {
        window.document.fichens.trt.value = "1";
        return true;
    }
}

/* maj du 19/01/2007 cette fonction n'est plus utilisée */
function GenServEns(idens)
{
    window.document.fichens.idensprserv.value = idens;
    window.document.fichens.action = "fichenseignant";
    window.document.fichens.target="_blank";
    window.document.fichens.submit();
}

function GenServCmp()
{
    if (window.document.fichens.codcmp.value == "cmpv")
    {
    }
    else
    {
        window.document.forms['fichens'].target='_blank';        
        window.document.forms['fichens'].action = 'ServiceEnseignant';
        window.document.forms['fichens'].submit();
    }
}

function EnrMLD()
{
    window.document.creliste.carelp.disabled = false;
}

function Venrldap()
{
    if ((window.document.procldap.lgldap.value == "") || (window.document.procldap.pssldap.value == ""))
    {
        alert("Vous devez entrer votre login et mot de passe");
        return false;
    }
    else
    {
        if (confirm("Voulez vous vraiment enregistrer les enseignants non utilisateurs en utilisateurs?"))
        {
            window.document.procldap.proceldap.value = "1";
            return true;
        }
        else
        {
            return false;
        }
    }
}

function PassTrue()
{
    if (confirm("Lancer cette procedure?"))
    {
        window.document.procldap2.procherchldap.value = "2";
        return true;
    }
    else
    {
        return false;
    }
}

function suprutil()
{
    if (confirm("Voulez vous vraiment supprimer ces utilisateurs?"))
    {
        window.document.procldap2.procherchldap.value = "3";
        return true;
    }
    else
    {
        return false;
    }
}

function modsuprutil()
{
    if (confirm("Voulez vous vraiment supprimer ces utilisateurs?"))
    {
        window.document.procldap2.procherchldap.value = "4";
        return true;
    }
    else
    {
        return false;
    }
}

function PassFalse()
{
    if (confirm("Voulez vous vraiment enlever les droits d'acces aux utilisateurs?"))
    {
        window.document.procldap.proceldap.value = "3";
        return true;
    }
    else
    {
        return false;
    }

}

function Gr_reportutil(idldap)
{
    window.opener.document.affectprofilg.id.value = idldap;
    window.opener.document.affectprofilg.enrutil.disabled = true;
    window.opener.document.affectprofilg.suprutil.disabled = true;
    window.opener.document.affectprofilg.submit();
    window.close();
}

