var titreDefaut = "Ideo : les Domaines Oubliés";
var bouton_courant = false;
var lien_courant = false;
var bouton_courant2 = false;
var lien_courant2 = false;

function ajuster()
{
  centre = parseInt(document.body.clientWidth / 2) - 200;
  document.getElementById("msgBox").style.top = "130px";
  document.getElementById("msgBox").style.left = centre + "px";
  if(document.all)
  {
    if(document.getElementById("logomj"))
      document.getElementById("logomj").style.position = "absolute";

    document.getElementById("msgBox").style.position = "absolute";

        img = document.getElementById("msgBox_hd");
    img.outerHTML = "<span style=\"" + img.style.cssText + ";width:7px; height:31px;"
       + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
     + "(src='" + img.src + "', sizingMethod='scale');\"></span>";

        img = document.getElementById("msgBox_d");
    img.outerHTML = "<span style=\"" + img.style.cssText + ";width:7px; height:103px;"
       + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
     + "(src='" + img.src + "', sizingMethod='scale');\"></span>";

        img = document.getElementById("msgBox_bas");
    img.outerHTML = "<span style=\"" + img.style.cssText + ";width:417px; height:43px;"
       + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
     + "(src='" + img.src + "', sizingMethod='scale');\"></span>";
  }
  else
  {
    document.getElementById("msgBox").style.position = "absolute";
    if(document.getElementById("logomj"))
      document.getElementById("logomj").style.position = "absolute";
  }
}

function formatData(strdata, txtformat) {
	if (txtformat=='noformat') {
 		return strdata;
	}

 	var strtmp = strdata.replace(/\n\r/gi,"<br\/>");
	strtmp = strtmp.replace(/\r/gi,"<br\/>");
 	strtmp = strtmp.replace(/\n/gi,"<br\/>");

 	strtmp = strtmp.replace( RegExp('&amp;',"gi") ,"&");

 	strtmp = strtmp.replace( RegExp('&lt;b&gt;',"gi") ,"<b>");
 	strtmp = strtmp.replace( RegExp('&lt;/b&gt;',"gi") ,"</b>");

 	strtmp = strtmp.replace( RegExp('&lt;i&gt;',"gi") ,"<i>");
 	strtmp = strtmp.replace( RegExp('&lt;/i&gt;',"gi") ,"</i>");

 	strtmp = strtmp.replace( RegExp('&lt;u&gt;',"gi") ,"<u>");
 	strtmp = strtmp.replace( RegExp('&lt;/u&gt;',"gi") ,"</u>");

 	strtmp = strtmp.replace( RegExp('&lt;br&gt;',"gi") ,"<br/>");
 	strtmp = strtmp.replace( RegExp('&lt;br/&gt;',"gi") ,"<br/>");

 	if (txtformat == 'plain') 
	{
		//
 	}
 	else if (txtformat == 'text') 
	{
		strtmp = strtmp.replace( RegExp('<br/>',"gi") ,'\n');
 		strtmp = strtmp.replace( RegExp('&lt;',"gi") ,'<');
		strtmp = strtmp.replace( RegExp('&gt;',"gi") ,'>');
 	}
 	else if (txtformat == 'html') 
	{
 		strtmp = strtmp.replace( RegExp('&lt;',"gi") ,'<');
 		strtmp = strtmp.replace( RegExp('&gt;',"gi") ,'>');
 	}
	
 	return strtmp;
}


