
  function repertoire(page)
  {
    var donnees = { cheminAbsolue: page };
    
      $.post('requete.php', donnees, function success(data){
      
      });
    
  } 
  
  function connexion(Pseudo,Password,resultat)
  {
    var donnees = { pseudo: Pseudo,password: Password, connexionAutomatique: resultat };
    
    $.post('requete.php', donnees, function success(data){  
      if( data == 'TRUE' )
      {
        window.location = 'index.php';
      }          
    });    
  }   
  
  function deconnexion()
  {  
    var donnees = { deconnexion: 'yes' };
    
    $.post('requete.php', donnees, function success(data){     
        window.location = 'index.php';            
    });
  }
  
  function supprimerNews(element,id)
  {   
    var donnees = {  page: 'administrationNews',supprimerNews: id };
    
    $.post('requete.php', donnees, function success(data){
       $(element).parents("div:first").fadeOut('slow',function(){ $(element).parents("div:first").remove(); });   
    });    
  }
  
   function modifierArticle(element,id)
  {    
     var texte = $(element).parents("div:first").children("span.contenu").html(); 
      var donnees = {  page: 'administrationArticles',getArticle: id};  
   
    $(element).parents("div:first").children("span.contenu").html('<img src="Images/ajax-loader.gif" alt="ajax-loader.gif">');
    
     $.post('requete.php', donnees, function success(data){ 
     $(element).parents("div:first")
     .children("span.contenu")
     .html('<form method="post" action="index.php?page=administrationArticles&afficher=0&lireFichier='+id+'"><input type="hidden" name="idModifierArticle" value="'+id+'"><textarea name="texteModifierArticle">'+data+'</textarea><input type="submit" name="modifierArticle" value="Modifier"></form>'); 
     } );
   } 
  
  function modifierNews(element,id)
  {         
    texte = $(element).parents("div:first").children("span.contenu").children("textarea").val();
    $(element).parents("div:first").children("span.contenu").html('<img src="Images/ajax-loader.gif" alt="ajax-loader.gif">');
    
    var donnees = {  page: 'administrationNews',getNews: id};  
    
   $.post('requete.php', donnees, function success(data){ 
    
        $(element).parents("div:first").children("span.contenu")
     .html('<form method="post" action="index.php"><input type="hidden" name="idModificationNews" value="'+id+'"><textarea name="messageModificationNews">'+data+'</textarea><input type="submit" name="modifierNews" value="Modifier"></form>');  
      
    
    });   
  } 
  
  function BBcodeToHTML(texte)
  {                                     
    texte = texte.replace(/\</g,'&lt;');
    texte = texte.replace(/\</g,'&gt;');                         
    texte = texte.replace(/\n/gi,'<br>');
    texte = texte.replace(/\[b\](.*?)\[\/b\]/g, '<b>$1</b>');    
    texte = texte.replace(/\[i\](.*?)\[\/i\]/g, '<em>$1</em>');   
    texte = texte.replace(/\[u\](.*?)\[\/u\]/g, '<u>$1</u>');
    texte = texte.replace(/\[s\](.*?)\[\/s\]/g, '<s>$1</s>');   
    texte = texte.replace(/\[img\](.*?)\[\/img\]/g, '<img src="$1" alt="$1">');                     
  	texte = texte.replace(/\[url\](.*?)\[\/url\]/g, '<a href="$1">$1</a>');     
    texte = texte.replace(/\[url=(.*?)\](.*?)\[\/url\]/g, '<a href="$1">$2</a>');    
    texte = texte.replace(/\[left\](.*?)\[\/left\]/g, '<div style="text-align:left;">$1</div>');   
    texte = texte.replace(/\[center\](.*?)\[\/center\]/g, '<div style="text-align:center;">$1</div>');  
    texte = texte.replace(/\[right\](.*?)\[\/right\]/g, '<div style="text-align:right;">$1</div>'); 
    texte = texte.replace(/\[color=(.*?)\](.*?)\[\/color\]/g, '<font color=$1>$2</font>');   
    texte = texte.replace(/\[flash\](.*?)\[\/flash\]/g, '<object><embed pluginspage="http://www.microsoft.com/windows/mediaplayer/" src="$1" autostart="0"></object>');    
    texte = texte.replace(/\[code=(.*?)\](.*?)\[\/code\]/g, '<code class="$1">$2</code>');   
	   return texte;   
  }  
  
  function HTMLToBBcode(texte)
  {   
	  texte = texte.replace(/\n/gi,'');    
	  texte = texte.replace(/\t/gi,'   ');    
    texte = texte.replace(/\<b\>(.*?)\<\/b\>/gi, '[b]$1[/b]');  
    texte = texte.replace(/\<em\>(.*)\<\/em\>/g, '[i]$1[/i]');
    texte = texte.replace(/\<u\>(.*)\<\/u\>/g, '[u]$1[/u]'); 
    texte = texte.replace(/\<s\>(.*)\<\/s\>/g, '[s]$1[/s]');  
    texte = texte.replace(/\<img src="(.*?)" alt="(.*?)"\>/g, '[img]$1[/img]');
    texte = texte.replace(/\<a href="(.*?)"\>(.*?)\<\/a\>/g, '[url=$1]$2[/url]'); 
    texte = texte.replace(/\<div style="text-align: left;"\>(.*)\<\/div\>/g, '[left]$1[/left]'); 
    texte = texte.replace(/\<pre style="text-align: center;"\>(.*)\<\/pre\>/g, '[center]$1[/center]');  
    texte = texte.replace(/\<span style="text-align: right;"\>(.*)\<\/span\>/g, '[right]$1[/right]'); 
    texte = texte.replace(/\<font color=(.*?)\>(.*?)\<\/font\>/g, '[color=$1]$2[/color]');  
    texte = texte.replace(/\<object\>\<embed pluginspage="http:\/\/www.microsoft.com\/windows\/mediaplayer\/" src="(.*)" autostart="0"\>\<\/object>/g, '[flash]$1[/flash]');   
    texte = texte.replace(/\<code class="(.*?)"\>(.*?)\<\/code\>/g, '[code=$1]$2[/code]');     
	  texte = texte.replace(/\<br\>/g,'\n');
    return texte;    
  }  
  
  function ajouterDossier(element,page,type)
  {
    $(element).before("<a href=\"#\" class=\"fichier\"><img src=\"Images/"+type+".png\" alt=\"Images/"+type+".png\"><span class=\"nomFichier\"><input type=\"text\" onkeypress=\"if(event.keyCode == 13) creationDossier($(this),'"+page+"','"+type+"');\"></span></a>");
  }

  function creationDossier(element,id,type)
  {
    if( $(element).val() != '')
    {
       var donnees = {  page: 'administrationArticles', setType: type, setNom: $(element).val(),ajouterDossier: id, };
      
      $.post('requete.php', donnees, function success(data){ 
          $(element).parents('.fichier:first').attr('href',data);
          $(element).parents('.nomFichier:first').text($(element).val());
      });
    }
  }
  
  
  function supprimerArticle(element,id)
  {   
    var donnees = {  page: 'administrationArticles',supprimerArticle: id };
    
    $.post('requete.php', donnees, function success(data){ 
       $(element).parents("div:first").fadeOut('slow',function(){ $(element).parents("div:first").remove(); });   
        location.reload();         
    
    });  
  }
  
 
