
function resizeBg() {
	var bg = $('.bg-resize');
		var imgW = $(bg).width();
		var imgH = $(bg).height();
		var ratio = imgW / imgH;
		var w = $(window).width();
		var h = $(window).height();
	
		if ((w/h) > ratio) {
			$(bg).width("100%");
			$(bg).height("");
		} else {
			$(bg).width("");
			$(bg).height("100%");
		}
}
setInterval('resizeBg()', 100);

	
	function resizeBloc(){
		$('.article').each(function(){
			var $prevArticle = $(this).prev('.article');
			var $nextArticle = $(this).next('.article');
			var $this = $(this);
		   	var heightThis = $this.innerHeight();
			var heightPrev = $prevArticle.innerHeight();
			
			if($this.is(".paire")){
				if (heightThis < heightPrev){
					$this.height(heightPrev-44);
				}
				else if(heightThis > heightPrev){
					$prevArticle.height(heightThis-44);
				}
			}
		 });
	}
	setInterval('resizeBloc()', 100);

$(document).ready(function(){
	// menu top
	$('#nav-top .two-level').hover(function(){
			$(this).find('.sous-nav').filter(':not(:animated)').slideDown('fast');
	 },function(){
	   		$(this).find('.sous-nav').slideUp('fast');
	 });

	// form nav top
	$('#nav-rechercher').hover(function(){
		$(this).addClass('hover');
	},function(){
		$(this).removeClass('hover');
	});

	$("#nav-rechercher").click(function(){
		$('#moteur_recherche').slideToggle('fast');
		$(this).toggleClass('selected');
		return false;
	});

/*	
	$('#inp-text-recherche').click(
		function() {
			if (this.value == this.defaultValue) {
				this.value = '';
			}
		})
	.blur(
		function() {
			if (this.value == '') {
				this.value = this.defaultValue;
			}
		}
	);
*/


	// bloc hover
	$('.block-hover').hover(function(){
		$(this).addClass('hover');
	},function(){
		$(this).removeClass('hover');
	});
	
	// resize des bloc article

	$(".block-click").click(function(){
		window.location=$(this).find("a").attr("href");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);