// Affiche un message d'alerte
function ouvreMsgBox(msg,img,type,titre,special)
{
  if(document.getElementById("msgBox").style.display != "block")
  {
    delier();
    delier2();
    form = document.forms["msgBox_form"];

    if(!img)
        img = 'info';
    if(!type)
        type = 'ok';
    if(!titre)
        titre = titreDefaut;
    if(special)
          document.imgMsgBox.src = img;
    else
          document.imgMsgBox.src = repSite + "msgbox/" + img + ".png";

    divMsgBox = document.getElementById("msgBoxMsg");
    setContent("msgBox_titre", titre);
    divMsgBox.innerHTML = formatData(msg,'html');
    
    form.ok.style.display = "none";
    form.annuler.style.display = "none";
    form.oui.style.display = "none";
    form.non.style.display = "none";
    form.saisie.style.display = "none";
    form.aide.style.display = "none";
    form.liste.style.display = "none";
    divMsgBox.style.height = "93px";
    switch(type)
    {
    case "ok":
        form.ok.style.display = "inline";
        break;
    case "saisieaide":
        form.aide.style.display = "inline";
    case "saisie":
      divMsgBox.style.height = "45px";
        form.saisie.value = "";
        form.saisie.style.display = "inline";
        form.ok.style.display = "inline";
        form.annuler.style.display = "inline";
        break;
    case 'liste':
      divMsgBox.style.height = "60px";
        form.liste.value = "";
        form.liste.options.length = 0;
        form.liste.style.display = "inline";
        form.ok.style.display = "inline";
        form.annuler.style.display = "inline";
        break;
    case "okannuler":
        form.ok.style.display = "inline";
        form.annuler.style.display = "inline";
        break;
    case "ouinonannuler":
        form.annuler.style.display = "inline";
    case "ouinon":
        form.oui.style.display = "inline";
        form.non.style.display = "inline";
        break;
    case "ouinonaide":
        form.aide.style.display = "inline";
        form.oui.style.display = "inline";
        form.non.style.display = "inline";
        break;
    }
    document.getElementById("msgBox").style.display = "block";
    if(type == "saisie")
        form.saisie.focus();
  }
}
function fermeMsgBox()
{
  document.getElementById("msgBox").style.display = "none";
}
// Lie une fonction à un bouton de la boite de message
function lier(bouton,action)
{
  if(!bouton_courant)
  {
    bouton_courant = bouton;
      lien_courant = action;
    if(document.all)
          document.forms["msgBox_form"][bouton].attachEvent("onclick",action);
    else
          document.forms["msgBox_form"][bouton].addEventListener("click",action,false);
  }
}
// Lie une fonction à un bouton de la boite de message
function lier2(bouton,action)
{
  if(!bouton_courant2)
  {
    bouton_courant2 = bouton;
      lien_courant2 = action;
    if(document.all)
          document.forms["msgBox_form"][bouton].attachEvent("onclick",action);
    else
          document.forms["msgBox_form"][bouton].addEventListener("click",action,false);
  }
}

// Délie une fonction d'un bouton de la boite de message
function delier()
{
  if(document.forms["msgBox_form"][bouton_courant] && lien_courant)
    {
    if(document.all)
          document.forms["msgBox_form"][bouton_courant].detachEvent("onclick",lien_courant);
    else
          document.forms["msgBox_form"][bouton_courant].removeEventListener("click",lien_courant,false);
  }
  bouton_courant = false;
  lien_courant = false;
}

// Délie une fonction d'un bouton de la boite de message
function delier2()
{
  if(document.forms["msgBox_form"][bouton_courant2] && lien_courant2)
    {
    if(document.all)
          document.forms["msgBox_form"][bouton_courant2].detachEvent("onclick",lien_courant2);
    else
          document.forms["msgBox_form"][bouton_courant2].removeEventListener("click",lien_courant2,false);
  }
  bouton_courant2 = false;
  lien_courant2 = false;
}

// Récupère la saisie de la boite de message
function recupSaisie()
{
  return document.forms["msgBox_form"].saisie.value;
}

// Met un texte de saisie dans la boite de message
function setSaisie(str)
{
  document.forms["msgBox_form"].saisie.value = str;
}

// Récupère la saisie de la boite de message
function recupListe()
{
  return valueList(document.forms["msgBox_form"].liste);
}

