function fermer(_id) {
	$("#"+_id).fadeOut("fast");
}

// --------------------------------------------------------
// Ecrire un mp
// --------------------------------------------------------
function ecrireMp(_idCompte) {
	$("#ecrireMp").fadeIn('fast');
	$("#mp").html('<img src="./images/tourne.gif">').fadeIn('fast');   
	$.post(
	  "./ajax.php" ,
	  { ecrireMp: 1 , idCompte: _idCompte} ,
	  function(data){ 
		$("#boiteForm").html(data).fadeIn('fast'); 
		$("#mp").fadeOut('fast');  
	  }
	 );      
}

// --------------------------------------------------------
// Envoyer mp
// --------------------------------------------------------
function envoyerMp(_idCompte) {  
	_texte = $("#texte").val();  
	$("#boiteForm").html('<img src="images/attente.gif"> Envoi en cours ...'); 
	$.post(
		  "./ajax.php" ,
		  { envoyerMp: 1 , idCompte: _idCompte, texte: _texte} ,
		  function(data){ $("#boiteForm").html(data); }
		 );  
}

// --------------------------------------------------------
// Envoyer mp  via courrier
// --------------------------------------------------------
function envoyerCourrier(_idCompte) {  
	_texte = $("#texte").val();  
	$("#boiteFormCourrier").html('<img src="images/attente.gif"> Envoi en cours ...'); 
	$.post(
		  "./ajax.php" ,
		  { envoyerCourrier: 1 , idCompte: _idCompte, texte: _texte} ,
		  function(data){ $("#boiteFormCourrier").html(data); }
		 );  
}


// --------------------------------------------------------
// Envoyer mp
// --------------------------------------------------------
function ajouterAmie(_idCompte) {  
	$("#ajoutAmie").html('<img src="./images/tourne.gif">').fadeIn('fast');   
	$.post(
		  "./ajax.php" ,
		  { ajoutAmie: 1 , idCompte: _idCompte} ,
		  function(data){ $("#ajoutAmie").html(data); }
		 );  
}

// --------------------------------------------------------
// Envoyer mp
// --------------------------------------------------------
function babysou(_idCompte) {  
	$("#babysou").html('<img src="./images/tourne.gif">').fadeIn('fast');   
	$.post(
		  "./ajax.php" ,
		  { babysou: 1 , idCompte: _idCompte} ,
		  function(data){ $("#babysou").html(data); }
		 );  
}

// --------------------------------------------------------
// Form message perso
// --------------------------------------------------------
var msgOuvert = 0;
function EditFormMsgPerso(_idCompte) {
	if (msgOuvert == 0) {
		_texte = $('#msgPerso').html();   
		$("#msgPerso").html('<textarea id="texteMsg" cols="40" rows="2">'+_texte+'</textarea><input type="button" value="Sauver" onclick="EditMsgPerso();" />').fadeIn("slow");
		msgOuvert = 1;
	}
	else {
		_texte = $('#texteMsg').val();  
		$("#msgPerso").html(_texte).fadeIn("fast");
		msgOuvert = 0;
	}
}

// --------------------------------------------------------
// Editer message perso
// --------------------------------------------------------
function EditMsgPerso() {  
	_texte = $('#texteMsg').val();
	$("#msgPerso").html('<img src="./images/tourne.gif">').fadeIn('fast');   
	$.post(
		  "./ajax.php" ,
		  { EditMsgPerso: 1, texte : _texte} ,
		  function(data){ 
			$("#msgPerso").html(_texte);  
		  }
		 );  
	msgOuvert = 0;
}

// --------------------------------------------------------
// Form signature
// --------------------------------------------------------
var signatureOuvert = 0;
function EditFormSignature(_idCompte) {
	if (signatureOuvert == 0) {
		_texte = $('#signature').html();   
		$("#signature").html('<textarea id="texteSignature" cols="40" rows="2">'+_texte+'</textarea><input type="button" value="Sauver" onclick="EditSignature();" />').fadeIn("slow");
		signatureOuvert = 1;
	}
	else {
		_texte = $('#texteSignature').val();  
		$("#signature").html(_texte).fadeIn("fast");
		signatureOuvert = 0;
	}
}

