// JavaScript Document
function CreSession(value,session)
{
     if(window.XMLHttpRequest) // FIREFOX
          xhr_object = new XMLHttpRequest(); 
     else if(window.ActiveXObject) // IE
          xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
     else 
          return(false); 
        var method   = "POST";
        var filename = "ajax/creation_session.php";
        var requete  = "session="+session+"&valeursession="+value;
                
        xhr_object.open(method, filename, false);
        xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xhr_object.send(requete);
}
function Redir(pge)
{
   window.location.href='index.php?pge='+pge;
}
function LaunchDemoSite(style)
{
      if (style != "")
      {
          var Rep = $.ajax({ type: 'POST',url: 'ajax/demo_site.php',data: "idx_style="+style, async: true,error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); } , success: function(reponse){
           
           var TabRep = reponse.split("||");
    			 document.getElementById("SiteDemo").innerHTML = "<br /><a onclick=\"window.open(this.href,'','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=850,height=550,left=0,top=0,status'); return false\" href='http://"+TabRep[0]+".myzik.eu/index-exemple.php' style='font-size:14px;'>Voir un site du style "+TabRep[1]+"</a>";
                  
          
          } }); 
      }
}
function ColoreLigne(LigneId,nbLigne,Couleur)
{
  for (var i = 0; i <= nbLigne;i++)
  {
    if (document.getElementById("Ligne"+i))
    {
      if (i == LigneId)
      {
      document.getElementById("Ligne"+i).style.backgroundColor = Couleur;
      }
      else 
      document.getElementById("Ligne"+i).style.backgroundColor = "";
    }
  }                 
} 