// Met un texte de saisie dans la boite de message
function setListe(data, selIndex)
{
    document.forms["msgBox_form"].liste.options.length = 0;
    i = 0;
  var group = false;
  for(value in data)
  {
      if(data[value] == "group")
      {
          group = document.createElement("optgroup");
      group.label = value;
      document.forms["msgBox_form"].liste.appendChild(group);
      }
      else
      {
          var option = document.createElement("option");
      option.text = data[value];
      option.innerText = data[value];
      option.value = value;
      if(group)
        group.appendChild(option);
      else
        document.forms["msgBox_form"].liste.appendChild(option);
    }
    i++;
  }
  if(selIndex)
    document.forms["msgBox_form"].liste.options.selectedIndex = selIndex;
}

function debug(variable)
{
  msg = new Array();
  for(param in variable)
    msg += param + " = " + variable[param] + "<br>";

  ouvreMsgBox(msg);
}

// Envoie un formulaire, s'il n'a pas déjà été envoyé
var envoye = false;
function envoyer(form)
{
  if(!envoye)
  {
    envoye = true;
    form.submit();
  }
}

// Envoyer une missive à un joueur
function missive(nom)
{
  if(!nom)
  {
  	
    id = vue_principale.document.infosPerso.idPerso.value
     if(id != "" && persos[id])
    {
      nom = persos[id]["nom"];
    }
    else
    {
       ouvreMsgBox("Vous n'avez choisis personne !","warning");
       return;
    }
  }
  
  location.replace(rep_jeu + "missives." + EXT + "?m=new&dest=" + nom);
}

// Afficher les infos détaillées d'un joueur
function details(id)
{
  if(id == "0")
      ouvreMsgBox("Les fantômes sont des joueurs dont les comptes ont été supprimés.");
  else if(!id)
     id = vue_principale.document.infosPerso.idPerso.value;
  if(id == "liste")
  {
      window.open(rep_jeu + "popups/details_perso." + EXT,"","width=780,height=450");
    return;
  }
  if(id == 'mj' || id == 'MJ')
    ouvreMsgBox("Les MJ (Maîtres de Jeu) sont là pour animer le monde d'Ideo et veillez au bon déroulement du jeu. Les MJ peuvent effectuer certaines opérations de modération (modifier ou supprimer un message, changer un nom, etc...). Si vous contestez l'opération d'un MJ, adressez-vous à ce dernier (ou à un autre) et on étudiera votre problème.","info","ok","Les maîtres de jeu");
  else if(id)
    window.open(rep_jeu + "popups/details_perso." + EXT + "?id=" + id,"","width=780,height=450");
}

// Afficher les infos détaillées d'un joueur
function details_mj(id)
{
  if(id == "0")
      ouvreMsgBox("Les fantômes sont des joueurs dont les comptes ont été supprimés.");
  else if(!id)
     id = vue_principale.document.infosPerso.idPerso.value;
  if(id == "liste")
  {
      window.open(rep_jeu + "popups/details_perso." + EXT,"","width=780,height=450");
    return;
  }
  if(id == 'mj' || id == 'MJ')
    ouvreMsgBox("Les MJ (Maîtres de Jeu) sont là pour animer le monde d'Ideo et veillez au bon déroulement du jeu. Les MJ peuvent effectuer certaines opérations de modération (modifier ou supprimer un message, changer un nom, etc...). Si vous contestez l'opération d'un MJ, adressez-vous à ce dernier (ou à un autre) et on étudiera votre problème.","info","ok","Les maîtres de jeu");
  else if(id)
    window.open(rep_jeu + "popups/details_perso." + EXT + "?id=" + id,"","width=780,height=450");
}

// Afficher les infos détaillées d'un joueur
function chronique(id,chap)
{
   window.open(rep_jeu + "popups/chroniques." + EXT + "?id=" + id + "&c=" + chap,"","width=780,height=450");
}

