function fermer(_id) {
	$("#"+_id).fadeOut("fast");
}

// --------------------------------------------------------
// Ecrire un mp
// --------------------------------------------------------
function ecrireMp(_idCompte) {
	$("#ecrireMp_"+_idCompte).fadeIn('fast');
	//$("#mp_"+_idCompte).html('<img src="./images/tourne.gif">').fadeIn('fast');   
	$.post(
	  "http://www.baby.be/nl/babyclub/ajax.php" ,
	  { ecrireMp: 1 , idCompte: _idCompte} ,
	  function(data){ 
		$("#boiteForm_"+_idCompte).html(data).fadeIn('fast'); 
		//$("#mp_"+_idCompte).fadeOut('fast');  
	  }
	 );      
}

// --------------------------------------------------------
// Envoyer mp
// --------------------------------------------------------
function envoyerMp(_idCompte, _idMp) {  
	_texte = $("#texte_"+_idCompte).val(); 
	if (_texte != '')   {
		$("#boiteForm_"+_idCompte).html('<img src="images/attente.gif"> Please wait ... ...'); 
		$.post(
			  "http://www.baby.be/nl/babyclub/ajax.php" ,
			  { envoyerMp: 1 , idCompte: _idCompte, texte: _texte, idMp: _idMp} ,
			  function(data){ $("#boiteForm_"+_idCompte).html(data); }
			 );  
	}		
}

// --------------------------------------------------------
// Envoyer mp  via courrier
// --------------------------------------------------------
function envoyerCourrier(_idCompte, _idMp) {  
	_texte = $("#texte_"+_idMp).val();  
	$("#boiteFormCourrier").html('<img src="images/attente.gif"> Please wait ... ...'); 
	$.post(
		  "http://www.baby.be/nl/babyclub/ajax.php" ,
		  { envoyerCourrier: 1 , idCompte: _idCompte, texte: _texte, idMp: _idMp} ,
		  function(data){ $("#boiteFormCourrier").html(data); }
		 );  
}


// --------------------------------------------------------
// Envoyer mp
// --------------------------------------------------------
function ajouterAmie(_idCompte) {  
	$("#ajoutAmie").html('<img src="./images/tourne.gif">').fadeIn('fast');   
	$.post(
		  "http://www.baby.be/nl/babyclub/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(
		  "http://www.baby.be/nl/babyclub/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="50" rows="8">'+_texte+'</textarea><br><input type="button" value="Save" 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(
		  "http://www.baby.be/nl/babyclub/ajax.php" ,
		  { EditMsgPerso: 1, texte : _texte} ,
		  function(data){ 
			$("#msgPerso").html(_texte);  
		  }
		 );  
	msgOuvert = 0;
}

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