function opacity(id)
{

var objet = document.getElementById("1"+id);
var objet2 = document.getElementById("2"+id);
if(document.getElementById("3"+id))
{
var objet3 = document.getElementById("3"+id);
objet3.style.backgroundColor = "#d7deec";
} 
objet2.style.backgroundColor = "#d7deec"; 

objet.style.backgroundColor = "#d7deec"; 

}
function opacity_out(id)
{
 var objet = document.getElementById("1"+id);
 var objet2 = document.getElementById("2"+id);
 if(document.getElementById("3"+id))
  {
  var objet3 = document.getElementById("3"+id);
  objet3.style.backgroundColor = "#ffffff";
  }
 objet.style.backgroundColor = "#ffffff";
 objet2.style.backgroundColor = "#ffffff";
 

}
function texteLien(div, texte)
{
    document.getElementById(div).innerHTML = texte;
}
function InitAjax()
{
  var xhr_object = null;
        
        if(window.XMLHttpRequest) // Firefox
           xhr_object = new XMLHttpRequest();
        else
        {
        if(window.ActiveXObject) // Internet Explorer
          xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
        else // XMLHttpRequest non supporté par le navigateur
          {
          alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
          return;
          }
        }
  return xhr_object;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////DEBUT ACTIVITE////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var nbChampsActivite = 0;
    function Activite(J)
    {
      nbChampsActivite ++;
      ChangeActivitePrincipale(J);
    }

    function ChangeActivitePrincipale(J)
    {
      var MonActivitePrincipale = $("#ActivitePrincipale"+J);
      var Jsuivant = Number(J) + Number(1);
      
      $(MonActivitePrincipale).live("change",function(event,ChangeArtificiel){
        var valueee = $("#ActivitePrincipale"+J+" option").index($("#ActivitePrincipale"+J+" option:selected"));
        if (ChangeArtificiel != "")
        {
          $("#ActivitePrincipale"+J+" option[value='"+ChangeArtificiel+"']").attr("selected", "selected");
        }
        $("#imgload").show();
        if (document.getElementById("ActiviteSecondaire"+J));
        $("#ActiviteSecondaire"+J).remove("");
        
        var id = $(MonActivitePrincipale).val();
        if ($("#ActivitePrincipale"+J+" option").index($("#ActivitePrincipale"+J+" option:selected")) == 0)
        {  //si l'index selectionner == 0
            $("#BoutonDelActivite"+J).remove("");
            $("#SpanBoutonActivite"+Jsuivant).remove("");
            $("#BoutonNextActivite"+Jsuivant).remove("");
            $("#Explication_activite").html("<span class='errorFormulaire'>Vous devez completer les activités !</span>");
        }
        else
        { //si l'index selectionner == 1
          $.ajax
          ({  //On va chercher le champ, pour savoir si on déroule un nouveau menu
              method: "POST", //methode
              url: "ajax/categories_musique_page.php", //url
              data: "id="+id, //variable
              async: false, //false : tout s'arrete. true : tout continu
              success: function(html)
              { 
              $("input[name='TableHidden']").val(html);
              }
          });
          var Table = $("input[name='TableHidden']").val();
          
          if (Table == 1) //nouveau menu
          {
              
              $.ajax
              ({  //On cherche le nouveau menu
                  method: "POST", //methode
                  url: "ajax/categories_musique.php", //url
                  data: "id="+id+"&j="+J, //variable
                  async: false, //false : tout s'arrete. true : tout continu
                  success: function(html)
                  { 
                    MonActivitePrincipale.after(html);
                  }
              });
              $("#SpanBoutonActivite"+Jsuivant).remove("");
              ChangeActiviteSecondaire(J);
          }
          else //pas de nouveau menu
          {
            GETBoutonDeleteActivite(J);
            GETBoutonNextActivite(Jsuivant);
          }
        
        }
      $("#imgload").hide();
      });    
    }

    function ChangeActiviteSecondaire(J)
    {
        var Jsuivant = Number(J) + Number(1);
        MonActiviteSecondaire = $("#ActiviteSecondaire"+J);
        MonActiviteSecondaire.live("change",function(event,ChangeArtificielBis)
        {
          if (ChangeArtificielBis != "")
          {
            $("#ActiviteSecondaire"+J+" option[value='"+ChangeArtificielBis+"']").attr("selected", "selected");
          }
          if ($("#ActiviteSecondaire"+J+" option").index($("#ActiviteSecondaire"+J+" option:selected")) == 0)
          {  //si l'index selectionner == 0
              $("#BoutonDelActivite"+J).remove("");
              $("#SpanBoutonActivite"+Jsuivant).remove("");
              $("#BoutonNextActivite"+Jsuivant).remove("");
          }
          else
          {
            GETBoutonDeleteActivite(J);
            GETBoutonNextActivite(Jsuivant);          
          }
        });    
    }



    function functionDelActivite(J)
    {
        $("#BoutonDelActivite"+J).live("click",function(){
        $("#BoutonDelActivite"+J).die("click");
        $("#ActivitePrincipale"+J).remove(""); 
        $("#ActiviteSecondaire"+J).remove("");
        $("#SpanActivitePrincipale"+J).remove("");
        $("#BoutonDelActivite"+J).remove("");
  
        
            var P = 0;    
            for (var K = 1; K <= nbChampsActivite;K++)
            {
                if (K > J)
                {
                  Kmoins = K-1;
                  $("#ActivitePrincipale"+K).die("change");
                  $("#ActiviteSecondaire"+K).die("change");
                  DiminuerElementName($("#ActivitePrincipale"+K),"ActivitePrincipale");
                  DiminuerElementName($("#ActiviteSecondaire"+K),"ActiviteSecondaire");  
                  DiminuerElementId($("#ActivitePrincipale"+K),"ActivitePrincipale");
                  DiminuerElementId($("#SpanActivitePrincipale"+K),"SpanActivitePrincipale");
                  DiminuerElementId($("#ActiviteSecondaire"+K),"ActiviteSecondaire");
                  DiminuerElementId($("#BoutonDelActivite"+K),"BoutonDelActivite");                 
                  functionDelActivite(Kmoins);
                  ChangeActivitePrincipale(Kmoins);
                  ChangeActiviteSecondaire(Kmoins);
                }
                     
            }
            $("span[id^=SpanBoutonActivite]").remove(""); 
            GETBoutonNextActivite(nbChampsActivite);
            nbChampsActivite --; 
            
        if (nbChampsActivite == 0)
        {  
            $.ajax
            ({  //On cherche le nouveau menu
                method: "POST", //methode
                url: "ajax/categories_musique_default.php", //url
                data: "j=1", //variable
                async: false, //false : tout s'arrete. true : tout continu
                success: function(html)
                { 
                  $("#SpanActivite1").after(html);
                }
            });
            $("span[id^=SpanBoutonActivite]").remove(""); 
            Activite(1);
        }
      });
    }
    function GETBoutonDeleteActivite(J)
    {
      if (!document.getElementById("BoutonDelActivite"+J))
      {
      var JAvant = Number(J) - Number(1);
      if (document.getElementById("ActiviteSecondaire"+J))
      var ActivitePrincipaleAvant = $("#ActivitePrincipale"+J);
      else var ActivitePrincipaleAvant = $("#ActivitePrincipale"+J);
    
      ActivitePrincipaleAvant.before("<img width='10px' height='10px' style='cursor:pointer' src='/img_myzik/moins.png' id='BoutonDelActivite"+J+"' alt='Suppr' title='Supprimer cette activité'> ");
      
      functionDelActivite(J);          
        
      }
    }
        
    function GETBoutonNextActivite(Jsuivant)
    {
      $("#Explication_activite").html(""); 
      if (!document.getElementById("BoutonNextActivite"+Jsuivant) && !document.getElementById("SpanActivitePrincipale"+Jsuivant))
      {
        var J = Number(Jsuivant) - Number(1);
        if (document.getElementById("ActiviteSecondaire"+J))
        var LActivitePrincipale = "#ActiviteSecondaire"+J;
        else var LActivitePrincipale = "#ActivitePrincipale"+J;
        var SpanActivitePrincipale = "#SpanActivitePrincipale"+J; 
        $(LActivitePrincipale).after("<span id='SpanBoutonActivite"+Jsuivant+"'><br /><input type='button' id='BoutonNextActivite"+Jsuivant+"' value='Saisir une autre activité'>  <img src='img_myzik/ok.gif'> ok</span>");
        $("#BoutonDelActivite"+Jsuivant).die("click");
        $("#BoutonNextActivite"+Jsuivant).click(function(){
            $("#Explication_activite").html("<span class='errorFormulaire'>Vous devez completer les activités !</span>");
            $.ajax
            ({  //On cherche le nouveau menu
                method: "POST", //methode
                url: "ajax/categories_musique_default.php", //url
                data: "j="+Jsuivant, //variable
                async: false, //false : tout s'arrete. true : tout continu
                success: function(html)
                { 
                  $(LActivitePrincipale).after("<span id='SpanActivitePrincipale"+Jsuivant+"'><br /></span>"+html);
                }
            });
            $("#SpanBoutonActivite"+Jsuivant).remove("");
            Activite(Jsuivant);
        });
      }
    }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////FIN ACTIVITE////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////DEBUT STYLE////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var nbChampsStyle = 0;
    function Style(J)
    {
      nbChampsStyle ++;
      var MonStylePrincipal = $("#StylePrincipal"+J);
      //var SpanStylePrincipal = $("#SpanStylePrincipal"+J);
      var Jsuivant = Number(J) + Number(1);
      
       //Si l'on ne veux afficher que les catégorie mère dans le déroulant bis
       var req2 = "";
       
       if ($("#DeclareCatMere").val() == "non")
       {
          req2 = "&catmere=non";
       }
       else req2 = "";
        
      $(MonStylePrincipal).change(function(event,ChangeArtificiel){
        if (ChangeArtificiel != "")
        {
          $("#StylePrincipal"+J+" option[value='"+ChangeArtificiel+"']").attr("selected", "selected");
        }
        
        var id = $(MonStylePrincipal).val();
        if (document.getElementById("StylePrincipal"+J).selectedIndex == 0)
        {  //si l'index selectionner == 0
            $("BoutonDelStyle"+J).remove("");
            $("BoutonNextStyle"+Jsuivant).remove("");
        }
        else
        { //si l'index selectionner == 1
          GETBoutonDeleteStyle(J);
          GETBoutonNextStyle(Jsuivant);
        }
      });  
    }
    
    function GETBoutonNextStyle(Jsuivant)
    {
      if (!document.getElementById("BoutonNextStyle"+Jsuivant) && !document.getElementById("StylePrincipal"+Jsuivant))
      {
        var J = Number(Jsuivant) - Number(1);
        $("#Explication_style").html(""); 
        var LeStylePrincipal = "#StylePrincipal"+J;
        var SpanStylePrincipal = "#SpanStylePrincipal"+J; 
        $(LeStylePrincipal).after("<span id='SpanBoutonStyle"+Jsuivant+"'><br /><input type='button' id='BoutonNextStyle"+Jsuivant+"' value='Saisir un autre style'>  <img src='img_myzik/ok.gif'> ok</span></span>");
        $("#BoutonDelStyle"+Jsuivant).die("click");
        $("#BoutonNextStyle"+Jsuivant).click(function(){
            $("#Explication_style").html("<span class='errorFormulaire'>Vous devez completer les styles !</span>");
            $.ajax
            ({  //On cherche le nouveau menu
                method: "POST", //methode
                url: "ajax/categories_style_musique.php", //url
                data: "j="+Jsuivant, //variable
                async: false, //false : tout s'arrete. true : tout continu
                success: function(html)
                { 
                  $(LeStylePrincipal).after("<span id='SpanStylePrincipal"+Jsuivant+"'><br /></span>"+html);
                }
            });
            $("#SpanBoutonStyle"+Jsuivant).remove("");
            Style(Jsuivant);
        });
      }
    }

    function functionDelStyle(J)
    {
        $("#BoutonDelStyle"+J).live("click",function(){
        $("#BoutonDelStyle"+J).die("click");
        $("#StylePrincipal"+J).remove(""); 
        $("#BoutonDelStyle"+J).remove("");
       $("#SpanStylePrincipal"+J).remove("");  
        
            var P = 0;    
            for (var K = 1; K <= nbChampsStyle;K++)
            {
                if (K > J)
                {
                  Kmoins = K-1;
                  DiminuerElementName($("#StylePrincipal"+K),"StylePrincipal",J); 
                  DiminuerElementId($("#StylePrincipal"+K),"StylePrincipal",J);
                  DiminuerElementId($("#SpanStylePrincipal"+K),"SpanStylePrincipal",J);
                  DiminuerElementId($("#BoutonDelStyle"+K),"BoutonDelStyle",J);                 
                  functionDelStyle(Kmoins);
                }
                     
            }
            $("span[id^=SpanBoutonStyle]").remove(""); 
            GETBoutonNextStyle(nbChampsStyle); 
            nbChampsStyle --;

        if (nbChampsStyle == 0)
        {  
            $.ajax
            ({  //On cherche le nouveau menu
                method: "POST", //methode
                url: "ajax/categories_style_musique.php", //url
                data: "j=1", //variable
                async: false, //false : tout s'arrete. true : tout continu
                success: function(html)
                { 
                  $("#SpanStyle1").after(html);
                }
            });
            $("span[id^=SpanBoutonStyle]").remove(""); 
            Style(1);
        }
      });
    }
    function GETBoutonDeleteStyle(J)
    {
      if (!document.getElementById("BoutonDelStyle"+J))
      {
      var JAvant = Number(J) - Number(1);
      var StylePrincipalAvant = $("#StylePrincipal"+J);
      StylePrincipalAvant.before("<img width='10px' height='10px' style='cursor:pointer' src='/img_myzik/moins.png' id='BoutonDelStyle"+J+"' alt='Suppr' title='Supprimer ce style'> ");
      
      functionDelStyle(J);          
        
      }
    }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////FIN STYLE////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////DATE (JOUR)(MOIS)(ANNEE)/////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//var Mois = new array('01','02','03','04','05','06','07','08','09','10','11','12');
var NbJoursMois = ['31','29','31','30','31','30','31','31','30','31','30','31'];

function InitJour(Mois)
{
  if (Mois != "")
  {
    NbJour = $("#JourFormulaire").attr("options").length - 1;
    ValeurDefaut = $("#JourFormulaire").val();
    PosDefaut = $("#JourFormulaire option").index($("#JourFormulaire option:selected"));
    PosTableau = Mois - 1;
    if (NbJour != NbJoursMois[PosTableau])
    {
      var Affich = "";
      var Contenu = "";
      $("#JourFormulaire").html("");
      $("#JourFormulaire").html("<option value=''>Jour :</option>");
      for (var G = 1;G <= NbJoursMois[PosTableau];G++)
      {
        if (G < 10) Affich = "0"+G;
        else Affich = G; 
        Contenu += "<option value='"+Affich+"'>"+Affich+"</option>";
      }
      $("#JourFormulaire").append(Contenu);
      if (ValeurDefaut <= NbJoursMois[PosTableau])
      {  
        $("#JourFormulaire option:eq("+PosDefaut+")").attr('selected', 'selected');
      }
      else $("#JourFormulaire option").index(0);
    }
  }
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////FIN DATE ////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    function DiminuerElementId(Objet,NomChamp)
    {
      LongueurASoustraire = NomChamp.length;
      $(Objet).attr('id',function(arr){
        var LongeurId = this.id.length;
        var Chiffre = this.id.substring(LongueurASoustraire,LongeurId);
        var Calcul = parseInt(Chiffre) - 1;
        return NomChamp+Calcul;
      });
    }
    function DiminuerElementName(Objet,NomChamp)
    {
      LongueurASoustraire = NomChamp.length;
      $(Objet).attr('name',function(arr){
        var LongeurId = this.id.length;
        var Chiffre = this.id.substring(LongueurASoustraire,LongeurId);
        var Calcul = parseInt(Chiffre) - 1;
        return NomChamp+Calcul;
      });
    }  

function GetCategoriePost(Lescateg)
{
var ActivitesPrincipales = Lescateg.split('||');
  for (var k = 1; k <= ActivitesPrincipales.length;k++)
  {
    var J = k+1;
    var K = k-1;
    var SousActives = ActivitesPrincipales[K].split('[]');
    var Time = 250*k;
    setTimeout( "AppelActivite("+k+", [ "+SousActives[0]+" ])",Time); 
      if ($("#ActivitesSecondaire"+k))
    setTimeout( "AppelActiviteBis("+k+", [ "+SousActives[1]+" ])",Time); 
    
    if (ActivitesPrincipales[k])
    setTimeout( "CliqueBoutton("+J+")",Time); 

  }
}
function AppelActivite(k,index)
{
  $("#ActivitePrincipale"+k).trigger("change", [ index ]); 
}
function AppelActiviteBis(k,index)
{
  if ($("#ActivitesSecondaire"+k))
  $("#ActiviteSecondaire"+k).trigger("change", [ index ]);
} 
function CliqueBoutton(J)
{
  $("#BoutonNextActivite"+J).trigger("click");
}
function GetStylePost(Chaine)
{

var StylePrincipal = Chaine.split('||');
for (var v = 1; v <= StylePrincipal.length;v++)
  {
    var J = v+1;
    var K = v-1;
    var Time = 250*v;
    var LeStyle = StylePrincipal[K];
    setTimeout( "AppelStyle("+v+", [ "+LeStyle+" ])",Time); 
    if (StylePrincipal[v])
    setTimeout( "CliqueBouttonStyle("+J+")",Time); 
  }
}
function AppelStyle(k,index)     
{
  $("#StylePrincipal"+k).trigger("change", [ index ]); 
}
function CliqueBouttonStyle(J)
{
  $("#BoutonNextStyle"+J).trigger("click");
}
var editor;
function AffichEditor(bouton,div,img,width)
{
  if (!img || img == "") var img = "contactperson.png";
  if( $("#"+div).is(":visible") )
  { 
    $(bouton).html("<img src='img_myzik/"+img+"' width='142px' height='18px' border=0 alt='Contacter'>");
    $("#"+div).fadeOut("fast");
    removeEditor();      
  }
  else
  {
    $(bouton).html("<img src='img_myzik/cacherform.png' width='142px' height='18px' border=0 alt='Cacher le formulaire'>");
    $("#"+div).fadeIn("fast");
    createEditor(width);
  }
}
function createEditor(width)
{
	if ( editor )
		return;

  if(!width || width == "") width = 600;
	var html = document.getElementById( 'editorcontents' ).innerHTML;
  document.getElementById( 'texte' ).value = html;
	// Create a new editor inside the <div id="editor">, setting its value to html
	var config = {
  width : width,
  height : 150, 
  toolbar : 'ToolbarSimple',
  contentsCss : ''
  
  };
	//editor = CKEDITOR.appendTo( 'editor', config, html );
	editor = CKEDITOR.replace( 'texte' , config);
}

function removeEditor()
{
	if ( !editor )
		return;

	// Retrieve the editor contents. In an Ajax application, this data would be
	// sent to the server or used in any other way.    
	document.getElementById( 'editorcontents' ).innerHTML = editor.getData();
	document.getElementById( 'contents' ).style.display = '';

	// Destroy the editor.
	editor.destroy();
	editor = null;
}

function Hidden(name)                          
{
  var Champ = document.getElementById(name);

  var nameTemp = "";
  var ChampTemp = "";
  for (var i=1;i <= 5;i++)
  {
      nameTemp = "box"+i;
      ChampTemp = document.getElementById(nameTemp);
      if (name != nameTemp)
      {
        if ((ChampTemp.style.display == 'inline-block') || (ChampTemp.style.display == 'block'))
        ChampTemp.style.display = 'none';
      }
  }
  Champ.style.display = 'inline-block';
}
function VerifMdp(Leform)
{
  var pass1 = Leform.pass1;
  var pass2 = Leform.pass2;
  var passancien =  Leform.passancien;
 if (passancien.value != "")
 { 
    if (pass1.value != "")
    {
      if(pass1.value != pass2.value)
      {
      alert("Les deux mots de passe ne sont pas identique");
      return false;
      }
      else return true;
    }
    else 
    {
      alert("Vous n'avez pas saisi votre ancien mot de passe");
      return false;
    }
  }
  else  
  {
    alert("Vous n'avez pas saisi votre mot de passe actuel");
    return false;
  }
}
function Display(name)
{
Champ = document.getElementById(name);
if (Champ.style.display == 'none') 
Champ.style.display = 'block';

else Champ.style.display = 'none';
}
function DisplayEffet(name)
{
Champ = document.getElementById(name);
if (Champ.style.display == 'none') 
$('#'+name).fadeIn();
else $('#'+name).fadeOut();
}

//AFFICHE LES ERREURS LORS DE LA VALIDATION DU FORMULAIRE
function AffichErrorValidation(Error) { $("#AffichErr").html(Error); $("#AffichErr").show();}
//REDIMENTIONNE LE TEXTAREA AVEC ENTREE
  var OneRowHeight = 0;
	function ResizeTextarea(textArea) {
		if (OneRowHeight == 0) OneRowHeight = textArea.style.height;
		var rows = textArea.value.split('\n');
		nRows=-1;
		for (i=0;i < rows.length; i++) {
			if (rows[i].length >= textArea.cols) nRows+= Math.floor(rows[i].length/textArea.cols);
		}
		nRows += rows.length;
		if (nRows >= textArea.rows) {
			textArea.rows = Math.min(5, nRows);
			textArea.style.height = "auto";
		} else if (nRows == 1) {
			textArea.rows = 1;
		} else if (nRows == 0) {
			textArea.rows = 1;
			textArea.style.height = OneRowHeight;
		}
}
function RemoveForLoad(IdGoOff,IdGoOn)
{
  $("#"+IdGoOff).hide();
  $("#"+IdGoOn).show();
}
function DisplayNoneBlock(IdGoOff,IdGoOn)
{
  $("#"+IdGoOff).hide();
  $("#"+IdGoOn).show();
}
function ModifTitre(Obj,Texte,NomChamp,Id,Type,Size)
{ //SERT A AFFICHER LE CHAMP INPUT POUR MODIFIER UNE DESCRIPTION 
  if (Size == "undefined") var Size = "70";
  $(Obj).before("<input type='text' id='"+NomChamp+Id+"' value=\""+$(Obj).text()+"\" size='"+Size+"' onkeyup='if(event.keyCode == 13) {UpdateTitre(\""+Id+"\",\""+Type+"\",\""+NomChamp+"\",\""+Obj.id+"\",$(\"#ImgANext"+Id+"\") )};'/> <img id='ImgANext"+Id+"' src='/img_myzik/modifier_16.png' style='cursor:pointer;' height='13' width='13' title=\""+Texte+"\" onclick='UpdateTitre(\""+Id+"\",\""+Type+"\",\""+NomChamp+"\",\""+Obj.id+"\",this);' />");
  $("#"+NomChamp+Id).focus();
  $(Obj).hide();
}
function ModifTexte(Obj,Texte,NomChamp,Id,Type)
{ //SERT A AFFICHER LE CHAMP INPUT POUR MODIFIER UNE DESCRIPTION
  $(Obj).before("<textarea id='"+NomChamp+Id+"' cols=35 rows=2>"+$(Obj).text()+"</textarea><span onclick='UpdateTitre(\""+Id+"\",\""+Type+"\",\""+NomChamp+"\",\""+Obj.id+"\",this)'><br /><input type='button' value=\""+Texte+"\" /></span>");
  $(Obj).hide();
}
function UpdateTitre (Id,Type,Champ,ObjOn,Obj)
{ //SERT A VALIDER LA MODIF D'UNE DESCRIPTION OU D'UN TITRE
     var NomChamp = Champ+Id;
     var NewValue = $("#"+NomChamp).val();
     if (NewValue != "")
     {
     var Rep = $.ajax({ type: 'POST',url: 'ajax/ModifTitre.php' ,data: "idTitre="+Id+"&Titre="+NewValue+"&Type="+Type, async: false, error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); } }).responseText;
     $("#"+ObjOn).text(NewValue);
     }
     $("#"+NomChamp).remove("");
     $(Obj).remove(""); 
     $("#"+ObjOn).show();
}	
function DelElem(Elem,Id,Type,Parent)
{ //SCRIPT POUR SUPPRESSION D'UNE PHOTO DANS LA FICHE
  //TYPE : 1 - Photo   ;   2 - Morceau de musique
  switch (Type)
  {
  case "1": var Phrase = "Êtes vous sûr de vouloir supprimer cette photo ?"; break;
  case "2": var Phrase = "Êtes vous sûr de vouloir supprimer ce morceau ?"; break;
  }
  if (confirm(Phrase))
  {
  var Rep = $.ajax({beforeSend : function () {$("#BoutonSuppr"+Id).hide();$("#imgLoad"+Id).show(); } ,
  type: 'POST',url: 'ajax/delElem.php',data: "idElem="+Id+"&Type="+Type, async: false,
  error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); } }).responseText;
  switch (Type)
  {
  case "1": $(Elem).parents("."+Parent).html("<img src='/img_myzik/ItemOff.png' title='Image supprimée' width=90px' height='90px' alt='Image supprimée'>"); break;
  case "2": $(Elem).parents("."+Parent).remove(); $("."+parent+":[even]").css({'background-color':'#F5F5F5'}); $("."+parent+":[odd]").css({'background-color':'#D8DFEA'}); break;
  }

  }
}
function ModifTitreMorceau(Id)
{ //SCRIPT POUR AFFICHER LE FORMULAIRE DE MODIFICATION DE LA DESCRIPTION D'UNE PHOTO DANS UNE FICHE
  var Description = $("#"+Id).text();
  $("#"+Id).before("<span id='ModifTemp"+Id+"'><input type='text' size=55 id='TextModifMorceau"+Id+"' class='InputChange' value=\""+Description+"\" onkeyup='if(event.keyCode == 13) {ValidTitre(\""+Id+"\",\"TextModifMorceau"+Id+"\",\"4\");}'><img src='/img_myzik/modifier_16.png' style='cursor:pointer;margin-left:8px;' height='11' width='11' onclick='ValidTitre(\""+Id+"\",\"TextModifMorceau"+Id+"\",\"4\")' title='Modifier le titre'></span>")
  $("#TextModifMorceau"+Id).focus();
  $("#"+Id).hide();   
}
function ValidTitre(Id,Obj,Type)
{  //SCRIPT POUR MODIFIER LA DESCRIPTION D'UNE PHOTO DANS UNE FICHE
   var Text = $("#"+Obj).val();
   if (Text != "")
   {
   var Rep = $.ajax({
   type: 'POST',url: 'ajax/ModifTitre.php',data: "idTitre="+Id+"&Titre="+Text+"&Type="+Type, async: false,
   error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); } }).responseText;
   $("#"+Id).text(Text);
   }
   $("#ModifTemp"+Id).remove();
   $("#"+Id).show();
} 
function DelElemParent(Elem,Id,Type,Phrase)
{
  if (confirm(Phrase))
  {
  var Rep = $.ajax({beforeSend : function () {$("#BoutonSuppr"+Id).hide();$("#imgLoad"+Id).show(); } ,
  type: 'POST',url: 'ajax/delElemParent.php',data: "idElem="+Id+"&Type="+Type, async: false,error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); } 
  }).responseText;
    switch (Type)
    {
    case "1" : $(Elem).parents(".DivAlbum").fadeOut(); break;
    case "2" : $(Elem).parents(".DivAlbumPhoto").fadeOut(); break;
    }
  }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////DEBUT MENU DEROULANT AVEC RESULTAT DES VILLES///////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function GetVille(IdSearch,IdContentSearch,width)
{
  var couleurInstruction = "#8C8A8A";
  var couleurCase = "#D5E2FF";
  var backgroundCase = "#D8DFEA";
  if ((($("#"+IdSearch).val().length == 4 || $("#"+IdSearch).val().length == 5) && !isNaN($("#"+IdSearch).val())) || (isNaN($("#"+IdSearch).val()))) { $.ajax({ type: 'POST',url: 'ajax/cp.php',data: "valeur="+$("#"+IdSearch).val(), async: true, success: function(html){ 
  if (html != ""){var villes = html.split('[|]');  //séparation entre chaque résultat de ville
  var content = "";var contentInfo = "";for (var i = 1;i <= villes.length;i++){ var j = i - 1; var v = villes[j].split('(|)'); //séparation entre la première partie de texte et la deuxieme partie de données
  content += "<div id='Ville"+j+"' class='v' style='width:"+width+"'>"; content += v[0]; content += "</div>";
  var vInfo = v[1].split('-'); //séparation des deux champs code postal et numéro de la ville
  contentInfo += "<span id='VilleInfoCp"+j+"' style='display:none'>"; contentInfo += vInfo[0];  //code postal
  contentInfo += "</span>"; contentInfo += "<span id='VilleInfoNum"+j+"' style='display:none'>"; contentInfo += vInfo[1];  //numéro de la ville
  contentInfo += "</span>"; } $("#"+IdContentSearch).css("background-color",backgroundCase); $("#"+IdContentSearch).html(content+contentInfo);   //on affiche les recherches en dessous du déroulant
  $('div[id^=Ville]').mouseover(function(){ $(this).css({backgroundColor: couleurCase});   //lorsqu'on met la souris sur un résultat
  });
  $('div[id^=Ville]').mouseout(function(){ $(this).css({backgroundColor: backgroundCase});   //lorsqu'on enlève la souris d'un résultat
  });  
  $('div[id^=Ville]').click(function(){   //lorsqu'on clique sur un résultat
  $("#"+IdContentSearch).css("background-color","transparent");
  idChamp = this.id;   //on récupère l'id de l'objet
  idChamp = idChamp.replace( "Ville", ""); //on récupère le numéro de la case ou il est insérer
  $("#cpVille"+IdSearch).val($("#VilleInfoCp"+idChamp).text());  //on donne la valeur au input code postal
  $("#numVille"+IdSearch).val($("#VilleInfoNum"+idChamp).text()); //on donne la valeur au input numéro de la ville
  $("#"+IdSearch).val($(this).text()); $("#"+IdContentSearch).html("");  //on efface les recherche
  $("#Explication_ville").html("<img src='img_myzik/ok.gif'> ok"); }); } else $("#"+IdContentSearch).html("Aucun résultat pour cette recherche"); } }); } else $("#contentsearch").html(""); 
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////FIN MENU DEROULANT AVEC RESULTAT DES VILLES///////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////DEBUT MENU DEROULANT AVEC LES UTILISATEUR///////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  function GetUtil(IdSearch,IdContentSearch,width)
  {
      if (width) width = width;
      else width = '200';
      var couleurInstruction = "#8C8A8A";
      var couleurCase = "#D5E2FF";
      var backgroundCase = "transparent";
      if ($("#"+IdSearch).value == "")
      {
        $("#"+IdContentSearch).css("display","none");
      }
      else
      {
      var Rep = $.ajax({ type: 'POST',url: 'ajax/search.php',data: "valeur="+$("#"+IdSearch).val(), async: true,error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); } , success: function(html){ 
        $("#"+IdContentSearch).css("display","block");  
        if (html != "" && html != " " && html != "  "){
            var user = html.split('[|]');  //séparation entre chaque résultat d'user
            if (user.length > 0)
            {
              var content = "";
              for (var i = 1;i <= user.length;i++){ var j = i - 1; var v = user[j].split('(|)'); var u = v[0].split("%|%");//séparation entre la première partie de texte et la deuxieme partie de données
              content += "<div id='Res"+IdSearch+j+"' style='font-size:15px;width:"+width+";padding:5px;cursor:pointer' onclick=\"window.location.href='index.php?pge=fiche&id="+v[1]+"'\">"; content += "<span class='BleuEpais'>"+u[0]+"</span><br /><span style='color:grey;font-size:10px'>"+u[1]+"</span>"; content += "</div>";
              } 
              $("#"+IdContentSearch).html(content);   //on affiche les recherches en dessous du déroulant
              $("#"+IdContentSearch).css("display","block");
              $('div[id^=Res'+IdSearch+']').mouseover(function(){ $(this).css({backgroundColor: couleurCase});   //lorsqu'on met la souris sur un résultat
              });
              $('div[id^=Res'+IdSearch+']').mouseout(function(){ $(this).css({backgroundColor: backgroundCase});   //lorsqu'on enlève la souris d'un résultat
              });
            }  
            else $("#"+IdContentSearch).html("<div id='Res"+IdSearch+j+"' class='' style='font-size:15px;width:210px;font-weight:bold;padding:3px;'>Aucun résultat</div>");
        }
        else $("#"+IdContentSearch).html("<div id='Res"+IdSearch+j+"' style='font-size:15px;width:210px;font-weight:bold;padding:3px;' align='center'>Aucun résultat</div>");  
      } 
      
      }).responseText; 
      }  
  }
  //MENU DEROULANT DEUX
  function GetUtilId(IdSearch,IdContentSearch,IdContentStockId,IdContentStockGroupe)
  {
      var couleurInstruction = "#8C8A8A";
      var couleurCase = "#D5E2FF";
      var backgroundCase = "transparent";
      if ($("#"+IdSearch).value == "")
      {
        $("#"+IdContentSearch).css("display","none");
      }
      else
      {
      var Rep = $.ajax({ type: 'POST',url: 'ajax/search.php',data: "valeur="+$("#"+IdSearch).val(), async: true,error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); } , success: function(html){ 
        $("#"+IdContentSearch).css("display","block");  
        if (html != "" && html != " " && html != "  "){
            var user = html.split('[|]');  //séparation entre chaque résultat d'user
            if (user.length > 0)
            {
              var content = "";
              for (var i = 1;i <= user.length;i++){ var j = i - 1; var v = user[j].split('(|)'); var u = v[0].split("%|%");//séparation entre la première partie de texte et la deuxieme partie de données
              content += "<div id='Res"+IdSearch+j+"' style='font-size:15px;width:200px;padding:5px;cursor:pointer' onclick='SetNomIdUser(\""+IdSearch+"\",\""+IdContentStockId+"\",\""+IdContentStockGroupe+"\",\""+v[1]+"\",\""+u[0]+"\");'>"; content += "<span class='BleuEpais'>"+u[0]+"</span><br /><span style='color:grey;font-size:10px'>"+u[1]+"</span>"; content += "</div>";
              } 
              $("#"+IdContentSearch).html(content);   //on affiche les recherches en dessous du déroulant
              $("#"+IdContentSearch).css("display","block");
              $('div[id^=Res'+IdSearch+']').mouseover(function(){ $(this).css({backgroundColor: couleurCase});   //lorsqu'on met la souris sur un résultat
              });
              $('div[id^=Res'+IdSearch+']').mouseout(function(){ $(this).css({backgroundColor: backgroundCase});   //lorsqu'on enlève la souris d'un résultat
              });
            }  
            else $("#"+IdContentSearch).html("<div id='Res"+IdSearch+j+"' class='' style='font-size:15px;width:210px;font-weight:bold;padding:3px;'>Aucun résultat</div>");
        }
        else $("#"+IdContentSearch).html("<div id='Res"+IdSearch+j+"' style='font-size:15px;width:210px;font-weight:bold;padding:3px;' align='center'>Aucun résultat</div>");  
      } 
      
      }).responseText; 
      }  
  }
  function SetNomIdUser(IdSearch,IdContentStockId,IdContentStockGroupe,Identifiant,NomGroupe)
  {  //ON SELECTIONNE UN NOUVEAU GROUPE
    
    //ON TESTE LEXISTANCE DE LID DANS LA LISTE
    var TabContentStockId = $("#"+IdContentStockId).val().split(',')
    var present = "";
    for(var h = 0; h < TabContentStockId.length;h++ )
    {
      if (TabContentStockId[h] == Identifiant)
      {
        present = "ok";
      }
    }
    //SI L ID EST DEJA PRESENT DANS LA LISTE ON NE L AJOUTE PAS
    if (present != "ok")
    {
      //ON MET UNE VIRGULE SI LE CHAMPS DES ID EST DEJA REMPLI
      if($("#"+IdContentStockId).val() != "")
      $("#"+IdContentStockId).val($("#"+IdContentStockId).val()+",");
      //ON AJOUTE L ID COURANT
      $("#"+IdContentStockId).val($("#"+IdContentStockId).val()+Identifiant);
      //ON ATTRIBUE LA NOUVELLE LISTE
      $("#"+IdSearch).val(NomGroupe);
      //ON CRER LA BOX CONTENANT LE NOM DU GROUPE
      $("#"+IdContentStockGroupe).before("<div style='width:170px;border:1px solid #AEBACC;padding:5px;background-color:#D8DFEA;float:left;text-align:left;margin-right:1px;' class='BleuEpaisNonSouligne BoxNomGroupe'>"+NomGroupe+"<div style='float:right;margin-top:2px;margin-bottom:2px;'><img src='icones/supprimer_gris.gif' width='10px' height='10px' style='cursor:pointer' onclick=\"DelBoxNomGroupe(this,'"+Identifiant+"','"+IdContentStockId+"')\"></div></div>");
    }
    //ON REMET A ZERO LE CHAMPS DE RECHERCHE
      $("#"+IdSearch).val("");
  }
  
  function DelBoxNomGroupe(Elem,Identifiant,IdContentStockId)
  {  //SUPPRESSION D UN GROUPE CHOISI
    //ON EFFACE LA BOX AVEC LE NOM DU GROUPE DEVANT
    $(Elem).parents('.BoxNomGroupe').fadeOut('fast');
    //ON RECUPERE LES ID DES GROUPES DEJA SELECTIONNE
    var ValContentStockId = $("#"+IdContentStockId).val();
    //ON ENLEVE LES "," ET L IDENTIFIANT SUPPRIMER
    var NewVal = ValContentStockId.replace(RegExp(Identifiant,"g"),'');
    NewVal = NewVal.replace(RegExp(",,","g"),','); //DOUBLE VIRGULE DANS LE CAS OU L ID A ETE SUPPRIMER AU MILLIEU
    if (NewVal.charAt(0) == ",") NewVal = NewVal.substring(1,NewVal.length); //DANS LE CAS OU LA VIRGULE EST AU DEBUT
    if (NewVal.charAt(NewVal.length - 1) == ",") NewVal = NewVal.substring(0,NewVal.length - 1); //DANS LE CAS OU LA VIRGULE EST A LA FIN
    //ON ATTRIBU LA NOUVELLE LISTE NETOYEE
    $("#"+IdContentStockId).val(NewVal);
  }
  
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////DEBUT MENU DEROULANT AVEC LES UTILISATEUR///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
function TestFormCheckedAll(form)
{
  var G = false;
  for(var z=0; z<form.length;z++)
	{
  	if(form[z].type == 'checkbox'){if (form[z].checked){return true;}}
  }
  $("#AffichErrContact").show().html("Vous devez sélectionner des contacts"); 
return false;
}
function toggleAll(element) 
{
form = element.form;
for(var z=0; z<form.length;z++)
	{
	if(form[z].type == 'checkbox')
		form[z].checked = element.checked;
   	}
}
function ReturnIdOfElementId(IdVoulu,NomChamp)
{
  LongueurASoustraire = NomChamp.length;
  var LongeurId = IdVoulu.length;
  var IdRecherche = IdVoulu.substring(LongueurASoustraire,LongeurId);
  return IdRecherche;

}
function goEvent(id,type)
{
   var Rep = $.ajax({ type: 'POST',url: 'ajax/AddEventFavorite.php',data: "valeur="+id+"&type="+type, async: true,error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }}).responseText; 
}
function goOutEvent(id)
{
   var Rep = $.ajax({ type: 'POST',url: 'ajax/DelEventFavorite.php',data: "valeur="+id, async: true,error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }}).responseText; 
}
function GethtmlEvents(TypeHtml,TypeAffichage,IdEvent,Rep)
{
  switch (TypeAffichage)
  {
  case 0:
    var htmlOrigine = "<span class='ParticipationEvent'>"+Rep+"</span><br /><br /><a href='#' class='BtAnnuleEventsParticipation LienAnnuleEventParticipation' style='font-size:12px' id='BtAnnuleEvents"+IdEvent+"'>Annuler</a>";
    var htmlApresModif = "<a href='#' class='BtOn BtEventsOui' id='BtEventsOui"+IdEvent+"' style='padding-left:24px;padding-right:25px;'>OUI</a><br /><br /><a href='#' class='BtOn BtEventsPeutEtre' id='BtEventsPeutEtre"+IdEvent+"'>PEUT ETRE</a><br /><br /><a href='#' class='BtOn BtEventsNon' id='BtEventsNon"+IdEvent+"' style='padding-left:22px;padding-right:23px;'>NON</a>";
  break;
  case 1:
    var htmlOrigine = "<span class='ParticipationEvent'>"+Rep+"</span><a href='#' class='BtAnnuleEventsParticipation LienAnnuleEventParticipation' style='font-size:12px;margin-left:45px;' id='BtAnnuleEvents"+IdEvent+"'>Annuler</a>";
    var htmlApresModif = "<a href='#' class='BtOn BtEventsOui' id='BtEventsOui"+IdEvent+"' style='padding-left:24px;padding-right:25px;'>OUI</a><a href='#' class='BtOn BtEventsPeutEtre' id='BtEventsPeutEtre"+IdEvent+"'>PEUT ETRE</a><a href='#' class='BtOn BtEventsNon' id='BtEventsNon"+IdEvent+"' style='padding-left:22px;padding-right:23px;'>NON</a>";
  break;
  }
  switch (TypeHtml)
  {
  case 1: return htmlOrigine; break;
  case 2: return htmlApresModif; break;
  }
}
function ParticipeEvent(Type)
{
  var TypeAffichage = Type;
  if (TypeAffichage == "undefined") TypeAffichage = 0;
  $(".BtEventsOui").die("click");
  $(".BtEventsPeutEtre").die("click");
  $(".BtEventsNon").die("click");
  $(".BtAnnuleEventsParticipation").die("click");
                                     
  $(".BtEventsOui").live("click",function()
  {
     if (idx_user == "")
     { 
        GoInscription("2"); 
     }
     else
     {
       var IdEvent = $(this).attr("id");
       IdEvent = ReturnIdOfElementId(IdEvent,"BtEventsOui");
       goEvent(IdEvent,1);  
       $(this).parents(".ContentEvent").html(GethtmlEvents(1,TypeAffichage,IdEvent,"Oui"));     
       ParticipeEvent(TypeAffichage);
     }
     return false;
  });
  $(".BtEventsPeutEtre").live("click",function()
  {
     if (idx_user == "")
     { 
        GoInscription("2"); 
     }
     else
     {
     var IdEvent = $(this).attr("id");
     IdEvent = ReturnIdOfElementId(IdEvent,"BtEventsPeutEtre");
     goEvent(IdEvent,2);
     $(this).parents(".ContentEvent").html(GethtmlEvents(1,TypeAffichage,IdEvent,"Peut-être"));
     ParticipeEvent(TypeAffichage);
     }
     return false;
  });
  $(".BtEventsNon").live("click",function()
  {
     if (idx_user == "")
     { 
        GoInscription("2"); 
     }
     else
     {
     var IdEvent = $(this).attr("id");
     IdEvent = ReturnIdOfElementId(IdEvent,"BtEventsNon");
     goEvent(IdEvent,3);
     $(this).parents(".ContentEvent").html(GethtmlEvents(1,TypeAffichage,IdEvent,"Non"));
     ParticipeEvent(TypeAffichage);
     }
     return false;
  });
  $(".BtAnnuleEventsParticipation").live("click",function()
  {
     if (confirm("Êtes-vous sûr de vouloir annuler la participation à l'évènement ?"))
     {
     var IdEvent = $(this).attr("id");
     IdEvent = ReturnIdOfElementId(IdEvent,"BtAnnuleEvents");
     goOutEvent(IdEvent);
     $(this).parents(".ContentEvent").html(GethtmlEvents(2,TypeAffichage,IdEvent));
     ParticipeEvent(TypeAffichage);
     return false;
     }
  });
}	
function goFavorite(id)
{
   $.ajax({ type: 'POST',url: '/ajax/AddFan.php',data: "valeur="+id, async: true,error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }}); 
}
function goOutFavorite(id)
{
   $.ajax({ type: 'POST',url: '/ajax/DelFan.php',data: "valeur="+id, async: true,error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }}); 
}
function GoInscription(Type)
{
    switch (Type)
    {
      case "1" : $("#GoError").html("Pour devenir fan, <a href='index.php?pge=inscription;'>inscrivez-vous gratuitement</a> et profitez des nombreux outils de Myzik,<br /> suivez vos artistes favoris, écoutez leur musique et découvrez de nouveaux artistes grâce à notre annuaire !"); break;
      case "2" : $("#GoError").html("Pour participer un évènement, <a href='index.php?pge=inscription;'>inscrivez-vous gratuitement</a> et profitez des outils Myzik,<br /> suivez vos artistes favoris, écoutez leur musique et découvrez de nouveaux artistes grâce à notre annuaire !"); break;
      case "3" : $("#GoError").html("Pour envoyer un message à l'artiste, <a href='index.php?pge=inscription;'>inscrivez-vous gratuitement</a> et profitez des outils Myzik,<br /> suivez vos artistes favoris, écoutez leur musique et découvrez de nouveaux artistes grâce à notre annuaire !"); break;
    }
    $("#GoError").fadeIn("fast");
    window.scrollTo(50,0);
}
function Favorite()
{
  $(".BtDevenirFan").die("click");
  $(".BtPlusFan").die("click");
  $(".BtDevenirFan").live("click",function()
  {
     if (idx_user == "")
     { 
        GoInscription("1"); 
     }
     else
     {
       var IdUser = $(this).attr("id");
       IdUser = ReturnIdOfElementId(IdUser,"FanDe");
       goFavorite(IdUser);
       $(this).removeClass("BtDevenirFan BtOn").addClass("BtPlusFan BtOff").text("Ne plus être Fan");
       Favorite();
     }     
     
     return false;
  });
  $(".BtPlusFan").live("click",function()
  {
     var IdUser = $(this).attr("id");
     IdUser = ReturnIdOfElementId(IdUser,"FanDe");
     goOutFavorite(IdUser);
     $(this).removeClass("BtPlusFan BtOff").addClass("BtDevenirFan BtOn").text("+ Devenir Fan");
     Favorite();
     return false;
  });
}
function goFavoriteFacebook(id)
{
   var rep = $.ajax({ type: 'POST',url: '/ajax/AddFanFacebook.php',data: "valeur="+id, async: true,error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }}).responseText; 
}
function FavoriteFacebook()
{
  $(".BtDevenirFan").die("click");
  $(".BtPlusFan").die("click");
  $(".BtDevenirFan").live("click",function()
  {
     if (idx_user != "")
     { 
       var IdUser = $(this).attr("id");
       IdUser = ReturnIdOfElementId(IdUser,"FanDe");
       goFavoriteFacebook(IdUser);
       $(this).removeClass("BtDevenirFan BtOn").addClass("BtPlusFan BtOff").text("Ne plus être Fan");
       FavoriteFacebook();
     }     
     
     return false;
  });
  $(".BtPlusFan").live("click",function()
  {
     var IdUser = $(this).attr("id");
     IdUser = ReturnIdOfElementId(IdUser,"FanDe");
     goOutFavorite(IdUser);
     $(this).removeClass("BtPlusFan BtOff").addClass("BtDevenirFan BtOn").text("Devenir Fan");
     FavoriteFacebook();
     return false;
  });
}
function TestSiFan(id)
{
  var Rep = $.ajax({ type: 'POST',url: '/ajax/TestSiFan.php',data: "valeur="+id, async: true,error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }}).responseText; 
  return Rep;
}
function Onglet(idOnglet,classOnglet)
{
   $("."+classOnglet).hide();
   $("#"+idOnglet).show();

}   
function TestChampsVide(texte)
{
      texte = texte.replace(/ /g,'');
      if (texte.length > 0) return true;
      else return false;  
}
function DomaineSansRien(texte)
{
    var accent = new Array("À","Á","Â","Ã","Ä","Å","à","á","â","ã","ä","å","Ò","Ó","Ô","Õ","Ö","Ø","ò","ó","ô","õ","ö","ø","È","É","Ê","Ë","é","è","ê","ë","Ç","ç","Ì","Í","Î","Ï","ì","í","î","ï","Ù","Ú","Û","Ü","ù","ú","û","ü","ÿ","Ñ","ñ"); 
    var noaccent = new Array("a","a","a","a","a","a","a","a","a","a","a","a","o","o","o","o","o","o","o","o","o","o","o","o","e","e","e","e","e","e","e","c","c","i","i","i","i","i","i","i","i","u","u","u","u","u","u","u","u","y","n","n"); 
    for (var i=0; i < accent.length; i++) {
         texte = texte.replace(RegExp(accent[i],"g"), noaccent[i]);
    }
    /*var accent='ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËéèêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ'; 
    var noaccent='aaaaaaaaaaaaooooooooooooeeeeeeecciiiiiiiiuuuuuuuuynn'; */
    texte = texte.replace(/ /g,'-');
    //texte = texte.replace(/\//g,'');
    texte = texte.replace(/_/g,'-');
    texte = texte.replace(/%/g,'');
    texte = texte.replace(/µ/g,'');
    texte = texte.replace(/=/g,'');
    texte = texte.replace(RegExp("'","g"), "");
    texte = texte.replace(/>/g, "");
    texte = texte.replace(/</g, "");
    texte = texte.replace(/:/g, "");
    texte = texte.replace(/\*/g, "");
    texte = texte.replace(/\\/g, "");
    texte = texte.replace(RegExp("/","g"), "");
    texte = texte.replace(/|/g, "");
    texte = texte.replace(/\?/g, "");
    texte = texte.replace(RegExp('"',"g"), "");
    texte = texte.replace(/!/g, "");
    texte = texte.replace(/\(/, "");
    texte = texte.replace(/\)/g, "");
    texte = texte.replace(/\{/, "");
    texte = texte.replace(/\}/g, "");
    texte = texte.replace(/;/g, "");
    texte = texte.replace(/@/g, "");
    texte = texte.replace(/,/g, "");
    texte = texte.replace(/&/g, "");
    texte = texte.replace(/#/g, "");
    texte = texte.replace(/¤/g, "");
    texte = texte.replace(/$/g, "");
    texte = texte.replace(/£/g, "");
    texte = texte.replace(/\+/g, "");
    texte = texte.replace(/©/g, "");
	  texte = texte.replace(/°/g, "");  
    texte = texte.toLowerCase();
    return texte; 
}		  
//VERIFIE LEMAIL
function TestEmailFormulaire(email,longu) 
{ 
  var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');
  if (email.length > 0) 
  { 
    if (reg.test(email)) { var Response = $.ajax({  method: "POST", url: "fonctions/verif_mail.php?", data: "mail="+email, async: false }).responseText; if(Response == 1) { if (longu == 1) return "L'adresse email que vous avez saisie est déjà rattachée à un compte, merci d'en saisir une autre"; else return "Mail déjà utilisé";} else return "";}else{if (longu == 1) return "Le format de votre adresse mail est incorect";else return "Format incorrect !";} 
  } 
  else 
  { 
    if (longu == 1) return "Votre adresse mail est obligatoire, vous recevrez un mail de confirmation à cette adresse"; 
    else return "Obligatoire, vous recevrez un mail de confirmation !"; 
  } 
}
function SetValueSpan(Value,Id)
{
  $("#"+Id).html(Value);  
} 
function MakeMessErreurAlbum(id,Mess)
{
   $("#Error"+id).html("<div class='okFormulaire okFormulaireFond' align='center'>"+Mess+"</div>").fadeIn("fast");  
   setTimeout("$('#Error"+id+"').fadeOut('fast');setTimeout(\"$('#Error"+id+"').html('');\",1000);",1000);
} 
function OubliMdp()
{
  var Email = $("#emailCode").val();
  var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');
  if (Email.length > 0) 
  { 
    if (reg.test(Email))
    {
     var Rep = $.ajax({ type: 'GET',url: '/ajax/codes.php',data: "email="+Email, async: true,error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }
     ,success: function(html) { 
       if (html == 2) $("#TextMdp").text("Votre adresse n'est pas bonne");
       if (html == 1) $("#TextMdp").text("Un email vient de vous être envoyé !");
     }
     }).responseText; 

    }
    else $("#TextMdp").text("Merci de saisir un format valide !");
  }
  else $("#TextMdp").text("Merci de saisir une adresse");
}
function getYOffset() {
    var pageY;
    if(typeof(window.pageYOffset)=='number') {
       pageY=window.pageYOffset;
    }
    else {
       pageY=document.documentElement.scrollTop;
    }
    return pageY;
}
function GetFenetre(Content)
{
    var WidthFenetre = $(document).width();
    var MarginLeft = (WidthFenetre - 800) / 2; 
   
    var ContentUser = Content;     
    var top = getYOffset()+25;
    var topFleche = top+10;  
    
    $(".FenetreUser").remove();
    
    //$("body").before('<div class="FenetreUser" style="background-color:#000;position:abolute;width:1500px;height:1500px;"></div>');
    
    $('<div class="FenetreUser" id="FenetreUser"></div>')
    .appendTo("body")
    .addClass("ListeUser")
    .css({
      left: MarginLeft+"px",
      top: top+"px",
      minHeight: "50px"
    }) 
    .html(ContentUser)
    .fadeIn();

    $("#FenetreUser .ElemUser").click(function()
    {
      var IdElem = $(this).attr("data-id");
      $(Elem).val(IdElem);
      $(".FenetreUser").remove();
      CheckChoixUser(1);
    });
    
    //CROIX FERMER
    var LeftTmp = MarginLeft+800;
    $('<div class="FenetreUser closeWindow"></div>')
    .appendTo("body")
    .addClass("")
    .fadeIn()
    .css({
      left: LeftTmp+"px",
      top: topFleche+"px"
    })
    .click(function()
    {
      $(".FenetreUser").remove();
    });
    //FOND NOIR
   $('<div class="FenetreUser AutourFenetre" width="100%" height="100%"></div>')
   .appendTo("body")
   .show()
   .click(function()
   { 
   $(".FenetreUser").remove(); 
   });  
}   
function GetFenetreArtistePro()
{
    var Agenda = "";
    var Rep = $.ajax({ 
       type: 'POST',
       url: 'ajax/GetContentAgenda.php',
       data: "op=1",
       async: false,
       error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }, 
       }).responseText;  
     Agenda = Rep;
     
     var Content = "";
     Content += "<div width='100%' style='background-color:#F5F5F5;'><div width='left' align='left' id='ContentImgGroupe'></div>";
     Content += "<div align='left' id='ContentNomGroupe'></div></div>";    
     Content += "<br /><div width='100%' align='left' id='ContentMenuBoxGroupe'>";
     Content += "<li><a href='javascript:void(0);' onclick='Onglet(\"ContentContentGeneral\",\"ContentBox\");'>Infos</a></li>"; 
     Content += "<li><a href='javascript:void(0);' onclick='Onglet(\"ContentContentMusique\",\"ContentBox\");'>Musiques</a></li>";
     Content += "<li><a href='javascript:void(0);' onclick='Onglet(\"ContentContentVideo\",\"ContentBox\");'>Videos</a></li>";
     Content += "<li><a href='javascript:void(0);' id='LinkAgendaFentreArtiste'>Agenda</a></li>";
     Content += "</div>";
     Content += "<div class='BoxLecteurMp3'><span id='TitreMorceau' class='LabelFormulaire' width='50px'></span>&nbsp;&nbsp;<iframe name='Mp3Sound' width='250' frameborder='0' scrolling='no' height='21px' marginheight='0' marginwidth='0' align='right'></iframe></div>";
     Content += "<div width='100%' align='left' class='ContentContentGroupe ContentBox' id='ContentContentVideo'></div>";
     Content += "<div width='100%' align='left' class='ContentContentGroupe ContentBox' id='ContentContentMusique'></div>";
     Content += "<div width='100%' align='left' class='ContentContentGroupe ContentBox' id='ContentContentGeneral'></div>";
     GetFenetre(Content);
     Onglet("ContentContentGeneral","ContentBox");     
}
function GetFenetreAgendaArtistePro(idUser)
{

  var InfoArtiste = RecupInfoArtiste(idUser);
  var RepAgenda = RecupAgendaContent();
  var Content = RepAgenda;
  
  GetFenetre(Content);
  
   var Rep = $.ajax({ 
   type: 'POST',
   url: 'ajax/GetEventArtiste.php',
   data: "idx_artiste="+idUser,
   async: true,
   error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }, 
   success: function(html){
      //ON RECUP LE RESULTAT DANS L'ORDRE DU TABLEAU 1:GROUPE 2:DESCRPTION 3:NB FAN 4:PHOTO
      var Tab = html.split("[||]");
      for (var j = 0;j < Tab.length;j++)
      {
         $("#CalendDay"+Tab[j]).addClass("CalendTodayPasDispo");
         
      }
      
      $("[id^=CalendDay]").not(".CalendTodayPasDispo,.CalendodayOut").click(function()
      {
         var Date = $(this).attr("id").substring(9,$(this).attr("id").length);
         window.location.href='prestation.php?date='+Date+'&id='+idUser;
      }).css("cursor","pointer").mouseover(function(){ $(this).css("background-color","#FF7E11") }).mouseout(function(){ $(this).css("background-color","#FFF") });
    } 
   });
   
   $("#ContentEnSavoirPlusUser").html("<a href='javascript:void(0);' onclick='GetFenetreArtistePro(\""+idUser+"\");GetArtistePro(\""+idUser+"\");' class='LienOrangeEpaisNonSouligne' style='font-size:17px;'>En savoir plus sur "+InfoArtiste[0]+"</a>");  
}
function RecupAgendaContent()
{
  var Agenda = "";
  var Rep = $.ajax({ 
     type: 'POST',
     url: 'ajax/GetContentAgenda.php',
     data: "op=1",
     async: false,
     error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }, 
     }).responseText;  
  return Rep;
} 
function RecupInfoArtiste(idUser)
{
   var Rep = $.ajax({ 
   type: 'POST',
   url: 'ajax/GetInfosArtiste.php',
   data: "idx_artiste="+idUser,
   async: false,
   error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }, 
   }).responseText;
  //ON RECUP LE RESULTAT DANS L'ORDRE DU TABLEAU 0:GROUPE 1:DESCRPTION 2:NB FAN 3:PHOTO 
  var Tab = Rep.split("[||]");
  return Tab;
}
function RecupMusiqueArtiste(idUser)
{
   var Rep = $.ajax({ 
   type: 'POST',
   url: 'ajax/GetMusiqueArtiste.php',
   data: "idx_artiste="+idUser,
   async: false,
   error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }, 
   }).responseText;
  if (Rep != "")
  {
    var RepBis = Rep.split("|||(())"); //0: Tous les albums avec tous les morceaux, 1: Morceaux phare, facultatif  
    var ContentMorceauxPhare = "";
    if (TestChampsVide(RepBis[1])) 
    { 
        var InfoMorceauPhare = RepBis[1].split("((||))"); //0 : Lien morceau, 1: Titre morceau, 2: id Morceau
        ContentMorceauxPhare += "<div class='' style='font-size:15px;font-weight:bold;'>Morceau phare de l'artiste : <span id='TitreMorceauPhare' style='text-decoration:underline'>"+InfoMorceauPhare[1]+"</span> <a href='"+InfoMorceauPhare[0]+"' onclick=\"TransfereTexteHtml('#TitreMorceauPhare','#TitreMorceau');\" target='Mp3Sound' class='LienOrange'><img src='http://www.myzik.eu/img_myzik/Playmp3.png' width='15px' height='15px' border='0' title='Ecouter le morceau'></a></div><hr /><br /><br />";
    }
    
    var All = RepBis[0].split("|[||]|"); //SEPARATEUR ENTRE TOUS LES ALBUMS
    var ContentAlbum = "<div id='Album' class='DisplayAlbum'>"+ContentMorceauxPhare+"<span class='texteEpais'>Cliquez sur les albums pour voir les musiques</span><br /><br />";
    var ContentAllMorceaux = "";
    for (var k = 0; k < All.length;k++)
    {
      var AlbumMorceau = All[k].split("||[]||"); //0: Titre album, 1:Photo album, 2:id album, 3:Description,4:Tous les morceaux, 5:Lien Musique Album
      
      ContentAlbum += "<div class='BoxAlbumArtiste' onclick='Onglet(\"BoxAlbum"+AlbumMorceau[2]+"\",\"DisplayAlbum\")'><img src='"+AlbumMorceau[1]+"' style='margin-right:10px;' align='left' title=\""+AlbumMorceau[0]+"\"/><span style='font-size:15px;font-weight:bold;color:#000;'>"+AlbumMorceau[0]+"</span><br /><br />"+AlbumMorceau[3]+"</div>";
      var AllMorceaux = AlbumMorceau[4].split("([||])"); //Tous les morceaux  0:Lien Musique, 1: Titre
      
      ContentAllMorceaux += "<div id='BoxAlbum"+AlbumMorceau[2]+"' class='DisplayAlbum' style='display:none;'>";
      ContentAllMorceaux += "<a href='javascript:void(0)' onclick='Onglet(\"Album\",\"DisplayAlbum\");' class='LienOrange'>Retour aux albums</a>";
      ContentAllMorceaux += "<div class='BoxAlbumArtiste'><img src='"+AlbumMorceau[1]+"' style='margin-right:10px;' align='left' title=\""+AlbumMorceau[0]+"\"/><span id='TitreAlbum"+AlbumMorceau[2]+"'>"+AlbumMorceau[0]+"</span><br /><br />"+AlbumMorceau[3]+"</div>";
      ContentAllMorceaux += "<div class='BoxAllMorceaux'><div style='float:right;font-size:15px;'><a href='"+AlbumMorceau[5]+"' title=\"Ecouter l'album\" onclick=\"TransfereTexteHtml('#TitreAlbum"+AlbumMorceau[2]+"','#TitreMorceau');\" target='Mp3Sound' class='LienOrange'>Ecouter l'album</a></div>";
      ContentAllMorceaux += "<table width='100%' cellpadding='4px' cellspacing='0'>";                                                                                                                       
      var Style = "";
      for(g = 0; g < AllMorceaux.length; g++)
      {
           if ((g%2) == 0) Style = "background-color:#F5F5F5;";
           else Style = "background-color:#FFF;";
           
           var ContentMorceau =  AllMorceaux[g].split("((||))"); //0 : Lien morceau, 1: Titre morceau, 2: id Morceau
           ContentAllMorceaux += "<tr style='"+Style+"'><td><span id='TitreMorceau"+ContentMorceau[2]+"'>"+ContentMorceau[1]+"</span></td><td align='right' width='20px'><a href='"+ContentMorceau[0]+"' onclick=\"TransfereTexteHtml('#TitreMorceau"+ContentMorceau[2]+"','#TitreMorceau');\" target='Mp3Sound'><img src='http://www.myzik.eu/img_myzik/Playmp3.png' width='15px' height='15px' border='0' title='Ecouter le morceau'></a></td></tr>";
      }                                                                            
      ContentAllMorceaux += "</table></div></div>";
    }
    ContentAlbum += "</div>";
    return ContentAlbum+ContentAllMorceaux;
  }
  else return "Aucune musique";
}
function RecupVideoArtiste(idUser)
{
   var Rep = $.ajax({ 
   type: 'POST',
   url: 'ajax/GetVideoArtiste.php',
   data: "idx_artiste="+idUser,
   async: false,
   error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }, 
   }).responseText;
  var ContentVideo = "<span class='texteEpais'>Cliquez sur le titre de la video pour afficher la vidéo</span><br /><br />";
  if (Rep != "")
  {
    var Tab = Rep.split("|[||]|"); //SEPARATEUR ENTRE LES VIDEOS
    for (var p = 0; p < Tab.length;p++)
    {
        var Video = Tab[p].split("[([])]");  //0 : titre, 1 : description, 2:embed, 3:id
        ContentVideo += "<div class='BoxVideoArtiste' onclick='Display(\"ContentVideo"+Video[3]+"\");'><span class='Orange' style='font-size:15px;text-decoration:none;'>"+Video[0]+"</span><br />"+Video[1]+"<br /><div style='display:none;' id='ContentVideo"+Video[3]+"'>"+Video[2]+"</div></div><br /><br />";
    }
    return ContentVideo;
  }
  else return "Aucune vidéo";
}
function GetArtistePro(idUser)
{
  var Rep = RecupInfoArtiste(idUser);      
  var ContentAlbum = RecupMusiqueArtiste(idUser);  
  var ContentVideo = RecupVideoArtiste(idUser);  
  var Tab = Rep;
  var TabStyle = Tab[4].split("[!]");
  var TabActivite = Tab[5].split("[!]");
  
  var ContentStyle = "";
  for (var j = 0; j < TabStyle.length;j++)
  {
    if (j > 0) ContentStyle += "<br />";
    ContentStyle += "• "+TabStyle[j];
  }
  
  var ContentActivite = "";
  for (var j = 0; j < TabActivite.length;j++)
  {
    if (j > 0) ContentActivite += "<br />";
    ContentActivite += "• "+TabActivite[j];
  }
  
  $("#LinkAgendaFentreArtiste").click(function(){ GetFenetreAgendaArtistePro(idUser); });
  $("#ContentNomGroupe").html("<span class='Orange' style='font-size:20px'>"+Tab[0]+"</span><br /><span>"+Tab[2]+" Fan(s)</span>");
  $("#ContentImgGroupe").html("<img src='"+Tab[3]+"' align='center'/>");
  $("#ContentContentGeneral").html("<span class='texteEpais'>Description :</span><br /><br /><span class='texte'>"+Tab[1]+"</span><br /><br /><span class='texteEpais'>Style(s) de musique :</span><br /><br /><span class='texte'>"+ContentStyle+"</span><br /><br /><span class='texteEpais'>Activité(s) :</span><br /><br /><span class='texte'>"+ContentActivite+"</span>");
  $("#ContentContentMusique").html(ContentAlbum);
  $("#ContentContentVideo").html(ContentVideo);
}
function TransfereTexteHtml(elem,id)
{
   if ($(elem).length > 0)
   {
     var Value = $(elem).html();
     $(id).text(Value).text(Value);
   }
}  
function ChangeNumberPhoto(idNumeroActuel)
{
  var NumeroActuel = $("#"+idNumeroActuel).text();
  var ContentTel = "<div align='center'><span class='texteEpais'>Pour changer votre numéro de téléphone il suffit de la modifier ci-dessous et valider. <br />Le numéro de téléphone est indispensable, il nous servira tout au long du processus de sélection<br /> <input type='text' value='"+NumeroActuel+"' id='TelePhone' class='InputText' size='10' style='float:none;'/><br /><br /><input type='button' class='Submit' value='Enregistrer' id='ValidModifTelePhone' ></div>";
  GetFenetre(ContentTel);
  $("#ValidModifTelePhone").click(function(){ 
     var NewTelephone = $("#TelePhone").val();
     if (NewTelephone.length == 10 || NewTelephone.length == 11 || NewTelephone.length == 12)
     {
         var Rep = $.ajax({ 
         type: 'POST',
         url: '../ajax/ChangeNumTel.php',
         data: "NumTel="+NewTelephone,
         async: false,
         error:function(xhr, ajaxOptions, thrownError){ alert("Une erreur est survenue, merci de prévenir l'administrateur. \nErreur : "+xhr.status); }, 
         }).responseText;

         if (Rep == 1)
         {
          alert("Le numéro à bien été changé");
          $("#"+idNumeroActuel).text(NewTelephone);
          $(".FenetreUser").remove();
         }
         else if (Rep == 2)
         {
           alert("Merci de saisir un numéro valide");
         } 
      }
      else 
      {
        alert ("Merci de saisir un numéro valide");
      }     
  }); 
  
}       	                     	
