/*
'---
'--- JSFonctions.js - Page de fonction en Javascript
'---
'--- Par JP Bernard
'---     CIBLE Solutions d'affaires
'---
'--- RÉVISION
 -- 2008/12/17 JPB-    Création
*/

//-------------------------------------------------------------------------------------
// Message d'avertissement temporaire
//-------------------------------------------------------------------------------------
function DoPupDeveloppement()
{
    alert("IMPORTANT!!!\nCette section du site Internet est présentement en développement.\nElle sera fonctionnelle dans le plus bref délai. Merci!\n\nJean-Philip Bernard\nProgrammeur Analyste\jean-philip.bernard@ciblesolutions.com");            
}

//-------------------------------------------------------------------------------------
//trouve la référence pour l'objet document
//-------------------------------------------------------------------------------------
function GetReference(id)
{
    if(document.layers) return document.layers[id];
    if(document.all && !document.getElementById) return document.all[id];
    if(document.all && document.getElementById) return document.getElementById(id);
    if(!document.all && document.getElementById) return document.getElementById(id);
    return false;
}


//---------------------------------------------------------------------
//Ouvrir une fenêtre
//---------------------------------------------------------------------
function OuvrirFenetre(iNomPage, iTitre, iWidth, iHeight)
{
    fenetre = window.open(iNomPage, iTitre, "top=0, left=0, width=" + iWidth + ", height=" + iHeight + ", scrollbars=yes, location=no, toolbar=no, menubar=no");
    fenetre.focus()
}