// --------------------------------------------------------
// Form signature
// --------------------------------------------------------
var signatureOuvert = 0;
function EditFormSignature(_idCompte) {
	if (signatureOuvert == 0) {
		_texte = $('#signature').html();   
		$("#signature").html('<textarea id="texteSignature" cols="50" rows="8">'+_texte+'</textarea><br><input type="button" value="Save" onclick="EditSignature();" style="border:1px solid #000" />').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(
		  "http://www.baby.be/nl/babyclub/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>Please wait ...</center></h2>");
	$.get(
		"./ajax_tags.php" , 
		{maj:1} , 
		function(data){ 
	  $("#majTag").html(data); 
	  affichetags();
	}
	);    
}

// --------------------------------------------------------
// Affichage des tags
// --------------------------------------------------------
function affichetags() {
	
	$("#majTag").show().html("Please wait ...")

	$.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(
		".http://www.baby.be/nl/babyclub/ajax.php" , 
		{forumFavoris: 1, id : _id} , 
		function(data){ $("#msgFavoris").html(data).fadeIn("fast"); }
	);    
}

// --------------------------------------------------------
// Ajouter une discussion aux favoris
// --------------------------------------------------------
function sujetFavoris(_id) {
	$.post(
		".http://www.baby.be/nl/babyclub/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(
	  "http://www.baby.be/nl/babyclub/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"> Please wait ... ...'); 
	$.post(
		  "http://www.baby.be/nl/babyclub/ajax.php" ,
		  { envoiAdhesionGourpe: 1 , id: _id, texte: _texte} ,
		  function(data){ $("#boiteForm").html(data); }
		 );  
}

initMp = 0;

// --------------------------------------------------------
// Lire un mp recu
// --------------------------------------------------------
function lireMp(_id) {
	
	document.getElementById('mp_'+_id).style.background = '#F6F6F6';
	$.get(
		"http://www.baby.be/nl/babyclub/ajax.php" , 
		{ id: _id, LIREMP: 1 } , 
		function(data){ $("#msg_"+_id).html(data).slideDown(); }
	);
	
	/*if (initMp > 0) 
		document.getElementById('mp_'+initMp).style.background = '#FFFFFF'; 
		
	initMp = _id; */      
}

// --------------------------------------------------------
// Lire un mp recu
// --------------------------------------------------------
function supprimerMp(_id) {
	if(confirm('Ben je er zeker van dat je dit bericht wil verwijderen?')) { 
		$.post(
			"http://www.baby.be/nl/babyclub/ajax.php" , 
			{ id: _id, SUPPRIMERMP: 1 } , 
			function(data){ $("#msg_"+_id).html(data).fadeOut('fast'); }
		);     
	}       
}

// --------------------------------------------------------
// Lire un mp envoyé
// --------------------------------------------------------
function lireMpEnvoye(_id) {
	
	$("#lireMp").fadeOut("fast");
	document.getElementById('mp_'+_id).style.background = '#F6F6F6';
	$.get(
		"http://www.baby.be/nl/babyclub/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('Even wachten ...');

	$("#fondMpRecus").removeClass('onglet1');  
	$("#fondMpRecus").addClass('onglet1_current'); 
	$("#fondMpEnvoyes").removeClass('onglet2_current');  
	$("#fondMpEnvoyes").addClass('onglet2'); 
	
	$.get(
		"http://www.baby.be/nl/babyclub/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('fondMpRecus_current');  
	$("#fondMpRecus").addClass('fondMpRecus'); 
	$("#fondMpEnvoyes").removeClass('fondMpEnvoyes'); 
	$("#fondMpEnvoyes").addClass('fondMpEnvoyes_current'); 
	
	$("#allMp").fadeOut("fast");
	
	$.get(
		"http://www.baby.be/nl/babyclub/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(
		"http://www.baby.be/nl/babyclub/ajax.php" , 
		{ ALLMP: 1, page:_page, total:_total } , 
		function(data){ $("#allMp").html(data).fadeIn('fast'); }
	);
}

// --------------------------------------------------------
// Ouvrir / fermer un groupe
// --------------------------------------------------------
function clotureGroupe(_id, _flag) { 
	$.get(
		"http://www.baby.be/nl/babyclub/ajax.php" , 
		{ CLOTUREGROUPE: 1, id: _id, flag: _flag} , 
		function(data){ $("#cloture").html(data).fadeIn('fast'); }
	);
}

// --------------------------------------------------------
// Quitter un groupe
// --------------------------------------------------------
function quitterGroupe(_id) { 
	if(confirm('Ben je er zeker van dat je uit deze groep verwijderd wil worden?')) {
		$.get(
			"http://www.baby.be/nl/babyclub/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();


function smilies(text) {
	text = ' ' + text + ' ';
	if (document.getElementById('form').texte.createTextRange && document.getElementById('form').texte.caretPos) {
		var caretPos = document.getElementById('form').texte.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
		document.getElementById('form').texte.focus();
	} else {
	document.getElementById('form').texte.value  += text;
	document.getElementById('form').texte.focus();
	}
}


var initheme = '';
var inithemeimg = ''; 
function chooseTheme(_theme, _img, _value) {
	
	if (initheme != '') {
		$("#"+initheme).html('');
		$("#"+inithemeimg).css('border','solid 1px #CCC');	
	}	
		
	$("#"+_theme).html('<input type="hidden" name="theme" id="theme" value="'+_value+'">');
	$("#"+_img).css('border','solid 3px #98ba02');
	
	initheme =  _theme;
	inithemeimg = _img;
	
}

function form_blog() {
	var error_titre = 0;
	var error_theme = 0;
	if ($("#titre").val() == '') {
		$("#div_identifiant").css('border','solid 1px #CC0000');
		error_titre++;
	}
	else {
		$("#div_identifiant").css('border','solid 1px #FFF');
		error_titre = 0;	
	}
	
	if ($("#theme").val() == '' || $("#theme").val() == null || $("#theme").val() == 'undefined') {
		error_theme++;
		alert('Zies een thema AUB!');
	}
	else 
		error_theme = 0;    
		
	if (error_theme + error_titre == 0)
		$("#blogform").submit();
	
}

// --------------------------------------------------------
// Show google maps
// --------------------------------------------------------
function showGoogleMaps() { 
	_donnee = $("#show_googlemaps").val();
	$.get(
		"/nl/babyclub/ajax.php" , 
		{ showGoogleMaps: 1, donnee: _donnee} , 
		function(data){ $("#confirmGoogle").html(data); }
	);
}