// Afficher les infos détaillées d'une ville
function detailsVille(id)
{
   window.open(rep_jeu + "popups/ville." + EXT + "?id=" + id,"","width=780,height=450");
}

function gererRep()
{
  window.open(rep_jeu + "popups/repertoire." + EXT,"win_rep","scrollbars,resizable,width=600,height=500");
}

function livreSorts()
{
   window.open(rep_jeu + "popups/livre_sorts." + EXT,"","width=780,height=450");
}

function statut(texte)
{
  if(texte)
      window.status = texte;
  else
      window.status = defaultStatus;
  return true;
}

function retirer(id,nom)
{
  window.open(rep_jeu + "popups/repertoire." + EXT + "?act=retirer&perso=" + nom + "&id=" + id,"win_rep","scrollbars,resizable,width=600,height=500");
}

function ajouter(nom)
{
  window.open(rep_jeu + "popups/repertoire." + EXT + "?act=ajouter&perso=" + nom,"win_rep","scrollbars,resizable,width=600,height=500");
}

function bloquer(nom)
{
  window.open(rep_jeu + "popups/repertoire." + EXT + "?act=bloquer&perso=" + nom,"win_rep","scrollbars=yes,width=600,height=500");
}

function debloquer(id,nom)
{
  window.open(rep_jeu + "popups/repertoire." + EXT + "?act=debloquer&perso=" + nom + "&id=" + id,"win_rep","scrollbars=yes,width=600,height=500");
}

function carteDetaillee(x,y)
{
  if(x && y)
     window.open(rep_jeu + "popups/carte." + EXT + "?x=" + x + "&y=" + y,"","width=785,height=455,top=40,left=150");
  else
     window.open(rep_jeu + "popups/carte." + EXT,"","width=785,height=455,top=40,left=150");
}

var ouvert = true;
function switchBloc(nomBloc,all)
{
  bloc = document.getElementById(nomBloc);
  bouton = document.forms["switch_" + nomBloc].bouton;
  if(((document.all && ouvert) || (!document.all && !ouvert)) && all)
  {
    ouvrirBlocs();
      bouton.blur();
  }
  else if(all)
  {
      fermerBlocs();
      bouton.blur();
  }
  else if(bouton.style.backgroundImage == "url(" + repSite + "boutons/ouvrir.gif)")
  {
    ouvert = true;
      bloc.style.height = "210px";
      bloc.style.borderBottom = "none";
      bouton.style.backgroundImage = "url(" + repSite + "boutons/reduire.gif)";
      bouton.blur();
  }
  else
  {
    ouvert = false;
      bloc.style.height = "42px";
      bloc.style.borderBottom = "black solid 2px";
      bouton.style.backgroundImage = "url(" + repSite + "boutons/ouvrir.gif)";
      bouton.blur();
  }
}
function fermerBlocs()
{
  for(b in listeBlocs)
  {
    bloc = document.getElementById(listeBlocs[b]);
    bouton = document.forms["switch_" + listeBlocs[b]].bouton;
      bloc.style.height = "42px";
      bloc.style.borderBottom = "black solid 2px";
      bouton.style.backgroundImage = "url(" + repSite + "boutons/ouvrir.gif)";
  }
}
function ouvrirBlocs()
{
  for(b in listeBlocs)
  {
    bloc = document.getElementById(listeBlocs[b]);
    bouton = document.forms["switch_" + listeBlocs[b]].bouton;
      bloc.style.height = "210px";
      bloc.style.borderBottom = "none";
      bouton.style.backgroundImage = "url(" + repSite + "boutons/reduire.gif)";
  }
}

// Enroule / déroule le résultat de l'attaque
function switchAttaque()
{
  div = document.getElementById("attaqueRes");
  bouton = document.getElementById("boutonSwitchAttaque");
  if(div.style.display == "none")
  {
    bouton.style.backgroundImage = "url(" + repSite + "boutons/reduire.gif)";
    bouton.blur();
      div.style.display = "block";
  }
  else
  {
    bouton.style.backgroundImage = "url(" + repSite + "boutons/ouvrir.gif)";
    bouton.blur();
      div.style.display = "none";
  }
}

