$(document).ready(function(){$('.dot_me').each(function(){$(this).html($(this).html()+'...')});jQuery.fn.input_event();$('#textarea_wall').bind('keydown keyup keypress focus blur change',function(event){var key=event.which;if($('#textarea_wall').val().length>=380&&key!=8){event.preventDefault()}$('#count_form_wall').html($('#textarea_wall').val().length)});$('#humeur_du_jour').editable('/api/forum/espace_communaute_ajax.php?ajax=humeur_du_jour_save',{tooltip:'Cliquer pour éditer...',width:'146px',height:'16px',callback:function(reponse){reponse=eval('('+reponse+')');if(reponse.update=='ok'){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=update_wall&type=humeur',success:function(contenu){$('#ajax_wall').html(contenu+''+$('#ajax_wall').html())}})}$("#humeur_du_jour").html(reponse.value);if(reponse.value==''){$('#humeur_du_jour').css({'background':'transparent url(/api/img/pencil.png) no-repeat 6px 0px','height':'22px'})}else{$('#humeur_du_jour').css({'background':'none'})}}});$('#a_propos_send').click(function(){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=a_propos_save',data:{value:$('#a_propos_edit').val()},type:'POST',success:function(contenu){$('.a_propos_content').slideUp('normal',function(){$('.a_propos_content').html('<div><p>'+contenu+'</p></div>');$('.a_propos_content').slideDown()});$('#a_propos_max').slideUp()}})});$('#send_wall').click(function(){$(this).after('<img src="/api/img/loading.gif" class="loading" align="absmiddle" />');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=add_wall',data:{message:$('#textarea_wall').val(),id_membre:$('#to_wall').val(),is_group:($('#id_group').val()?$('#id_group').val():0),lien_url:$('.wall_link_true_url').val(),lien_titre:($('.wall_link_title').html()=='...'?null:$('.wall_link_title').html()),lien_description:($('.wall_link_description').html()=='...'?null:$('.wall_link_description').html())},type:'POST',success:function(contenu){$('#textarea_wall').val('');$('#count_form_wall').html(0);jQuery.fn.suppr_link();$('#ajax_wall').html(contenu+''+$('#ajax_wall').html());$('.loading').remove()}})});$('.send_comment_article').click(function(e){e.preventDefault();$(this).after('<img src="/api/img/loading.gif" class="loading" align="absmiddle" />');var id_article=$(this).attr('id');var texte=$('#txt').val();if(texte.length>0){$(this).attr('disabled','disabled');$('#txt').val('');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=add_comment_article',data:{message:texte,id_article:id_article},type:'POST',success:function(id_comment){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=maj_comment_article',data:{id_comment:id_comment,id_sujet:id_article},type:'POST',success:function(contenu){if($('.com_article')){$('#commentaires_article').after(contenu)}else{$('#commentaires_article').html(contenu)}$('.loading').remove()}})}})}});$('#leave_message .send_wall_link').css('cursor','pointer').click(function(){if($('#leave_message .wall_link_content').css('display')=='none'){$('#leave_message .wall_link_content').show();$('#leave_message .wall_link_input').focus()}else{$('#leave_message .wall_link_content').hide();$('#leave_message #textarea_wall').focus()}});$('#wall_add_link').click(function(){$('.wall_add_link_err').remove();$(this).after('<img src="/api/img/loading.gif" class="loading" align="absmiddle" />');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=lien_wall',data:{lien:$('.wall_link_input').val()},type:'POST',success:function(html){$('.loading').remove();$('.wall_link_url').hide();$('.wall_link_check').html(html).slideDown();$('.wall_link_title').editable('/api/forum/espace_communaute_ajax.php?ajax=lien_wall&edit=1',{maxlength:'250'});$('.wall_link_description').editable('/api/forum/espace_communaute_ajax.php?ajax=lien_wall&edit=1',{maxlength:'800'})}})});$('.show_more_comment').click(function(){var id_evenement=$(this).attr('id').replace('more_comment_','');var id_zone=$(this).attr('id')+'_zone';$(this).after('<img src="/api/img/loading.gif" class="loading_'+id_evenement+'" align="absmiddle" style="border:0px;" />');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=more_comment',data:{id_evenement:id_evenement},type:'POST',success:function(contenu){$('#'+id_zone).replaceWith(contenu);$('.loading_'+id_evenement).remove()}})});$("#search_ami_form").submit(function(){var searchbox=$(".search_ami").val();if(searchbox.length>2){$('#bloc_pagination_amis').html('');$(this).after('<img src="/api/img/loading.gif" class="loading_search" align="absmiddle" />');$.ajax({type:"POST",url:'/api/forum/espace_communaute_ajax.php?ajax=ami',data:{search:searchbox,page:'1'},cache:true,success:function(contenu){$('#bloc_pagination_amis').html(contenu);$('.loading_search').remove()}})}return false});$(".search_ami").bind('keyup click',function(){var searchbox=$(this).val();if(searchbox.length>2){$.ajax({type:"POST",url:"/api/forum/espace_communaute_ajax.php?ajax=ami",data:{search_box:searchbox},cache:false,success:function(html){$("#display_ami").html(html).show()}})}else{$("#display_ami").html('').show()}return false});$(".create_groupe_form").submit(function(){$(".erreur").html('<img src="/api/img/loading.gif" align="absmiddle" border="0" />');if($("#groupe_nom").val()==''){$(".erreur").html('Le nom du groupe ne peut être vide !');return false}if($("#groupe_description").val()==''){$(".erreur").html('La description du groupe ne peut être vide !');return false}if($("#id_noeud_final").val()<=0){$(".erreur").html('Veuillez choisir un secteur !');return false}$.ajax({type:"POST",url:'/api/forum/espace_communaute_ajax.php?ajax=groupe&type=create',data:{nom:$("#groupe_nom").val(),description:$("#groupe_description").val(),bdc:$("#id_noeud_final").val(),status:0,banniere:$("#input_idphoto").val()},success:function(contenu){if(contenu!=''){window.location.href=contenu}else{$(".erreur").html('Un groupe porte déjà ce nom ! Veuillez en choisir un autre.')}}});return false});$("#groupe_nom").bind('keyup click blur',function(){var group_name=$(this).val();if(group_name.length>2){$.ajax({type:"POST",url:"/api/forum/espace_communaute_ajax.php?ajax=groupe&type=check_url",data:{nom:group_name},cache:false,dataType:'json',success:function(contenu){$("#groupe_url").val(contenu.exist=='false'?contenu.url:'Un groupe possède déjà ce nom !')}})}else{$("#groupe_url").val('')}return false});$('.send_desc_groupe').click(function(){$('#desc_groupe_error').html('');if($('#desc_groupe_txt').val()!=''){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=groupe&type=description',data:{id:$('#id_group').val(),desc:$('#desc_groupe_txt').val()},type:'POST',success:function(contenu){$('#contenu_article').html(contenu);$('#desc_groupe_error').html('<span style="color:#009900;">Description mise à jour !</span>')}})}else{$('#desc_groupe_error').html('<span style="color:#C50000;">La description ne peut être vide !</span>')}});$('#update_banniere').click(function(){$('<iframe src="/api/forum/espace_communaute_ajax.php?ajax=choose_photos&type=4&groupe='+$('#id_group').val()+'"></iframe>').modal()});$('#join_group').click(function(){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=groupe&type=join',data:{id:$('#id_group').val()},type:'POST',success:function(contenu){location.reload(true)}})});$('.quit_group').click(function(){if(confirm('Etes-vous sûr de vouloir quitter ce groupe ?')){id=$(this).attr('id').replace('quit_group_','');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=groupe&type=quit',data:{id:id},type:'POST',success:function(contenu){if(contenu=='1'){$('#quit_group_'+id).hide();$('#join_group_'+id).show()}}})}else{return false}});$('.join_group').live('click',function(){id=$(this).attr('id').replace('join_group_','');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=groupe&type=fast_join',data:{id:id},type:'POST',success:function(contenu){if(contenu=='1'){$('#join_group_'+id).hide();$('#quit_group_'+id).show()}}})});$("#search_group_form").submit(function(){var searchbox=$(".search_group").val();if(searchbox.length>2){$('#block_group').hide();$(this).after('<img src="/api/img/loading.gif" class="loading_search" align="absmiddle" />');$.ajax({type:"POST",url:'/api/forum/espace_communaute_ajax.php?ajax=groupe&type=search',data:{search:searchbox,page:'1'},cache:true,success:function(contenu){$('#block_pagination_group').html(contenu);$('.loading_search').remove()}})}else{$('#block_pagination_group').html('');$('#block_group').show()}return false});var up_button=$('#fichier'),interval;new AjaxUpload(up_button,{action:'/api/forum/espace_communaute_ajax.php?ajax=upload_ugc&id_groupe='+$('#id_group').val()+'&id_membre='+getCookie('nfuserid')+'&hash='+$('#hash').val(),name:'Filedata',autoSubmit:true,onSubmit:function(file,ext){if($('#titre').val()==''){$('.finish_upload').html('<span style="color:#C50000;"><b>Veuillez entrer un titre !</b></span>');return false}else{if(ext&&/^(jpg|jpeg|png|gif)$/.test(ext)){this.setData({titre_photo:$('#titre').val()});up_button.text('Chargement');this.disable();interval=window.setInterval(function(){var text=up_button.text();if(text.length<13){up_button.text(text+'.')}else{up_button.text('Chargement')}},200)}else{$('.finish_upload').html('<span style="color:#C50000;"><b>Fichier JPG/JPEG/PNG/GIF uniquement !</b></span>');return false}}},onComplete:function(file,response){up_button.text('Parcourir...');window.clearInterval(interval);this.enable();if(response=='nofile'){$('.finish_upload').html('<span style="color:#C50000;"><b>Aucun fichier présent !</b></span>')}else if(response=='ext'){$('.finish_upload').html('<span style="color:#C50000;"><b>Fichier JPG/JPEG/PNG/GIF uniquement !</b></span>')}else{$('#mes_dernieres_photos').load('/api/forum/espace_communaute_ajax.php?ajax=show_photos&id_groupe='+$('#id_group').val());$('#finish_upload').load('/api/forum/espace_communaute_ajax.php?ajax=show_info_photo',{id_photo:response});if($('#input_idphoto')){$('#input_idphoto').val(response)}}}});$('.show_info_photo').click(function(){var id_photo=$(this).attr('rel');$('#finish_upload').load('/api/forum/espace_communaute_ajax.php?ajax=show_info_photo',{id_photo:id_photo})})});jQuery.fn.send_comment=function(){$(this).after('<img src="/api/img/loading.gif" class="loading" align="absmiddle" />');var id_button=$(this).attr('id');var texte=$('#'+id_button+'_text').val();if(texte){$(this).attr('disabled','disabled');$('#'+id_button+'_text').val('');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=add_comment',data:{message:texte,id_evenement:id_button},type:'POST',success:function(id_comment){$('#'+id_button).attr('disabled','');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=maj_comment',data:{id_comment:id_comment,id_evenement:id_button},type:'POST',success:function(contenu){$('#'+id_button+'_new').before(contenu);$('.loading').remove()}})}})}};jQuery.fn.suppr_event_comment=function(){$('.suppr_event_comment').live("click",function(){id=$(this).attr('id').replace('suppr_event_comment_','');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=suppr_wall_comment',data:{id:id,id_evenement:$(this).attr('rel')},type:'POST',success:function(){$('#commentaire_actif_'+id+'_zone').slideUp('normal',function(){$(this).remove()})}})})};jQuery.fn.refresh_avatar_upload=function(){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=get_avatar',type:'POST',success:function(res){var date=new Date();$('.mon_avatar').attr("src",res+"?time="+date.getTime())}})};jQuery.fn.suppr_event=function(){var id_evenement=$(this).attr('id').replace('suppr_event_','');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=suppr_wall',data:{id_evenement:id_evenement,groupe:($(this).attr('rel')?$(this).attr('rel'):false)},type:'POST',success:function(){$('#wall_post_'+id_evenement+'_zone').slideUp('normal',function(){$(this).remove()});$('#wall_separate_'+id_evenement).slideUp('normal',function(){$(this).remove()})}})};jQuery.fn.suppr_avatar=function(){$('.supprimer_avatar').click(function(){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=suppr_avatar',type:'POST',success:function(){$('.mon_avatar').attr('src','/forum/img/avatar_defaut.gif')}})})};jQuery.fn.suppr_link=function(){$('.wall_link_content').slideUp('normal',function(){$('.wall_link_url').show();$('.wall_link_input').val('http://');$('.wall_link_check').html('')})};jQuery.fn.suppr_article=function(){$('.the_actions .suppr_article').click(function(){if(confirm("Voulez-vous vraiment supprimer l'article ?")){var id_article=$(this).attr('id').replace('suppr_article_','');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=suppr_article',data:{id_article:id_article},type:'POST',success:function(){$('#article_liste_'+id_article+'_zone').slideUp('normal',function(){$(this).remove()})}})}})};jQuery.fn.suppr_article_com=function(){$('.suppr_article_com').live("click",function(){var id_article=$(this).attr('id').replace('suppr_article_com_','');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=suppr_article_com',data:{id_article:id_article},type:'POST',success:function(res){$('#com_article_'+id_article).slideUp('normal',function(){$(this).remove()})}})})};jQuery.fn.vote_event=function(){var tmp=$(this).attr('id').replace('vote_','');var vote=tmp.split('_')[0];var id_evenement=tmp.split('_')[1];$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=add_vote',data:{id_evenement:id_evenement,vote:vote,type:$(this).attr('rel')},type:'POST',dataType:'json',success:function(contenu){$('#nb_plus_'+id_evenement).html(contenu.plus);$('#nb_moins_'+id_evenement).html(contenu.moins)}})};jQuery.fn.vote_event2=function(id_evenement,vote,type){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=add_vote',data:{id_evenement:id_evenement,vote:vote,type:type},type:'POST',dataType:'json',success:function(contenu){$('#nb_plus_'+id_evenement).html(contenu.plus);$('#nb_moins_'+id_evenement).html(contenu.moins)}})};jQuery.fn.suppr_photo=function(id,method){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=suppr_photo',data:{id_photo:id,is_group:($('#id_group').val()?$('#id_group').val():0),method:method},type:'POST',success:function(contenu){if(method=='maxi'){if(contenu!=''){window.location.href=contenu}}else{$('#finish_upload').html('');$('#photo_'+id+'_zone').hide('slow',function(){$('#photo_'+id+'_zone').remove()})}}})};jQuery.fn.liens_amis=function(id){var str=$(this).attr('id').replace('liens_ami_'+id+'_','');$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=ami',data:{id:id,type:str},type:'POST',success:function(retour){if(str=='demande-block'){$('#liens_ami_'+id+'_demande-block').text($('#liens_ami_'+id+'_demande-block').text()=='Bloquer'?'Débloquer':'Bloquer')}else if(str=='demande-ajout-fast'){$('#ajout_ami_fast_check').html(retour);setTimeout("$('#ajout_ami_fast_zone').slideUp();",3000)}else if(str=='suggestions-suppr'){$('#ami_'+id+'_zone').slideUp('normal')}else{$('#ami_'+id+'_zone').slideUp('normal',function(){$('#ami_'+id+'_zone').html(retour);$('#ami_'+id+'_zone').slideDown('normal',function(){setTimeout("$('#ami_"+id+"_zone').slideUp();",3000)})})}}})};jQuery.fn.groupe_amis=function(id){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=groupe&type=ami&id_membre='+id,success:function(){$('#groupe_amis_'+id).html(' - Demande envoyée');setTimeout("$('#groupe_amis_"+id+"').fadeOut('slow', function(){ $('#groupe_amis_"+id+"').remove(); });",1500)}})};jQuery.fn.amis_communs=function(login,id){tb_init('a.thickbox');tb_show('Mes amis en communs avec <b>'+login+'</b>','/api/forum/espace_communaute_ajax.php?ajax=ami&type=communs&id='+id+'&width=600&height=500',false)};jQuery.fn.input_event=function(){$('.input_text').css({'background':'#ffffff url(/api/img/watermark_wall_commentaire.png) no-repeat 2px 50%','border':'1px solid #c6c6c6','color':'#c6c6c6'});$('#wall textarea, #leave_message textarea').autogrow({restore:true,maxHeight:100,minHeight:14,lineHeight:14});$('textarea.input_text').focus(function(){var textarea_id=$(this).attr('id').replace('_text','');$('#'+textarea_id).show();$('#'+textarea_id+'_avatar').show();$('#'+textarea_id+'_text').css({'background':'#ffffff','border':'1px solid #4D6DB3','color':'#222222'})});$('textarea.input_text').blur(function(){var textarea_id=$(this).attr('id').replace('_text','');if($('#'+textarea_id+'_text').val()==''){setTimeout(function(){$('#'+textarea_id).hide();$('#'+textarea_id+'_avatar').hide();$('#'+textarea_id+'_text').val('');$('#'+textarea_id+'_text').css({'background':'#ffffff url(/api/img/watermark_wall_commentaire.png) no-repeat 2px 50%','border':'1px solid #c6c6c6','color':'#c6c6c6'})},1000)}});$('.comment_input_show').live("click",function(){$('#comment_'+$(this).attr('rel')+'_zone').show();$('#comment_'+$(this).attr('rel')+'_text').focus();$(this).remove()})};jQuery.fn.qualite=function(id){if($('#contenu_ok1').is(':checked')&&$('#contenu_ok2').is(':checked')&&$('#contenu_ok3').is(':checked')&&$('#contenu_ok4').is(':checked')&&$('#contenu_ok5').is(':checked')&&$("#id_noeud_final").val()>0){if(confirm('Etes-vous sur de vouloir soumettre cette article comme contenu de qualité ?')==true){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=article_qualite&id='+id,type:"POST",data:{bdc:$("#id_noeud_final").val()},success:function(reponse){$('#qualite_info').slideUp('normal',function(){if(reponse>'0'){$('#qualite_info').html('<small>Contenu soumis à la rédaction. Il sera étudié dans les plus bref délais.</small>')}else{$('#qualite_info').html('<small style="color:#C50000;font-weight:bold;">Une erreur est survenue, veuillez réessayer ultérieurement.</small>')}$('#qualite_info').slideDown('normal',function(){setTimeout("$('#qualite_info_zone').slideUp('normal', function(){$('#qualite_info_zone').html('<small>Soumis comme article de qualité en date du "+reponse+".</small>');$('#qualite_info_zone').slideDown();});",2000)})})}})}else{$('#contenu_ok1').attr('checked',false);$('#contenu_ok2').attr('checked',false);$('#contenu_ok3').attr('checked',false);$('#contenu_ok4').attr('checked',false);$('#contenu_ok5').attr('checked',false);$('#qualite_info').slideUp()}}};jQuery.fn.get_banniere=function(id){if(id>0){$.ajax({url:'/api/forum/espace_communaute_ajax.php?ajax=groupe&type=get_banniere&id='+id,success:function(reponse){$('#banniere').html(reponse)}})}else{$('#banniere').html('').fadeOut()}};jQuery.fn.show_text_complet=function(id){$('#first_text'+id).hide('fast',function(){$('#div_suite'+id).remove();$('#first_text'+id+' .dot_me').html($('#first_text'+id+' .dot_me').html().substr(0,($('#first_text'+id+' .dot_me').html().length-3)));$('#first_text'+id).show('fast',function(){$('#long_text'+id).show('fast')})})}