/*
 * Fonctions lancées au démarrage
 */

$(document).ready( function () {

    $(".item .btnMore").click(function(){

        rel = $(this).attr("rel");

        $(".item .btnMore").fadeIn();
        $(".contentNews").slideUp();

        $("#News-"+rel).slideDown();
        $("#Btn-"+rel).fadeOut();

    })

    $("#cheques-cadeaux input[type='text']").focus(function()  {if(this.value == this.defaultValue) {this.value = "";}});
    $("#cheques-cadeaux input[type='text']").blur(function()  {if(this.value == "") {this.value = this.defaultValue;}});
    $("#cheques-cadeaux textarea").focus(function()  {if(this.value == this.defaultValue) {this.value = "";}});
    $("#cheques-cadeaux textarea").blur(function()  {if(this.value == "") {this.value = this.defaultValue;}});

    $(".wm-gallery a").lightBox({
        overlayBgColor: "#000",
        containerResizeSpeed: 350,
        txtImage: "",
        txtOf: "/"
    });

    $("a.wm-gallery").lightBox({
        overlayBgColor: "#000",
        containerResizeSpeed: 350,
        txtImage: "",
        txtOf: "/"
    });


    $(".txt-body").hide();
    $(".btnMore a").html($(".btnMore a").attr("show"));
    
    //on regarde si il faut afficher une news en particulier ou la premiere (si on en a pas précisé)
    if ($(".showthatone").length) {
        $(".showthatone .txt-body").show();
        $(".showthatone .btnMore a").html($(".btnMore a").attr("hide"));
    }
    else {
        //$(".txt-body:first").show();
        //$(".btnMore:first a").html($(".btnMore a").attr("hide"));
    }


    $(".btnMore a").click(
        function () {
            if ($(this).html() == $(this).attr("show")) {
                $(".txt-body").slideUp();
                $(".btnMore a").html($(".btnMore a").attr("show"));
                $(this).parent().prev(".txt-body").slideDown();
                $(this).html($(this).attr("hide"));
            }
            else {
                $(this).parent().prev(".txt-body").slideUp();
                $(this).html($(this).attr("show"));
            }
        }
    );



    //cette partie du code gère les "lire la suite" multiple au sein d'une page
    $("a.wm-readmore-multiple").html($("a.wm-readmore-multiple").attr("show"));

    $("a.wm-readmore-multiple").click(
        function () {
            $(this).hide();
            $('.wm-readmore-multiple-hidden:hidden:first').slideDown();
        }
    );



});