function valueList(liste)
{
  id = liste.options.selectedIndex;
  if(id >= 0)
    return liste.options[id].value;
  else
    return false;
}
var style = false;
function changeStyle(liste,pack)
{
  return envoiStyle();
  
  style = valueList(liste);
  if(style == "autre")
  {
      document.formstyle.style_autre.style.backgroundColor = "white";
      document.formstyle.style_autre.disabled = false;
  }
  else if(pack)
  {
      ouvreMsgBox("Attention, vous avez activé le pack d'image. Veillez à ce que la skin soit bien installée sinon vous ne verrez rien. Si elle n'est pas installée, vous pouvez la télécharger ou désactiver votre pack. Télécharger la skin ?","question","ouinonannuler");
      lier("oui",telecharger)
    lier2("non",envoiStyle);
  }
  else
      envoiStyle();
}
function envoiStyle()
{
  document.formstyle.submit();
}
function telecharger()
{
  window.open("http://ns3911.ovh.net/skins/" + style + ".zip","","");
}

var forum_ouvert = "camp";
function switch_forum(forum)
{
  bloc = document.getElementById("forum_" + forum);
  bouton = document.getElementById("switch_" + forum);
  if(forum_ouvert == forum)
  {
    forum_ouvert = false;
      bloc.style.display = "none";
      bouton.style.backgroundImage = "url(" + repSite + "boutons/ouvrir.gif)";
      bouton.blur();
  }
  else
  {
      if(forum_ouvert)
      {
        document.getElementById("forum_" + forum_ouvert).style.display = "none";
        document.getElementById("switch_" + forum_ouvert).style.backgroundImage = "url(" + repSite + "boutons/ouvrir.gif)";
      }
    forum_ouvert = forum;
      bloc.style.display = "block";
      bouton.style.backgroundImage = "url(" + repSite + "boutons/reduire.gif)";
      bouton.blur();
  }
}

function jouerMusique(musique)
{
  winMusique = window.open("popups/musique." + EXT + "?id=" + musique,"winMusique","width=200,height=50");
}

function precedent(liste)
{
  if(liste.selectedIndex > 0)
    liste.selectedIndex--;
}

function suivant(liste)
{
  if(liste.selectedIndex < liste.options.length)
    liste.selectedIndex++;
}

function getWidth(objet)
{
  //  if(!existe(objet)) alert(objet + " n'existe pas !");
  return parseInt(document.getElementById(objet).style.width.substr(0,-2));
}

function getHeight(objet)
{
  // if(!existe(objet)) alert(objet + " n'existe pas !");
  return parseInt(document.getElementById(objet).style.height.substr(0,-2));
}

function setContent(objet, content)
{
  // if(!existe(objet)) alert(objet + " n'existe pas !");
  document.getElementById(objet).innerHTML = content;
}

function Show(objet, visibility)
{
  if(!existe(objet))
    return;
  if(visibility == "inline")
  {
      document.getElementById(objet).style.display = "inline";
  }
  else if(visibility)
  {
      document.getElementById(objet).style.visibility = "visible";
  }
  else
  {
      document.getElementById(objet).style.display = "block";
  }
}

function Hide(objet, visibility)
{
  if(!existe(objet))
    return;
  if(visibility)
  {
      document.getElementById(objet).style.visibility = "hidden";
  }
  else
  {
      document.getElementById(objet).style.display = "none";
  }
}

function estVisible(objet)
{
  if(!existe(objet))
    return false;
  else if(document.getElementById(objet).style.visibility == "visible" &&
    document.getElementById(objet).style.display == "block")
    return true;
  else
    return false;
}

function setColor(objet, color)
{
  // if(!existe(objet)) alert(objet + " n'existe pas !");
  document.getElementById(objet).style.color = color;
}

