 /* BLOCK ACTUALITE HOME */

    var timerencours = 0;
    var animencours = 0;

    function sTimer()
    {
        timerencours = window.setTimeout('mooveNews();', 5000);
    }

    function clearTimer()
    {
        window.clearTimeout(timerencours);
    }

    function onPage(element)
    {
        if ( $('.' + element).hasClass('out') )
        {
            $('.' + element).removeClass('out');
            $('.' + element).addClass('active');
        }
        else
        {
            $('.' + element).addClass('active');
        }
    }

    function offPage(element)
    {
        if ( $('.' + element).hasClass('active') )
        {
            $('.' + element).removeClass('active');
            $('.' + element).addClass('out');
        }
        else
        {
            $('.' + element).addClass('out');
        }
    }

    function fPuces()
    {
        /*
        * Déplacer div NEWS
        */
        var tailleMoveSlide = 125;
        var vitesseSlide = 'slow';
        var nomSlide = 'p';
        
        $("." + nomSlide + "1").click(function()
        {

            onPage('p1');
            offPage('p2');
            offPage('p3');
            $('#tabs-1').attr('src','/public/images/blockActu_1Hover.png');
            $('#tabs-2').attr('src','/public/images/blockActu_2.png');
            $('#tabs-3').attr('src','/public/images/blockActu_3.png');
            if( animencours == 0 )
            {
                animencours = 1;
                clearTimer();
                $(".mooveNews").animate({
                    bottom: "0px"
                }, vitesseSlide, function(){
                    animencours = 0;
                    sTimer();
                });
            }
        });

       $("." + nomSlide + "2").click(function()
       {
            offPage('p1');
            onPage('p2');
            offPage('p3');
            $('#tabs-1').attr('src','/public/images/blockActu_1.png');
            $('#tabs-2').attr('src','/public/images/blockActu_2Hover.png');
            $('#tabs-3').attr('src','/public/images/blockActu_3.png');
            if( animencours == 0 )
            {
                animencours = 1;
                clearTimer();
                $(".mooveNews").animate({
                    bottom: tailleMoveSlide+'px'
                    }, vitesseSlide, function(){
                    animencours = 0;
                    sTimer();
                });
            }
        });

       $("." + nomSlide + "3").click(function()
       {
            offPage('p1');
            offPage('p2');
            onPage('p3');
            $('#tabs-1').attr('src','/public/images/blockActu_1.png');
            $('#tabs-2').attr('src','/public/images/blockActu_2.png');
            $('#tabs-3').attr('src','/public/images/blockActu_3Hover.png');
            if( animencours == 0 )
            {
                animencours = 1;
                clearTimer();

                $(".mooveNews").animate({
                    bottom: tailleMoveSlide*2+'px'
                    }, vitesseSlide, function(){
                    animencours = 0;
                    sTimer();
                });
            }
        });

    }

    function mooveNews()
    {
        /*
        * Animation div NEWS
        */
        var tailleMoveSlide = 125;
        var vitesseSlide = 'slow';
        // test si 3eme image
        if( $(".mooveNews").css("bottom") == (tailleMoveSlide * 2) + 'px' )
        {
            // retour 1ere image
            onPage('p1');
            offPage('p2');
            offPage('p3');
            $('#tabs-1').attr('src','/public/images/blockActu_1Hover.png');
            $('#tabs-2').attr('src','/public/images/blockActu_2.png');
            $('#tabs-3').attr('src','/public/images/blockActu_3.png');
            $(".mooveNews").animate({
                bottom: "0px"
            }, vitesseSlide, function(){
                sTimer();
            });
        }
        // test si 3eme image
        else if( $(".mooveNews").css("bottom") == tailleMoveSlide + 'px' )
        {
            offPage('p1');
            offPage('p2');
            onPage('p3');
            $('#tabs-1').attr('src','/public/images/blockActu_1.png');
            $('#tabs-2').attr('src','/public/images/blockActu_2.png');
            $('#tabs-3').attr('src','/public/images/blockActu_3Hover.png');
            $(".mooveNews").animate({
                bottom: tailleMoveSlide*2+'px'
                }, vitesseSlide, function(){
                sTimer();
            });

        }
        else // sinon 2eme image
        {
            offPage('p1');
            onPage('p2');
            offPage('p3');
            $('#tabs-1').attr('src','/public/images/blockActu_1.png');
            $('#tabs-2').attr('src','/public/images/blockActu_2Hover.png');
            $('#tabs-3').attr('src','/public/images/blockActu_3.png');
            $(".mooveNews").animate({
                bottom: tailleMoveSlide+'px'
                }, vitesseSlide, function(){
                sTimer();
            });
        }
    }


    /* GESTION D'ERREURS FORMULAIRE */
    function verifierTelephone(numero)
    {
        /*
         * Name: verifierTelephone
         * Param: Valeur du téléphone
         * Description: Vérifie la syntaxe du téléphone
         */
      var regex = new RegExp(/^[0-9]{10}/gi);
      // Definition de la variable booleene match
      var match = false;
      // Test sur le motif
      if(regex.test(numero)){
        match = true;
      }else{
        match = false;
      }
      // On renvoie match
      return match;
    }

    function verifierMail(email)
    {
        /*
         * Name: verifierMail
         * Param: Valeur du mail
         * Description: Vérifie la syntaxe de l'adresse mail
         */
        var regex = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');
        if(regex.test(email)){
            return(true);
        }else{
            return(false);
        }
    }

    function change_color(elm)
    {
        /*
         * Name: change_color
         * Param: id du champ séléctionné
         * Description: Met en couleur la bordure du champ séléctionné, et remet par défaut les autres sauf en cas d'erreurs.
         */
        if (typeof this.border == 'undefined')
                this.border = 0;
        if (this.border == "0")
        {
                if ($("#txtNom").css('border-left-color') != "rgb(255, 0, 0)")
                        $("#txtNom").css("border-color", "#848484");
                if ($("#txtMail").css('border-left-color') != "rgb(255, 0, 0)")
                        $("#txtMail").css("border-color", "#848484");
                if ($("#txtSociete").css('border-left-color') != "rgb(255, 0, 0)")
                        $("#txtSociete").css("border-color", "#848484");
                if ($("#txtTelephone").css('border-left-color') != "rgb(255, 0, 0)")
                        $("#txtTelephone").css("border-color", "#848484");
                if ($("#txtObjet").css('border-left-color') != "rgb(255, 0, 0)")
                        $("#txtObjet").css("border-color", "#848484");
                if ($("#txtMsg").css('border-left-color') != "rgb(255, 0, 0)")
                        $("#txtMsg").css("border-color", "#848484");
                $("#txtPrenom").css("border-color", "#848484");
                $("#txtAdresse").css("border-color", "#848484");
                $("#txtCodePostal").css("border-color", "#848484");
                $("#txtVille").css("border-color", "#848484");
        }
        this.border = "0";
        if (elm)
        {
                this.border = "1";
                $("#"+elm).css("border-color", "#0157a4");
        }
    }

    function getFileImage(gSrc)
    {
        /*
         * Name: getFileImage
         * Param: chemin de l'image
         * Description: Retourne nom image
         */
        ext = gSrc.substring(gSrc.length-4,gSrc.length);
        gSrc = gSrc.split("/");
        gSrc = gSrc[gSrc.length - 1];
        gSrc = gSrc.substr(0, gSrc.lastIndexOf("."));
        return gSrc;
    }

    function getFileExtension(nomImage)
    {
        /*
         * Name: getFileExtension
         * Param: nom de l'image
         * Description: Retourne l'extension de l'image
         */
        ext = nomImage.substring(nomImage.length-4,nomImage.length);
        return ext;
    }
