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



$(document).ready(function() {


    /* si le titre de la ville dans les réalisations est trop long, on le rétrécit pour caser tout le texte */
    var town = $('.slide_label');
	for(var i=0; i < town.length; i++) {
		if (town[i].html().length > 10) 
			town[i].css('font-size','16px');
		if (towni[i].html().length > 20) 
			town[i].css('font-size','12px');
    }


    
    $(".navHorz #frm_tri").change(function(){
        
        $("#filter").submit();
        
    })
    
    $(".navHorz #frm_filtre").change(function(){
        
        $("#filter").submit();
        
    })
    
    $("#search").focus(function()  {if(this.value == this.defaultValue) {this.value = "";}});
    $("#search").blur(function()  {if(this.value == "") {this.value = this.defaultValue;}});

    $("#frm_captcha").focus(function()  {if(this.value == this.defaultValue) {this.value = "";}});
    $("#frm_captcha").blur(function()  {if(this.value == "") {this.value = this.defaultValue;}});

    $("#inscription").click(function(){

        $("ge-search-form").submit();

    })
	
	
	/* marginRightNone : on supprime la marge droit dans la derni�re colonne
	---------------------------------------------------------------------------- */
	// lastNews
        $(".news li:nth-child(3n)").addClass("marginRightNone");
        
        $("#surface span:last").addClass("marginBottomNone");
        
	
	// gallery
    $(".gallery ul li a:nth-child(3n)").addClass("marginRightNone");
	
	
	
	/* HOVER 
	--------------------------------------------------------- */
	//mouseover
    $(".hover").parent("a").mouseover (

            function () {
                    $(this).children(".hover").animate({
                             "opacity": ".75"
                    }, 300);
            }
    );
    //mouseout
    $(".hover").parent("a").mouseout (
            function () {
                    $(this).children(".hover").animate({
                             "opacity": "0"
                    }, 400);
            }
    );
	
	
	/* Effet sur vignette (.thumbs img)
	--------------------------------------------------------- */
	$(".thumbs li a").hover(			
		function () { 
			if ( $(this).isHover = true) {
				$(this).children(".visual").children("img").animate({"opacity": ".3"}, 300);
				$(this).children(".visual").children("img").clearQueue();
			}
		},
		function () { 
			if ( $(this).isHover = true) {
				$(this).children(".visual").children("img").animate({"opacity": "1" }, 500);
				$(this).children(".visual").children("img").clearQueue();
			}
		}
	)
	




    /*Reinitialisation de la fancBox
	--------------------------------------------------------- */
    $("a[rel=gallery_link]").fancybox({
									  
			'padding' : 10,
			'margin' : 40,
			'opacity' : false,
			'modal' : false,
			'cyclic' : false,
			'scrolling' : 'auto',	//*'auto', 'yes' or 'no'
	
			'width' : 560,
			'height' : 340,
	
			'autoScale' : true,
			'autoDimensions' : true,
			'centerOnScroll' : false,
	
			'ajax' : {},
			'swf' : { wmode: 'transparent' },
	
			'hideOnOverlayClick' : true,
			'hideOnContentClick' : false,
	
			'overlayShow' : true,
			'overlayOpacity' : 0.8,
			'overlayColor' : '#fff',
	
			'titleShow' : true,
			'titlePosition' : 'float', // 'float', 'outside', 'inside' or 'over'
			'titleFormat' : 
				function(title, currentArray, currentIndex, currentOpts) {
                    return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? '' : '') + '</span>';
            	}, //null
	
			'transitionIn' : 'fade', // 'elastic', 'fade' or 'none'
			'transitionOut' : 'fade', // 'elastic', 'fade' or 'none'
	
			'speedIn' : 200,
			'speedOut' : 200,
	
			'changeSpeed' : 300,
			'changeFade' : 'fast',
	
			'easingIn' : 'swing',
			'easingOut' : 'swing',
	
			'showCloseButton	' : true,
			'showNavArrows' : true,
			'enableEscapeButton' : true,
			'enableKeyboardNav' : true,
									  			
			onStart : function(){},
			onCancel : function(){},
			onComplete : function(){},
			onCleanup : function(){},
			onClosed : function(){},
			onError : function(){}
            
    });

});	