function setStyle(objet, style, value)
{
  // if(!existe(objet)) alert(objet + " n'existe pas !");
  
  objet = document.getElementById(objet);
  objet.style[style] = value;
}

function setImage(objet, image, width)
{
  // if(!existe(objet)) alert(objet + " n'existe pas !");
  img = document.getElementById(objet);
  if(document.all && image.substring(image.length - 4) == ".png")
  {
    img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + image + "', sizingMethod='scale')";
  }
  else
    document.getElementById(objet).src = image;
}

function jouer()
{
    open("jouer." + EXT,"","fullscreen=yes,top=0,left=0,width="+screen.width+",height="+screen.height);
}

function carte()
{
    open("carte." + EXT,"","fullscreen=yes,top=0,left=0,width="+screen.width+",height="+screen.height);
}

function existe(objet)
{
  return document.getElementById(objet);
}

function forum(lien)
{
  winForum = window.open("forum." + EXT + "?f=" + lien,"forum","fullscreen=yes,top=0,left=0,width="+screen.width+",height="+screen.height);
  winForum.focus();
}
var aideAffichee = false;
var aideOver = false;
var aideTimeout = false;
function aide(texte)
{
  if(document.getElementById("aide_contenu"))
  {
      if(aideTimeout)
        clearTimeout(aideTimeout);
    if(texte)
    {
      aideAffichee = true;
        document.getElementById("aide_contenu").innerHTML = texte;
        document.getElementById("aide_bulle").style.visibility = "visible";
    }
    else
    {
      aideAffichee = false;
        aideTimeout = setTimeout("cacheAide()",2);
    }
  }
  else
    statut(texte);
}
function cacheAide()
{
    if(!aideOver)
       Hide("aide_bulle","hidden",true);
}
function overAide()
{
  aideOver = true;
}
function outAide()
{
  aideOver = false;
    if(!aideAffichee)
      Hide("aide_bulle","hidden",true);
}
function avertDelog(timeout)
{
  ouvreMsgBox("Attention, vous allez être déconnecté d'ici une minute. Cliquez sur ok pour ne pas être déconnecté.","warning");
  lier("ok", annuleDelog);
  setTimeout("avertDelog(" + timeout + ")", timeout);
}
function annuleDelog()
{
  window.open("popups/annuledelog." + EXT, "", "width=10,height=10,top=0,left=0"); 
}

function createCSSClass(selector, style)
{
 // using information found at: http://www.quirksmode.org/dom/w3c_css.html
 // doesn't work in Opera due to lack of styleSheets support

 if(!document.styleSheets) return;
 if(document.getElementsByTagName("head").length == 0) return;
 var stylesheet;
 var mediaType;
 if(document.styleSheets.length > 0)
 {
  for(i = 0; i<document.styleSheets.length; i++)
  {
   if(document.styleSheets[i].disabled) continue;
   var media = document.styleSheets[i].media;
   mediaType = typeof media;
   // IE
   if(mediaType == "string")
   {
    if(media == "" || media.indexOf("screen") != -1)
    {
     styleSheet = document.styleSheets[i];
    }
   }
   else if(mediaType == "object")
   {
    if(media.mediaText == "" || media.mediaText.indexOf("screen") != -1)
    {
     styleSheet = document.styleSheets[i];
    }
   }
   // stylesheet found, so break out of loop
   if(typeof styleSheet != "undefined") break;
  }
 }
 // if no style sheet is found
 if(typeof styleSheet == "undefined")
 {
  // create a new style sheet
  var styleSheetElement = document.createElement("style");
  styleSheetElement.type = "text/css";
  // add to <head>
  document.getElementsByTagName("head")[0].appendChild(styleSheetElement);
  // select it
  for(i = 0; i<document.styleSheets.length; i++)
  {
   if(document.styleSheets[i].disabled) continue;
   styleSheet = document.styleSheets[i];
  }
  // get media type
  var media = styleSheet.media;
  mediaType = typeof media;
 }
 // IE
 if(mediaType == "string")
 {
  for(i = 0;i<styleSheet.rules.length;i++)
  {
   // if there is an existing rule set up, replace it
   if(styleSheet.rules[i].selectorText.toLowerCase() == selector.toLowerCase())
   {
    styleSheet.rules[i].style.cssText = style;
    return;
   }
  }
  // or add a new rule
  styleSheet.addRule(selector,style);
 }
 else if(mediaType == "object")
 {
  for(i = 0;i<styleSheet.cssRules.length;i++)
  {
   // if there is an existing rule set up, replace it
   if(styleSheet.cssRules[i].selectorText.toLowerCase() == selector.toLowerCase())
   {
    styleSheet.cssRules[i].style.cssText = style;
    return;
   }
  }
  // or insert new rule
  styleSheet.insertRule(selector + "{" + style + "}", styleSheet.cssRules.length);
 }
}

