$(document).ready(function(){

    // gestion des delai setimeout
    $.fn.delay = function(time, callback){
        jQuery.fx.step.delay = function(){};
        return this.animate({
            delay:1
        }, time, callback);
    }
	
    // gestion des value input
    $('.inp-value').click(
        function() {
            if (this.value == this.defaultValue) {
                this.value = '';
            }
        })
    .blur(
        function() {
            if (this.value == '') {
                this.value = this.defaultValue;
            }
        }
        );
	
    // gestion des block droite accordeon
    $('.encart-titre').click(function () {
        $(this).parent().find('.block-toggle').slideToggle();
        $(this).toggleClass('selected');
    });
    $('.encart-titre').hover(function(){
        $(this).addClass('hover');
    },function(){
        $(this).removeClass('hover');
    });
	
    $('#fil li::last-child').css("font-weight","bold");


    //gestion accordeon formulaire
    $('#titre-encart-comm').click(function () {
        $(this).parent().find('.form-comm').slideToggle();
    });

    //gestion ouvre form repondre
    $('.link-rep-comm').click(function () {
        $('.form-comm').delay(700).slideDown('slow');
        $("#encart-commentaire").scrollTo(500);
        return false;
    });

    blockCliquable();

    $('a#imprim').click(
        function(){
            window.print();
            return false;
        }
        );	
		
});

// gestion des block clickable
function blockCliquable(){

    $('.block-hover').hover(function(){
        $(this).addClass('hover');
        $(this).find('.picto p').addClass('selected');
    },function(){
        $(this).removeClass('hover');
        $(this).find('.picto p').removeClass('selected');
    });

    $(".block-hover").click(function(){
        var link = $(this).find("a");
        var target = link.attr('target');
        if(target == '')
            target = '_self';
        window.open(link.attr('href'),target);
        return false;
    });

}

(function($) {
    $.scrollToElement = function( $element, speed ) {

        speed = speed || 750;

        $("html, body").animate({
            scrollTop: $element.offset().top,
            scrollLeft: $element.offset().left
        }, speed);
        return $element;
    };

    $.fn.scrollTo = function( speed ) {
        speed = speed || "normal";
        return $.scrollToElement( this, speed );
    };
})(jQuery);












