/******************************************************************************************************
 * filename: csq.js
 * description: fichier Javascript utilisé pour le site du Conseil de la Sculpture du Québec.
 * author: Hélène Fortier;		Modifié par Pellicam.ca
 * start date: octobre 2005;		Octobre 2008
 ******************************************************************************************************/
 
/*if(!document.getElementById){
  if(document.all){
    document.getElementById=function(){
if(typeof document.all[arguments[0]]!="undefined"){return document.all[arguments[0]]}else{return null}
    }
  }else if(document.layers){
    document.getElementById=function(){
if(typeof document[arguments[0]]!="undefined"){return document[arguments[0]]}else{return null}
    }
  }
}*/


////////////////////////Ajouté par Pellicam.ca//////////////////////////////////

pic1 = new Image(134,102); 
pic1.src = "newimages/TopMenu1.jpg";

pic2 = new Image(134,102);
pic2.src = "newimages/TopMenu1Hover.jpg";

pic3 = new Image(134,102); 
pic3.src = "newimages/TopMenu2.jpg";

pic4 = new Image(134,102);
pic4.src = "newimages/TopMenu2Hover.jpg";

function SwitchEntree()
{
	EntreeMembresDiv.innerHTML = "<form action='connexion_0.html' name='form_login' method='post' onSubmit=\"return ValiderFormulaire('form_login', ''); return false;\"><input type='text' name='username' value='NIP' size='11' class='LoginBoxes' onClick='Blurrer()'><br><input type='password' name='mp' value='*****' size='11' class='LoginBoxes'><br><input type='submit' value='Connecter' name='B1' class='LoginBoxes'></form>";
}

function Blurrer()
{
	if (document.form_login.username.value == "NIP")
	{
		document.form_login.username.value ="";
		document.form_login.mp.value = "";
	}
}

function CourrielFocuser()
{
	if (document.getElementById('courriel').value == 'admission@conseildelasculpture.ca')
	{
		document.getElementById('courriel').style.color='#000000';
		document.getElementById('courriel').value = '';
	}
}

function CourrielBlurrer()
{
	if (document.getElementById('courriel').value == '')
	{
		document.getElementById('courriel').style.color='#FFFFFF';
		document.getElementById('courriel').value = 'admission@conseildelasculpture.ca';
	}
}

////////////////////////Fin Ajouté par Pellicam.ca//////////////////////////////////


//var baseURL = 'http://localhost/';
var baseURL = 'http://www.conseildelasculpture.ca/';


//Vide un champ donné
function EmptyEntry(obj){
    obj.value = "";
}
function SelectEntry(obj){
    obj.select();
}

//Effets sur le menu
function Over(obj, titre){
    if(titre == null)
    {
        titre = '';
    }
    obj.style.background='#E1E1E1';
    obj.title=titre;
    /*obj.className='tdmenuover cursor';*/
    /*obj.style.fontstyle='underline';*/
    //obj.style.color='black';
}
function Out(obj){
    obj.style.background='#EAEAEA';
    obj.title="";
    /*obj.className='tdmenu cursor';*/
    //obj.style.color='black';
}
function OverSearch(obj, obj2, obj3, obj4){
    Over(obj);
    Over(document.getElementById(obj2));
    Over(document.getElementById(obj3));
    Over(document.getElementById(obj4));
}
function OutSearchGray(obj, obj2, obj3, obj4){    
    Out(obj);
    Out(document.getElementById(obj2));
    Out(document.getElementById(obj3));
    Out(document.getElementById(obj4));
}
function OutSearchWhite(obj, obj2, obj3, obj4){
    obj.style.background='white';
    document.getElementById(obj2).style.background='white';
    document.getElementById(obj3).style.background='white';
    document.getElementById(obj4).style.background='white';
}
/*function Lien(obj){
    if(obj.id == "accueil")
    {
        window.open("index_site.php", "_top");
    }
    else if(obj.id == "forum")
    {
        window.open("/forum/", "_top");
    }
    else
    {
        window.open(obj.id + ".php", "_top");
    }
}*/
function Lien(id){
    if(id == '0')
    {
        window.open("?", "_top");
    }
    else if(id == '84')
    {
        window.open("/forum/", "_top");
    }
    else if(id == '85')
    {
        window.open("/doc/", "_top");
    }
    else
    {
        window.open("?p=" + id, "_top");
    }
}
function LienHtml(id, nom){
    if(id == '0')
    {
        window.open("?", "_top");
    }
    else if(id == '84')
    {
        window.open("/forum/", "_top");
    }
    else
    {
        window.open(nom + ".html", "_top");
    }
}

function returnkey(event) {
    var Key = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    
    if(Key == 13)
        return true;
    else 
        return false;
}


