$(function() {

$("div.flux").css("display","none");
$(".clic_flux a").livequery('click', function()
{
	var theAction=$(this).attr("id");  // theAction = clic_1
	var Split = theAction.split('_'); var numberAction = Split[1];
	
	$(".clic_flux a").removeClass(); $(".clic_flux a").addClass("notselected"); $(".clic_flux a#clic_"+numberAction).addClass("current");
	$("div.flux").css("display","none"); $("div#flux_"+numberAction).css("display","block"); 
	return false; 
});

$("a.close_flux").livequery('click', function()
{ $(".clic_flux a").removeClass().addClass("notselected"); $("div.flux").hide(); return false;  });

$("a.couv").fancybox();

$(".mp_highlights").fadeOut(800).fadeIn(800).fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400);
	 
$("div.news_comment").hide();
	$("div.news_text a.affich_comment").livequery('click', function()
	{ $(this).slideToggle(); $(this).parent().parent().parent().find('.news_comment').slideToggle(); return false; });
	
$('.submitmypost input.submit').livequery('click', function()
{
	var Conteneur = $(this).parent(); var Conteneur2 = $(this).parent().parent();
	var myText = Conteneur.find('input.input_comment').val();
	var reactionId = Conteneur.find('input.input_re_id').val();
	var reacIdProfil = Conteneur.find('input.input_id_profil').val();
	if (myText != "")
	{
		$.post("http://www.livraddict.com/include/post.php", {mytext: myText, re_id: reactionId, id_profil: reacIdProfil}, 
		function success(data){
			if (reactionId != "") // si c'est un comment de réaction
			{ Conteneur2.before(data).fadeIn(); }
			else // si c'est un post de my_id_user
			{ Conteneur.after(data).fadeIn(); }
		}); 
		$('input.input_comment').val(''); return false
	}
	else { alert("Votre message est vide !");}
		return false; 
});

$('.news_status a.suppr_post').livequery('click', function()
{
	var postToDelete = $(this).attr("id");
	var Conteneur = $(this).parent(); var TimetoCache = $('div#time'+postToDelete);  var Conteneur2 = $(this).parent().parent().parent();
	if (postToDelete != "")
	{
		$.post("http://www.livraddict.com/include/post.php", {id_post: postToDelete}, 
		function success(data){
			if (data == 0) // si c'est un premier post
			{ Conteneur2.slideUp(); }
			else // sinon
			{ Conteneur.slideUp();  TimetoCache.slideUp();  }
		}); 
		return false
	}
	return false; 
});

}); // fin ready
