var coeur_ajax=false;var NB_MAX_FP=50;var coeur_fpp=[];function get_ajax(a){if(LireCookie("tehlogin")||LireCookie("wenvjgol")){if(coeur_ajax){return false}else{coeur_ajax=true;jQuery("#global").css("cursor","progress");return true}}else{aff_greybox("Se Connecter",a);form_connect("form",null);return false}}function free_ajax(){if(coeur_ajax){coeur_ajax=false;jQuery("#global").css("cursor","default")}}function coeur_ajouter_anim_add(){coeur_fpp.push(numf);var a=jQuery('<li id="coeur_suppr_'+numf+'"><a href="'+document.URL+'">'+namef+'</a><a forum="'+numf+'" href="#" class="sup_pref" title="Supprimer le forum '+namef+'"><span>[Supprimer]</span></a></li>');a.hide();jQuery("#forums_pref .bloc_inner2 ul").append(a);a.show("slow");free_ajax()}function coeur_ajouter_ajax(d){if(d.r==="ok"){if(coeur_fpp.length===0){if(jQuery("#forums_pref").css("display")==="none"){jQuery("#forums_pref").show("slow")}jQuery("#forums_pref .bloc_inner2").show("slow");coeur_ajouter_anim_add()}else{coeur_ajouter_anim_add()}}else{aff_greybox("Ajout de forums préférés",null);free_ajax();var a=jQuery("<div>").addClass("dialog_body").appendTo(jQuery(".window"));var c=jQuery("<div>").addClass("warning").appendTo(a);var b=jQuery("<p>").addClass("info").appendTo(c);jQuery("<strong>").text('Le forum "'+namef+'" est déjà présent dans vos forums personnalisés préférés.').appendTo(b)}}function delete_forum_tab(b,a){var d=[];for(var c in b){if(b[c]!==parseInt(a,10)){d.push(b[c])}}return d}function coeur_delete_ajax(c){if(c.r==="ok"){jQuery("#coeur_suppr_"+c.f).hide("slow",function(){if(jQuery("#coeur_suppr_"+c.f).parent().attr("id")==="liste_forums_perso_pref"){coeur_fpp=delete_forum_tab(coeur_fpp,c.f)}jQuery("#coeur_suppr_"+c.f).remove();free_ajax();var d=jQuery("#forums_pref .bloc_inner #liste_forums_pref");var e=jQuery("li",d);if(e.length===0){d.parent().hide("slow")}var g=jQuery("#forums_pref .bloc_inner2 #liste_forums_perso_pref");var f=jQuery("li",g);if(f.length===0){g.parent().hide("slow")}if((e.length===0)&&(f.length===0)){jQuery("#forums_pref").hide("slow")}})}else{aff_greybox("Suppression de forums préférés",null);var a=jQuery("<div>").addClass("dialog_body").appendTo(jQuery(".window"));var b=jQuery("<div>").addClass("success").appendTo(a);jQuery("<p>").addClass("info").text("Une erreur est survenue, et le forum en question ne peut-etre supprimé").appendTo(b);free_ajax()}}function coeur_ajouter(){if(coeur_fpp.length<NB_MAX_FP&&jQuery.inArray(numf,coeur_fpp)<0){if(get_ajax("af")){jQuery.post("http://"+document.domain+"/profil/ajax_forum_perso.php","a=add&f="+numf+"&x="+lo_time+"&z="+lo_cod,coeur_ajouter_ajax,"json")}}return false}function coeur_delete(){var a;if(get_ajax("sf")){if(jQuery(this).parent().parent().attr("id")==="liste_forums_pref"){a="del"}else{a="del_p"}jQuery.post("http://"+document.domain+"/profil/ajax_forum_perso.php","a="+a+"&f="+jQuery(this).attr("forum")+"&x="+lo_time+"&z="+lo_cod,coeur_delete_ajax,"json")}return false}jQuery(function(){jQuery("#liste_forums_pref, .bloc_inner2 ul").sortable({delay:300,items:"li",cursor:"move",placeholder:"ui-state-highlight",stop:function(b,a){a.item.css({top:"0",left:"0"})},update:function(c,b){var a;if(jQuery(this).attr("id")==="liste_forums_pref"){a="srt"}else{a="srtp"}jQuery.post("http://"+document.domain+"/profil/ajax_forum_perso.php","a="+a+"&x="+lo_time+"&z="+lo_cod+"&"+jQuery(this).sortable("serialize"))}});jQuery("#liste_forums_pref").disableSelection();jQuery("#coeur_ajouter").bind("click",coeur_ajouter);jQuery("a.sup_pref").live("click",coeur_delete);jQuery("#liste_forums_perso_pref li a.sup_pref").each(function(){coeur_fpp.push(parseInt(jQuery(this).attr("forum"),10))})});
