$(document).ready(function() {
	
	$("#fav").live("click",function(e){
                e.preventDefault();

                $.ajax({
                        type: "POST",
                        data: "entite=" + $("#fav").attr("vale") + "&entite_id=" + $("#fav").attr("valeid"),
                        url: "/ajax/membre/membre_favori.php",
                        dataType : "json",
                        error: function(msg, string){
                                return false;
                        },
                        success: function(data, status){
                                if(typeof(data.retour) != 'undefined')
                                {
                                        if (data.retour == "0")
                                        {
                                                $("#fav").text(data.action);
                                                hidemedia_err();
                                        }
                                        else
                                        {
                                                if (data.retour == "1")
                                                {
                                                        window.location = "/login.php";
                                                }
                                                else
                                                {
                                                        affmedia_err(data.error);
                                                }
                                        }
                                }
                        }
                });

                return false;
        });

	$(".fav").live("click",function(e){
                e.preventDefault();

                $.ajax({
                        type: "POST",
                        data: "entite=" + $(this).attr("vale") + "&entite_id=" + $(this).attr("valeid"),
                        url: "/ajax/membre/membre_favori.php",
                        dataType : "json",
                        error: function(msg, string){
                                return false;
                        },
                        success: function(data, status){
                                if(typeof(data.retour) != 'undefined')
                                {
                                        if (data.retour == "0")
                                        {
						document.location.reload();
                                        }
                                        else
                                        {
                                                if (data.retour == "1")
                                                {
                                                        window.location = "/login.php";
                                                }
                                        }
                                }
                        }
                });

                return false;
        });

});