if(window.RegExp)
{
    var numerique = /^[0-9]+$/;
    var alphabet = /^[A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç]+$/;
    var alphabetspacedash = /^[A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç \-]+$/;
    var alphabetspacedashapp = /^[A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç \-\']+$/;
    var alphabetspacedashappdot = /^[A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç \-\'\.]+$/;
    var alphabetspacedashappdotSpecial = /^[A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç]+[A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç \-\'\.]+$/;
    var alphabetspacedashappdotdoubleSpecial = /^[A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç]+[A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç \-\'\.\:]+$/;
    var alphanum = /^[A-Za-z0-9]+$/;
    var alphanumspace = /^[A-Za-z0-9 ]+$/;
    var alphanumspacedashappdotSpecial = /^[A-Za-z0-9ÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç]+[A-Za-z0-9ÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç\(\) \-\'\.]+$/;
    var alphanumspacedashappdotdoubleSpecial = /^[A-Za-z0-9ÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç]+[A-Za-z0-9ÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç\(\) \-\'\.\:]+$/;
    var pseudo = /^[A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç ]+$/;
    var ville = /^[A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç \-\.]+$/;
    var adresse = /^[0-9]+(\,)? [0-9A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç \-\.\']+$/;
    var casepostale = /^c(\.)?p(\.)?((:| )?)+[0-9A-Za-z \-\.\']+$/;
    var adr_casepostale = /^[0-9]+(\,)? [0-9A-Za-zÀàÂâÉéÈèÊêËëÎîÏïÔôÖöÙùÛûÇç \-\.\']+(\,|\.| )+c(\.)?p(\.)?((:| )?)+[0-9A-Za-z \-\.\']+$/;
    var cp = /^([A-Za-z][0-9]){3}$/;
    var telregqc = /^(438|450|514|418|819)$/; //438 en vigueur en 2006, dans la région du 514
    var telpart1qc1 = /^[0-9]{3}$/;
    var telpart1qc2 = /^(911|411|((0|1)[0-9]{2}))$/;
    var telpart1qc3 = /^555$/;
    var telpart2qc1 = /^[0-9]{4}$/;
    var telpart2qc2 = /^(0000)$/;
    var telpart2qc3 = /^01[0-9]{2}$/;//555-0100 to 555-0199 range. (réservés pour les films/tv)
    var emailNo = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|( )/;
    var emailYes = /^.+\@(\[?)[A-Za-z0-9\-\.]+\.([A-Za-z]{2,4}|[0-9]{1,3})(\]?)$/;
    var url = /^(?:(?:ftp|https?):\/\/)?(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z])\b(?:\d+)?(?:\/[^;"'<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^;"'<>()\[\]{}\s\x7f-\xff]+)*)?/;
    var username1 = /^[A-Za-z0-9_]{6,}$/;
    var username2 = /^.*_{2}.*$/;
    var passwd = /^[A-Za-z0-9]{6,}$/;
    var formatannee = /^[0-9]{4}$/;
    var formatdate = /^[0-9]{4}-((0[1-9])|(1[0-2]))-((0[1-9])|((1|2)[0-9])|(3(0|1)))$/;
    var monetaire = /^[0-9]+((\.|\,)[0-9]{2})?$/;
    var dateannee = /^2[0-9]{3}$/;
    var datejour = /^((0[1-9])|((1|2)[0-9])|(3(0|1)))$/;
    var heure = /^(((0|1)[0-9])|(2[0-3]))$/;
    var minute = /^[0-5][0-9]$/;
    
    var notempty = /^.+$/;
    var onlyspace = /^ +$/;
}
var erreur = false;
var champsErreur = "";


function ValiderChamps(c, regex){
    return regex.test(document.getElementById(c).value);
}
function ValiderTel(indice){
    if(document.getElementById("province") != null && document.getElementById("province").value == 'QC_PELLICAM')
    {
        if(!ValiderChamps("telreg" + indice, telregqc))
            ErreurChamps("telreg" + indice);
        else
            OkChamps("telreg" + indice);
    }
    else
    {
        if(!ValiderChamps("telreg" + indice, telpart1qc1))
            ErreurChamps("telreg" + indice);
        else
            OkChamps("telreg" + indice);
    }
    
    if(!ValiderChamps("telpart" + indice + "1", telpart1qc1) || ValiderChamps("telpart" + indice + "1", telpart1qc2))
        ErreurChamps("telpart" + indice + "1");
    else
        OkChamps("telpart" + indice + "1");
    if(!ValiderChamps("telpart" + indice + "2", telpart2qc1) || ValiderChamps("telpart" + indice + "2", telpart2qc2))
        ErreurChamps("telpart" + indice + "2");
    else if(ValiderChamps("telpart" + indice + "1", telpart1qc3) && ValiderChamps("telpart" + indice + "2", telpart2qc3))
    {
        erreur = true;
        champsErreur += "telpart" + indice + "1 telpart" + indice + "2 ";
        document.getElementById("telpart" + indice + "1").style.border = "1px solid #F00";
        document.getElementById("telpart" + indice + "2").style.border = "1px solid #F00";
    }
    else
    {
        //OkChamps("telpart" + indice + "1");
        OkChamps("telpart" + indice + "2");
    }
}
function ErreurChamps(c){
    erreur = true;
    champsErreur += c + " ";
    document.getElementById(c).style.border = "1px solid #F00";
    document.getElementById(c).style.color = "#F00";
    document.getElementById(c).style.background = "#FFC";
}
function OkChamps(c){
    /*erreur = true;
    champsErreur += c + " ";*/
    
    document.getElementById(c).style.border = "1px #CCC solid";
    document.getElementById(c).style.color = "#000";
    document.getElementById(c).style.background = "#FFF";
}
function ValiderFormulaire(f, b){    
    /*if(!document.getElementById){
      if(document.all){
        document.getElementById=function(){
    if(typeof document.all[arguments[0]]!="undefined"){return document.all[arguments[0]]}else{return null}
        }
      }else if(document.layers){
        document.getElementById=function(){
    if(typeof document[arguments[0]]!="undefined"){return document[arguments[0]]}else{return null}
        }
      }
    }*/
    
    erreur = false;
    
    if(document.getElementById)
    {
        //désactiver bouton
        DesactiverBouton(b);
        
        switch(f)
        {
            case 'form_inscription_m':
            case 'form_contact':
            case 'form_gestion_evenements_ajout':
            case 'form_gestion_evenements_modif':
            case 'form_gestion_materiaux_ajout':
            case 'form_gestion_materiaux_modif':
            case 'form_gestion_fournisseurs_ajout':
            case 'form_gestion_fournisseurs_modif':
            case 'form_gestion_crendus_ajout':
            case 'form_gestion_crendus_modif':
            case 'form_infosculpture':
            case 'form_gestion_csq':
                if(document.getElementById("msgerreur") != null)
                    ViderMsgErreur("msgerreur");
                break;
            case 'form_perso_profil':
                if(document.getElementById("msgerreurprofil") != null)
                    ViderMsgErreur("msgerreurprofil");
                break;
            case 'form_perso_cours_ajout':
            case 'form_perso_cours_modif':
                if(document.getElementById("msgerreurcours") != null)
                    ViderMsgErreur("msgerreurcours");
                break;
        }
        
        /*if(f == 'form_inscription_m' || f == 'form_contact' || f == 'form_gestion_evenements_ajout')
        {
            if(document.getElementById("msgerreur") != null)
            {
                //Vider msg erreur
                ViderMsgErreur("msgerreur");
            }
        }
        else if(f == 'form_perso_profil')
        {
            if(document.getElementById("msgerreurprofil") != null)
            {
                //Vider msg erreur
                ViderMsgErreur("msgerreurprofil");
            }
        }
        else if(f == 'form_perso_cours_ajout' || f == 'form_perso_cours_modif')
        {
            if(document.getElementById("msgerreurcours") != null)
            {
                //Vider msg erreur
                ViderMsgErreur("msgerreurcours");
            }
        }*/
        
        if(window.RegExp)
        {
            if(f == 'form_inscription_m' || f == 'form_perso_profil')
            {
                //if(!ValiderChamps("adresse", adresse) && !ValiderChamps("adresse", casepostale) && !ValiderChamps("adresse", adr_casepostale))
                if(document.getElementById("adresse").value == '')
                    ErreurChamps("adresse");
                else
                    OkChamps("adresse");
                if((document.getElementById("appt").value != "") && !ValiderChamps("appt", alphanum))
                    ErreurChamps("appt");
                else
                    OkChamps("appt");
                //if(!ValiderChamps("ville", ville))
                if(!ValiderChamps("ville", alphabetspacedashappdot))
                    ErreurChamps("ville");
                else
                    OkChamps("ville");
                if(!ValiderChamps("cp", cp))
                    ErreurChamps("cp");
                else
                    OkChamps("cp");
                ValiderTel("1");
                if(document.getElementById("telreg2").value != '')
                    ValiderTel("2");
                if(document.getElementById("telreg3").value != '')
                    ValiderTel("3");
                if(document.getElementById("telreg4").value != '')
                    ValiderTel("4");
                if(document.getElementById("radcourrielhtmlno") != null && document.getElementById("radcourrielhtmlyes") != null)
                {
                    if(!(!ValiderChamps("courriel", emailNo) && ValiderChamps("courriel", emailYes)))
                        ErreurChamps("courriel");
                    else
                        OkChamps("courriel");
                    
                    if(!(document.getElementById("radcourrielhtmlno").checked || document.getElementById("radcourrielhtmlyes").checked))
                    {
                        erreur = true;
                        champsErreur += "courrielhtml ";
                        document.getElementById("courrielhtml").style.color = "#F00";
                    }
                    else
                    {
                        document.getElementById("courrielhtml").style.color = "#000";
                    }
                }
                else
                {
                    if(ValiderChamps("courriel", notempty))
                    {
                        if(!(!ValiderChamps("courriel", emailNo) && ValiderChamps("courriel", emailYes)))
                            ErreurChamps("courriel");
                        else
                            OkChamps("courriel");
                    }
                    else
                        OkChamps("courriel");
                }
                if((document.getElementById("url").value != "") && !ValiderChamps("url", url))
                    ErreurChamps("url");
                else
                    OkChamps("url");
            }
            
            if(f == 'form_inscription_m' || f == 'form_perso_profil' || f == 'form_activation_m')
            {
                if(document.getElementById("questionmp") != null)
                {
                    if(!ValiderChamps("questionmp", notempty) || ValiderChamps("questionmp", onlyspace))
                        ErreurChamps("questionmp");
                    else
                        OkChamps("questionmp");
                    if(!ValiderChamps("repmp", notempty))
                        ErreurChamps("repmp");
                    else
                        OkChamps("repmp");
                }
            }
            
            switch(f)
            {
                case 'form_inscription_m':
                    if(!(document.getElementById("sexem").checked || document.getElementById("sexef").checked))
                    {
                        erreur = true;
                        champsErreur += "sexe ";
                        document.getElementById("sexem").style.color = "#F00";
                        document.getElementById("sexef").style.color = "#F00";
                    }
                    else
                    {
                        document.getElementById("sexem").style.color = "#000";
                        document.getElementById("sexef").style.color = "#000";
                    }
                    if(!ValiderChamps("prenom", alphabetspacedashappdotSpecial))
                        ErreurChamps("prenom");
                    else
                        OkChamps("prenom");
                    if(!ValiderChamps("nomfamille", alphabetspacedashappdotSpecial))
                        ErreurChamps("nomfamille");
                    else
                        OkChamps("nomfamille");
                    if(document.getElementById("pseudo").value != "" && !ValiderChamps("pseudo", alphabetspacedashappdotSpecial))
                        ErreurChamps("pseudo");
                    else
                        OkChamps("pseudo");
                    
                    if(document.getElementById("cotisationo") != null)
                    {
                        if(!(document.getElementById("cotisationo").checked || document.getElementById("cotisationn").checked))
                        {
                            erreur = true;
                            champsErreur += "cotisation ";
                            document.getElementById("cotisationo").style.color = "#F00";
                            document.getElementById("cotisationn").style.color = "#F00";
                        }
                        else
                        {
                            document.getElementById("cotisationo").style.color = "#000";
                            document.getElementById("cotisationn").style.color = "#000";
                        }
                    }
                    
                    if(document.getElementById("username") != null)
                    {
                        if(!ValiderChamps("username", username1) || ValiderChamps("username", username2))
                            ErreurChamps("username");
                        else
                            OkChamps("username");
                        if(!ValiderChamps("mp", passwd) || (document.getElementById("username").value == document.getElementById("mp").value))
                        {
                            ErreurChamps("mp");
                            EmptyEntry(document.getElementById("mp"));
                            EmptyEntry(document.getElementById("mp2"));
                        }
                        else if((document.getElementById("mp2") != null) && (document.getElementById("mp").value != document.getElementById("mp2").value))
                        {
                            ErreurChamps("mp2");
                            EmptyEntry(document.getElementById("mp"));
                            EmptyEntry(document.getElementById("mp2"));
                        }
                        else
                        {
                            OkChamps("mp");
                            OkChamps("mp2");
                        }
                    }
                    break;
                case 'form_perso_profil':
                    if(/*document.getElementById("nomfamille").readonly != null && */document.getElementById("nomfamille").readonly != false)
                    {
                        if(!(document.getElementById("sexem").checked || document.getElementById("sexef").checked))
                        {
                            erreur = true;
                            champsErreur += "sexe ";
                            document.getElementById("sexe").style.color = "#F00";
                        }
                        if(!ValiderChamps("prenom", alphabetspacedashappdotSpecial))
                            ErreurChamps("prenom");
                        else
                            OkChamps("prenom");
                        if(!ValiderChamps("nomfamille", alphabetspacedashappdotSpecial))
                            ErreurChamps("nomfamille");
                        else
                            OkChamps("nomfamille");
                        if(document.getElementById("pseudo").value != "" && !ValiderChamps("pseudo", alphabetspacedashappdotSpecial))
                            ErreurChamps("pseudo");
                        else
                            OkChamps("pseudo");
                        if(!(document.getElementById("cotisationo").checked || document.getElementById("cotisationn").checked))
                        {
                            erreur = true;
                            champsErreur += "cotisation ";
                            document.getElementById("cotisation").style.color = "#F00";
                        }
                    }
                    else
                    {
                        if(document.getElementById("ancienmp").value != '' || document.getElementById("mp").value != '')
                        {
                            if(!ValiderChamps("ancienmp", passwd))
                            {
                                ErreurChamps("ancienmp");
                                EmptyEntry(document.getElementById("ancienmp"));
                                EmptyEntry(document.getElementById("mp"));
                                EmptyEntry(document.getElementById("mp2"));
                            }
                            else
                                OkChamps("ancienmp");
                            if(!ValiderChamps("mp", passwd))
                            {
                                ErreurChamps("mp");
                                EmptyEntry(document.getElementById("ancienmp"));
                                EmptyEntry(document.getElementById("mp"));
                                EmptyEntry(document.getElementById("mp2"));
                            }
                            else if((document.getElementById("mp2") != null) && (document.getElementById("mp").value != document.getElementById("mp2").value))
                            {
                                ErreurChamps("mp2");
                                EmptyEntry(document.getElementById("ancienmp"));
                                EmptyEntry(document.getElementById("mp"));
                                EmptyEntry(document.getElementById("mp2"));
                            }
                            else
                            {
                                OkChamps("mp");
                                OkChamps("mp2");
                            }
                        }
                    }
                    break;
                case 'form_perso_cours_ajout':
                    if(!ValiderChamps("titrecours", alphanumspacedashappdotdoubleSpecial))
                        ErreurChamps("titrecours");
                    else
                        OkChamps("titrecours");
                    if(document.getElementById("datedebut").value != "" && !ValiderChamps("datedebut", formatdate))
                        ErreurChamps("datedebut");
                    else
                        OkChamps("datedebut");
                    if(document.getElementById("dureecours").value != "" && !ValiderChamps("dureecours", numerique))
                        ErreurChamps("dureecours");
                    else
                        OkChamps("dureecours");
                    if(document.getElementById("coutcours").value != "" && !ValiderChamps("coutcours", monetaire))
                        ErreurChamps("coutcours");
                    else
                        OkChamps("coutcours");
                    if(!ValiderChamps("nbadmissions", numerique))
                        ErreurChamps("nbadmissions");
                    else
                        OkChamps("nbadmissions");
                    break;
                case 'form_perso_cours_modif':
                    var done_cours = false;
                    var indcours = 0;
                    while(!done_cours)
                    {
                        if(document.getElementById("titrecours" + indcours) != null)
                        {
                            if(!ValiderChamps("titrecours" + indcours, alphanumspacedashappdotdoubleSpecial))
                                ErreurChamps("titrecours" + indcours);
                            else
                                OkChamps("titrecours" + indcours);
                            if(document.getElementById("datedebut" + indcours).value != "" && !ValiderChamps("datedebut" + indcours, formatdate))
                                ErreurChamps("datedebut" + indcours);
                            else
                                OkChamps("datedebut" + indcours);
                            if(document.getElementById("dureecours" + indcours).value != "" && !ValiderChamps("dureecours" + indcours, numerique))
                                ErreurChamps("dureecours" + indcours);
                            else
                                OkChamps("dureecours" + indcours);
                            if(document.getElementById("coutcours" + indcours).value != "" && !ValiderChamps("coutcours" + indcours, monetaire))
                                ErreurChamps("coutcours" + indcours);
                            else
                                OkChamps("coutcours" + indcours);
                            if(!ValiderChamps("nbadmissions" + indcours, numerique))
                                ErreurChamps("nbadmissions" + indcours);
                            else
                                OkChamps("nbadmissions" + indcours);
                            
                            indcours++;
                        }
                        else
                            done_cours = true;
                    }
                    break;
                case 'form_login':
                    if(!ValiderChamps("username", username1) || ValiderChamps("username", username2))
                        ErreurChamps("username");
                    else
                        OkChamps("username");
                    if(!ValiderChamps("mp", passwd))
                    {
                        ErreurChamps("mp");
                        EmptyEntry(document.getElementById("mp"));
                    }
                    else
                        OkChamps("mp");
                    break;
                case 'form_forgotten':
                    if(!(!ValiderChamps("courriel", emailNo) && ValiderChamps("courriel", emailYes)))
                        ErreurChamps("courriel");
                    else
                        OkChamps("courriel");
                    break;
                case 'form_activation_m':
                    if(!ValiderChamps("usernametemp", username1) || ValiderChamps("usernametemp", username2))
                        ErreurChamps("usernametemp");
                    else
                        OkChamps("usernametemp");
                    if(!ValiderChamps("mptemp", passwd))
                        ErreurChamps("mptemp");
                    else
                        OkChamps("mptemp");
                    if(!ValiderChamps("username", username1) || ValiderChamps("username", username2))
                        ErreurChamps("username");
                    else
                        OkChamps("username");
                    if(!ValiderChamps("mp", passwd) || (document.getElementById("username").value == document.getElementById("mp").value))
                        ErreurChamps("mp");
                    else if(document.getElementById("mp").value != document.getElementById("mp2").value)
                        ErreurChamps("mp2");
                    else
                    {
                        OkChamps("mp");
                        OkChamps("mp2");
                    }
                    break;
                case 'form_contact':
                    if(!(document.getElementById("radmembreo").checked || document.getElementById("radmembren").checked))
                    {
                        erreur = true;
                        champsErreur += "Membre (oui/non) ";
                        document.getElementById("estmembre").style.color = "#F00";
                    }
                    if(document.getElementById("prenom").value == '')
                        ErreurChamps("prenom");
                    else
                        OkChamps("prenom");
                    if(document.getElementById("nomfamille").value == '')
                        ErreurChamps("nomfamille");
                    else
                        OkChamps("nomfamille");
                    if(!(!ValiderChamps("courriel", emailNo) && ValiderChamps("courriel", emailYes)))
                        ErreurChamps("courriel");
                    else
                        OkChamps("courriel");
                    if(document.getElementById("sujet").value == '')
                        ErreurChamps("sujet");
                    else
                        OkChamps("sujet");
                    if(document.getElementById("msg").value.length < 5)
                        ErreurChamps("msg");
                    else
                        OkChamps("msg");
                    break;
                case 'form_infosculpture':
                    if(document.getElementById("titre").value == '')
                        ErreurChamps("titre");
                    else
                        OkChamps("titre");
                    
                    for(i=1; i<=document.getElementById("nbsujets").value; i++)
                    {
                        if(document.getElementById("titresujet" + i).value == '')
                            ErreurChamps("titresujet" + i);
                        else
                            OkChamps("titresujet" + i);
                        if(document.getElementById("contenusujet" + i).value == '')
                            ErreurChamps("contenusujet" + i);
                        else
                            OkChamps("contenusujet" + i);
                    }
                    break;
                case 'form_gestion_fournisseurs_ajout':
                case 'form_gestion_fournisseurs_modif':
                    if(!ValiderChamps("nomcompagnie", alphanumspacedashappdotdoubleSpecial))
                        ErreurChamps("nomcompagnie");
                    else
                        OkChamps("nomcompagnie");
                    if((document.getElementById("nomcontact").value != "") && (!ValiderChamps("nomcontact", alphabetspacedashappdotSpecial)))
                        ErreurChamps("nomcontact");
                    else
                        OkChamps("nomcontact");
                    if((document.getElementById("prenomcontact").value != "") && (!ValiderChamps("prenomcontact", alphabetspacedashappdotSpecial)))
                        ErreurChamps("prenomcontact");
                    else
                        OkChamps("prenomcontact");
                    if(!ValiderChamps("adresse", adresse))
                        ErreurChamps("adresse");
                    else
                        OkChamps("adresse");
                    if(!ValiderChamps("ville", ville))
                        ErreurChamps("ville");
                    else
                        OkChamps("ville");
                    if(!ValiderChamps("cp", cp))
                        ErreurChamps("cp");
                    else
                        OkChamps("cp");
                    ValiderTel("1");
                    OkChamps("telreg2");
                    OkChamps("telpart21");
                    OkChamps("telpart22");
                    if(document.getElementById("telreg2").value != '')
                        ValiderTel("2");
                    OkChamps("telreg4");
                    OkChamps("telpart41");
                    OkChamps("telpart42");
                    if(document.getElementById("telreg4").value != '')
                        ValiderTel("4");
                    if(document.getElementById("courriel").value != '' && !(!ValiderChamps("courriel", emailNo) && ValiderChamps("courriel", emailYes)))
                        ErreurChamps("courriel");
                    else
                        OkChamps("courriel");
                    if((document.getElementById("url").value != "") && !ValiderChamps("url", url))
                        ErreurChamps("url");
                    else
                        OkChamps("url");
                    break;
                case 'form_gestion_evenements_ajout':
                case 'form_gestion_evenements_modif':
                    if(!ValiderChamps("titreevenement", alphanumspacedashappdotdoubleSpecial))
                        ErreurChamps("titreevenement");
                    else
                        OkChamps("titreevenement");
                    if(document.getElementById("typeevenement").value == 'null')
                        ErreurChamps("typeevenement");
                    else
                        OkChamps("typeevenement");
                    if(!ValiderChamps("anneedebut", dateannee))
                        ErreurChamps("anneedebut");
                    else
                        OkChamps("anneedebut");
                    if(document.getElementById("moisdebut").value == 'null')
                        ErreurChamps("moisdebut");
                    else
                        OkChamps("moisdebut");
                    if(!ValiderChamps("jourdebut", datejour))
                        ErreurChamps("jourdebut");
                    else
                        OkChamps("jourdebut");
                    if(!ValiderChamps("anneefin", dateannee))
                        ErreurChamps("anneefin");
                    else
                        OkChamps("anneefin");
                    if(document.getElementById("moisfin").value == 'null')
                        ErreurChamps("moisfin");
                    else
                        OkChamps("moisfin");
                    if(!ValiderChamps("jourfin", datejour))
                        ErreurChamps("jourfin");
                    else
                        OkChamps("jourfin");
                    if(!ValiderChamps("heuredebut", heure))
                        ErreurChamps("heuredebut");
                    else
                        OkChamps("heuredebut");
                    if(!ValiderChamps("minutedebut", minute))
                        ErreurChamps("minutedebut");
                    else
                        OkChamps("minutedebut");
                    if(!ValiderChamps("heurefin", heure))
                        ErreurChamps("heurefin");
                    else
                        OkChamps("heurefin");
                    if(!ValiderChamps("minutefin", minute))
                        ErreurChamps("minutefin");
                    else
                        OkChamps("minutefin");
                    OkChamps("nomendroit");
                    OkChamps("adresse");
                    if(document.getElementById("nomendroit").value != "" && !ValiderChamps("nomendroit", alphanumspacedashappdotdoubleSpecial))
                        ErreurChamps("nomendroit");
                    if(document.getElementById("nomendroit").value == "" && document.getElementById("adresse").value == '')
                    {
                        ErreurChamps("nomendroit");
                        ErreurChamps("adresse");
                    }
                    if(!ValiderChamps("ville", alphabetspacedashappdot))
                        ErreurChamps("ville");
                    else
                        OkChamps("ville");
                    if(document.getElementById("cp").value != '' && !ValiderChamps("cp", cp))
                        ErreurChamps("cp");
                    else
                        OkChamps("cp");
                    if(document.getElementById("prenomcontact").value != '' && !ValiderChamps("prenomcontact", alphabetspacedashappdotSpecial))
                        ErreurChamps("prenomcontact");
                    else
                        OkChamps("prenomcontact");
                    if(document.getElementById("nomcontact").value != '' && !ValiderChamps("nomcontact", alphabetspacedashappdotSpecial))
                        ErreurChamps("nomcontact");
                    else
                        OkChamps("nomcontact");
                    OkChamps("telreg1");
                    OkChamps("telpart11");
                    OkChamps("telpart12");
                    if(document.getElementById("telreg1").value != '')
                        ValiderTel("1");
                    OkChamps("telreg4");
                    OkChamps("telpart41");
                    OkChamps("telpart42");
                    if(document.getElementById("telreg4").value != '')
                        ValiderTel("4");
                    if(document.getElementById("courriel").value != '' && !(!ValiderChamps("courriel", emailNo) && ValiderChamps("courriel", emailYes)))
                        ErreurChamps("courriel");
                    else
                        OkChamps("courriel");
                    if((document.getElementById("url").value != "") && !ValiderChamps("url", url))
                        ErreurChamps("url");
                    else
                        OkChamps("url");
                    if((document.getElementById("cout").value != "") && !ValiderChamps("cout", monetaire))
                        ErreurChamps("cout");
                    else
                        OkChamps("cout");
                    break;
                case 'form_gestion_materiaux_ajout':
                case 'form_gestion_materiaux_modif':
                    if(document.getElementById("type").value == 'null')
                        ErreurChamps("type");
                    else
                        OkChamps("type");
                    if(!ValiderChamps("nom", alphanumspacedashappdotdoubleSpecial))
                        ErreurChamps("nom");
                    else
                        OkChamps("nom");
                    break;
                case 'form_gestion_crendus_ajout':
                case 'form_gestion_crendus_modif':
                    if(!ValiderChamps("date", formatdate))
                        ErreurChamps("date");
                    else
                        OkChamps("date");
                    
                    for(i=1; i<=document.getElementById("nbsujets").value; i++)
                    {
                        if(document.getElementById("titresujet" + i).value == '')
                            ErreurChamps("titresujet" + i);
                        else
                            OkChamps("titresujet" + i);
                        if(document.getElementById("contenusujet" + i).value == '')
                            ErreurChamps("contenusujet" + i);
                        else
                            OkChamps("contenusujet" + i);
                    }
                    break;
                case 'form_gestion_csq':
                    if(!ValiderChamps("nom", alphabetspacedashappdotSpecial))
                        ErreurChamps("nom");
                    else
                        OkChamps("nom");
                    if(document.getElementById("adresse").value == '')
                        ErreurChamps("adresse");
                    else
                        OkChamps("adresse");
                    if(!ValiderChamps("ville", alphabetspacedashappdot))
                        ErreurChamps("ville");
                    else
                        OkChamps("ville");
                    if(!ValiderChamps("cp", cp))
                        ErreurChamps("cp");
                    else
                        OkChamps("cp");
                    ValiderTel("1");
                    OkChamps("telreg4");
                    OkChamps("telpart41");
                    OkChamps("telpart42");
                    if(document.getElementById("telreg4").value != '')
                        ValiderTel("4");
                    if(!(!ValiderChamps("courriel", emailNo) && ValiderChamps("courriel", emailYes)))
                        ErreurChamps("courriel");
                    else
                        OkChamps("courriel");
                    if(!ValiderChamps("url", url))
                        ErreurChamps("url");
                    else
                        OkChamps("url");
                    
                    for(i=1; i < nombreliens; i++)
                    {
                        OkChamps("nom_lien" + i);
                        OkChamps("url_lien" + i);
                        
                        if(document.getElementById("nom_lien" + i).value != '')
                        {
                            if(!ValiderChamps("nom_lien" + i, alphanumspacedashappdotdoubleSpecial))
                                ErreurChamps("nom_lien" + i);
                            if(!ValiderChamps("url_lien" + i, url))
                                ErreurChamps("url_lien" + i);
                        }
                    }
                    break;
            }
        }
        
        if(erreur)
        {
            switch(f)
            {
                case 'form_inscription_m':
                case 'form_contact':
                case 'form_infosculpture':
                case 'form_activation_m':
                case 'form_gestion_evenements_ajout':
                case 'form_gestion_evenements_modif':
                case 'form_gestion_materiaux_ajout':
                case 'form_gestion_materiaux_modif':
                case 'form_gestion_fournisseurs_ajout':
                case 'form_gestion_fournisseurs_modif':
                case 'form_gestion_crendus_ajout':
                case 'form_gestion_crendus_modif':
                case 'form_gestion_csq':
                    if(document.getElementById("msgerreur") != null)
                        document.getElementById("msgerreur").value = "Les champs en rouge contiennent une erreur.";
                    break;
                case 'form_perso_profil':
                    if(document.getElementById("msgerreurprofil") != null)
                        document.getElementById("msgerreurprofil").value = "Les champs en rouge contiennent une erreur.";
                    break;
                case 'form_perso_cours_ajout':
                case 'form_perso_cours_modif':
                    if(document.getElementById("msgerreurcours") != null)
                        document.getElementById("msgerreurcours").value = "Les champs en rouge contiennent une erreur.";
                    break;
            }
            
            ActiverBouton(b);
            return false;
        }
        else
        {
            //f.submit();
            //document.getElementById(f).submit();
            ActiverBouton(b);
            
            if(f != 'form_infosculpture')
                document.forms[f].submit();
            
            //désactiver bouton
            //DesactiverBouton(b);
        }
    }
    else
    {
        document.forms[f].submit();
        //return true;    //si ça a pas envoyé...
    }
}

function DesactiverBouton(b){
    if(b != '')
    {
        document.getElementById(b).disabled = true;
    }
}
function ActiverBouton(b){
    if(b != '')
    {
        document.getElementById(b).disabled = false;
    }
}

function ViderMsgErreur(msg){
    if(document.getElementById(msg) != null)
    {
        document.getElementById(msg).value = "";
    }
}

function checkLength(f, c, l)
{
    switch(f)
    {
        case 'form_perso_folio':
            var limite = 300;
            var old = document.getElementById("compteuroeuvre").value;
            
            var compteur = document.getElementById(c).value.length;
            
            //document.getElementById("compteur").value = limite - document.getElementById(c).value.length;
            document.getElementById("compteuroeuvre").value = compteur;
            
            if(compteur > limite)
                ErreurChamps(c);
            else
                OkChamps(c);
            
            if(compteur > limite && old <= limite)
            {
                alert('Vous pouvez entrer un maximum de ' + limite + ' caractères.');
                
                //f.msgerreurbio.text = 
            }
            break;
        case 'form_perso_cours_ajout':
        case 'form_gestion_evenements_ajout':
        case 'form_gestion_evenements_modif':
        case 'form_gestion_materiaux_ajout':
        case 'form_gestion_materiaux_modif':
            var limite = l;
            
            var compteur = document.getElementById(c).value.length;
            
            if(c == 'descriptioncours' || c == 'description')
            {
                var old = document.getElementById("compteurdescr").value;
                
                document.getElementById("compteurdescr").value = compteur;
            }
            else if(c == 'remarquescours' || c == 'remarques')
            {
                var old = document.getElementById("compteurrem").value;
                
                document.getElementById("compteurrem").value = compteur;
            }
            
            if(compteur > limite)
                ErreurChamps(c);
            else
                OkChamps(c);
            
            if(compteur > limite && old <= limite)
            {
                alert('Vous pouvez entrer un maximum de ' + limite + ' caractères.');
            }
            break;
        case 'form_gestion_csq':
            var compteur = document.getElementById(c).value.length;
            
            if(c == 'about')
            {
                var limite = 800;
                var old = document.getElementById("compteurabout").value;
                
                document.getElementById("compteurabout").value = compteur;
            }
            else if(c == 'historique')
            {
                var limite = 5000;
                var old = document.getElementById("compteurhistorique").value;
                
                document.getElementById("compteurhistorique").value = compteur;
            }
            
            if(compteur > limite)
                ErreurChamps(c);
            else
                OkChamps(c);
            
            if(compteur > limite && old <= limite)
            {
                alert('Vous pouvez entrer un maximum de ' + limite + ' caractères.');
            }
            break;
        default:
            var limite = 20000;
            var old = document.getElementById("compteur").value;
            
            var compteur = document.getElementById(c).value.length;
            
            //document.getElementById("compteur").value = limite - document.getElementById(c).value.length;
            document.getElementById("compteur").value = compteur;
            
            if(compteur > limite)
                ErreurChamps(c);
            else
                OkChamps(c);
            
            if(compteur > limite && old <= limite)
            {
                alert('Vous pouvez entrer un maximum de 20 000 caractères.');
                
                //f.msgerreurbio.text = 
            }
            break;
    }
}
function checkLengthSpecial(f, c, i)
{
    if(f == 'form_perso_cours_modif')
    {
        var limite = 300;
        
        var compteur = document.getElementById(c).value.length;
        
        if(c == 'descriptioncours' + i)
        {
            var old = document.getElementById("compteurdescr" + i).value;
            
            document.getElementById("compteurdescr" + i).value = compteur;
        }
        else if(c == 'remarquescours' + i)
        {
            var old = document.getElementById("compteurrem" + i).value;
            
            document.getElementById("compteurrem" + i).value = compteur;
        }
        
        if(compteur > limite)
            ErreurChamps(c);
        else
            OkChamps(c);
        
        if(compteur > limite && old <= limite)
        {
            alert('Vous pouvez entrer un maximum de ' + limite + ' caractères.');
        }
    }
}

function ModifCotisationMembre(rep){
    if(document.getElementById("courriel").value != '')    //cotisation payée
    {
        document.getElementById("rang").disabled = false;
    }
    else    //cotisation non payée
    {
        document.getElementById("rang").value = 1;
        document.getElementById("rang").disabled = true;
        
        document.getElementById("fonction").value = "null";
        document.getElementById("fonction").disabled = true;
        
        document.getElementById("chkpermission1").disabled = true;
        document.getElementById("chkpermission2").disabled = true;
        document.getElementById("chkpermission3").disabled = true;
        document.getElementById("chkpermission4").disabled = true;
        document.getElementById("chkpermission5").disabled = true;
        document.getElementById("chkpermission6").disabled = true;
        document.getElementById("chkpermission7").disabled = true;
        
        document.getElementById("chkpermission1").checked = false;
        document.getElementById("chkpermission2").checked = false;
        document.getElementById("chkpermission3").checked = false;
        document.getElementById("chkpermission4").checked = false;
        document.getElementById("chkpermission5").checked = false;
        document.getElementById("chkpermission6").checked = false;
        document.getElementById("chkpermission7").checked = false;
    }
}
function ModifRangMembre(){
    switch(document.getElementById("rang").value)
    {
        case '1': /*membre régulier*/
            document.getElementById("fonction").value = "null";
            document.getElementById("fonction").disabled = true;
            
            document.getElementById("chkpermission1").disabled = true;
            document.getElementById("chkpermission2").disabled = true;
            document.getElementById("chkpermission3").disabled = true;
            document.getElementById("chkpermission4").disabled = true;
            document.getElementById("chkpermission5").disabled = true;
            document.getElementById("chkpermission6").disabled = true;
            document.getElementById("chkpermission7").disabled = true;
            
            document.getElementById("chkpermission1").checked = false;
            document.getElementById("chkpermission2").checked = false;
            document.getElementById("chkpermission3").checked = false;
            document.getElementById("chkpermission4").checked = false;
            document.getElementById("chkpermission5").checked = false;
            document.getElementById("chkpermission6").checked = false;
            document.getElementById("chkpermission7").checked = false;
            break;
        case '2': /*comité spécial*/
            document.getElementById("fonction").value = "null";
            document.getElementById("fonction").disabled = true;
            
            document.getElementById("chkpermission1").disabled = false;
            document.getElementById("chkpermission2").disabled = false;
            document.getElementById("chkpermission3").disabled = false;
            document.getElementById("chkpermission4").disabled = false;
            document.getElementById("chkpermission5").disabled = false;
            document.getElementById("chkpermission6").disabled = false;
            document.getElementById("chkpermission7").disabled = false;
            
            document.getElementById("chkpermission1").checked = false;
            document.getElementById("chkpermission2").checked = false;
            document.getElementById("chkpermission3").checked = false;
            document.getElementById("chkpermission4").checked = false;
            document.getElementById("chkpermission5").checked = false;
            document.getElementById("chkpermission6").checked = false;
            document.getElementById("chkpermission7").checked = false;
            break;
        case '3': /*conseil d'administration*/
            document.getElementById("fonction").value = 4;
            document.getElementById("fonction").disabled = false;
            
            document.getElementById("chkpermission1").disabled = false;
            document.getElementById("chkpermission2").disabled = false;
            document.getElementById("chkpermission3").disabled = false;
            document.getElementById("chkpermission4").disabled = false;
            document.getElementById("chkpermission5").disabled = false;
            document.getElementById("chkpermission6").disabled = false;
            document.getElementById("chkpermission7").disabled = false;
            break;
        case '4': /*ancien président*/
            document.getElementById("fonction").value = "null";
            document.getElementById("fonction").disabled = true;
            
            document.getElementById("chkpermission1").disabled = true;
            document.getElementById("chkpermission2").disabled = true;
            document.getElementById("chkpermission3").disabled = true;
            document.getElementById("chkpermission4").disabled = true;
            document.getElementById("chkpermission5").disabled = true;
            document.getElementById("chkpermission6").disabled = true;
            document.getElementById("chkpermission7").disabled = true;
            
            document.getElementById("chkpermission1").checked = false;
            document.getElementById("chkpermission2").checked = false;
            document.getElementById("chkpermission3").checked = false;
            document.getElementById("chkpermission4").checked = false;
            document.getElementById("chkpermission5").checked = false;
            document.getElementById("chkpermission6").checked = false;
            document.getElementById("chkpermission7").checked = false;
            break;
    }
}
function ModifFctMembre(){
    switch(document.getElementById("fonction").value)
    {
        case '1': /*président*/
            document.getElementById("chkpermission1").checked = true;
            document.getElementById("chkpermission2").checked = true;
            document.getElementById("chkpermission3").checked = true;
            document.getElementById("chkpermission4").checked = true;
            document.getElementById("chkpermission5").checked = true;
            document.getElementById("chkpermission6").checked = true;
            document.getElementById("chkpermission7").checked = true;
            break;
        case '2': /*secrétaire*/
            document.getElementById("chkpermission1").checked = false;
            document.getElementById("chkpermission2").checked = false;
            document.getElementById("chkpermission3").checked = false;
            document.getElementById("chkpermission4").checked = true;
            document.getElementById("chkpermission5").checked = false;
            document.getElementById("chkpermission6").checked = false;
            document.getElementById("chkpermission7").checked = true;
            break;
        case '3': /*trésorier*/
            document.getElementById("chkpermission1").checked = true;
            document.getElementById("chkpermission2").checked = false;
            document.getElementById("chkpermission3").checked = false;
            document.getElementById("chkpermission4").checked = false;
            document.getElementById("chkpermission5").checked = false;
            document.getElementById("chkpermission6").checked = false;
            document.getElementById("chkpermission7").checked = false;
            break;
        case '4': /*administrateur*/
            document.getElementById("chkpermission1").checked = false;
            document.getElementById("chkpermission2").checked = false;
            document.getElementById("chkpermission3").checked = false;
            document.getElementById("chkpermission4").checked = false;
            document.getElementById("chkpermission5").checked = false;
            document.getElementById("chkpermission6").checked = false;
            document.getElementById("chkpermission7").checked = false;
            break;
        case '5': /*webmestre*/
            document.getElementById("chkpermission1").checked = true;
            document.getElementById("chkpermission2").checked = true;
            document.getElementById("chkpermission3").checked = true;
            document.getElementById("chkpermission4").checked = true;
            document.getElementById("chkpermission5").checked = true;
            document.getElementById("chkpermission6").checked = true;
            document.getElementById("chkpermission7").checked = true;
            break;
        case 'null': /*null*/
            document.getElementById("rang").value = "1";
            
            document.getElementById("fonction").value = "null";
            document.getElementById("fonction").disabled = true;
            
            document.getElementById("chkpermission1").disabled = true;
            document.getElementById("chkpermission2").disabled = true;
            document.getElementById("chkpermission3").disabled = true;
            document.getElementById("chkpermission4").disabled = true;
            document.getElementById("chkpermission5").disabled = true;
            document.getElementById("chkpermission6").disabled = true;
            document.getElementById("chkpermission7").disabled = true;
            
            document.getElementById("chkpermission1").checked = false;
            document.getElementById("chkpermission2").checked = false;
            document.getElementById("chkpermission3").checked = false;
            document.getElementById("chkpermission4").checked = false;
            document.getElementById("chkpermission5").checked = false;
            document.getElementById("chkpermission6").checked = false;
            document.getElementById("chkpermission7").checked = false;
            break;
    }
}



function pageReload(){
    location.reload();
}


function RechercheBig(){ //recherche sur le site (avec Google)
    //var termes = document.getElementById("keywordbig").value;
    //window.open("http://www.google.com/search?lr=lang_fr&cr=&q="+ termes + "+site:http://www.conseildelasculpture.ca/","Google");
}
function Recherche(sorte){
    p = '';
    
    if(sorte == 'm')
        p = 'membres';
    else if(sorte == 'f')
        p = 'fournisseurs';
        
    window.open("gestion_" + p + ".php?action=modif&keyword=" + document.getElementById("keyword").value + "&categorie=" + document.getElementById("categorie").value + "&ordre=" + document.getElementById("ordre").value, "_top");
}
function Recherche2(a, id_page){
    s = '';
    //p = '';
    
    if(id_page == 14)
    {
        //p = 'membres';
        s = 'nom';
    }
    else if(id_page == 11)
    {
        //p = 'fournisseurs';
        s = 'id_fournisseur';
    }
    else if(id_page == 10)
    {
        //p = 'evenements';
        s = 'id_evenement';
    }
        
    window.open("?p=" + id_page + "&action=" + a + "&keyword=" + document.getElementById("keyword").value + "&categorie=" + document.getElementById("categorie").value + "&rechercheetat=" + document.getElementById("rechercheetat").value + "&ordre=" + s, "_top");
}
function RechercheGMembres(id_page, ordre, change){
    window.open("?p=" + id_page + "&keyword=" + document.getElementById("keyword").value + "&categorie=" + document.getElementById("categorie").value + "&rechercheetat=" + document.getElementById("rechercheetat").value + "&ordre=" + ordre + "&change=" + change, "_top");
}
function RechercheGEvenements(id_page, ordre, change){
    window.open("?p=" + id_page + "&keyword=" + document.getElementById("keyword").value + "&categorie=" + document.getElementById("categorie").value + "&rechercheetat=" + document.getElementById("rechercheetat").value + "&ordre=" + ordre + "&change=" + change, "_top");
}
function RechercheGMateriaux(id_page, ordre, change){
    window.open("?p=" + id_page + "&s=mx&keyword=" + document.getElementById("keyword").value + "&categorie=" + document.getElementById("categorie").value + "&rechercheetat=" + document.getElementById("rechercheetat").value + "&ordre=" + ordre + "&change=" + change, "_top");
}
function RechercheGMateriauxSS(id_page, ordre, change){
    window.open("?p=" + id_page + "&s=ss&keyword=" + document.getElementById("keyword_ss").value + "&categorie=" + document.getElementById("categorie_ss").value + "&rechercheetat=" + document.getElementById("rechercheetat_ss").value + "&ordre=" + ordre + "&change=" + change, "_top");
}
function RechercheGFournisseurs(id_page, ordre, change){
    window.open("?p=" + id_page + "&keyword=" + document.getElementById("keyword").value + "&categorie=" + document.getElementById("categorie").value + "&rechercheetat=" + document.getElementById("rechercheetat").value + "&ordre=" + ordre + "&change=" + change, "_top");
}
function RechercheEvenements(ordre, change){
    window.open(baseURL + "evenements/keyword=" + document.getElementById("keyword").value + "&categorie=" + document.getElementById("categorie").value + "&rechercheetat=" + document.getElementById("rechercheetat").value + "&ordre=" + ordre + "&change=" + change, "_top");
}
function RechercheCours(ordre, change){
    window.open(baseURL + "cours/keyword=" + document.getElementById("keyword").value + "&categorie=" + document.getElementById("categorie").value + "&rechercheetat=" + document.getElementById("rechercheetat").value + "&niveau=" + document.getElementById("niveaucours").value + "&ordre=" + ordre + "&change=" + change, "_top");
}
function LienSearch(id, id_page){
    window.open("?p=" + id_page + "&id=" + id, "_top");
}
function LienSearchSpecial(id, action, id_page){
    window.open("?p=" + id_page + "&action=" + action + "&id=" + id, "_top");
}
/*function LienSearchAppr(id){    
    window.open("gestion_membres.php?action=listatt&id=" + id, "_top");
}*/
//function Ecrire(){
    /* provient de http://backword.me.uk/email.html */
    var href_opener = "<a href=\"";
    var first = 'ma';
    var second = 'il';
    var third = 'to:';
    var otliam = href_opener + first + second + third;
    var href_closer = "<\/a>.";
    
    function Ecrire(add, dom, subject, title, text) {
        document.write(otliam); 
        document.write(add);
        document.write('@');
        document.write(dom);
        if(subject != '')
        {
            document.write('?');
            document.write('subject');
            document.write('=');
            document.write(subject);
        }
        
        document.write('" title="');
        
        if(title != '')
        {
            //document.write('" title="' + title + '">');
            document.write(title);
        }
        else if(text != '')
        {
            document.write(text);
        }
        else
        {
            document.write(add);
            document.write('@');
            document.write(dom);
        }
        
        document.write('" class="normal">');
        
        if(text == '')
        {
            document.write(add);
            document.write('@');
            document.write(dom);
        }
        else
        {
            document.write(text);
        }
        document.write('<\/a>');
    }
//}

function TypeMateriau(tmx, sorte){
    materiaux = window.open("mx.php?tmx=" + tmx + "&amp;s=" + sorte, "materiaux", "height=450,width=400,toolbar=0,menubar=0,scrollbars=1,resizable=1,status=1,location=0,left=" + ((screen.width - 400)/2) + ",screenX=" + ((screen.width - 400)/2) + ",top=" + ((screen.height - 450)/2) + ",screenY=" + ((screen.height - 450)/2));
    
    if(window.focus)
    {
        materiaux.focus();
    }
    materiaux.opener.name = "mx";
}
function ChoisirMateriaux(f, tmx){
    var tot = countChecked();
    
    window.opener.document.getElementById("nbchoisis" + tmx).value = tot;
    
    if(tot != 0)
    {
        window.opener.document.getElementById("chkmateriau" + tmx).checked = true;
    }
    
    document.getElementById(f).submit();
    //FermerFenetre();
}
function countChecked(){
    var total = 0;
    for(var i = 0; i < document.form_materiaux.elements.length; i++)
    {
        if(document.form_materiaux.elements[i].type == 'checkbox')
        {
            if (document.form_materiaux.elements[i].checked == true)
            {
                total ++;
            }
        }
    }
    //mx.getElementById("nbchoisis").value = total;
    return total;
}
function VoirOeuvre(id_m, id_o, cat){
    photos = window.open(baseURL + "photo.php?m=" + id_m + "&cat=" + cat + "&id=" + id_o, "photos", "height=450,width=400,toolbar=0,menubar=0,scrollbars=1,resizable=1,status=1,location=0,left=" + ((screen.width - 400)/2) + ",screenX=" + ((screen.width - 400)/2) + ",top=" + ((screen.height - 450)/2) + ",screenY=" + ((screen.height - 450)/2));
    if(window.focus)
    {
        photos.focus();
    }
    photos.opener.name = "perso";
}
function VoirPhotoMembre(id_m, cat){
    photos = window.open(baseURL + "photo.php?cat=" + cat + "&id=" + id_m, "photos", "height=450,width=400,toolbar=0,menubar=0,scrollbars=1,resizable=1,status=1,location=0,left=" + ((screen.width - 400)/2) + ",screenX=" + ((screen.width - 400)/2) + ",top=" + ((screen.height - 450)/2) + ",screenY=" + ((screen.height - 450)/2));
    if(window.focus)
    {
        photos.focus();
    }
    photos.opener.name = "perso";
}
function Lexique(id_mot){
    lexique = window.open("lexique.php?id=" + id_mot, "lexique", "height=400,width=550,toolbar=0,menubar=0,scrollbars=1,resizable=1,status=1,location=0,left=" + ((screen.width - 550)/2) + ",screenX=" + ((screen.width - 550)/2) + ",top=" + ((screen.height - 400)/2) + ",screenY=" + ((screen.height - 400)/2));
    if(window.focus)
    {
        lexique.focus();
    }
    lexique.opener.name = "ethique";
}
function LexiqueHtml(mot){
    lexique = window.open(baseURL + "lexique/" + mot + ".html", "lexique", "height=400,width=550,toolbar=0,menubar=0,scrollbars=1,resizable=1,status=1,location=0,left=" + ((screen.width - 550)/2) + ",screenX=" + ((screen.width - 550)/2) + ",top=" + ((screen.height - 400)/2) + ",screenY=" + ((screen.height - 400)/2));
    if(window.focus)
    {
        lexique.focus();
    }
    lexique.opener.name = "ethique";
}
//change la taille de la fenêtre
function resizeOuterTo(w, h){
    if(parseInt(navigator.appVersion) > 3)
    {
        if(w > screen.width)
        {
            width = screen.width
        }
        else
        {
            width = w;
        }
        
        if(h > screen.height)
        {
            height = screen.width;
        }
        else
        {
            height = h;
        }
        
        if (navigator.appName == "Netscape")
        {
            top.outerWidth = width;
            top.outerHeight = height;
        }
        else
        {
            top.resizeTo(w, h);
        }
        
        //re-centrer la fenêtre
        if(((screen.width - w)/2) < 0)
        {
            w_pos = 0;
        }
        else
        {
            w_pos = (screen.width - w)/2;
        }
        
        if(((screen.height - h)/2) < 0)
        {
            h_pos = 0;
        }
        else
        {
            h_pos = (screen.height - h)/2;
        }
        top.moveTo(w_pos, h_pos);
    }
}

function FermerFenetre(){
    self.close();
}


function ToNormalText(id){
    document.getElementById(id).className = 'textblack';
    document.getElementById(id).value = "";
}



var indice_champ = 2;
var nombreliens = 2;
//document.getElementById("infosculpture_top_js").innerHTML="";
function twAjoutChamp(divpage, nbliens){
    if(divpage == 'infosculpture_top_js')
    {
        //document.getElementById("infosculpture_top_js").removeChildren();
        var nb = document.getElementById("nbsujets").value;
        
        if(nb < indice_champ)
        {
            //document.getElementById("trsujet").parentNode.parentNode.removeChild(document.getElementById("trsujet").parentNode);
            var del = nb*2;
            var keep = nb*2;//how many rows you wanna keep up on the table?
            var oRows = document.getElementById('divsujets').getElementsByTagName('div');
            var root = oRows[0].parentNode;
            
            while(nb < indice_champ-1)
            {
                root.removeChild(oRows[del]);
                root.removeChild(oRows[del]);
                
                indice_champ--;
            }
            
            return;
        }
        
        /*var oDiv = document.createElement('div');
        //oDiv.setAttribute('id','titresujet' + i);
        var oTable = document.createElement('table');
        oTable.className = 'tablecontenu';
        oTable.setAttribute('id','tablesujets');
        oTable.setAttribute('name','tablesujets');
        var oTBody = document.createElement('tbody');
        oTBody.setAttribute('id','tbodysujets');
        oTBody.setAttribute('name','tbodysujets');*/
            
        for(indice_champ=indice_champ; indice_champ<=nb; indice_champ++)
        {
            /*Ligne 1, sujet*/
            var oDiv = document.createElement('div');
            oDiv.setAttribute('id','sujet' + indice_champ);
            //oDiv.setAttribute('name','sujet' + i);
            if(indice_champ != 1)
                oDiv.className = 'required notfirst';
            else
                oDiv.className = 'required';
            var oLabel = document.createElement('label');
            oLabel.setAttribute('for','titresujet' + indice_champ);
            oLabel.className = 'largerlabel';
            var oSpan = document.createElement('span');
            oSpan.className = 'textimportant';
            var oAppos = document.createTextNode('*');
            oSpan.appendChild(oAppos);
            oLabel.appendChild(oSpan);
            var oSujet = document.createTextNode(' Sujet ' + indice_champ + ':');
            oLabel.appendChild(oSujet);
            oDiv.appendChild(oLabel);
            
            var oChamp = document.createElement('input');
            oChamp.setAttribute('type','text');
            oChamp.className = 'textbox';
            oChamp.setAttribute('id','titresujet' + indice_champ);
            oChamp.setAttribute('name','titresujet' + indice_champ);
            oChamp.setAttribute('size',28);
            oChamp.setAttribute('maxLength',80);
            oDiv.appendChild(oChamp);
            document.getElementById("divsujets").appendChild(oDiv);
            
            /*Ligne 2, contenu*/
            var oDiv = document.createElement('div');
            oDiv.setAttribute('id','divcontenu' + indice_champ);
            //oDiv.setAttribute('name','divcontenu' + i);
            oDiv.className = 'required';
            var oFieldset = document.createElement('fieldset');
            var oLegend = document.createElement('legend');
            var oSpan = document.createElement('span');
            oSpan.className = 'textimportant';
            var oAppos = document.createTextNode('*');
            oSpan.appendChild(oAppos);
            oLegend.appendChild(oSpan);
            var oLegendText = document.createTextNode(' Contenu du sujet ' + indice_champ);
            oLegend.appendChild(oLegendText);
            oFieldset.appendChild(oLegend);
            var oChamp = document.createElement('textarea');
            oChamp.className = 'textbox';
            oChamp.setAttribute('id','contenusujet' + indice_champ);
            oChamp.setAttribute('name','contenusujet' + indice_champ);
            oChamp.setAttribute('cols',40);
            oChamp.setAttribute('rows',5);
            oFieldset.appendChild(oChamp);
            oDiv.appendChild(oFieldset);
            document.getElementById("divsujets").appendChild(oDiv);
        }
    }
    else if( divpage == 'crendu_top_js')
    {
        //document.getElementById("infosculpture_top_js").removeChildren();
        var nb = document.getElementById("nbsujets").value;
        
        /*if(nb >= indice_champ && (nbliens >= indice_champ || indice_champ >= 2))
            indice_champ = nb + 1;*/
        
        if(nb < indice_champ)
        {
            //document.getElementById("trsujet").parentNode.parentNode.removeChild(document.getElementById("trsujet").parentNode);
            var del = nb*2;
            var keep = nb*2;//how many rows you wanna keep up on the table?
            var oRows = document.getElementById('divsujets').getElementsByTagName('div');
            var root = oRows[0].parentNode;
            
            while(nb < indice_champ-1)
            {
                root.removeChild(oRows[del]);
                root.removeChild(oRows[del]);
                
                indice_champ--;
            }
            
            return;
        }
            
        for(indice_champ=indice_champ; indice_champ<=nb; indice_champ++)
        {
            /*Ligne 1, sujet*/
            var oDiv = document.createElement('div');
            oDiv.setAttribute('id','sujet' + indice_champ);
            //oDiv.setAttribute('name','sujet' + i);
            oDiv.className = 'required notfirst';
            var oLabel = document.createElement('label');
            oLabel.setAttribute('for','titresujet' + indice_champ);
            oLabel.className = 'largerlabel';
            var oSpan = document.createElement('span');
            oSpan.className = 'textimportant';
            var oAppos = document.createTextNode('*');
            oSpan.appendChild(oAppos);
            oLabel.appendChild(oSpan);
            var oSujet = document.createTextNode(' Sujet ' + indice_champ + ':');
            oLabel.appendChild(oSujet);
            oDiv.appendChild(oLabel);
            
            var oChamp = document.createElement('input');
            oChamp.setAttribute('type','text');
            oChamp.className = 'textbox';
            oChamp.setAttribute('id','titresujet' + indice_champ);
            oChamp.setAttribute('name','titresujet' + indice_champ);
            oChamp.setAttribute('size',28);
            oChamp.setAttribute('maxLength',80);
            oDiv.appendChild(oChamp);
            document.getElementById("divsujets").appendChild(oDiv);
            
            /*Ligne 2, contenu*/
            var oDiv = document.createElement('div');
            oDiv.setAttribute('id','divcontenu' + indice_champ);
            //oDiv.setAttribute('name','divcontenu' + i);
            oDiv.className = 'required';
            var oFieldset = document.createElement('fieldset');
            var oLegend = document.createElement('legend');
            var oSpan = document.createElement('span');
            oSpan.className = 'textimportant';
            var oAppos = document.createTextNode('*');
            oSpan.appendChild(oAppos);
            oLegend.appendChild(oSpan);
            var oLegendText = document.createTextNode(' Contenu du sujet ' + indice_champ);
            oLegend.appendChild(oLegendText);
            oFieldset.appendChild(oLegend);
            var oChamp = document.createElement('textarea');
            oChamp.className = 'textbox';
            oChamp.setAttribute('id','contenusujet' + indice_champ);
            oChamp.setAttribute('name','contenusujet' + indice_champ);
            oChamp.setAttribute('cols',40);
            oChamp.setAttribute('rows',10);
            oFieldset.appendChild(oChamp);
            oDiv.appendChild(oFieldset);
            document.getElementById("divsujets").appendChild(oDiv);
        }
    }
    else if(divpage == 'gestion_csq_liens_js')
    {
        if(nombreliens == 2 && nbliens >= nombreliens)
            nombreliens = nbliens + 1;
        
        //Ligne 1, nom du site
        var oDiv = document.createElement('div');
        oDiv.setAttribute('id','div_nom_lien' + nombreliens);
        if(nombreliens != 1)
            oDiv.className = 'required notfirst';
        else
            oDiv.className = 'required';
        oDiv.setAttribute('style','width: 570px;');
        var oLabel = document.createElement('label');
        oLabel.setAttribute('for','nom_lien' + nombreliens);
        oLabel.className = 'largerlabel';
        var oSpan = document.createElement('span');
        oSpan.className = 'textimportant';
        var oAppos = document.createTextNode('*');
        oSpan.appendChild(oAppos);
        oLabel.appendChild(oSpan);
        var oSujet = document.createTextNode(' Nom du site:');
        oLabel.appendChild(oSujet);
        oDiv.appendChild(oLabel);
        
        var oChamp = document.createElement('input');
        oChamp.setAttribute('type','text');
        oChamp.className = 'textbox';
        oChamp.setAttribute('id','nom_lien' + nombreliens);
        oChamp.setAttribute('name','nom_lien' + nombreliens);
        oChamp.setAttribute('size',28); //pour IE
        oChamp.setAttribute('style','width: 405px;');
        oChamp.setAttribute('maxLength',90);
        oDiv.appendChild(oChamp);
        document.getElementById("divliens").appendChild(oDiv);
        
        //Ligne 2, url du site
        var oDiv = document.createElement('div');
        oDiv.setAttribute('id','div_url_lien' + nombreliens);
        oDiv.className = 'required';
        oDiv.setAttribute('style','width: 570px;');
        var oLabel = document.createElement('label');
        oLabel.setAttribute('for','url_lien' + nombreliens);
        oLabel.className = 'largerlabel';
        var oSpan = document.createElement('span');
        oSpan.className = 'textimportant';
        var oAppos = document.createTextNode('*');
        oSpan.appendChild(oAppos);
        oLabel.appendChild(oSpan);
        var oSujet = document.createTextNode(' URL du site:');
        oLabel.appendChild(oSujet);
        oDiv.appendChild(oLabel);
        
        /*var oSpan = document.createElement('span');
        oSpan.className = 'smalltext';
        var oURL = document.createTextNode('http://');
        oSpan.appendChild(oURL);
        oDiv.appendChild(oSpan);*/
        
        var oChamp = document.createElement('input');
        oChamp.setAttribute('type','text');
        oChamp.className = 'textbox';
        oChamp.setAttribute('id','url_lien' + nombreliens);
        oChamp.setAttribute('name','url_lien' + nombreliens);
        oChamp.setAttribute('size',28); //pour IE
        oChamp.setAttribute('style','width: 405px;');
        oChamp.setAttribute('maxLength',90);
        oChamp.setAttribute('value','http://');
        oDiv.appendChild(oChamp);
        document.getElementById("divliens").appendChild(oDiv);
        
        /*if(nombreliens == 2 && nbliens > nombreliens)
            nombreliens = nbliens + 1;
        
        document.getElementById('divliens').innerHTML += '<hr class="grey" style="width: 570px;">';        
        document.getElementById('divliens').innerHTML += '<div class="required" id="div_nom_lien' + nombreliens + '" style="width: 570px;"><label for="nom_lien' + nombreliens + '" class="largerlabel"><span class="textimportant">*</span> Nom du site:</label><input type="text" class="textbox" style="width: 405px;" id="nom_lien' + nombreliens + '" name="nom_lien' + nombreliens + '" maxlength="80"></div>';
        document.getElementById('divliens').innerHTML += '<div class="required" id="div_url_lien' + nombreliens + '" style="width: 570px;"><label for="url_lien' + nombreliens + '" class="largerlabel" style="width:120px;"><span class="textimportant">*</span> URL du site:</label><span class="smalltext">http:// </span><input type="text" class="textbox" style="width: 405px;" id="url_lien' + nombreliens + '" name="url_lien' + nombreliens + '" maxlength="90" value=""></div>';*/
        
        nombreliens++;
    }
    else if(divpage == 'inscription_pres_js')
    {
        if(nombreliens == 2 && nbliens >= nombreliens)
            nombreliens = nbliens + 1;
        
        //Ligne 1, début du mandat
        var oDiv = document.createElement('div');
        oDiv.setAttribute('id','div_debutmandat' + nombreliens);
        if(nombreliens != 1)
            oDiv.className = 'optional notfirst';
        else
            oDiv.className = 'optional';
        var oLabel = document.createElement('label');
        oLabel.setAttribute('for','debutmandat' + nombreliens);
        oLabel.className = 'largerlabel';
        var oSujet = document.createTextNode('Mandat:');
        oLabel.appendChild(oSujet);
        oDiv.appendChild(oLabel);
        
        var oChamp = document.createElement('input');
        oChamp.setAttribute('type','text');
        oChamp.className = 'textbox';
        oChamp.setAttribute('id','debutmandat' + nombreliens);
        oChamp.setAttribute('name','debutmandat' + nombreliens);
        oChamp.setAttribute('size',4); //pour IE
        oChamp.setAttribute('maxLength',4);
        oDiv.appendChild(oChamp);
        var oTo = document.createTextNode(' à ');
        oDiv.appendChild(oTo);
        var oChamp = document.createElement('input');
        oChamp.setAttribute('type','text');
        oChamp.className = 'textbox';
        oChamp.setAttribute('id','finmandat' + nombreliens);
        oChamp.setAttribute('name','finmandat' + nombreliens);
        oChamp.setAttribute('size',4); //pour IE
        oChamp.setAttribute('maxLength',4);
        oDiv.appendChild(oChamp);
        document.getElementById("divpres").appendChild(oDiv);
        
        nombreliens++;
    }
}

function toggleLayer(whichLayer) // http://www.netlobo.com/div_hiding.html
{
    if (document.getElementById)
    {
        // this is the way the standards work
        var style2 = document.getElementById(whichLayer).style;
        style2.display = style2.display? "":"inline";
    }
    else if (document.all)
    {
        // this is the way old msie versions work
        var style2 = document.all[whichLayer].style;
        style2.display = style2.display? "":"block";
    }
    else if (document.layers)
    {
        // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
        style2.display = style2.display? "":"block";
    }
}

function selectCheckBox(chk, chktype, nbchoisis)
{
    if(document.getElementById)
    {
        if(document.getElementById(chk).checked)
            document.getElementById(nbchoisis).value ++;
        else
            document.getElementById(nbchoisis).value --;
        
        if(document.getElementById(nbchoisis).value != 0)
            document.getElementById(chktype).checked = true;
        else
            document.getElementById(chktype).checked = false;
    }
}