/*
'---
'--- fonctions.js - Page de fonction en Javascript
'---
'--- Par Sacha Vincent
'---     www.sachavincent.com
'---
'--- RÉVISION
'--- 2008/05/07 -SJV	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\nSacha Vincent\nProgrammeur Analyste\nsacha20_100@hotmail.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;
}

function GetSelectedControlValue(iObject)
{
    var x = document.getElementsByName(iObject);
    var ArrayResult = new Array();
            
            
    for(i = 0; i < x.length; i++)
    {
        alert(iObject)  
        if(x[i].checked == true)  
            ArrayResult[ArrayResult.length] = x[i].value  
            
        if(i == 20) return;          
    }
    
    return ArrayResult;
}

function GetSelectedControlID(iObject)
{
    var x = document.getElementsByName(iObject);
    var ArrayResult = new Array();
            
    for(i = 0; i < x.length; i++)
    {
        if(x[i].checked == true)  
            ArrayResult[ArrayResult.length] = x[i].id            
    }
    
    return ArrayResult;
}

//---------------------------------------------------------------------
//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()
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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)
{                                                
	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();
}


function OuvrirFicheInformation(iIndividuID)
{
    if(iIndividuID != '')
	   	 OuvrirFenetre("fiche.php?IndividuID=" + iIndividuID, "Informations", 310, 500);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* DoSupprimerPhoto() - Supprimer une photo
*/
function DoSupprimerPhoto(iName, iCadre, iRemplacement)
{
    var ObjName=GetReference(iName);          	
    var ObjCadre=GetReference(iCadre);

    ObjName.value = "";    		
    ObjCadre.src = iRemplacement;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* DoVisualiserPhoto() - Voir la photo en gros
*/
function DoVisualiserPhoto(iMembreID)
{
    if(iMembreID != '')
	   	 OuvrirFenetre("image.php?M=" + iMembreID, "Photo", 600, 600);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* DoVisualiserAlbumPhoto() - Voir la photo en gros
*/
function DoVisualiserAlbumPhoto(iMembreID, iPhotoID)
{
    if(iMembreID != '')
	   	 OuvrirFenetre("image.php?M=" + iMembreID + "&AP=" + iPhotoID, "Photo", 600, 600);
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* DoChercherPhoto() - Ouvre la fenêtre du navigateur de photo
*/
function DoChercherPhoto(iImg, iName, iClientID, iModuleID)
{
    if(iImg != '' && iClientID!='' && iModuleID!= '')
  		OuvrirFenetre("navigateur_photo.php?Img=" + iImg + "&N=" + iName + "&C=" + iClientID + "&M=" + iModuleID, "Photos", 800, 600);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* DoInsertImage() - Insère la photo à la bonne place
*/
function DoInsertImage(iImgPath, iCadre, iName)
{           
    var reg = new RegExp("[/\\/]+", "g");          

    var tableau = iImgPath.split(reg);    
    
    var ObjName = GetReference(iName); 
    var ObjCadre = GetReference(iCadre);    
    
    var ImgName = tableau[tableau.length - 1]; 
    ObjName.value = ImgName.substring(2);
    
    ObjCadre.src = iImgPath; 
}

function getOffsetPosition(inID, inTYPE)
{
    var iVal = 0;
    var oObj = GetReference(inID);
    var sType = 'oObj.offset' + inTYPE;

    while (oObj && oObj.tagName != 'body') 
    {
        iVal += eval(sType);
        oObj = oObj.offsetParent;
    }
    
    return iVal;
}



function OuvrirCharteCouleur(iObject, iUpdate)
{   
    var Texte = "";
    
    var ForReturn = iObject.split("_");
    
    if(ForReturn[0] == "CouleurFond")
    {
        var BoutonClear = false;
        Texte = "Couleur de fond";
    }
    else if(ForReturn[0] == "CouleurTexte")
    {
        var BoutonClear = true;
        Texte = "Couleur de texte";        
    }
  
    var PositionTop = getOffsetPosition(iObject, "Top");
    var PositionLeft = getOffsetPosition(iObject, "Left"); 
     
     
    PositionLeft = PositionLeft - (PositionLeft < 360 ? 0 : 360);
    PositionTop = PositionTop - 250;
    
    EspaceColor = GetReference("CharteCouleur");
    EspaceColor.style.left = PositionLeft + "px";
    EspaceColor.style.top = PositionTop + "px"; 
    EspaceColor.style.display = "block";
   
    ObjInfoAppelant = GetReference("Select" + iObject);
    
    ObjTitre = GetReference("TitreCharte");
        ObjTitre.innerHTML = Texte;    
    
    ObjSampleFond = GetReference("selhicolor");
        ObjSampleFond.style.background = ObjInfoAppelant.value;
        
    ObjSampleName = GetReference("selcolor");
        ObjSampleName.value = ObjInfoAppelant.value;
    
    ObjBtnClear = GetReference("btnClear");
        ObjBtnClear.disabled = BoutonClear;  
    
    
    ObjPlace = GetReference("PlaceToShip");
        ObjPlace.value = iObject;  
    
    ObjUpdateAfter = GetReference("UpdateAfter");
        ObjUpdateAfter.value = iUpdate;  
} 

function AfficherDivDemo(iObject)
{  
    var PositionTop = getOffsetPosition(iObject, "Top");
    var PositionLeft = getOffsetPosition(iObject, "Left"); 
     
    PositionLeft = PositionLeft + 10;
    PositionTop = PositionTop - 10;
    
    EspaceDemo = GetReference("Demo");
    EspaceDemo.style.left = PositionLeft + "px";
    EspaceDemo.style.top = PositionTop + "px"; 
    EspaceDemo.style.display = "block";
}

function FermerDivDemo()
{
    EspaceDemo = GetReference("Demo");   
    EspaceDemo.style.display = "none";
} 

function ChoisirCouleurCharte()
{                
    ObjCouleur = GetReference("selcolor");           
    ObjPlace = GetReference("PlaceToShip"); 
    ObjUpdateAfter = GetReference("UpdateAfter");
    
    var PlaceValue = ObjPlace.value
    var ForReturn = PlaceValue.split("_");    
    
    ObjReturn1 = GetReference("Select" + PlaceValue);
    ObjReturn2 = GetReference(PlaceValue);
        
    ObjReturn2.style.background = ObjCouleur.value;
    
    if(ObjCouleur.value == "")
    {
        ObjReturn2.innerHTML= "aucune"; 
        ObjReturn1.value = "transparent";  
    }
    else
    {
        ObjReturn2.innerHTML= "&nbsp;";
        ObjReturn1.value = ObjCouleur.value;  
    }
    
    if(ObjUpdateAfter.value == 1)
        ModifierStyle(ForReturn[1]);
    
    FermerCharteCouleur()
     
}

function FermerCharteCouleur()
{
    EspaceColor = GetReference("CharteCouleur");   
    EspaceColor.style.display = "none";
}

function GetStyle(iElement)
{
    ObjPolice = GetReference("SelectPolice_" + iElement);
    ObjTaille = GetReference("SelectTaille_" + iElement);
    ObjItalic = GetReference("SelectItalic_" + iElement);
    ObjGrosseur = GetReference("SelectBold_" + iElement);
    ObjSouligne = GetReference("SelectSouligne_" + iElement);
    ObjColorFace = GetReference("SelectCouleurTexte_" + iElement);
    ObjColorFond = GetReference("SelectCouleurFond_" + iElement);
      
    var Style = "";
    
    // Fabrication du style
    Style = "font-size: " + ObjTaille.value + "; ";
    Style += "font-family:" + ObjPolice.value + "; ";
    Style += "font-weight:" + (ObjGrosseur.checked == true ? ObjGrosseur.value : "normal") + "; "; 
    Style += "font-style:" + (ObjItalic.checked == true ? ObjItalic.value : "normal") + "; ";  
    Style += "text-decoration:" + (ObjSouligne.checked == true ? ObjSouligne.value : "none") + "; ";
    Style += "color:" + ObjColorFace.value + "; ";
    Style += "background-color:" + ObjColorFond.value + "; ";
    
    return Style;
}	

function SetDateFin(iFrom, iTo)
{       
    var ObjFrom = GetReference(iFrom);
    var ObjTo = GetReference(iTo);
    
    var iDate = ObjFrom.value
    
    if(iDate != "")
    {
        var Annee = iDate.substring(0,4);
        
        Annee = parseInt(Annee) + 1;            
        var YearAfter = Annee + iDate.substring(4,10);        
        
        ObjTo.value = YearAfter;
    }
}

function ModifierStyle(iElement)
{
    ObjPolice = GetReference("SelectPolice_" + iElement);
    ObjTaille = GetReference("SelectTaille_" + iElement);
    ObjItalic = GetReference("SelectItalic_" + iElement);
    ObjGrosseur = GetReference("SelectBold_" + iElement);
    ObjSouligne = GetReference("SelectSouligne_" + iElement);
    ObjColorFace = GetReference("SelectCouleurTexte_" + iElement);
    ObjColorFond = GetReference("SelectCouleurFond_" + iElement);
    
    // Attribution à l'élément
    ObjElement = GetReference(iElement);               
    
    ObjElement.style.fontSize = ObjTaille.value;
    ObjElement.style.fontFamily = "'" + ObjPolice.value + "'";
    ObjElement.style.fontWeight = (ObjGrosseur.checked == true ? ObjGrosseur.value : "normal");
    ObjElement.style.fontStyle = (ObjItalic.checked == true ? ObjItalic.value : "normal");  
    ObjElement.style.textDecoration = (ObjSouligne.checked == true ? ObjSouligne.value : "none");
    ObjElement.style.color = ObjColorFace.value;
    ObjElement.style.background = ObjColorFond.value;
    
}  

// Permet de changer l'ordre dans les colonnes des listes
function ChangerOrdre(iColonne)
{
    ObjOrdreActuel = GetReference("Or" + iColonne);    
    document.formOrdreColonne.Or.value = ObjOrdreActuel.value;
    document.formOrdreColonne.submit()
}


/* Les menus de gauche  */
function MenuOverOut(iMenuID)
{
    ObjMenu = GetReference("Menu" + iMenuID);
    ObjLien = GetReference("Lien" + iMenuID);         
      
    if(ObjMenu.className == "cellule_menu_over")
    {
        ObjMenu.className = "cellule_menu";
        ObjLien.className = "souscategorie_lien";
    }
    else
    {
         ObjMenu.className = "cellule_menu_over";
         ObjLien.className = "souscategorie_lien_over"; 
    }

}

function GoMenuLien(iMenuID)
{
    ObjLien = GetReference("Lien" + iMenuID);
    window.location.href = ObjLien.href;
}

// Retourne la position de chr (caractère recherché) dans str(le texte de recherche)
function FindCharInString(str, chr)
{
    return str.indexOf(chr);
}

function htmlentities(texte) 
{
	texte = texte.replace(/"/g,'&quot;'); // 34 22     "// Pour empêcher erreur     
	texte = texte.replace(/&/g,'&amp;'); // 38 26
	texte = texte.replace(/\'/g,'&#39;'); // 39 27     '// Pour empêcher erreur
	texte = texte.replace(/</g,'&lt;'); // 60 3C
	texte = texte.replace(/>/g,'&gt;'); // 62 3E
	texte = texte.replace(/\^/g,'&circ;'); // 94 5E
	texte = texte.replace(/‘/g,'&lsquo;'); // 145 91
	texte = texte.replace(/’/g,'&rsquo;'); // 146 92
	texte = texte.replace(/“/g,'&ldquo;'); // 147 93
	texte = texte.replace(/”/g,'&rdquo;'); // 148 94
	texte = texte.replace(/•/g,'&bull;'); // 149 95
	texte = texte.replace(/–/g,'&ndash;'); // 150 96
	texte = texte.replace(/—/g,'&mdash;'); // 151 97
	texte = texte.replace(/˜/g,'&tilde;'); // 152 98
	texte = texte.replace(/™/g,'&trade;'); // 153 99
	texte = texte.replace(/š/g,'&scaron;'); // 154 9A
	texte = texte.replace(/›/g,'&rsaquo;'); // 155 9B
	texte = texte.replace(/œ/g,'&oelig;'); // 156 9C
	//texte = texte.replace(/?/g,'&#357;'); // 157 9D
	texte = texte.replace(/ž/g,'&#382;'); // 158 9E
	texte = texte.replace(/Ÿ/g,'&Yuml;'); // 159 9F
	texte = texte.replace(/ /g,'&nbsp;'); // 160 A0
	texte = texte.replace(/¡/g,'&iexcl;'); // 161 A1
	texte = texte.replace(/¢/g,'&cent;'); // 162 A2
	texte = texte.replace(/£/g,'&pound;'); // 163 A3
	texte = texte.replace(/ /g,'&curren;'); // 164 A4
	texte = texte.replace(/¥/g,'&yen;'); // 165 A5
	texte = texte.replace(/¦/g,'&brvbar;'); // 166 A6
	texte = texte.replace(/§/g,'&sect;'); // 167 A7
	texte = texte.replace(/¨/g,'&uml;'); // 168 A8
	texte = texte.replace(/©/g,'&copy;'); // 169 A9
	texte = texte.replace(/ª/g,'&ordf;'); // 170 AA
	texte = texte.replace(/«/g,'&laquo;'); // 171 AB
	texte = texte.replace(/¬/g,'&not;'); // 172 AC
	texte = texte.replace(/­/g,'&shy;'); // 173 AD
	texte = texte.replace(/®/g,'&reg;'); // 174 AE
	texte = texte.replace(/¯/g,'&macr;'); // 175 AF
	texte = texte.replace(/°/g,'&deg;'); // 176 B0
	texte = texte.replace(/±/g,'&plusmn;'); // 177 B1
	texte = texte.replace(/²/g,'&sup2;'); // 178 B2
	texte = texte.replace(/³/g,'&sup3;'); // 179 B3
	texte = texte.replace(/´/g,'&acute;'); // 180 B4
	texte = texte.replace(/µ/g,'&micro;'); // 181 B5
	texte = texte.replace(/¶/g,'&para'); // 182 B6
	texte = texte.replace(/·/g,'&middot;'); // 183 B7
	texte = texte.replace(/¸/g,'&cedil;'); // 184 B8
	texte = texte.replace(/¹/g,'&sup1;'); // 185 B9
	texte = texte.replace(/º/g,'&ordm;'); // 186 BA
	texte = texte.replace(/»/g,'&raquo;'); // 187 BB
	texte = texte.replace(/¼/g,'&frac14;'); // 188 BC
	texte = texte.replace(/½/g,'&frac12;'); // 189 BD
	texte = texte.replace(/¾/g,'&frac34;'); // 190 BE
	texte = texte.replace(/¿/g,'&iquest;'); // 191 BF
	texte = texte.replace(/À/g,'&Agrave;'); // 192 C0
	texte = texte.replace(/Á/g,'&Aacute;'); // 193 C1
	texte = texte.replace(/Â/g,'&Acirc;'); // 194 C2
	texte = texte.replace(/Ã/g,'&Atilde;'); // 195 C3
	texte = texte.replace(/Ä/g,'&Auml;'); // 196 C4
	texte = texte.replace(/Å/g,'&Aring;'); // 197 C5
	texte = texte.replace(/Æ/g,'&AElig;'); // 198 C6
	texte = texte.replace(/Ç/g,'&Ccedil;'); // 199 C7
	texte = texte.replace(/È/g,'&Egrave;'); // 200 C8
	texte = texte.replace(/É/g,'&Eacute;'); // 201 C9
	texte = texte.replace(/Ê/g,'&Ecirc;'); // 202 CA
	texte = texte.replace(/Ë/g,'&Euml;'); // 203 CB
	texte = texte.replace(/Ì/g,'&Igrave;'); // 204 CC
	texte = texte.replace(/Í/g,'&Iacute;'); // 205 CD
	texte = texte.replace(/Î/g,'&Icirc;'); // 206 CE
	texte = texte.replace(/Ï/g,'&Iuml;'); // 207 CF
	texte = texte.replace(/Ð/g,'&ETH;'); // 208 D0
	texte = texte.replace(/Ñ/g,'&Ntilde;'); // 209 D1
	texte = texte.replace(/Ò/g,'&Ograve;'); // 210 D2
	texte = texte.replace(/Ó/g,'&Oacute;'); // 211 D3
	texte = texte.replace(/Ô/g,'&Ocirc;'); // 212 D4
	texte = texte.replace(/Õ/g,'&Otilde;'); // 213 D5
	texte = texte.replace(/Ö/g,'&Ouml;'); // 214 D6
	texte = texte.replace(/×/g,'&times;'); // 215 D7
	texte = texte.replace(/Ø/g,'&Oslash;'); // 216 D8
	texte = texte.replace(/Ù/g,'&Ugrave;'); // 217 D9
	texte = texte.replace(/Ú/g,'&Uacute;'); // 218 DA
	texte = texte.replace(/Û/g,'&Ucirc;'); // 219 DB
	texte = texte.replace(/Ü/g,'&Uuml;'); // 220 DC
	texte = texte.replace(/Ý/g,'&Yacute;'); // 221 DD
	texte = texte.replace(/Þ/g,'&THORN;'); // 222 DE
	texte = texte.replace(/ß/g,'&szlig;'); // 223 DF
	texte = texte.replace(/à/g,'&agrave;'); // 224 E0
	texte = texte.replace(/á/g,'&aacute;'); // 225 E1
	texte = texte.replace(/â/g,'&acirc;'); // 226 E2
	texte = texte.replace(/ã/g,'&atilde;'); // 227 E3
	texte = texte.replace(/ä/g,'&auml;'); // 228 E4
	texte = texte.replace(/å/g,'&aring;'); // 229 E5
	texte = texte.replace(/æ/g,'&aelig;'); // 230 E6
	texte = texte.replace(/ç/g,'&ccedil;'); // 231 E7
	texte = texte.replace(/è/g,'&egrave;'); // 232 E8
	texte = texte.replace(/é/g,'&eacute;'); // 233 E9
	texte = texte.replace(/ê/g,'&ecirc;'); // 234 EA
	texte = texte.replace(/ë/g,'&euml;'); // 235 EB
	texte = texte.replace(/ì/g,'&igrave;'); // 236 EC
	texte = texte.replace(/í/g,'&iacute;'); // 237 ED
	texte = texte.replace(/î/g,'&icirc;'); // 238 EE
	texte = texte.replace(/ï/g,'&iuml;'); // 239 EF
	texte = texte.replace(/ð/g,'&eth;'); // 240 F0
	texte = texte.replace(/ñ/g,'&ntilde;'); // 241 F1
	texte = texte.replace(/ò/g,'&ograve;'); // 242 F2
	texte = texte.replace(/ó/g,'&oacute;'); // 243 F3
	texte = texte.replace(/ô/g,'&ocirc;'); // 244 F4
	texte = texte.replace(/õ/g,'&otilde;'); // 245 F5
	texte = texte.replace(/ö/g,'&ouml;'); // 246 F6
	texte = texte.replace(/÷/g,'&divide;'); // 247 F7
	texte = texte.replace(/ø/g,'&oslash;'); // 248 F8
	texte = texte.replace(/ù/g,'&ugrave;'); // 249 F9
	texte = texte.replace(/ú/g,'&uacute;'); // 250 FA
	texte = texte.replace(/û/g,'&ucirc;'); // 251 FB
	texte = texte.replace(/ü/g,'&uuml;'); // 252 FC
	texte = texte.replace(/ý/g,'&yacute;'); // 253 FD
	texte = texte.replace(/þ/g,'&thorn;'); // 254 FE
	texte = texte.replace(/ÿ/g,'&yuml;'); // 255 FF
    
	return texte;
}


//Décode une chaîne
function html_entity_decode(texte) 
{
	texte = texte.replace(/&quot;/g,'"'); // 34 22
	texte = texte.replace(/&amp;/g,'&'); // 38 26	
	texte = texte.replace(/&#39;/g,"'"); // 39 27
	texte = texte.replace(/&lt;/g,'<'); // 60 3C
	texte = texte.replace(/&gt;/g,'>'); // 62 3E
	texte = texte.replace(/&circ;/g,'^'); // 94 5E
	texte = texte.replace(/&lsquo;/g,'‘'); // 145 91
	texte = texte.replace(/&rsquo;/g,'’'); // 146 92
	texte = texte.replace(/&ldquo;/g,'“'); // 147 93
	texte = texte.replace(/&rdquo;/g,'”'); // 148 94
	texte = texte.replace(/&bull;/g,'•'); // 149 95
	texte = texte.replace(/&ndash;/g,'–'); // 150 96
	texte = texte.replace(/&mdash;/g,'—'); // 151 97
	texte = texte.replace(/&tilde;/g,'˜'); // 152 98
	texte = texte.replace(/&trade;/g,'™'); // 153 99
	texte = texte.replace(/&scaron;/g,'š'); // 154 9A
	texte = texte.replace(/&rsaquo;/g,'›'); // 155 9B
	texte = texte.replace(/&oelig;/g,'œ'); // 156 9C
	texte = texte.replace(/&#357;/g,'?'); // 157 9D
	texte = texte.replace(/&#382;/g,'ž'); // 158 9E
	texte = texte.replace(/&Yuml;/g,'Ÿ'); // 159 9F
	texte = texte.replace(/&nbsp;/g,' '); // 160 A0
	texte = texte.replace(/&iexcl;/g,'¡'); // 161 A1
	texte = texte.replace(/&cent;/g,'¢'); // 162 A2
	texte = texte.replace(/&pound;/g,'£'); // 163 A3
	texte = texte.replace(/&curren;/g,' '); // 164 A4
	texte = texte.replace(/&yen;/g,'¥'); // 165 A5
	texte = texte.replace(/&brvbar;/g,'¦'); // 166 A6
	texte = texte.replace(/&sect;/g,'§'); // 167 A7
	texte = texte.replace(/&uml;/g,'¨'); // 168 A8
	texte = texte.replace(/&copy;/g,'©'); // 169 A9
	texte = texte.replace(/&ordf;/g,'ª'); // 170 AA
	texte = texte.replace(/&laquo;/g,'«'); // 171 AB
	texte = texte.replace(/&not;/g,'¬'); // 172 AC
	texte = texte.replace(/&shy;/g,'­'); // 173 AD
	texte = texte.replace(/&reg;/g,'®'); // 174 AE
	texte = texte.replace(/&macr;/g,'¯'); // 175 AF
	texte = texte.replace(/&deg;/g,'°'); // 176 B0
	texte = texte.replace(/&plusmn;/g,'±'); // 177 B1
	texte = texte.replace(/&sup2;/g,'²'); // 178 B2
	texte = texte.replace(/&sup3;/g,'³'); // 179 B3
	texte = texte.replace(/&acute;/g,'´'); // 180 B4
	texte = texte.replace(/&micro;/g,'µ'); // 181 B5
	texte = texte.replace(/&para/g,'¶'); // 182 B6
	texte = texte.replace(/&middot;/g,'·'); // 183 B7
	texte = texte.replace(/&cedil;/g,'¸'); // 184 B8
	texte = texte.replace(/&sup1;/g,'¹'); // 185 B9
	texte = texte.replace(/&ordm;/g,'º'); // 186 BA
	texte = texte.replace(/&raquo;/g,'»'); // 187 BB
	texte = texte.replace(/&frac14;/g,'¼'); // 188 BC
	texte = texte.replace(/&frac12;/g,'½'); // 189 BD
	texte = texte.replace(/&frac34;/g,'¾'); // 190 BE
	texte = texte.replace(/&iquest;/g,'¿'); // 191 BF
	texte = texte.replace(/&Agrave;/g,'À'); // 192 C0
	texte = texte.replace(/&Aacute;/g,'Á'); // 193 C1
	texte = texte.replace(/&Acirc;/g,'Â'); // 194 C2
	texte = texte.replace(/&Atilde;/g,'Ã'); // 195 C3
	texte = texte.replace(/&Auml;/g,'Ä'); // 196 C4
	texte = texte.replace(/&Aring;/g,'Å'); // 197 C5
	texte = texte.replace(/&AElig;/g,'Æ'); // 198 C6
	texte = texte.replace(/&Ccedil;/g,'Ç'); // 199 C7
	texte = texte.replace(/&Egrave;/g,'È'); // 200 C8
	texte = texte.replace(/&Eacute;/g,'É'); // 201 C9
	texte = texte.replace(/&Ecirc;/g,'Ê'); // 202 CA
	texte = texte.replace(/&Euml;/g,'Ë'); // 203 CB
	texte = texte.replace(/&Igrave;/g,'Ì'); // 204 CC
	texte = texte.replace(/&Iacute;/g,'Í'); // 205 CD
	texte = texte.replace(/&Icirc;/g,'Î'); // 206 CE
	texte = texte.replace(/&Iuml;/g,'Ï'); // 207 CF
	texte = texte.replace(/&ETH;/g,'Ð'); // 208 D0
	texte = texte.replace(/&Ntilde;/g,'Ñ'); // 209 D1
	texte = texte.replace(/&Ograve;/g,'Ò'); // 210 D2
	texte = texte.replace(/&Oacute;/g,'Ó'); // 211 D3
	texte = texte.replace(/&Ocirc;/g,'Ô'); // 212 D4
	texte = texte.replace(/&Otilde;/g,'Õ'); // 213 D5
	texte = texte.replace(/&Ouml;/g,'Ö'); // 214 D6
	texte = texte.replace(/&times;/g,'×'); // 215 D7
	texte = texte.replace(/&Oslash;/g,'Ø'); // 216 D8
	texte = texte.replace(/&Ugrave;/g,'Ù'); // 217 D9
	texte = texte.replace(/&Uacute;/g,'Ú'); // 218 DA
	texte = texte.replace(/&Ucirc;/g,'Û'); // 219 DB
	texte = texte.replace(/&Uuml;/g,'Ü'); // 220 DC
	texte = texte.replace(/&Yacute;/g,'Ý'); // 221 DD
	texte = texte.replace(/&THORN;/g,'Þ'); // 222 DE
	texte = texte.replace(/&szlig;/g,'ß'); // 223 DF
	texte = texte.replace(/&agrave;/g,'à'); // 224 E0
	texte = texte.replace(/&aacute;/g,'á'); // 225 E1
	texte = texte.replace(/&acirc;/g,'â'); // 226 E2
	texte = texte.replace(/&atilde;/g,'ã'); // 227 E3
	texte = texte.replace(/&auml;/g,'ä'); // 228 E4
	texte = texte.replace(/&aring;/g,'å'); // 229 E5
	texte = texte.replace(/&aelig;/g,'æ'); // 230 E6
	texte = texte.replace(/&ccedil;/g,'ç'); // 231 E7
	texte = texte.replace(/&egrave;/g,'è'); // 232 E8
	texte = texte.replace(/&eacute;/g,'é'); // 233 E9
	texte = texte.replace(/&ecirc;/g,'ê'); // 234 EA
	texte = texte.replace(/&euml;/g,'ë'); // 235 EB
	texte = texte.replace(/&igrave;/g,'ì'); // 236 EC
	texte = texte.replace(/&iacute;/g,'í'); // 237 ED
	texte = texte.replace(/&icirc;/g,'î'); // 238 EE
	texte = texte.replace(/&iuml;/g,'ï'); // 239 EF
	texte = texte.replace(/&eth;/g,'ð'); // 240 F0
	texte = texte.replace(/&ntilde;/g,'ñ'); // 241 F1
	texte = texte.replace(/&ograve;/g,'ò'); // 242 F2
	texte = texte.replace(/&oacute;/g,'ó'); // 243 F3
	texte = texte.replace(/&ocirc;/g,'ô'); // 244 F4
	texte = texte.replace(/&otilde;/g,'õ'); // 245 F5
	texte = texte.replace(/&ouml;/g,'ö'); // 246 F6
	texte = texte.replace(/&divide;/g,'÷'); // 247 F7
	texte = texte.replace(/&oslash;/g,'ø'); // 248 F8
	texte = texte.replace(/&ugrave;/g,'ù'); // 249 F9
	texte = texte.replace(/&uacute;/g,'ú'); // 250 FA
	texte = texte.replace(/&ucirc;/g,'û'); // 251 FB
	texte = texte.replace(/&uuml;/g,'ü'); // 252 FC
	texte = texte.replace(/&yacute;/g,'ý'); // 253 FD
	texte = texte.replace(/&thorn;/g,'þ'); // 254 FE
	texte = texte.replace(/&yuml;/g,'ÿ'); // 255 FF
	return texte;
}   


function showbox (sDiv, sMessage, iDuration, iState) 
{
   var iClass = "";
   
   switch(iState)
   {
       case 1 :       // Régulier
            iClass = "information";
       break;
        
       case 2 :       // Avertissement
            iClass = "avertissement";
       break;
       
       case 3 :       // Erreur
            iClass = "erreur";
       break;
       
       case 4 :       // Suggestion
            iClass = "suggestion";
       break;
        
       default :
            iClass = "information";
       break;
   }           
   
    ObjShow = GetReference(sDiv)
	ObjShow.innerHTML = '';
	     
    ObjShow.className = iClass;
	ObjShow.innerHTML = sMessage;   
}      


function DoLoadPage(iPage)
{    
    var TargetFrame = "frame_edit";
    
    if(iPage == "")
        iPage = "blank.php";
    
    eval("parent."+TargetFrame+".location='"+iPage+"'");    

}

function DoEditer(ID, Section)
{
    /*
    ArrayInfo["Individus"] = array("url" => "edition_individus.php");
    ArrayInfo["Entreprises"] = array("url" => "edition_entreprises.php");
    ArrayInfo["Specialistes"] = array("url" => "edition_specialistes.php");
    */
    
    var TargetFrame = "frame_edit";
    var URL = "";

    switch(Section)
    {
        case "I" :                
            URL = "edition_individu.php?IndividuID=" + ID;
            //document.frame["frame_edit"].src = URL; 
            eval("parent."+TargetFrame+".location='"+URL+"'");
            parent.top.showbox("status", "Éditer la fiche" , 6000, 3); 
        break;
        
        case "E" :                
            URL = "edition_entreprise.php?EntrepriseID=" + ID;
            //document.frame["frame_edit"].src = URL; 
            eval("parent."+TargetFrame+".location='"+URL+"'");
            parent.top.showbox("status", "Éditer la fiche" , 6000, 3); 
        break;
        
        case "L" :                
            URL = "edition_licence.php?LicenceID=" + ID;            
            eval("parent."+TargetFrame+".location='"+URL+"'");
            parent.top.showbox("status", "Éditer une licence" , 6000, 3); 
        break;
        
        case "S" :                
            URL = "edition_specialiste.php?SpecialisteID=" + ID;
            //document.frame["frame_edit"].src = URL; 
            eval("parent."+TargetFrame+".location='"+URL+"'");
            parent.top.showbox("status", "Éditer la fiche" , 6000, 3); 
        break;
        
        case "A" :                
            URL = "edition_administrateur.php?AdminID=" + ID;
            //document.frame["frame_edit"].src = URL; 
            eval("parent."+TargetFrame+".location='"+URL+"'");
            showbox("status", "Éditer la fiche" , 6000, 3); 
        break;
        
        case "P" :                
            URL = "publipostage.php?P=" + ID;                
            eval("parent."+TargetFrame+".location='"+URL+"'");
            showbox("status", "Préparation des étiquettes « " + ID + " »" , 6000, 3); 
        break;
        
        case "V" :
        
            URL = "liste_valeurs_ref.php?TableID=" + ID;                
            eval("parent."+TargetFrame+".location='"+URL+"'");
            showbox("status", "Liste des valeurs de références" , 6000, 3); 
        break;
    }
}


function DoAjouter(Section, Param)
{
    
    var TargetFrame = "frame_edit";
    var URL = "";
    
    switch(Section)
    {
        case "I" :                
            URL = "edition_individu.php";                
            eval("parent."+TargetFrame+".location='"+URL+"'");  
            parent.top.showbox("status", "Création d'une fiche individu" , 6000, 3);     
        break;
        
        case "E" :                
            URL = "edition_entreprise.php?EntrepriseID";            
            eval("parent."+TargetFrame+".location='"+URL+"'");
            parent.top.showbox("status", "Création d'une fiche entreprise" , 6000, 3); 
        break;
        
        case "L" :                
            URL = "edition_licence.php?LicenceID";            
            eval("parent."+TargetFrame+".location='"+URL+"'");
            parent.top.showbox("status", "Création d'une licence" , 6000, 3); 
        break;
        
        case "S" :                
            URL = "edition_specialiste.php?SpecialisteID=" + ID;
            eval("parent."+TargetFrame+".location='"+URL+"'");
            parent.top.showbox("status", "Création d'une fiche de spécialiste" , 6000, 3); 
        break;
        
        case "P" :                
            URL = "publipostage.php";                
            eval("parent."+TargetFrame+".location='"+URL+"'");
            showbox("status", "Préparation des étiquettes" , 6000, 3); 
        break;
        
        case "A" :                
            URL = "edition_administrateur.php";                
            eval("parent."+TargetFrame+".location='"+URL+"'");
            parent.top.showbox("status", "Ajout d'un administrateur" , 6000, 3);   
        break;
        
        case "V" :                
            URL = "edition_valeur_ref.php";                
            
            if(Param != "")
                URL += "?" + Param + "&Retour=liste_valeurs_ref.php?" + Param;   
    
            eval("parent."+TargetFrame+".location='"+URL+"'");
            parent.top.showbox("status", "Ajout d'une valeur de référence" , 6000, 3);   
        break;
        
    }
    
    parent.top.showbox("status", "Ajout d'une fiche" , 6000, 3);  
}   


function GetListeInfo(iAlpha, iSearch, iTable, iOrdre, iDeleteID, iDeleteName, iMessageSpecial)
{
    var OptionRecherche = "";
    var Limit = "";        
    
    if(iDeleteID != "")
    {
        var Question = "Êtes-vous sûr de vouloir supprimer « " + iDeleteName + " »?";
        var TargetFrame = "frame_edit";
        var URL = "";

		if (confirm(Question))
		{	    
            URL = "blank.php";                
            eval("parent."+TargetFrame+".location='"+URL+"'");   
                
            iMessageStatus = "Suppression de « " + iDeleteName + " »";
            parent.top.showbox("status", iMessageStatus , 6000, 3); 
            
            // Création du lien            
            var iLien = "../includes/global_ajax.inc.php?Query=Delete&Table=" + iTable + "&DeleteID=" + iDeleteID + "&OrderBy=" + iOrdre + "&Limit=" + Limit;                        
            
           
            //alert(iLien)
            //document.write(iLien);
            
            // Création de l'objet
            var XHR = new XHRConnection();  
            XHR.sendAndLoad(iLien, "GET", ReturnListeInfo);  
        }
                  
    }
    else
    {
        // Recherche ou listing régulier
    
        if(iAlpha != "")
        {                              
            iMessageStatus = "Recherche les noms commençant par « " + iAlpha + " »";
        }
        else
        {               
            if(iSearch != "")        
                iMessageStatus = "Recherche tous les noms contenant « " + iSearch + " »";
            else
                iMessageStatus = "Recherche tous les noms";                
        }
        
        if(iMessageSpecial != "")
        {
            if(iMessageSpecial == "NULL")
                iMessageStatus = "";
            else
                iMessageStatus = iMessageSpecial;
        }
        
        parent.top.showbox("status", iMessageStatus , 6000, 3);            
        
        var iLien = "../includes/global_ajax.inc.php?Query=Liste&Table=" + iTable + "&Alpha=" + iAlpha + "&RechTexte=" + iSearch + "&OptionRecherche=" + OptionRecherche + "&OrderBy=" + iOrdre + "&Limit=" + Limit;        
        
        iAlpha = "";
       
        //document.write(iLien);
        
        // Création de l'objet
        var XHR = new XHRConnection();  
        XHR.sendAndLoad(iLien, "GET", ReturnListeInfo);  
    }  
        
}

var ReturnListeInfo = function (obj)
{      
    var RetourInfo = obj.responseText;                      
    
    if(RetourInfo !== undefined && RetourInfo != "")
    {   
        var Information = RetourInfo.split("||||||||||");                                       
        
        // Les premiers éléments (indice 0) sont les résultats et message de résultats
        // 1 (réussite) - 0 (Échec)     
        var LogRetour = Information[0].split("====");
        var StatusRetour = Information[1].split("====");
        var Section = Information[2].split("====");
        var Liste = Information[3].split("===="); 
        
        //alert(
        // Commande réussite
        if(LogRetour[0] == 1)
        {                  
            var FieldValue = new Array();
            var StringValue = "";
            var Object = "";                   
                        
            switch(Section[1])
            {
                case "Individus" :                
                    Object = GetReference("Liste_Individus");    
                break;
                
                case "Administrateurs" :                
                    Object = GetReference("Liste_Administrateurs");    
                break;
                
                case "Entreprises" :                
                    Object = GetReference("Liste_Entreprises");    
                break;
                
                case "Specialistes" :                
                    Object = GetReference("Liste_Specialistes");    
                break;
            }      
            
            //Object = parent.top.Liste_Individus;
            
            if(Object !== undefined && Object !== null)  
            {       
                Object.innerHTML = html_entity_decode(Liste[1]);                
            }
        }
    }
}        

ObjTime = "";

function showTime(iSeconde)
{ 
    var myDate = new Date(); 
    var time = myDate.getTime(); 
    var hour = myDate.getHours(); 
    var minute = myDate.getMinutes(); 
    var second = myDate.getSeconds(); 
    if (hour < 10) { hour = "0" + hour; } 
    if (minute < 10) { minute = "0" + minute; } 
    if (second < 10) { second = "0" + second; } 
    
    var theDate = " " + hour + ":" + minute;
    
    if(iSeconde != "")
     theDate += ":" + second; 
    
    if(ObjTime == "")
        ObjTime = GetReference("hourPanel"); 
        
    ObjTime.innerHTML=theDate;
	setTimeout("showTime('" + iSeconde + "');",1000);
}


function BuildHeaderJavascript(iTitre, iIcone, iPrint, iAjout, iFermer)
{
    var Onglet = "";         
    
    Onglet += '<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">';
        Onglet += '<tr>';                    
            Onglet += '<td valign="top" style="padding-bottom:0px">';
                Onglet += '<table border="0" cellpadding="0" cellspacing="0">';
                    Onglet += '<tr>';                                    
                        Onglet += '<td height="31" style="padding-left:10px; padding-right:10px; background-image:url(images/onglet_background.png); background-repeat: repeat-x; background-position: top left"><img src="images/skin/' + iIcone + '" height="24" width="24" vspace="4" alt="" /></td>';
                        Onglet += '<td height="31" style="padding-left:0px; padding-right:10px; background-image:url(images/onglet_background.png); background-repeat: repeat-x; background-position: top left"><span class="grand_titre_xt">' + iTitre + '</span></td>';
                        Onglet += '<td width="17" height="31" valign="top" align="left"><img src="images/onglet_droit.png" width="17" height="31" border="0" alt="" /></td>';                                           
                    Onglet += '</tr>';
                Onglet += '</table>';            
            Onglet += '</td>';
            Onglet += '<td valign="top" align="right">';                            
                
                if(iPrint != "" || iFermer != "" || iAjout != "")
                {                       
                    Onglet += '<table border="0" cellpadding="0" cellspacing="0">';
                        Onglet += '<tr>';
                            Onglet += '<td width="17" height="31"><img src="images/onglet_gauche.png" width="17" height="31" border="0" alt="" /></td>';                            
                            
                            if(iPrint != "")
                            {                                    
                                Onglet += '<td style="paddin-left:5px; padding-right:5px; background-image:url(images/onglet_background.png); background-repeat: repeat-x; background-position: top left"><img src="images/icone_imprimante.png" alt="Imprimer" title="Imprimer" height="24" width="24" align="absmiddle" border="0" hspace="5"></td>';                    
                            }
                            
                            if(iAjout != "")
                            {                                                                                                                                                                                                                                                                                                                       
                                Onglet += '<td style="paddin-left:5px; padding-right:5px; background-image:url(images/onglet_background.png); background-repeat: repeat-x; background-position: top left"><img src="images/icone_imprimante.png" alt="Imprimer" title="Imprimer" height="24" width="24" align="absmiddle" border="0" hspace="5"></td>';                    
                            }
                            
                            if(iFermer != "")
                            {
                                Onglet += '<a href="javascript:window.close();" class="lien_xt"><img src="images/bt_fermer.gif" alt="Fermer" height="24" width="24" align="absmiddle" border="0" hspace="5">' + iFermer + '</a>';
                                
                            }
                                                        
                        Onglet += '</tr>';
                    Onglet += '</table>';
                
                }
                                        
            Onglet += '</td>';
        Onglet += '</tr>';
    Onglet += '</table>';
    
    ObjOnglet = GetReference("OngletHolder");
    ObjOnglet.innerHTML = Onglet;

}  

 
