function init() {
    
    // HEADER : AFFICHAGE DE LA REGION DE L'AGENT
    var dept = LireCookie('DptEtab');
    $("#region").html( dpt2reg(dept) );
    $("#region").click( function(event) {
        event.preventDefault();
        barreCgos_dptModal(true, true);
    });

    $("#notabene").easySlider({
        speed: 800,
        pause : 4000,
        controlsFade: true,
        auto: true, 
        continuous: true,
        controlsShow: true,
        numericId: 'controls',
        numeric : true
    });

    $("#content .colonne3 .contact").prepend().flash( {
        menu:false,
        wmode: "transparent",
        allowfullscreen: true,
        allowscriptaccess: "always",
        src: "/images/vigncontact.swf",
        name: "contact",
        id: "contact",
        width: 188,
        height: 74
    } );
    
    // HOME : CLIC SUR TOUTE LA ZONE D'ARTICLE
    $(".home .colonne2 .article").mouseover( function(event) {                                                                    
        $(".home .colonne2 .article *").css("cursor","pointer");        
        $(".home .colonne2 .article *").css("text-decoration","underline");
    });
    $(".home .colonne2 .article").mouseout( function(event) {                                   
        $(".home .colonne2 .article *").css("cursor","default");
        $(".home .colonne2 .article *").css("text-decoration","none");     
    });
    $(".home .colonne2 .article").click( function(event) {
        event.preventDefault();                                                     
        document.location.href = $(".home .colonne2 .article a.more-home").attr("href");
    });
    
    // OUTILS DE LECTURE D'ARTICLE
    var textSizeArticle = 2;
    $("#outils #agrandir").live( "click", function(event) {
        event.preventDefault();
        var nextSize = textSizeArticle+1;
        nextSize = (nextSize<4)? nextSize : 3;
        var divArticle = $(".article");
        divArticle.removeClass();
        divArticle.addClass("article");
        divArticle.addClass("size"+(nextSize));
        textSizeArticle = nextSize;
    });
    $("#outils #reduire").live( "click", function(event) {
        event.preventDefault();
        var nextSize = textSizeArticle-1;
        nextSize = (nextSize>0)? nextSize : 1;
        var divArticle = $(".article");
        divArticle.removeClass();
        divArticle.addClass("article");
        divArticle.addClass("size"+(nextSize));
        textSizeArticle = nextSize;
    });
    $("#outils #imprimer").live( "click", function(event) {
        event.preventDefault();
        $.ajax({
            type: "POST",
            url: "/php/modules/ajax-tinyUrl.php",
            data: 'url='+document.location+'&nom=printed',
            success: function(msg){
                //$("body").append(msg);
                $("#print .infosSupplementaires").append("<div class='QRCode'>"+msg+"</div>");
                print();
            }
        });
    });
    
    
    var tabJours = new Array ("dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi");
    var tabMois = new Array ("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");
    var la_date = new Date();
    $("#print .infosSupplementaires .title").prepend("<strong>imprimé le " + tabJours[ la_date.getDay() ] + " " + la_date.getDate() + " " + tabMois[ la_date.getMonth() ] + " " + la_date.getFullYear() + " à " + ( (la_date.getHours()<10)?"0"+la_date.getHours():la_date.getHours() ) + "h" + ( (la_date.getMinutes()<10)?"0"+la_date.getMinutes():la_date.getMinutes() ) + "</strong>");
    
    if ( $("*").index( $(".home .colonne2 .alaune .date") ) != -1 ) {
        $(".colonne2 .alaune .date").text ( tabJours[ la_date.getDay() ] + " " + la_date.getDate() + " " + tabMois[ la_date.getMonth() ] + " " + la_date.getFullYear() );
    }  
        
    if ( $("*").index( $("#outils #envoyer") ) != -1 ) {
        
        $("#outils #envoyer").live( "click", function(event) {
            event.preventDefault();
            var taillePopIn = 330; //$(".popin").height();
            $(".popin").fadeOut(200);
            $("#outils li a").removeClass("selected");
            
            if ($(".article .content").height()<taillePopIn) {
                $(".article .content").css("padding-bottom",taillePopIn+"px");
            }
                                                         
            $(this).toggleClass("selected");
            if ($(this).hasClass("selected")==true) {

                $.ajax({
                    type: "POST",
                    url: "/php/modules/ajax-captcha.php",
                    data: "html=all",
                    success: function(msg){
                        var htmlSendPost = "";
                        htmlSendPost += "<div class='sendPost popin'>";
                        htmlSendPost += "<div class='close'></div>";
                        htmlSendPost += "<h3>Envoyer un article par courriel</h3>";
                        htmlSendPost += "<p class='presentation'>Pour envoyer un article par email à un ami, il suffit de compléter le formulaire ci dessous :</p>";
                        //htmlSendPost += "<form action='/' method='post'>";
                        htmlSendPost += "<p><label>Votre nom *</label><input name='nom' class='text' type='text' value='' autocomplete='off' /></p>";
                        htmlSendPost += "<p><label>Votre courriel *</label><input name='email' class='text' type='text' value='' autocomplete='off' /></p>";
                        htmlSendPost += "<p><label>Courriel du destinataire *</label><input name='emaildest' class='text' type='text' value='' autocomplete='off' /></p>";
                        htmlSendPost += "<p><label>Message supplémentaire à son intention</label><textarea name='message' rows='4'></textarea></p>";
                        htmlSendPost += "<p class='captcha'><label>Recopiez les caractères du cryptogrammes *</label>" + msg + "</p>";
                        htmlSendPost += "<p><input name='envoyer' id='sendMail' type='button' value='envoyer' /></p>";
                        //htmlSendPost += "</form>";
                        htmlSendPost += "<div class='spacer'></div>";
                        htmlSendPost += "</div>";
                        $("#outils #envoyer").after( htmlSendPost );
                        $( htmlSendPost ).find("#captcha").live( "click", function(event) {
                            event.preventDefault();
                            $(this).html("<img src='" + $(this).attr("rel") + "&z=" + Math.random() + " alt='Protection anti-spam' title='Protection anti-spam' />");
                        });                                                                                                      
                        $( htmlSendPost ).find(".close").live( "click", function(event) {
                            event.preventDefault();
                            $("#outils #envoyer").removeClass("selected");    
                            $(".article .content").css("padding-bottom","0");
                            $(this).parent().fadeOut(200);
                        });
                        
                        $( htmlSendPost ).find("#sendMail").live( "click", submitSendFriend );
                        $( htmlSendPost ).find("input").live( "keyup", submitSendFriend);
                
                        $(this).find(".sendPost").fadeIn(200);
                
                        function submitSendFriend(event) {
                            event.preventDefault();
                            
                            if (event.keyCode==undefined || event.keyCode==0 || event.keyCode==13 ) {
                                var nom_Field = $(this).parent().parent().find("input[name='nom']");
                                var email_Field = $(this).parent().parent().find("input[name='email']");
                                var emailDest_Field = $(this).parent().parent().find("input[name='emaildest']");
                                var message_Field = $(this).parent().parent().find("textarea[name='message']");            
                                var captchaKey_Field = $(this).parent().parent().find("input[name='captcha_key']");
                                var captchaEntry_Field = $(this).parent().parent().find("input[name='captcha_entry']");
                                var pCaptcha = $(this).parent().parent().find("p.captcha");
                                var textPresentation = $(this).parent().parent().parent().find("p.presentation");
                                var reqStr = "nom=" + nom_Field.val();
                                reqStr += "&email=" + email_Field.val();
                                reqStr += "&emaildest=" + emailDest_Field.val();
                                reqStr += "&message=" + message_Field.val();
                                reqStr += "&captcha_key=" + captchaKey_Field.val();
                                reqStr += "&captcha_entry=" + captchaEntry_Field.val();
                                reqStr += "&titre=" + $(".colonne2 .titre").text();
                                reqStr += "&url=" + document.location.href;
                                if ( nom_Field.val()=="" || isValidEmailAddress(email_Field.val())==false || isValidEmailAddress(emailDest_Field.val())==false || captchaEntry_Field.val()=="" ) {
                                    alert("Merci de renseigner les champs obligatoires.");
                                    if (nom_Field.val()=="") nom_Field.addClass("form_error"); else nom_Field.removeClass("form_error");  
                                    if (isValidEmailAddress(email_Field.val())==false) email_Field.addClass("form_error"); else email_Field.removeClass("form_error");
                                    if (isValidEmailAddress(emailDest_Field.val())==false) emailDest_Field.addClass("form_error"); else emailDest_Field.removeClass("form_error");  
                                    if (captchaEntry_Field.val()=="") captchaEntry_Field.addClass("form_error"); else captchaEntry_Field.removeClass("form_error");  
                                } else {
                                    $.ajax({
                                        type: "POST",
                                        url: "/php/modules/ajax-sendFriend.php",
                                        data: reqStr,
                                        success: function(msg){
                                            if (msg == "catcha_error") {
                                                captchaEntry_Field.val("");
                                                captchaEntry_Field.addClass("form_error");
                                            } else if (msg == "failed") {
                                                alert("Erreur d'envoi. Merci de rééssayer.");
                                            } else if (msg == "succeed") {
                                                emailDest_Field.val("");
                                                $.ajax({
                                                    type: "POST",
                                                    url: "/php/modules/ajax-captcha.php",
                                                    data: "html=all",
                                                    success: function(msg){
                                                        nom_Field.removeClass("form_error");  
                                                        email_Field.removeClass("form_error");
                                                        emailDest_Field.removeClass("form_error");  
                                                        captchaEntry_Field.removeClass("form_error");  
                                                        pCaptcha.html("<label>Recopiez les caractères du cryptogrammes</label>" + msg);
                                                        textPresentation.html("Pour envoyer un article par email à un <strong>autre</strong> ami, il suffit de compléter à nouveau le formulaire :")
                                                        alert( "Merci, nous lui avons envoyé votre message !" );
                                                    }
                                                });
                                            }     
                                        }
                                    });
                                }
                            }
                        }
                    }
                });                           

                
            } else {
                $(this).next(".sendPost").fadeOut(200);
            }
            
        });

    }

    if ( $("*").index( $("#outils #addComment") ) != -1 ) {
        
        $("#outils #addComment").live( "click", function (event) { addCommentPopin(event) });
        $(".addComment").live( "click", function (event) { addCommentPopin(event) });
        
        var _this = $("#outils #addComment");
        
        function addCommentPopin(event) {
        //$("#outils #addComment").live( "click", function(event) {
            event.preventDefault();
            var taillePopIn = 330; //$(".popin").height();
            $(".popin").fadeOut(200);
            $("#outils li a").removeClass("selected");
            
            if ($(".article .content").height()<taillePopIn) {
                $(".article .content").css("padding-bottom",taillePopIn+"px");
            }
                                                         
            _this.toggleClass("selected");
            if (_this.hasClass("selected")==true) {

                $.ajax({
                    type: "POST",
                    url: "/php/modules/ajax-captcha.php",
                    data: "html=all",
                    success: function(msg){
                        var htmlSendPost = "";
                        htmlSendPost += "<div class='sendPost popin'>";
                        htmlSendPost += "<div class='close'></div>";
                        htmlSendPost += "<h3>Commenter cet article</h3>";
                        htmlSendPost += "<p class='presentation'>Pour commenter cet article, il suffit de compléter le formulaire ci dessous :</p>";
                        //htmlSendPost += "<form action='/' method='post'>";
                        htmlSendPost += "<p><label>Votre nom ou pseudo</label><input name='nom' class='text' type='text' value='' autocomplete='off' /></p>";
                        htmlSendPost += "<p><label>Votre courriel</label><input name='email' class='text' type='text' value='' autocomplete='off' /></p>";
                        htmlSendPost += "<p><label>Votre commentaire *</label><textarea name='commentaire' rows='4'></textarea></p>";
                        htmlSendPost += "<p class='captcha'><label>Recopiez les caractères du cryptogrammes *</label>" + msg + "</p>";
                        htmlSendPost += "<p><input name='soumettre' id='submitComment' type='button' value='soumettre' /></p>";
                        //htmlSendPost += "</form>";
                        htmlSendPost += "<div class='spacer'></div>";
                        htmlSendPost += "</div>";
                        $("#outils #addComment").after( htmlSendPost );
                        $( htmlSendPost ).find("#captcha").live( "click", function(event) {
                            event.preventDefault();
                            _this.html("<img src='" + _this.attr("rel") + "&z=" + Math.random() + " alt='Protection anti-spam' title='Protection anti-spam' />");
                        });                                                                                                      
                        $( htmlSendPost ).find(".close").live( "click", function(event) {
                            event.preventDefault();
                            $("#outils #addComment").removeClass("selected");    
                            $(".article .content").css("padding-bottom","0");
                            $(this).parent().fadeOut(200);
                        });
                        
                        $( htmlSendPost ).find("#submitComment").live( "click", submitSendFriend );
                        $( htmlSendPost ).find("input").live( "keyup", submitSendFriend);
                
                        _this.find(".sendPost").fadeIn(200);
                
                        function submitSendFriend(event) {
                            event.preventDefault();
                            
                            if (event.keyCode==undefined || event.keyCode==0 || event.keyCode==13 ) {
                                var nom_Field = _this.parent().parent().find("input[name='nom']");
                                var email_Field = _this.parent().parent().find("input[name='email']");
                                var message_Field = _this.parent().parent().find("textarea[name='commentaire']");            
                                var captchaKey_Field = _this.parent().parent().find("input[name='captcha_key']");
                                var captchaEntry_Field = _this.parent().parent().find("input[name='captcha_entry']");
                                var pCaptcha = _this.parent().parent().find("p.captcha");
                                var reqStr = "nom=" + nom_Field.val();
                                reqStr += "&email=" + email_Field.val();        
                                reqStr += "&message=" + message_Field.val();
                                reqStr += "&captcha_key=" + captchaKey_Field.val();
                                reqStr += "&captcha_entry=" + captchaEntry_Field.val();
                                reqStr += "&titre=" + $(".colonne2 .titre").text();
                                reqStr += "&url=" + document.location.href;
                                reqStr += "&region=" + LireCookie("RegCgos");
                                reqStr += "&dept=" + LireCookie("DptEtab");        
                                reqStr += "&table=" + $(".colonne2 #table_kiosque").text();
                                reqStr += "&id=" + $(".colonne2 #id_kiosque").text();
                                reqStr += "&mail_moderateur=" + $(".colonne2 #mail_moderateur").text();
                                if ( message_Field.val()=="" || (email_Field.val()!="" && isValidEmailAddress(email_Field.val())==false) || captchaEntry_Field.val()=="" ) {
                                    alert("Merci de renseigner les champs obligatoires.");
                                    if (message_Field.val()=="") message_Field.addClass("form_error"); else message_Field.removeClass("form_error");  
                                    if (email_Field.val()!="" && isValidEmailAddress(email_Field.val())==false) email_Field.addClass("form_error"); else email_Field.removeClass("form_error");
                                    if (captchaEntry_Field.val()=="") captchaEntry_Field.addClass("form_error"); else captchaEntry_Field.removeClass("form_error");  
                                } else {
                                    $.ajax({
                                        type: "POST",
                                        url: "/php/modules/ajax-addComment.php",
                                        data: reqStr,
                                        success: function(msg){
                                            if (msg == "catcha_error") {
                                                captchaEntry_Field.val("");
                                                captchaEntry_Field.addClass("form_error");
                                            } else if (msg == "failed") {
                                                alert("Erreur d'envoi. Merci de rééssayer.");
                                            } else if (msg == "succeed") {
                                                $.ajax({
                                                    type: "POST",
                                                    url: "/php/modules/ajax-captcha.php",
                                                    data: "html=all",
                                                    success: function(msg){                              
                                                        $("#outils #addComment").removeClass("selected");    
                                                        _this.parent().find(".sendPost").hide();
                                                        alert( "Merci, votre commentaire sera publié après son approbation." );
                                                    }
                                                });
                                            }     
                                        }
                                    });
                                }
                            }
                        }
                    }
                });                           

                
            } else {
                _this.next(".sendPost").fadeOut(200);
            }
            
        }

    }

    
    if ( $("*").index( $("#outils #calculQF") ) != -1 ) {
        
        $("#outils #calculQF").live( "click", function (event) { calculQFPopin(event) });
        $(".calculQF").live( "click", function (event) { calculQFPopin(event) });
        
        var _this = $("#outils #calculQF");
            
        function calculQFPopin(event) {
            event.preventDefault();
            
            $(".popin").fadeOut(200);
            $("#outils li a").removeClass("selected");
            
            
            _this.toggleClass("selected");
            if (_this.hasClass("selected")==true) {

                var curDate = new Date();
                var anneeRevenuFiscal = (curDate.getYear()>2000)?curDate.getYear()-2:1898+curDate.getYear();
                
                var htmlQF = "";
                htmlQF += "<div class='qf popin'>";
                htmlQF += "<div class='close'></div>";
                htmlQF += "<h3>Estimer son Quotient Familial</h3>";
                //htmlQF += "<p class='presentation'>Texte de présentation</p>";
                //htmlQF += "<form action='/' method='post'>";
                htmlQF += "<p><label for='revenuAnnuel'>Revenu fiscal de référence<br /><small>inscrit sur votre avis d'imposition sur les revenus " + anneeRevenuFiscal + "</small></label><input id='revenuAnnuel' name='revenuAnnuel' class='text' type='text' value='' autocomplete='off' /> €</p>";
                htmlQF += "<p><label for='revenuAnnuel2'>Revenu de référence<br /><small>inscrit sur l'avis d'imposition sur les revenus " + anneeRevenuFiscal + " de votre compagn(e/on)</small></label><input id='revenuAnnuel2' name='revenuAnnuel2' class='text' type='text' value='' autocomplete='off' /> €</p>";
                htmlQF += "<p><label for='plusMensuel'>Montant mensuel de vos allocations familiales</label><input id='plusMensuel' name='plusMensuel' class='text' type='text' value='' autocomplete='off' /> €</p>";
                htmlQF += "<p><label>Situation familiale</label><ul>";
                htmlQF += "<li><input id='Agent3' name='Agent' class='radio' type='radio' value='3' /><label for='Agent3'>Vis en couple*. M(a/on) compagn(e/on) est agent ou retraité d'un établissement adhérant au C.G.O.S</label></li>";
                htmlQF += "<li><input id='Agent25' name='Agent' class='radio' type='radio' value='2.5' /><label for='Agent25'>Vis en couple*. M(a/on) compagn(e/on) n'est pas agent ou retraité d'un établissement adhérant au C.G.O.S</label></li>";
                htmlQF += "<li><input id='Agent1' name='Agent' class='radio' type='radio' value='1.5' /><label for='Agent1'>Vis seul(e) sans enfant</label></li>";
                htmlQF += "<li><input id='Agent2' name='Agent' class='radio' type='radio' value='2' /><label for='Agent2'>Vis seul(e) avec enfant(s) à charge fiscale</label></li>";
                htmlQF += "</ul></p>";
                htmlQF += "<p><label for='Enfant'>Nombre d'enfants à charge fiscale</label><input id='Enfant' name='Enfant' class='text' type='text' value='' autocomplete='off' /></p>";
                htmlQF += "<p><input name='calculQf' id='calculQf' type='button' value='estimer' /></p>";
                //htmlQF += "</form>";
                htmlQF += "<p><em>* : Marié(e) ou non</em></p>";
                htmlQF += "<div class='spacer'></div>";
                htmlQF += "</div>";
                $("#outils #calculQF").after( htmlQF );

                $( htmlQF ).find(".close").live( "click", function(event) {
                    event.preventDefault();
                    $("#outils #calculQF").removeClass("selected");    
                    $(this).parent().fadeOut(200);
                });

                function submitQF(event) {
                    //prevent.preventDefault();   
                    if (event.keyCode==undefined || event.keyCode==0 || event.keyCode==13 ) {
                        var revenuA = parseInt( _this.parent().parent().find("input[name='revenuAnnuel']").val() ) + 0;
                        var revenuA2 = parseInt( _this.parent().parent().find("input[name='revenuAnnuel2']").val() ) + 0;
                        var revenuPM = parseInt( _this.parent().parent().find("input[name='plusMensuel']").val() ) + 0;
                        var nbEnf = _this.parent().parent().find("input[name='Enfant']").val();
                        var nbAge = _this.parent().parent().find("input[name='Agent']:checked").val();
                        revenuA = (revenuA>0)?revenuA:0;
                        revenuA2 = (revenuA2>0)?revenuA2:0;
                        revenuPM = (revenuPM>0)?revenuPM:0;
                        nbEnf = (nbEnf>0)?nbEnf:0;
                        nbAge = (nbAge>0)?nbAge:1;
                        
                        var revenuM = (revenuA/12) - (-revenuA2/12);
                        var revenuT = revenuM + revenuPM;
                        var nbParts = (nbEnf*1) - (-nbAge);
                        var qf = parseInt( revenuT/nbParts + 0.5 );
                        $("#field_oQFo").val(""+qf);
                        var note = "Cette simulation est réalisée à partir des informations que vous avez renseignées. Elle ne tient pas compte de certains cas particuliers.";
                        note += "<br />Votre quotient familial sera de toute façon recalculé par le C.G.O.S à partir des justificatifs fournis et figurera sur votre carte de membre.";
                        if ( $("*").index( $("input#field_oQFo") ) != -1 ) {
                            $("form li.note").remove();
                            $("#field_oQFo").parent().after("<li class='note'>" + note + "</li>");
                            $("#field_oQFo").parent().after("<li class='note'><label>Nombre total de parts</label><input class='text' type='text' value='" + nbParts + "' autocomplete='off' disabled='disabled' /></li>");
                        } else {
                            alert( note.replace("<br />", "\n") + "\n\n - Quotient Familial : " + qf + "\n - Nombre total de parts : " + nbParts );
                        }
                        $("#outils #calculQF").removeClass("selected");        
                        _this.parent().parent().fadeOut(200);
                        
                        return true;
                    }
                }
                
                $( htmlQF ).find("#calculQf").live( "click", submitQF );
                $( htmlQF ).find("input").live( "keyup", submitQF ); 
                
            } else {
                _this.next(".qf").fadeOut(200);
            }
            
        }

    }

    

    // SONDAGE
    if ( $("*").index( $("#mini_sondage") ) != -1 ) {
        $("#mini_sondage").html( $.ajax({ url: "/php/modules/ajax-sondages.php", async: false }).responseText );
        $("#mini_sondage input[type='radio']").live("click", function(){
            $.ajax({
                type: "POST",
                url: "/php/modules/ajax-sondages.php",
                data: "id="+ $(this).attr("class") +"&reponse="+ $(this).val(),
                success: function(msg){
                    if (msg=="true") {
                        $("#mini_sondage .a_vote").slideDown("fast");
                        $("#mini_sondage .form_vote").slideUp("fast");
                    } 
                }
            });
        });
    }
    
    // BANDEAU PUB
    if ( $("*").index( $("#bandeau") ) != -1 ) {
        $.getJSON("/php/modules/ajax-bandeauPublicite.php", function(pubs){
            for(pub in pubs) {
                var objPub = pubs[pub];
                var dimension = objPub.format.split("x");
                $("#bandeau").append("<div id='bandeau-" + objPub.format + "' class='pubFlash'></div>");
                $("#bandeau-" + objPub.format).flash({
                    src: '/images/preload-' + objPub.format + '.swf',
                    flashvars: {
                        url: objPub.url,
                        publicite: objPub.publicite,
                        target: objPub.target
                    },
                    menu:false,
                    wmode: 'transparent',
                    width: dimension[0],
                    height: dimension[1]
                });
            }    
        });
    }
    
    // CALCULS DE PRESTATIONS
    if ( $("*").index( $("#formulaireCalculSubmit") ) != -1 ) {
        $("#formulaireCalculSubmit").parent("form").submit( function(event) {
            var alertForm="";
            $(this).find("input").each( function() {
                if ($(this).val()=="") {
                    alertForm += "- " + $(this).attr("rel") + "\n";
                    $(this).addClass("form_error");
                }
            });
            if (alertForm!="") { 
                alert( "Merci de renseigner les champs suivants :\n" + alertForm ); 
                return false;
            } else {
                return true;
            }
        });
    }
    
    // STYLE : TABLEAUX
    $("table tr:even").addClass("highlight");
    $("table").attr({width:"100%"});
                                                                                         
    // TELECHARGEMENTS
    var listLiens = $("#content .colonne2 a").parent("li").parent("ul[id!='outils']");
    if ( listLiens.html() != null && listLiens.html() != undefined && $(listLiens).attr("id")!="listForm" && $(listLiens).parent().attr("id")!="reseaux_sociaux" && $(listLiens).hasClass("listTelechargement")==false && $(listLiens).hasClass("liensUtiles")==false && $(listLiens).hasClass("magazines")==false ) {
        listLiens.hide();       
        var moreBloc = $("#content .colonne2 div.more");
        $(moreBloc).find("h5").show()
                   .addClass("show")
                   .after( "<ul>" + listLiens.html() + "</ul>" ); 
    }                                    
    $("a.listForm").click( function(event) {
        event.preventDefault();
        $(this).parent().find("#listForm").slideToggle("fast");
    });
                                          
    // KIOSQUE
    $(".kiosque a.more").click( function(event) {    
        event.preventDefault();
        $(this).parent().parent().find("li.hidden").slideDown("fast");
        $(this).parent().slideUp("slow");
    });
    
    // PARSING DES LIENS                            
    //Chaine.indexOf(sous-chaîne, position)
    // 1. Liens externes
    $("#content .colonne2 a").filter(function() { //return (this.hostname && this.hostname !== location.hostname && $(this).attr("target")!="_self"); 
                                        return (this.hostname && ( this.hostname.indexOf("cgos.info")<0 || this.hostname.indexOf("download")>=0 ) && $(this).attr("target")!="_self"); 
                                     }).attr({target:"_blank"})
                                       .addClass("targetBlankIeParent")
                                       .append("<div class='targetBlank'></div>");
    $("#content .noColonne a").filter(function() { //return (this.hostname && this.hostname !== location.hostname && $(this).attr("target")!="_self"); 
                                        return (this.hostname && ( this.hostname.indexOf("cgos.info")<0 || this.hostname.indexOf("download")>=0 || this.href.indexOf("trace_lien")>=0 ) && $(this).attr("target")!="_self"); 
                                     }).attr({target:"_blank"})
                                       .addClass("targetBlankIeParent");
    //$("#content .noColonne a").attr({target:"_blank"});
    $("a[rel='fichier']").attr({target:"_blank"});
                             
    $("#content .colonne2 a[href$='pdf'], #content .colonne2 a[href$='jpg'], #content .colonne2 a[href$='zip'], #content .colonne2 a[href$='jpeg'], #content .colonne2 a[href$='gif'], #content .colonne2 a[href$='png'], #content .colonne2 a[href$='doc'], #content .colonne2 a[href$='xls'], #content .colonne2 a[href$='ppt']").attr({target:"_blank"});


    // 2. Liens interne vers fichier
    /*
    $("#content .colonne2 a[href$='pdf'], #content .colonne2 a[href$='jpg'], #content .colonne2 a[href$='zip'], #content .colonne2 a[href$='jpeg'], #content .colonne2 a[href$='gif'], #content .colonne2 a[href$='png'], #content .colonne2 a[href$='doc'], #content .colonne2 a[href$='xls'], #content .colonne2 a[href$='ppt']").click( function(event) {
        event.preventDefault();
        var width = 900;
        var height = 500;
        $.modal('<iframe src="' + $(this).attr("href") + '" height="'+height+'" width="'+width+'" style="border:0">', {
            containerId: "modalFileContainer",
            overlayId: "modalFileOverlay",
            closeHTML: "<a class='modalCloseImg' href='#'></a>",
            onOpen: function (dialog) {
                dialog.overlay.fadeIn('slow', function () {
                    dialog.data.hide();
                    dialog.container.fadeIn('slow', function () {
                        dialog.data.slideDown('slow');
                    });
                });
            },
            overlayId:"modalOverlay",
            overlay:80,               
            position: ['15%','50%'],
            containerCss:{         
                //backgroundColor:"#EBE8E4",
                //borderColor:"#EBE8E4",
                //height:height,
                //width:width
            },
            overlayClose:true
        });
    });
    */
    
    // PARSING DES ANNEES
    var aujoudhui = new Date();
    $("img.last_last_year").replaceWith( aujoudhui.getFullYear()-2 );
    $("img.last_year").replaceWith( aujoudhui.getFullYear()-1 );     
    $("img.this_year").replaceWith( aujoudhui.getFullYear() );
    $("img.next_year").replaceWith( aujoudhui.getFullYear()+1 );
    
    // KIOSQUE : NEWSLETTER
    $(".newsletter form").submit ( function(event) {
        event.preventDefault();
        
        if ($(this).hasClass("desabonnement")) {
        
            if ( isValidEmailAddress($("input[name='email']").val()) ) {
                var email = $("input[name='email']").val();
                var raison = $("textarea[name='raison']").val();
                $.ajax({
                    type: "POST",
                    url: "/php/modules/ajax-newsletter_inscription.php",
                    data: "email="+email+"&raison="+raison+"&desabonnement=true",
                    success: function(msg){
                        if (msg=="inserted") {
                            $(".newsletter form").html("<p class='alertError'>Votre désabonnement est confirmé.</p>")
                        } else if (msg=="duplicate") {
                            $(".newsletter form").prepend("<p class='alertError'>Cette adresse est déjà désinscrite.</p>")
                        } else {
                            $(".newsletter form").prepend("<p class='alertError'>Erreur pendant le processus de désabonnement. Merci de réessayer.</p>")
                        }
                    }
                });
            } else {
                $(this).find("input[name='email']").addClass("form_error");
                alert("Merci de renseigner une adresse électronique valide.");
            }   
            
            
        } else {
            
            if ($(this).find("input[name='next']").val() == 1) {
                
                var departement = LireCookie("DptEtab");
                departement = (departement>0 && departement!=null && departement!=undefined)?departement:"";
                var idRegion = (departement>0 && departement!=null && departement!=undefined)?regionCgos( departement ):"";
                var region = (departement>0 && departement!=null && departement!=undefined)?dpt2reg( departement ):""; 
                
                var newsletterForm = '<p><label>Retapez votre courriel *</label><input name="verif_email" id="newsletter_verif_email" autocomplete="off" type="text" class="text right" value="" /></p>';
                newsletterForm += '<p><label>Département de votre établissement</label><input name="departement" maxlength="2" autocomplete="off" id="newsletter_departement" type="text" class="text right small" value="' + departement + '" /></p>';
                newsletterForm += '<p><label>Région C.G.O.S</label><span id="newsletter_region">' + region + '</span><input name="region" type="hidden" value="' + idRegion + '" /></p>';
                newsletterForm += '<p><input type="submit" id="newsletter_submit" class="submit right" value="ok" /></p>';
                $(this).find("p").after( newsletterForm);
                
                $(this).find("input[name='next']").val(0);
                $(this).find("input.next").remove();
                $(this).find("#newsletter_verif_email").focus();
                
                $("#newsletter_departement").keyup ( function(event) {
                    var dept = $(this).val();
                    //alert($(this).val()+">"+ParseInt($(this).val()));
                    $("#newsletter_region").text( dpt2reg(dept) );
                });
                
            } else {           
                if ( ($("input[name='email']").val() == $("input[name='verif_email']").val()) && isValidEmailAddress($("input[name='verif_email']").val()) ) {
                    var email = $("input[name='email']").val();
                    var region = $("input[name='region']").val();
                    var departement = $("input[name='departement']").val();
                    $.ajax({
                        type: "POST",
                        url: "/php/modules/ajax-newsletter_inscription.php",
                        data: "email="+email+"&region="+region+"&departement="+departement+"",
                        success: function(msg){
                            if (msg=="inserted") {
                                $(".newsletter form").html("<p class='alertError'>Votre inscription est validée.</p>")
                            } else if (msg=="duplicate") {
                                $(".newsletter form").prepend("<p class='alertError'>Cette adresse est déjà inscrite.</p>")
                            } else {
                                $(".newsletter form").prepend("<p class='alertError'>Erreur pendant l'enregistrement. Merci de réessayer.</p>")
                            }
                        }
                    });
                } else {
                    $(this).find("input[name='email']").addClass("form_error");
                    $(this).find("input[name='verif_email']").addClass("form_error");
                    alert("Merci de renseigner deux fois la même adresse électronique valide.");
                }   
            }
            
        }
        
    });
    
    $("#erase_profil").click( function(event) {
        event.preventDefault();
        EffaceCookie("profil");
        document.location.href = $(this).attr("href");
    });
    $(".colonne3 .profil a").click( function(event) {
        event.preventDefault();
        EffaceCookie("profil");
        document.location.href = $(this).attr("href");
    });

    $(".colonne2").numero08XX("0820", "0,12 € TTC la minute"); // indigo
    $(".colonne2").numero08XX("0825", "0,15 € TTC la minute"); // indigo
    
    
    
    
    // Flash, YouTube, DailyMotion, etc.
    if ( $("*").index( $("#content .colonne2 .content .contenu_html object") ) != -1 ) { 
        var flashWidthContent = 455;
        var flashHeightContent = 0;
        $(".content .contenu_html object")
            .prependTo("#content .colonne2 .article")
            .attr("wmode", "transparent").addClass("visible")
            .attr("height", function() {
                var hauteur = $(this).attr("height");
                var newHauteur = Math.round( hauteur * flashWidthContent / $(this).attr("width") );
                flashHeightContent = newHauteur;
                return (hauteur>newHauteur)?newHauteur:hauteur;
            })
            .attr("width", function() {
                var largeur = $(this).attr("width");
                return (largeur>flashWidthContent)?flashWidthContent:largeur;
            })
            .find("embed")
                .attr("wmode", "transparent")
                .attr("height", function() { return $(this).parent().attr("height"); })
                .attr("width", function() { return $(this).parent().attr("width"); });
        
        $(".article img:first").hide();
        $(".kiosque #outils").css("top",flashHeightContent);
        $(".kiosque #outils").removeClass("noImg");
        
    }
    
    if ( $("*").index( $(".galery") ) != -1 ) {
        
        var urlZip = $("#content .colonne2 .galery a").attr("name");
        var urlXml = urlZip.replace("/fichiers/", "/photos/");
        urlXml = urlXml.replace(".zip", "/galery.xml");
        
        $(".galery a").appendTo("#content .colonne2 div.more");
        
        // A la place de l'image
        $("#content .colonne2 .article").prepend().flash({
            menu:false,
            wmode: "transparent",                   
            allowfullscreen: true,
            allowscriptaccess: "always",
            flashvars: {   
                file: urlXml,
                width: 455,
                height: 455,                  
                transition: "fade", // fade, bgfade, blocks, bubbles, circles, flash, fluids, lines or slowfade
                usefullscreen: true,
                enablejs: true,
                rotatetime: 5,
                autostart: true,
                overstretch: false, // true, false, none
                shuffle: false,
                repeat: true,
                javascriptid: "rotator",
                linkfromdisplay: true,
                linktarget: "_blank"
            },   
            src: "http://download.cgos.info/www/galery/photos/imagerotator.swf",      
            name: "rotator",
            id: "rotator",
            width: 455,
            height: 455
        });
        
        
        $("#content .colonne2 .article img:first").hide();
        $("#content .colonne2 .kiosque #outils").css("top","0");
        $(".kiosque #outils").removeClass("noImg");                   
    }
    
    if ( $("*").index( $(".video") ) != -1 ) {
        
        var urlVideo = $("#content .colonne2 .video").text();
        
        // A la place de l'image
        $("#content .colonne2 .article").prepend().flash( {
            menu:false,
            wmode: "transparent",
            allowfullscreen: true,
            allowscriptaccess: "always",
            flashvars: {
                file: urlVideo,
                image: $("#content .colonne2 .article img:first").attr("src"),
                stretching: "uniform", // uniform // none // exactfit // fill
                plugins: "gapro-1,googlytics-1",
                'gapro.accountid': "UA-7104939-2",
                'gapro.trackstarts': "true"
            },
            src: "/images/player.swf",
            name: "video",
            id: "video",
            width: 455,
            height: 276
        } );
        
        
        $("#content .colonne2 .article img:first").hide();
        $("#content .colonne2 .kiosque #outils").css("top","0");
        $(".kiosque #outils").removeClass("noImg");                   
    }
     
     if ( $("*").index( $('#profils_info') ) != -1 ) {    
     //   $("#profils_info").removeClass("hidden");
        $.getScript( "/javascript/jquery.captify.js", function() {
            $('img.captify').captify({
                // all of these options are... optional
                // ---
                // speed of the mouseover effect
                speedOver: 'fast',
                // speed of the mouseout effect
                speedOut: 'normal',
                // how long to delay the hiding of the caption after mouseout (ms)
                hideDelay: 500,    
                // 'fade', 'slide', 'always-on'
                animation: 'always-on',        
                // text/html to be placed at the beginning of every caption
                prefix: '<img src="/images/interface/profils_info.png" class="iconInformation" />',        
                // opacity of the caption on mouse over
                opacity: '0.8',                    
                // the name of the CSS class to apply to the caption box
                className: 'caption-bottom',    
                // position of the caption (top or bottom)
                position: 'bottom',
                // caption span % of the image
                spanWidth: '390px'
            });
        });
     }

}
 

