
var coeur_ajax=false;function get_ajax()
{if(LireCookie("tehlogin")||LireCookie("mocoedivxuejgol"))
{if(coeur_ajax)
{return false;}
else
{coeur_ajax=true;$("#global").css("cursor","progress");return true;}}
else
{location.href="/cgi-bin/admin/moncompte.cgi?oper=30";return false;}}
function free_ajax()
{if(coeur_ajax)
{coeur_ajax=false;$("#global").css("cursor","default");}}
function coeur_ajouter_anim_add()
{coeur_forums.push(numf);$("<li>").hide().attr("id","coeur_suppr_"+numf).append($("<a>").attr("href",document.URL).text(namef).append($("<a>").attr("title","Supprimer le forum "+namef).attr("alt","Supprimer le forum "+namef).attr("href","#").attr("forum",numf).attr("class","sup_pref").append($("<span>").text("[Supprimer]")))).appendTo("#liste_forums_pref").show("slow");free_ajax();}
function coeur_ajouter_anim_empty()
{$("#liste_forums_pref").empty();$("#liste_forums_pref").show();coeur_ajouter_anim_add();}
function coeur_ajouter_ajax(data)
{if(data.r=="ok")
{if(coeur_forums.length==0)
{$("#bloc_forums_img").text("Mes forums préférés");$("#liste_forums").attr("id","liste_forums_pref").hide("slow",coeur_ajouter_anim_empty);}
else
{coeur_ajouter_anim_add();}}
else
{free_ajax();}}
function coeur_delete_ajax(data)
{if(data.r=="ok")
{for(i=0;i<coeur_forums.length;i++)
{if(coeur_forums[i]==data.f)
{coeur_forums.splice(i,1);break;}}
$("#coeur_suppr_"+data.f).hide("slow",function(){$("#coeur_suppr_"+data.f).remove();if(coeur_forums.length==0)
{$.get("/cgi-bin/jvforums/ajax_coeur.cgi","a=rst",coeur_reset_ajax,"json");}
else
{free_ajax();}});}
else
{free_ajax();}}
function coeur_reset_ajax(data)
{$("#bloc_forums_img").text("Les autres forums");$("#liste_forums_pref").attr("id","liste_forums").hide();for(i=0;i<data.length;i++)
{f=data[i].split('|');$("<li>").append($("<a>").attr("href","/forums/0-"+f[0]+"-0-1-0-1-0-"+f[2]+".htm").text(f[1])).appendTo("#liste_forums");}
$("#liste_forums").show("slow",function(){free_ajax();});}
function coeur_ajouter()
{if(coeur_forums.length<NB_MAX_FP&&$.inArray(numf,coeur_forums)<0)
{if(get_ajax())
{$.post("/cgi-bin/jvforums/ajax_coeur.cgi","a=add&f="+numf,coeur_ajouter_ajax,"json");}}
return false;}
function coeur_delete()
{if(get_ajax())
{$.post("/cgi-bin/jvforums/ajax_coeur.cgi","a=del&f="+$(this).attr("forum"),coeur_delete_ajax,"json");}
return false;}
$(function(){$("#liste_forums_pref").sortable({delay:300,items:'li',cursor:'move',placeholder:'ui-state-highlight',stop:function(e,ui){ui.item.css({'top':'0','left':'0'});},update:function(e,ui){$.post("/cgi-bin/jvforums/ajax_coeur.cgi","a=srt&"+$("#liste_forums_pref").sortable("serialize"));}});$("#liste_forums_pref").disableSelection();$("#coeur_ajouter").bind("click",coeur_ajouter);$("a.sup_pref").live("click",coeur_delete);});