/////////////////////////////////////////
////     Fonction requestConfirm     ////
////         Mantis   0000155        ////
/////////////////////////////////////////
var paramsConfirm;

function fermeConfBox(isConfirm)
{
  if (isConfirm) 
  {
    paramsConfirm ['_confirmed'] = true;
    
    var curelem;
    for (e in document.forms['confBox_form'].elements) 
    {
      curelem  = document.forms['confBox_form'].elements[e];
      if (curelem.type=='text' || curelem.type=='textarea' || curelem.type=='select-one')
      {
        paramsConfirm [curelem.name] = curelem.value;
      } 
      else if (curelem.type=='radio' && curelem.checked) 
      {
          paramsConfirm [curelem.name]=curelem.value;
      }
      else if (curelem.type=='checkbox') 
      {      
        paramsConfirm [curelem.name] = curelem.checked;
      }
    }
    
    //////////////////////////
    // A SUPPRIMER pour la mise en PROD
    //  var tmpdebug=''
    //  for (p in paramsConfirm)
    //  {
    //    tmpdebug = tmpdebug + p + '=' + paramsConfirm[p] + '\n';
    //  }
    //     alert('xajax_executeFunction (paramsConfirm)  \n ' +  tmpdebug);  //A supprimer pour la mise en prod
    // fin de A SUPPRIMER
    //////////////////////////

    xajax_executeFunction (paramsConfirm);       
  }    
  document.getElementById('confirmBox').style.display='none';      
}