// --------------------------------------------------------
// Editer message perso
// --------------------------------------------------------
function EditSignature() {  
	_texte = $('#texteSignature').val();
	$("#signature").html('<img src="./images/tourne.gif">').fadeIn('fast');   
	$.post(
		  "./ajax.php" ,
		  { EditSignature: 1 , texte : _texte} ,
		  function(data){ 
			$("#signature").html(_texte); 
		  }
		 );  
	signatureOuvert = 0;  
}

// --------------------------------------------------------
// Mise à jours des tags
// --------------------------------------------------------
function maj_tags() {
	
	$("#majTag").show().html("<h2><center>Mise à jour en chargement ...</center></h2>");
	$.get(
		"./ajax_tags.php" , 
		{maj:1} , 
		function(data){ 
	  $("#majTag").html(data); 
	  affichetags();
	}
	);    
}

// --------------------------------------------------------
// Affichage des tags
// --------------------------------------------------------
function affichetags() {
	
	$("#majTag").show().html("Mise à jour en chargement ...")

	$.get(
		"./ajax_tags.php" , 
		{affiche: 1} , 
		function(data){ $("#majTag").html(data); }
	);    
}

// --------------------------------------------------------
// Attente de recherche
// --------------------------------------------------------
function attenteRecherche(_code) {
  if (_code == 1)
	$("#attenteRecherche").fadeIn("fast");
  else
	$("#attenteRecherche").fadeOut("fast");
}

// --------------------------------------------------------
// Ajouter un forum aux favoris
// --------------------------------------------------------
function forumFavoris(_id) {
	$.post(
		"../communaute/ajax.php" , 
		{forumFavoris: 1, id : _id} , 
		function(data){ $("#msgFavoris").html(data).fadeIn("fast"); }
	);    
}

// --------------------------------------------------------
// Ajouter une discussion aux favoris
// --------------------------------------------------------
function sujetFavoris(_id) {
	$.post(
		"../communaute/ajax.php" , 
		{sujetFavoris: 1, id : _id} , 
		function(data){ $("#msgFavoris").html(data).fadeIn("fast"); }
	);    
}

// --------------------------------------------------------
// Demande d'adhesion à un groupe
// --------------------------------------------------------
function demandeAdhesionGroupe(_id) {
	$("#ecrireDemande").fadeIn('fast');  
	$.post(
	  "./ajax.php" ,
	  { demandeAdhesionGroupe: 1 , id: _id} ,
	  function(data){ 
		$("#boiteForm").html(data).fadeIn('fast'); 
	  }
	 );   
}

// --------------------------------------------------------
// Envoi Demande d'adhesion à un groupe
// --------------------------------------------------------
function envoiAdhesionGourpe(_id) {
	_texte = $("#texte").val();  
	$("#boiteForm").html('<img src="images/attente.gif"> Envoi en cours ...'); 
	$.post(
		  "./ajax.php" ,
		  { envoiAdhesionGourpe: 1 , id: _id, texte: _texte} ,
		  function(data){ $("#boiteForm").html(data); }
		 );  
}

initMp = 0;

// --------------------------------------------------------
// Lire un mp recu
// --------------------------------------------------------
function lireMp(_id) {
	
	$("#lireMp").fadeOut("fast");  
	document.getElementById('mp_'+_id).style.background = '#F6F6F6';
	$.get(
		"./ajax.php" , 
		{ id: _id, LIREMP: 1 } , 
		function(data){ $("#lireMp").html(data).fadeIn('fast'); }
	);
	
	if (initMp > 0) 
		document.getElementById('mp_'+initMp).style.background = '#FFFFFF';
		
	initMp = _id;       
}

// --------------------------------------------------------
// Lire un mp recu
// --------------------------------------------------------
function supprimerMp(_id) {
	if(confirm('Êtes-vous sûr de vouloir supprimer ce MP?')) { 
		$.post(
			"./ajax.php" , 
			{ id: _id, SUPPRIMERMP: 1 } , 
			function(data){ $("#leMp").html(data).fadeIn('fast'); }
		);     
	}       
}

