var animationTime = 600;$.fn.exists = function () {    return $(this).length !== 0;};function showMenuElement(menuElement) {    var nextTarget = $(menuElement).attr("rel");    //alert("nextTarget : "+nextTarget);    $("#menu_top_container_left ul li a").each(function(index, element) {        var target = $(element).attr("rel");        //alert("target : "+target);        if (target == nextTarget) {            $(nextTarget).show();            $(element).parent().addClass("selected");        } else {            $(target).hide();            $(element).parent().removeClass("selected");            //alert("hide "+target);        }    });}function showMenu() {    showMenuElement(this);}function hideMenu() {}function isImage(path) {    var lowerpath = path.toLowerCase();    var result = (lowerpath.indexOf(".jpg") != -1) || (lowerpath.indexOf(".jpeg") != -1) || (lowerpath.indexOf(".gif") != -1) || (lowerpath.indexOf(".png") != -1);    return result;}function checkResumeSize() {    resumeText = $('#group_resume').val();    remaining = 280 - resumeText.length;    message = "";    if (remaining > 1) {        message = "Encore "+remaining+" caractères disponibles...";    } else if (remaining == 1) {        message = "Encore un dernier caractère disponible...";    } else if (remaining == 0) {        message = "Plus aucun caractère disponible !";    } else if (remaining == -1) {        message = "Vous avez un caractère en trop...";    } else if (remaining < -1) {        message = "Vous avez "+(-remaining)+" caractères en trop...";    }    $('#group_resume_handler').html(message);}function submitParticipation(type, author, title, values) {    //alert(type + title);    var datas = {            action: 'sendParticipation',            author: author,            type: type,            title: title        };    $.extend(datas, values);    $.ajax({        type: 'post',        url: myleneRootUri+"/js/ajax_gate.php",        data: datas,        async:false,        success: function(response){            //alert('participation : '+response);            $('#proposer_moderation_wrapper').fadeIn(animationTime);            $('#proposer_wrapper').fadeOut(animationTime);        },        error: function(jqXHR, textStatus, errorThrown){            alert('alerte participation erreur : '+textStatus+' : '+errorThrown);        }//success    });//ajax}function uploadifyOnError(event, queueId, fileObj, errorObj) {   alert('Problème envoi fichier : '+errorObj.type + ' Erreur: ' + errorObj.info);}function uploadifyOnComplete(event, queueId, fileObj, response, data) {    //alert('uploadifyOnComplete response: '+response);    //alert('uploadifyOnComplete name : '+fileObj.name);    var size = $(".part_img_holder").length;    if(size < 4) {        $('#part_imgs_holder').append(            '<div class="part_img_holder">' +                '<input type="hidden" id="part_img_holder_'+size+'" name="part_img_holder_'+size+'" value="'+fileObj.name+'"/>' +                '<img src="../timthumb?php?w=50&h=50&zc=1&src='+myleneRootUri+'uploads/participations/tmp/'+fileObj.name+'"/>' +            '</div>');    } else {        $('#part_imgs_errors').html("<p>Vous avez atteint la limite de 4 fichiers !</p>");    }    if(size >= 3) {        $('#part_file_upload_wrapper').fadeOut(animationTime);    }}function uploadifyOnFull(event,queueSizeLimit) {      alert("I'm stuffed, please don't put anymore files in me!");      return false;    }function adminParticipation(partId, action) {    //alert("adminParticipation " + action + " " + partId);    $.ajax({        type: 'post',        url: myleneRootUri+"/js/ajax_gate.php",        data: {            action: 'adminPart',            todo: action,            pid: partId        },        async:false,        beforeSend: function() {        },        success: function(response){            //alert("adminParticipation response = "+response);            if (action == "val") {                $("#participation_wrapper_"+partId).find('.participation_top').css('background-color', 'white');                $("#participation_wrapper_"+partId).find('.partval_wrapper p.proposition_adminvalider').hide();                $("#participation_wrapper_"+partId).find('.partval_wrapper p.proposition_admininvalider').show();            }            if (action == "inval") {                $("#participation_wrapper_"+partId).find('.participation_top').css('background-color', 'red');                $("#participation_wrapper_"+partId).find('.partval_wrapper p.proposition_adminvalider').show();                $("#participation_wrapper_"+partId).find('.partval_wrapper p.proposition_admininvalider').hide();            }            if (action == "del") {                $("#participation_wrapper_"+partId).fadeOut(600);            }                    },        error: function(response){            //alert('avis Alerte erreur : '+response);        }//success    });//ajax}$(document).ready(function() {    var newsColor = $('.news_colored').css('backgroundColor');    //Cufon.replace('.mf_dyn_menu');    //Cufon.replace('.mf_dyn_tabs');    if ($('#contenu_other h1').not('#index_title').not('.unmoveable').not('.titreNews').not('#profil_title_pseudo').length > 0) {        //$('#contenu h1').not('#index_title').not('.titreNews').before('<div class="contenu_title"></div>');        //$('#contenu').not('#index_title').not('.titreNews').before('<div class="contenu_title"></div>');        $('.contenu_title').append($('#contenu_other h1'));    }    $('table').each(function(index, element) {        //alert('width : '+$(element).css('width'));        if($(element).css('width')) {            var tabwidth = parseInt($(element).css('width').replace("px", ""));            if (tabwidth >= 600) {                //alert("cange table width from "+tabwidth+" to 100%");                $(element).css('width', '100%');            }        }    });    $("#menu_top_container_left ul li a").hoverIntent(showMenu , hideMenu);    showMenuElement('#menu'+myleneThema);    var myAnimSpeed = 500;    if (typeof(isIE) != 'undefined') {        myAnimSpeed = 0;       }    $('#nivoSlider').nivoSlider({        effect:'fade', //Specify sets like: 'fold,fade,sliceDown'        slices:8,        animSpeed:myAnimSpeed, //Slide transition speed        pauseTime:3000,        startSlide:0, //Set starting Slide (0 index)        directionNav:false, //Next & Prev        directionNavHide:true, //Only show on hover        controlNav:true, //1,2,3...        controlNavThumbs:false, //Use thumbnails for Control Nav        controlNavThumbsFromRel:false, //Use image rel for thumbs        controlNavThumbsSearch: '.jpg', //Replace this with...        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src        keyboardNav:true, //Use left & right arrows        pauseOnHover:true, //Stop animation while hovering        manualAdvance:false, //Force manual transitions        captionOpacity:0.8, //Universal caption opacity        beforeChange: function(){},        afterChange: function(){},        slideshowEnd: function(){}, //Triggers after all slides have been shown        lastSlide: function(){}, //Triggers when last slide is shown        afterLoad: function(){} //Triggers when slider has loaded    });    if ($('.profilIdTabs').exists()) {        if (typeof profilIdTab != 'undefined') {           $('.profilIdTabs').idTabs(profilIdTab);        } else {            $('.profilIdTabs').idTabs();        }    }    if ($('#group_resume').exists()) {        checkResumeSize();        $('#group_resume').keyup(checkResumeSize);    }    if ($('#comment_textarea').exists()) {        $('#comment_textarea').click(function(){            if($(this).val() == "Saisissez votre texte ici. Format HTML non supporté.") {                $(this).val("");            }        });        $('#comment_textarea').blur(function(){            if($(this).val() == "") {                $(this).val("Saisissez votre texte ici. Format HTML non supporté.");            }        });        $('#comment_textarea').val("Saisissez votre texte ici. Format HTML non supporté.");    }    $('table#news_table tr.news').hover(            function() {                $(this).css('backgroundColor', newsColor);            },            function() {                $(this).css('backgroundColor', 'transparent');            }    );    $("a.yoxview").each(function(index) {        $(this).addClass("fbox");        $(this).attr('rel','myfboxgal');    });    $(".yoxview a img").each(function(index) {        var alink = $(this).parent();        var href = alink.attr('href');        //alert(href);        if (isImage(href)) {            alink.addClass("fbox");            alink.attr('rel','myfboxgal');        }    });    $("a.fbox").fancybox({		'transitionIn'	:	'elastic',		'transitionOut'	:	'elastic',		'speedIn'		:	600,		'speedOut'		:	200	});    /*$(".yoxview").yoxview({        lang: 'fr',        renderInfo: false,        renderMenu: false,        showDescription: false,        popupResizeTime: animationTime*2,        controlsInitialDisplayTime: 0,        onOpen: function() {            //if ($('#profilvideo').exists()) {                //$('#profilvideo').fadeOut(0);            //}        },        onClose: function() {            //if ($('#profilvideo').exists()) {                //$('#profilvideo').fadeIn(2000);            //}        }    });*/    if ($('#alerte_profil').exists()) {        $('#alerte_profil').click(function(){            //alert(myleneRootUri+"/js/ajax_gate.php");            $.ajax({                type: 'post',                url: myleneRootUri+"/js/ajax_gate.php",                data: {                    action: 'sendMail',                    subject: 'Alerte sur profil '+$('#pseudo').val(),                    from: $('#pseudo_from').val(),                    body: '<p>Une alerte a été signalée sur le profil de <strong>'+$('#pseudo').val()+'</strong> par <strong>'+$('#pseudo_from').val()+'</strong></p>'                },                async:false,                beforeSend: function() {                    $('#alerte_profil_cont').html("<p>Veuillez patienter...</p>");                },                success: function(response){                    //alert('profilAlerte : '+response);                    alert("Votre alerte a bien été envoyée à l'équipe de modération !");                    $('#alerte_profil_cont').html("<p>L'équipe de modération est alertée</p>");                },                error: function(response){                    alert('profilAlerte error : '+response);                }//success            });//ajax        });    }    if ($('#alerte_group').exists()) {        $('#alerte_group').click(function(){            //alert(myleneRootUri+"/js/ajax_gate.php");            $.ajax({                type: 'post',                url: myleneRootUri+"/js/ajax_gate.php",                data: {                    action: 'sendMail',                    subject: 'Alerte sur groupe '+$('#group_name').val(),                    from: $('#pseudo_from').val(),                    body: '<p>Une alerte a été signalée sur le groupe <strong>'+$('#group_name').val()+' (id='+$('#group_id').val()+')</strong> par <strong>'+$('#pseudo_from').val()+'</strong></p>'                },                async:false,                beforeSend: function() {                    $('#alerte_group_cont').html("<p>Veuillez patienter...</p>");                },                success: function(response){                    //alert('profilAlerte : '+response);                    alert("Votre alerte a bien été envoyée à l'équipe de modération !");                    $('#alerte_group_cont').html("<p>L'équipe de modération est alertée</p>");                },                error: function(response){                    alert('profil Alerte erreur : '+response);                }//success            });//ajax        });    }    $('.comment_alerter').click(function() {        var avis = jQuery.trim($(this).parent().parent().siblings('.comment_text').html());        //alert("alerter : "+avis+"; ULR : "+myleneRootUri+"/js/ajax_gate.php");        var alerteDom = $(this).parent();        var theUrl = $('#avis_baseuri').val();        var theType = $('#avis_type').val();        var theId = $('#avis_id').val();        var avisAuthor = $('#avis_author').val();        var theBody = '<p>Une alerte a été signalée par <strong>'+$('#pseudo_from').val()+'</strong> sur l\'avis #'+theId+': de <strong>'+avisAuthor+'</strong> : "<strong>'+avis+'</strong>" </p><br>'+            '<a href="'+theUrl+'">Accéder '+theType+'</a>';        $.ajax({            type: 'post',            url: myleneRootUri+"/js/ajax_gate.php",            data: {                action: 'sendMail',                subject: "Alerte sur avis "+theType + " #"+theId+" de "+avisAuthor,                from: $('#pseudo_from').val(),                body: theBody            },            async:false,            beforeSend: function() {                alerteDom.html("<p>Veuillez patienter...</p>");            },            success: function(response){                //alert('profilAlerte : '+response);                //alert("Votre alerte a bien été envoyée à l'équipe de modération !");                alerteDom.html("<p>L'équipe de modération est alertée</p>");            },            error: function(response){                alert('avis Alerte erreur : '+response);            }//success        });//ajax    });    $('.comment_citer').click(function() {        var avis = jQuery.trim($(this).parent().parent().siblings('.comment_text').html());        var pseudoavis = jQuery.trim($(this).siblings('#citer_pseudo').val());        var citation = pseudoavis + ' dit: "' + avis + '" : ';        $('#comment_textarea').val(citation);        //alert("citer : '" + avis + "'");    });        if ($('textarea.tinymce').exists()) {        var line3 = "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo";        if (!$('#participation_proposer').exists()) {            line3 = line3 + ",|,link,unlink,image,help,code";        }        $('textarea.tinymce').tinymce({			// Location of TinyMCE script			script_url : 'http://www.mylene.net/js/tinymce/jscripts/tiny_mce/tiny_mce.js',            // Example content CSS (should be your site CSS)			//content_css : "http://www.mylene.net/js/tinymce/content.css",            theme : "advanced",            mode : "textareas",            plugins : "fullpage",            theme_advanced_toolbar_location : "top",			theme_advanced_toolbar_align : "center",            theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull",            theme_advanced_buttons2 : "styleselect,formatselect,fontselect,fontsizeselect",            theme_advanced_buttons3 : line3,            theme_advanced_buttons4 : "",            theme_advanced_resizing : true			// General options			//theme : "advanced",			//plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",			// Theme options			/*theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",			theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",			theme_advanced_toolbar_location : "top",			theme_advanced_toolbar_align : "left",			theme_advanced_statusbar_location : "bottom",			theme_advanced_resizing : true,*/			// Drop lists for link/image/media/template dialogs			/*template_external_list_url : "lists/template_list.js",			external_link_list_url : "lists/link_list.js",			external_image_list_url : "lists/image_list.js",			media_external_list_url : "lists/media_list.js",*/			// Replace values for the template plugin			/*template_replace_values : {				username : "Some User",				staffid : "991234"			}*/		});    }    $('.onerelatednews').hoverIntent(        function() {            $(this).children('.relatednews_hover').fadeIn(800);        },        function() {            $(this).children('.relatednews_hover').fadeOut(800);        }    );    $('.relatednews_hover').click(function() {        $(location).attr('href', $(this).parent().attr('rel'));    });    $('.relatednews_main').click(function() {        $(location).attr('href', $(this).parent().attr('rel'));    });    $('.tag_label').click(function(){        //alert("coucou"+$(this).attr('relid'));        $('#tag_update_id').attr('value', ($(this).attr('relid')));        $('#tag_update_text').attr('value', ($(this).attr('relval')));        $('#taglist_controls').fadeIn(400);    });    $('#taglist_controls').keyup(function(){        //alert('coucou:'+$('#tag_update_text').val());        if($('#tag_update_text').val() == "") {            $(this).fadeOut(400);        }    });    if ($('#participation_proposer').exists()) {        $('#participation_proposer').click(function(){            $('#proposer_wrapper').fadeIn(400);            $('#participation_proposer').fadeOut(400);        });    }    if ($('#participation_submitText').exists()) {        $('#participation_submitText').click(function(){            var content = $('textarea.tinymce').tinymce().getBody().innerHTML;            //alert(content);            if($('#part_text_title').val() == "") {                alert("Vous devez saisir un titre.");            } else if (content == '<p><br data-mce-bogus="1"></p>') {                alert("Vous devez saisir un texte.");            } else {                //alert(myleneRootUri+"/js/ajax_gate.php");                submitParticipation('texte', $('#part_text_author').val(), $('#part_text_title').val(),                    {                        content: content                    }                );            }        });    }    if ($('#participation_submitImages').exists()) {        $('#participation_submitImages').click(function(){            if($('#part_images_title').val() == "") {                alert("Vous devez saisir un titre.");            } else if (! $('#part_img_holder_0').exists()) {                alert("Vous devez choisir au moins une image.");            } else {                //alert(myleneRootUri+"/js/ajax_gate.php");                submitParticipation('images', $('#part_images_author').val(), $('#part_images_title').val(),                    {                        img1: $('#part_img_holder_0').val(),                        img2: $('#part_img_holder_1').val(),                        img3: $('#part_img_holder_2').val(),                        img4: $('#part_img_holder_3').val()                    }                );            }        });    }    if ($('#participation_submitVideo').exists()) {        $('#participation_submitVideo').click(function(){            if($('#part_video_title').val() == "") {                alert("Vous devez saisir un titre.");            } else if ($('#part_video').val() == "") {                alert("Vous devez fournir un code pour votre vidéo.");            } else {                //alert(myleneRootUri+"/js/ajax_gate.php");                submitParticipation('video', $('#part_video_author').val(), $('#part_video_title').val(),                    {                        video: $("#part_video").val()                    }                );            }        });    }    if ($('.participation_cancel').exists()) {        $('.participation_cancel').click(function(){            $('#proposer_wrapper').fadeOut(animationTime);            $('#participation_proposer').fadeIn(animationTime);            $('#part_imgs_holder').empty();            $('#part_file_upload_wrapper').fadeIn(animationTime);        });    }    if ($('#part_file_upload').exists()) {        //alert('path:'+myleneRootUri);        $('#part_file_upload').uploadify({            'uploader'  : myleneRootUri+'js/uploadify214/uploadify.swf',            'script'    : myleneRootUri+'js/uploadify214/uploadify.php',            'cancelImg' : myleneRootUri+'js/uploadify214/cancel.png',            'folder'    : '/uploads/participations/tmp/',            'fileExt'   : '*.jpg;*.jpeg;*.JPG;*.JPEG',            'fileDesc'  : 'images',            'multi'     : true,            'auto'      : true,            'sizeLimit' : 1024 * 400,            'queueSizeLimit' : 4,            'buttonText' : "Mes fichiers...",            'onError'   : uploadifyOnError,            'onComplete': uploadifyOnComplete,            'onQueueFull': uploadifyOnFull        });    }    if ($('#mode_ok').exists()) {        $('#mode_ok').click(function() {            $('#proposer_moderation_wrapper').fadeOut(animationTime);        });    }    if ($('.proposition_adminvalider').exists()) {        $('.proposition_adminvalider').click(function() {            var partId = $(this).attr('rel');            adminParticipation(partId, "val");        });        $('.proposition_admininvalider').click(function() {            var partId = $(this).attr('rel');            adminParticipation(partId, "inval");        });        $('.proposition_adminsupprimer').click(function() {            var partId = $(this).attr('rel');            adminParticipation(partId, "del");        });    }});