function requestConfirm(/*string*/ functionName, /*Array*/ params, /*string*/ text, /*Array*/ changeParams)
{
  if (! document.getElementById('confirmBox')) { return; }
    
  paramsConfirm = params;
  paramsConfirm ['_fctname'] = functionName;    
  
  document.getElementById('confirmBox').style.display='block';   
  document.getElementById('confBoxMsg').innerHTML = text;
  
  var isDefaultRadio='';
  var isFirstRadio=true;
  
  var tmphtml = '';
  for (p in changeParams)
  {
    // Mise en place du libelle du champ
    if (changeParams[p]['lib']) {
      tmphtml = tmphtml + '<label class="lblparamconf">' + changeParams[p]['lib'] + '</label>';
    } 
    else {
      tmphtml = tmphtml + '<label class="lblparamconf">&nbsp;</label>';    
    }
        
    ///////////////////////////////////
    ////////// type = SELECT ////////// 
    ///////////////////////////////////
    if (changeParams[p]['type'] == 'select' ) 
    {          
      tmphtml = tmphtml + '<select class="confparam" name="' + p + '">';
      for (op in changeParams[p]['options'])      
      {
        if (params[p] == op) {
          tmphtml = tmphtml + '<option value="' + op + '" selected="selected">' + changeParams[p]['options'][op] + '</option>';
        } 
        else {
          tmphtml = tmphtml + '<option value="' + op + '">' + changeParams[p]['options'][op] + '</option>';        
        }            
      }
      tmphtml = tmphtml + '</select><br/>';
    }

    ///////////////////////////////////
    ////////// type = radio /////////// 
    ///////////////////////////////////    
    else if (changeParams[p]['type'] == 'radio' ) 
    {      
      isFirstRadio=true;
      for (op in changeParams[p]['options'])      
      {
        isDefaultRadio=''
        if (params[p] == op) {
          isDefaultRadio = 'checked="checked"';
        }
        
        if (isFirstRadio) 
        {       
          tmphtml = tmphtml + '<input type="radio" name="'+ p + '" value="' + op + '"' + isDefaultRadio + '/>' + changeParams[p]['options'][op] + '<br/>';
          isFirstRadio=false;
        } 
        else 
        {
          tmphtml = tmphtml + '<label class="lblparamconf">&nbsp;</label>';    
          tmphtml = tmphtml + '<input type="radio" name="'+ p + '" value="' + op + '"' + isDefaultRadio + '/>' + changeParams[p]['options'][op] + '<br/>';        
        }        
      }

    }    
    
    ///////////////////////////////////
    ///////// type = TEXTAREA ///////// 
    ///////////////////////////////////
    else if (changeParams[p]['type'] == 'textarea' ) 
    {
      tmphtml = tmphtml + '<textarea class="confparam" name="' + p + '">'
      if (params[p]) {
        tmphtml = tmphtml + params[p];      
      }           
      tmphtml = tmphtml + '</textarea><br/>';
    }        
    
    ///////////////////////////////////
    ///////// type = checkbox ///////// 
    ///////////////////////////////////    
    else if (changeParams[p]['type'] == 'checkbox' ) 
    {
      if (params[p]) {
        tmphtml = tmphtml + '<input type="checkbox" value="1" checked="checked" name="' + p + '"/><br/>';      
      } 
      else {
        tmphtml = tmphtml + '<input type="checkbox" value="1" name="' + p + '"/><br/>';
      }        
    }        
    
    ///////////////////////////////////
    ////////// Autres  Types ////////// 
    ///////////////////////////////////    
    else //par default, ca sera un 'TEXT'
    {
      if (params[p]) {
        tmphtml = tmphtml + '<input class="confparam" type="text" name="' + p + '" value="' + params[p] + '"/><br/>';
      } 
      else {
        tmphtml = tmphtml + '<input class="confparam" type="text" name="' + p + '"/><br/>';      
      }
    }        
  }
  
  document.getElementById('confBoxSaisie').innerHTML = tmphtml;
}

// function switch du DEBUG
function switchBloc (debug_id, block)
{
  div = document.getElementById('var' + debug_id + '_block' + block);
  if(div.style.display == "none")
  {
    document.getElementById('var' + debug_id + '_b' + block).innerHTML = '-';
    div.style.display = "block";
  }
  else
  {
    document.getElementById('var' + debug_id + '_b' + block).innerHTML = '+';
    div.style.display = "none";
  }
}

//Création de noeud (balide HTML) dans le DOM
function CreerBalise(nParent, nType, a_Attrib, nText) {
    var new_n = null;
     var sAttrib = ' ';
    
    for (e in a_Attrib) {
      sAttrib += e + '="' + a_Attrib[e] + '" '; 
    } 
    
    try {
      new_n = nParent.appendChild(document.createElement('<' + nType + sAttrib + '>'));
    }
    catch(e) {
      // Ne fonctionne que sous IE
    }
      
    // Si ca n'a pas marché, c'est qu'on est sous Firefox/mozilla
    if (!new_n) {
      new_n = nParent.appendChild(document.createElement(nType));
      for (e in a_Attrib) {
        new_n.setAttribute(e,a_Attrib[e]);
      }
    }

    // Affecte le texte
    if (nText!='') {
      new_n.appendChild(document.createTextNode(nText));
    }
       
    return new_n;
}