// --------------------------------------------------------
// Lire un mp envoyé
// --------------------------------------------------------
function lireMpEnvoye(_id) {
	
	$("#lireMp").fadeOut("fast");
	document.getElementById('mp_'+_id).style.background = '#F6F6F6';
	$.get(
		"./ajax.php" , 
		{ id: _id, LIREMPENVOYE: 1 } , 
		function(data){ $("#lireMp").html(data).fadeIn('fast'); }
	);
	
	if (initMp > 0) 
		document.getElementById('mp_'+initMp).style.background = '#FFFFFF';
		
	initMp = _id;
} 

// --------------------------------------------------------
// Afficher les mp reçus
// --------------------------------------------------------
function mpRecus(_idCompte) {
	
	$("#allMp").html('Chargement des MP ...');

	$("#fondMpRecus").removeClass('onglet1');  
	$("#fondMpRecus").addClass('onglet1_current'); 
	$("#fondMpEnvoyes").removeClass('onglet2_current');  
	$("#fondMpEnvoyes").addClass('onglet2'); 
	
	$.get(
		"./ajax.php" , 
		{ idCompte: _idCompte, MPENVOYES: 1 } , 
		function(data){ $("#allMp").html(data).slideDown('fast'); }
	);

}

// --------------------------------------------------------
// Afficher les mp envoyé
// --------------------------------------------------------
function mpEnvoyes(_page, _total) {
	
	initMp = 0;

	$("#fondMpRecus").removeClass('onglet1_current');  
	$("#fondMpRecus").addClass('onglet1'); 
	$("#fondMpEnvoyes").removeClass('onglet2'); 
	$("#fondMpEnvoyes").addClass('onglet2_current'); 
	
	$("#allMp").fadeOut("fast");
	
	$.get(
		"./ajax.php" , 
		{ MPENVOYES: 1, page:_page, total:_total } , 
		function(data){ $("#allMp").html(data).fadeIn('fast'); }
	);
}

function allMp(_page, _total) {
	
	$("#allMp").fadeOut("fast"); 
	
	$("#fondMpRecus").removeClass('onglet1');  
	$("#fondMpRecus").addClass('onglet1_current'); 
	$("#fondMpEnvoyes").removeClass('onglet2_current');  
	$("#fondMpEnvoyes").addClass('onglet2'); 	
	
	$.get(
		"./ajax.php" , 
		{ ALLMP: 1, page:_page, total:_total } , 
		function(data){ $("#allMp").html(data).fadeIn('fast'); }
	);
}

// --------------------------------------------------------
// Ouvrir / fermer un groupe
// --------------------------------------------------------
function clotureGroupe(_id, _flag) { 
	$.get(
		"./ajax.php" , 
		{ CLOTUREGROUPE: 1, id: _id, flag: _flag} , 
		function(data){ $("#cloture").html(data).fadeIn('fast'); }
	);
}

// --------------------------------------------------------
// Quitter un groupe
// --------------------------------------------------------
function quitterGroupe(_id) { 
	if(confirm('Tu es sûre de vouloir quitter ce groupe?')) {
		$.get(
			"./ajax.php" , 
			{ QUITTERGROUPE: 1, id: _id} , 
			function(data){ $("#quitter_"+_id).html(data); }
		);
	}
}


// --------------------------------------------------------
// Click droit images
// --------------------------------------------------------
var clickmessage="Interdit!"
function disableclick(ev)
{
if (document.all)
{
if (event.button==2 || event.button==3)
{
if (event.srcElement.tagName=="IMG")
{
alert(clickmessage);
return false;
}
}
}
if (document.layers)
{
if (ev.which==3)
{
alert(clickmessage);
return false;
}
}
}

function associateimages()
{
for (i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick
}
if (document.all)
document.onmousedown=disableclick
else if (document.layers) associateimages()