//---------------------------------------------------------------------
//Ouvrir une fenêtre pour consulter les réponses texte d'une question de sondage
//---------------------------------------------------------------------
function OuvrirFenetreQuestionsTextesSondage(iNomPage, iTitre, iWidth, iHeight)
{
    fenetre = window.open(iNomPage, iTitre, "top=0, left=0, width=" + iWidth + ", height=" + iHeight + ", scrollbars=yes, location=no, toolbar=no, menubar=no, resizable=yes");
    fenetre.focus()
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* OuvrirConfidentialite() - Ouvre la page pour les politiques de confidentialité
*/
function OuvrirConfidentialite()
{         
   OuvrirFenetre("", "CONFIDENTIALITE", 630, 580);
   FormConfidentialite.submit();
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* DoInsertCodeHTML() - Insère le code HTML créé dans l'éditeur
*/
function DoInsertCodeHTML(iControlName, iContenu)
{  
   // alert("oui");
    
   // alert(iControlName);
   // alert(iContenu);
    
    if(iControlName!='')
    {
        var ObjName=GetReference(iControlName);

        ObjName.value = iContenu;
    }
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* OuvrirEditeurHTML() - Ouvre l'éditeur HTML
*/
function OuvrirEditeurHTML(iControlName)
{
    var ObjName = GetReference(iControlName);
    var ObjTexte = GetReference("TexteContenu");
    var ObjCtrl = GetReference("Ctrl");
    
    ObjTexte.value = ObjName.value;
    ObjCtrl.value = iControlName;
    
    if(iControlName!='')
    {
       OuvrirFenetre("", "EditeurTexte", 800, 600);
       document.EditeurHTML.submit();
    }
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * RemoveLineBreakJS() - Retourne la string sans les sauts de lignes ("\n" ou "\r\n")
 *
 *
 * Paramètres:
 *   iString - La chaine de caratère (type: String)
 *
 */
function RemoveLineBreakJS(iString)
{
    iString.replace("\r\n", "");
    iString.replace("\n", "");
    
    return iString;
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * JAVA_FormatStr() - Remplace les apostrophes (') par l'équivalent UNICODE \u0027
 *                 et les guillemets (") par l'équivalent UNICODE \u0022 pour
 *                 les fonctions JavaScript.
 */
function JAVA_FormatStr(iString)
{
    alert(iString);
    var chaine = new String(iString);

    remplace  = new RegExp("\'","g"),
    chaine = chaine.replace(remplace, "&#39;");

    remplace  = new RegExp('\"',"g"),
    chaine = chaine.replace(remplace, '&#39;');

    return chaine;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* ImprimerPage() - Lance l'impression de la fenêtre en cours
*/
function ImprimerPage(iLangue)
{       
    if (navigator.appVersion.indexOf("Mac",0)>0)
    {
        if (iLangue=="en")
            alert("This function is not available for Macintosh. Please use Apple-P.");
        else
            alert("Cette fonction n\'est pas réalisable sur Macintosh.\n\nUtilisez plutôt la combinaison de touches  « Pomme-P »");
    }
    else
    {
        window.print();
    }
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* OuvrirPrint() - Ouvre la page pour l'impression
*/
function OuvrirPrint()
{
   OuvrirFenetre("", "PRINTWINDOW", 610, 600);
   document.FormPrint.submit();
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * DoOuvrirNouvelle() - Ouvre un pop-up présentant une nouvelle
 *
 * Paramètres:
 *    iNouvelleID  - Le ID de la nouvelle à ouvrir (type: Integer)
 *    iLangue      - La langue à utiliser ('fr' ou 'en')
 */
function DoOuvrirNouvelle(iNouvelleID, iLangue)
{
    // On commence par former l'URL 
    var Url = "/detail_nouvelle.php"
        + "?L=" + iLangue
        + "&NouvelleID=" + iNouvelleID;

    // On défini le format de la fenêtre
    var Format = "width=657"
        + ",height=600"
        + ",top=5"
        + ",left=5"
        + ",menubar=no"
        + ",toolbar=no"
        + ",addressbar=no"
        + ",status=yes"
        + ",resizable=yes"
        + ",scrollbars=yes";

    // On tente d'ouvrir la fenêtre "Nouvelles"
    var NouvellesWin = window.open(Url, "Nouvelles", Format);

    // Si la création du pop-up est impossible (pop-up blocker ou autre), on
    // affiche un message d'erreur; sinon on y déplace le focus
    if (!NouvellesWin)
    {
        if (iLangue=="en")
            alert("This site uses pop-ups to display records, but your browser is blocking them. Please allow pop-ups for this site.");
        else
            alert("Ce site utilise des pop-up pour afficher les fiches mais votre navigateur semble les bloquer. Veuillez SVP autoriser l'affichage des pop-up pour ce site.");
    }
    else
    {
        NouvellesWin.focus();
    }
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * DoOuvrirImage() - Ouvre un pop-up présentant une image
 *
 * Paramètres:
 *    iImageID    - Le ID de l'image à ouvrir (type: Integer)
 *    iLangue     - La langue à utiliser ('fr' ou 'en')
 */
function DoOuvrirImage(iImageID, iLangue)
{
    // On commence par former l'URL
    var Url = "/fiche_photo.php"
        + "?L=" + iLangue
        + "&PhotoID=" + iImageID;

    // On défini le format de la fenêtre
    var Format = "width=657"
        + ",height=600"
        + ",top=5"
        + ",left=5"
        + ",menubar=no"
        + ",toolbar=no"
        + ",addressbar=no"
        + ",status=yes"
        + ",resizable=yes"
        + ",scrollbars=yes";

    // On tente d'ouvrir la fenêtre "Photos"
    var PhotosWin = window.open(Url, "Photos", Format);

    // Si la création du pop-up est impossible (pop-up blocker ou autre), on
    // affiche un message d'erreur; sinon on y déplace le focus
    if (!PhotosWin)
    {
        if (iLangue=="en")
            alert("This site uses pop-ups to display records, but your browser is blocking them. Please allow pop-ups for this site.");
        else
            alert("Ce site utilise des pop-up pour afficher les fiches mais votre navigateur semble les bloquer. Veuillez SVP autoriser l'affichage des pop-up pour ce site.");
    }
    else
    {
        PhotosWin.focus();
    }
}



/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Ensemble de fonctions pour transferer des selections d'une fenetre a une autre
 *
 *        DEBUT 
 *
 */

function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

function moveOptions(theSelFrom, theSelTo)
{
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
}
/* 
 * Ensemble de fonctions pour transferer des selections d'une fenetre a une autre
 *
 *        FIN 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 */

/* 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 * Tri les valeurs d'un SELECT
 *
 */
function sortArray()
{
    Liste= new Array();
    Obj= document.getElementById('SuggTous')

    for(i=0;i<Obj.options.length;i++)
    {
    Liste[i]=new Array()
    Liste[i][0]=Obj.options[i].value
    Liste[i][1]=Obj.options[i].text
    }

    Liste=Liste.sort()

    for(i=0;i<Obj.options.length;i++)
    {
    Obj.options[i].value=Liste[i][0]
    Obj.options[i].text=Liste[i][1]
    }
}
 


function changeClassName(iObject, iClassName)
{
    document.getElementById(iObject).className = iClassName;
}



function GererAffichageTextboxRecherche()
{
    var QuelleLangue;
    var QuelleMot;
    
    QuelleLangue = document.getElementById("hidden_langue").value;
    
    if(QuelleLangue == "fr")
        QuelMot = "Mots clés";
    else
        QuelMot = "Enter words";
    
    if(document.getElementById("Recherche"))
    {
        if(document.getElementById("Recherche").value == QuelMot)
        {
            document.getElementById("Recherche").value = "";
        }
        else if(document.getElementById("Recherche").value == "")
        {
            document.getElementById("Recherche").value = QuelMot;
        }
    }
}

function GererAffichageTextboxRechercheFaq()
{
    var QuelleLangue;
    var QuelleMot;
    
    QuelleLangue = document.getElementById("hidden_langue").value;
    
    if(QuelleLangue == "fr")
        QuelMot = "Recherche";
    else
        QuelMot = "Search";
    
    if(document.getElementById("recherche-faq"))
    {
        if(document.getElementById("recherche-faq").value == QuelMot)
        {
            document.getElementById("recherche-faq").value = "";
        }
        else if(document.getElementById("recherche-faq").value == "")
        {
            document.getElementById("recherche-faq").value = QuelMot;
        }
    }
}



/* FONCTIONS POUR LE BLOGUE */
function AfficherAjouterCommentaireBillet(iTRHidden, iBilletID)
{
    if(document.getElementById(iTRHidden).style.display == "none")
    {
        document.getElementById(iTRHidden).style.display = "";
    }
    else
    {
        document.getElementById(iTRHidden).style.display = "none";
        
        document.getElementById("TR_ErreurCommentaire_" + iBilletID).style.display = "none";
        document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "&nbsp;";
        document.getElementById("TD_NomCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
        document.getElementById("TD_CourrielCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
        document.getElementById("TD_TexteCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
    }
}


function AfficherAjouterCommentaireCommentaire(iTRHidden, iBilletID)
{
    if(document.getElementById(iTRHidden).style.display == "none")
    {
        document.getElementById(iTRHidden).style.display = "";
    }
    else
    {
        document.getElementById(iTRHidden).style.display = "none";
        
        document.getElementById("TR_ErreurCommentaire_" + iBilletID).style.display = "none";
        document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "&nbsp;";
        document.getElementById("TD_NomCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
        document.getElementById("TD_CourrielCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
        document.getElementById("TD_TexteCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
    }
}


function ValiderFormulaireCommentaireBlogue(iBilletID, iLangue)
{
    var Erreur = 0;
    
    // Reset toutes les erreurs 
    document.getElementById("TR_ErreurCommentaire_" + iBilletID).style.display = "none";
    document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "&nbsp;";
    document.getElementById("TD_NomCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
    document.getElementById("TD_CourrielCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
    document.getElementById("TD_TexteCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
    
    
    // Valide Nom
    if(document.getElementById("NomCommentaire_" + iBilletID).value == "")
    {
        Erreur = 1;
        document.getElementById("TR_ErreurCommentaire_" + iBilletID).style.display = "";
        if(iLangue == "fr")
            document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "Votre nom est obligatoire.";
        else
            document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "Your name is required.";
        document.getElementById("TD_NomCommentaire_" + iBilletID).className = "TD_LabelErreurBlogue";
        document.getElementById("NomCommentaire_" + iBilletID).focus();
        return false;
    }
    else
    {
        Erreur = 0;
        document.getElementById("TR_ErreurCommentaire_" + iBilletID).style.display = "none";
        document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "&nbsp;";
        document.getElementById("TD_NomCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
    }
    
    
    // Valide Courriel
    if(document.getElementById("CourrielCommentaire_" + iBilletID).value == "" || document.getElementById("CourrielCommentaire_" + iBilletID).value.indexOf("@") == -1 || document.getElementById("CourrielCommentaire_" + iBilletID).value.indexOf(".") == -1)
    {
        Erreur = 1;
        document.getElementById("TR_ErreurCommentaire_" + iBilletID).style.display = "";
        if(iLangue == "fr")       
            document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "Votre courriel est obligatoire.";
        else
            document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "Your email is required";
        document.getElementById("TD_CourrielCommentaire_" + iBilletID).className = "TD_LabelErreurBlogue";
        document.getElementById("CourrielCommentaire_" + iBilletID).focus();
        return false;
    }
    else
    {
        Erreur = 0;
        document.getElementById("TR_ErreurCommentaire_" + iBilletID).style.display = "none";
        document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "&nbsp;";
        document.getElementById("TD_CourrielCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
    }
    
    
    // Valide Commentaire
    if(document.getElementById("TexteCommentaire_" + iBilletID).value == "")
    {
        Erreur = 1;
        document.getElementById("TR_ErreurCommentaire_" + iBilletID).style.display = "";
        if(iLangue == "fr")
            document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "Votre commentaire est obligatoire.";
        else
            document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "Your comment is required.";
        document.getElementById("TD_TexteCommentaire_" + iBilletID).className = "TD_LabelErreurBlogue";
        document.getElementById("TexteCommentaire_" + iBilletID).focus();
        return false;
    }
    else
    {
        Erreur = 0;
        document.getElementById("TR_ErreurCommentaire_" + iBilletID).style.display = "none";
        document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "&nbsp;";
        document.getElementById("TD_TexteCommentaire_" + iBilletID).className = "TD_LabelFormulaireBlogue";
    }
    
    // Valide Accepter Nétiquette (checkbox)
    if(document.getElementById("AccepteNetiquette_" + iBilletID).checked == false)
    {
        Erreur = 1;
        document.getElementById("TR_ErreurCommentaire_" + iBilletID).style.display = "";
        if(iLangue == "fr")
            document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "Vous devez accepter la Nétiquette.";
        else
            document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "You need to accept the Nétiquette.";
        return false;
    }
    else
    {
        Erreur = 0;
        document.getElementById("TR_ErreurCommentaire_" + iBilletID).style.display = "none";
        document.getElementById("TD_MessageErreurCommentaire_" + iBilletID).innerHTML = "&nbsp;";
    }
    
    
    if(Erreur == 0)
        return true;
    else
        return false;    
}



function ValiderFormulaireCommentaireCommentaireBlogue(iCommentaireID, iLangue)
{
    var Erreur = 0;
    
    // Reset toutes les erreurs 
    document.getElementById("TR_ErreurCommentaireCommentaire_" + iCommentaireID).style.display = "none";
    document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "&nbsp;";
    document.getElementById("TD_NomCommentaireCommentaire_" + iCommentaireID).className = "TD_LabelFormulaireBlogue";
    document.getElementById("TD_CourrielCommentaireCommentaire_" + iCommentaireID).className = "TD_LabelFormulaireBlogue";
    document.getElementById("TD_TexteCommentaireCommentaire_" + iCommentaireID).className = "TD_LabelFormulaireBlogue";
    
    
    // Valide Nom
    if(document.getElementById("NomCommentaireCommentaire_" + iCommentaireID).value == "")
    {
        Erreur = 1;
        document.getElementById("TR_ErreurCommentaireCommentaire_" + iCommentaireID).style.display = "";
        if(iLangue == "fr")
            document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "Votre nom est obligatoire.";
        else
            document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "Your name is required.";
        document.getElementById("TD_NomCommentaireCommentaire_" + iCommentaireID).className = "TD_LabelErreurBlogue";
        document.getElementById("NomCommentaireCommentaire_" + iCommentaireID).focus();
        return false;
    }
    else
    {
        Erreur = 0;
        document.getElementById("TR_ErreurCommentaireCommentaire_" + iCommentaireID).style.display = "none";
        document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "&nbsp;";
        document.getElementById("TD_NomCommentaireCommentaire_" + iCommentaireID).className = "TD_LabelFormulaireBlogue";
    }
    
    
    // Valide Courriel
    if(document.getElementById("CourrielCommentaireCommentaire_" + iCommentaireID).value == "" || document.getElementById("CourrielCommentaireCommentaire_" + iCommentaireID).value.indexOf("@") == -1 || document.getElementById("CourrielCommentaireCommentaire_" + iCommentaireID).value.indexOf(".") == -1)
    {
        Erreur = 1;
        document.getElementById("TR_ErreurCommentaireCommentaire_" + iCommentaireID).style.display = "";
        if(iLangue == "fr")       
            document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "Votre courriel est obligatoire.";
        else
            document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "Your email is required";
        document.getElementById("TD_CourrielCommentaireCommentaire_" + iCommentaireID).className = "TD_LabelErreurBlogue";
        document.getElementById("CourrielCommentaireCommentaire_" + iCommentaireID).focus();
        return false;
    }
    else
    {
        Erreur = 0;
        document.getElementById("TR_ErreurCommentaireCommentaire_" + iCommentaireID).style.display = "none";
        document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "&nbsp;";
        document.getElementById("TD_CourrielCommentaireCommentaire_" + iCommentaireID).className = "TD_LabelFormulaireBlogue";
    }
    
    
    // Valide Commentaire
    if(document.getElementById("TexteCommentaireCommentaire_" + iCommentaireID).value == "")
    {
        Erreur = 1;
        document.getElementById("TR_ErreurCommentaireCommentaire_" + iCommentaireID).style.display = "";
        if(iLangue == "fr")
            document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "Votre commentaire est obligatoire.";
        else
            document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "Your comment is required.";
        document.getElementById("TD_TexteCommentaireCommentaire_" + iCommentaireID).className = "TD_LabelErreurBlogue";
        document.getElementById("TexteCommentaireCommentaire_" + iCommentaireID).focus();
        return false;
    }
    else
    {
        Erreur = 0;
        document.getElementById("TR_ErreurCommentaireCommentaire_" + iCommentaireID).style.display = "none";
        document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "&nbsp;";
        document.getElementById("TD_TexteCommentaireCommentaire_" + iCommentaireID).className = "TD_LabelFormulaireBlogue";
    }
    
    // Valide Accepter Nétiquette (checkbox)
    if(document.getElementById("AccepteNetiquetteCommentaire_" + iCommentaireID).checked == false)
    {
        Erreur = 1;
        document.getElementById("TR_ErreurCommentaireCommentaire_" + iCommentaireID).style.display = "";
        if(iLangue == "fr")
            document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "Vous devez accepter la Nétiquette.";
        else
            document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "You need to accept the Nétiquette.";
        return false;
    }
    else
    {
        Erreur = 0;
        document.getElementById("TR_ErreurCommentaireCommentaire_" + iCommentaireID).style.display = "none";
        document.getElementById("TD_MessageErreurCommentaireCommentaire_" + iCommentaireID).innerHTML = "&nbsp;";
    }
    
    
    if(Erreur == 0)
        return true;
    else
        return false;    
}



function AfficherCommentairesBillet(iTRHidden, iLangue, iBilletID)
{
    if(document.getElementById(iTRHidden).style.display == "none")
    {
        document.getElementById(iTRHidden).style.display = "";
        if(iLangue == "fr")
            document.getElementById('LienConsulterVoirCommentaires_' + iBilletID).innerHTML = "Voici les commentaires";
        else
            document.getElementById('LienConsulterVoirCommentaires_' + iBilletID).innerHTML = "Here is the comments";
    }
    else
    {
        document.getElementById(iTRHidden).style.display = "none";        
        if(iLangue == "fr")
            document.getElementById('LienConsulterVoirCommentaires_' + iBilletID).innerHTML = "Consulter les commentaires";
        else
            document.getElementById('LienConsulterVoirCommentaires_' + iBilletID).innerHTML = "Read the comments";
    }
}
/* FONCTIONS POUR LE BLOGUE */




/* FIN : FONCTIONS POUR DÉTECTION DU TYPE DE BROWSER, VERSION ET OS */
/* Voici l'adresse du site Web ou j'ai trouvé ce script : 
// http://www.quirksmode.org/js/detect.html // */

var BrowserDetect = {
    init: function () {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
            || this.searchVersion(navigator.appVersion)
            || "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function (data) {
        for (var i=0;i<data.length;i++)    {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function (dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
    },
    dataBrowser: [
        {
            string: navigator.userAgent,
            subString: "Chrome",
            identity: "Chrome"
        },
        {     string: navigator.userAgent,
            subString: "OmniWeb",
            versionSearch: "OmniWeb/",
            identity: "OmniWeb"
        },
        {
            string: navigator.vendor,
            subString: "Apple",
            identity: "Safari",
            versionSearch: "Version"
        },
        {
            prop: window.opera,
            identity: "Opera"
        },
        {
            string: navigator.vendor,
            subString: "iCab",
            identity: "iCab"
        },
        {
            string: navigator.vendor,
            subString: "KDE",
            identity: "Konqueror"
        },
        {
            string: navigator.userAgent,
            subString: "Firefox",
            identity: "Firefox"
        },
        {
            string: navigator.vendor,
            subString: "Camino",
            identity: "Camino"
        },
        {        // for newer Netscapes (6+)
            string: navigator.userAgent,
            subString: "Netscape",
            identity: "Netscape"
        },
        {
            string: navigator.userAgent,
            subString: "MSIE",
            identity: "Explorer",
            versionSearch: "MSIE"
        },
        {
            string: navigator.userAgent,
            subString: "Gecko",
            identity: "Mozilla",
            versionSearch: "rv"
        },
        {         // for older Netscapes (4-)
            string: navigator.userAgent,
            subString: "Mozilla",
            identity: "Netscape",
            versionSearch: "Mozilla"
        }
    ],
    dataOS : [
        {
            string: navigator.platform,
            subString: "Win",
            identity: "Windows"
        },
        {
            string: navigator.platform,
            subString: "Mac",
            identity: "Mac"
        },
        {
            string: navigator.platform,
            subString: "Linux",
            identity: "Linux"
        }
    ]

};
BrowserDetect.init();

/* FIN : FONCTIONS POUR DÉTECTION DU TYPE DE BROWSER, VERSION ET OS */



/* DÉBUT : FONCTIONS POUR LE SÉLECTEUR DE DATE AVEC COMBOBOX */

//set la date d'aujourd'hui
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "avril" || WhichMonth == "juin" || WhichMonth == "septembre" || WhichMonth == "novembre") DaysInMonth = 30;
  if (WhichMonth == "février" && (WhichYear/4) != Math.floor(WhichYear/4))    DaysInMonth = 28;
  if (WhichMonth == "février" && (WhichYear/4) == Math.floor(WhichYear/4))    DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(Which, QuestionID)
{
  DaysObject = eval("document.FormInscriptionSondage." + Which + "Day_" + QuestionID);
  MonthObject = eval("document.FormInscriptionSondage." + Which + "Month_" + QuestionID);
  YearObject = eval("document.FormInscriptionSondage." + Which + "Year_" + QuestionID);

  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
        DaysObject.options[DaysObject.options.length] = new Option(DaysObject.options.length + 1);
      //NewOption = new Option(DaysObject.options.length + 1);
     // DaysObject.add(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to set options to today
function SetToToday(Which, QuestionID)
{
    DaysObject = eval("document.FormInscriptionSondage." + Which + "Day_" + QuestionID);
    MonthObject = eval("document.FormInscriptionSondage." + Which + "Month_" + QuestionID);
    YearObject = eval("document.FormInscriptionSondage." + Which + "Year_" + QuestionID);
    
    //YearObject[0].selected = true;
    MonthObject[NowMonth].selected = true;
    
    ChangeOptionDays(Which, QuestionID);
    
    DaysObject[NowDay-1].selected = true;
}

//function to write option years plus x
function WriteYearOptions(YearsAhead)
{
      var d = new Date();
    var year=d.getFullYear();
      
      line = "";
      for(i=(year+50);i>year;i--){
        line += "<OPTION>";    
        line += i;
        line += "</OPTION>";    
    }
      
    line += "<OPTION SELECTED>";    
    line += year;
    line += "</OPTION>";
    
    for(i=year-1;i>=year-100;i--){
        line += "<OPTION>";    
        line += i;
        line += "</OPTION>";    
    }
  /*for (i=0; i<YearsAhead; i++)
  {
    line += "<OPTION>";
    line += NowYear + i;
  }*/
  //for (i = NowYear; i >= NowYear-110; i--)
  //{
  //  line += "<OPTION>";
  //  line += i;
 // }
  return line;
}

/* FIN : FONCTIONS POUR LE SÉLECTEUR DE DATE AVEC COMBOBOX */


/* DÉBUT : MODAL POPUP FUNCTIONS */
function revealModal(divID)
{
    window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; };
    document.getElementById(divID).style.display = "block";
    document.getElementById(divID).style.top = document.body.scrollTop;
}

function hideModal(divID)
{
    document.getElementById(divID).style.display = "none";
}            
/* FIN : MODAL POPUP FUNCTIONS */
                                                            


                                                            
                                                            
/* DÉBUT : FONCTION POUR LES SECTIONS CONDITIONNELLES DES SONDAGES */
function AfficherTR_SectionConditionnelle(trSectionConditionnelleID, arraySectionID)
{                                                                                                                          
    ArraySectionID = arraySectionID.split(",");
    if(ArraySectionID.length > 0)
    {
        for(Counter = 0; Counter < ArraySectionID.length; Counter++)
        {            
            document.getElementById("TR_HiddenSection_" + ArraySectionID[Counter]).style.display = "none";
        }
    }    
    document.getElementById("TR_HiddenSection_" + trSectionConditionnelleID).style.display = "";
}
/* DÉBUT : FONCTION POUR LES SECTIONS CONDITIONNELLES DES SONDAGES */


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* InfoOuvrirConfidentialite()
*/
function OuvrirReglements(iLangue)
{
    // Adresse de la page à ouvrir
    if(iLangue == "fr")
    {
        var Url = "concours_reglements.php"
            + "?L=" + iLangue;                
    }
    else
    {
        var Url = "concours_reglements.php"
            + "?L=" + iLangue;                
    }
      
    // On défini le format de la fenêtre
    var Format = "width=700"
        + ",height=600"
        + ",top=5"
        + ",left=5"
        + ",menubar=yes"
        + ",toolbar=no"
        + ",addressbar=no"
        + ",status=yes"
        + ",resizable=yes"
        + ",scrollbars=yes";
        
    // On tente d'ouvrir la fenêtre
    OuvrePopup(Url, "Règlements", Format, "");    
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * OuvrePopup() - Tente d'ouvrir une fenêtre en pop-up et d'y apporter
 *                le focus.
 *
 * Valeur de retour :
 *   Une référence à la fenêtre créée ou null en cas d'erreur.
 */
function OuvrePopup(iUrl, iNomFenetre, iFormat, iMessageErreur)
{
    // On tente d'ouvrir la fenêtre
    var oWin = window.open(iUrl, iNomFenetre, iFormat);

    // Si la création du pop-up est impossible (pop-up blocker ou autre), on
    // affiche le message d'erreur; sinon on y déplace le focus
    if (!oWin)
    {
        // Message par défaut ou message personnalisé
        if (iMessageErreur == "")
            alert("Ce site utilise des pop-up pour afficher cette fonctionnalité mais votre navigateur semble les bloquer. Veuillez SVP autoriser l'affichage des pop-up pour ce site.");
        else
            alert(iMessageErreur);

        return null;
    }
    else
    {
        oWin.focus();
        return oWin;
    }
}




