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

function changeSecureImage() {
    $("#captcha").attr("src","/wm-public/tools/securimage/securimage_show.php?sid=" + Math.random());
    return false;
}

$(document).ready( function () {

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

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

	$(".gallery li a span").mouseover (
		function () {
			$(this).animate({
				  top: '-16px'
			  }, 200);
			$(this).siblings('img').animate({
				  top: '-6px'
			  }, 200)
		}
	);
	$(".gallery li a span").mouseout (
		function () {
			$(this).animate({
				  top: '5px'
			  }, 300);
			$(this).siblings('img').animate({
				  top: '2px'
			  }, 200)
		}
	);


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

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

    $(".wm-gallery a:nth-child(5n)").addClass("lastColumn");


    $(".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")) {
                $(this).html($(this).attr("hide"));
                $(this).parent().prev(".txt-body").slideDown();
            }
            else {
                $(this).parent().prev(".txt-body").slideUp();
                $(this).html($(this).attr("show"));
            }
        }
    );



});


