$(document).ready(function(){
   resizeBackground();
 });

$(window).resize(function() {
  
  resizeBackground();
});

function resizeBackground()
{
	console.log($(window).width());
	if($(window).width() >= 1900)
	{
		$("#background img").css("width","100%");
		$("#background").css("width",$("#footer").width());
		//$("#background img").css("left", ($(window).width()/2)-(1900/2));
		$("#background img").css("left", 0);
	}
	else
	{
		$("#background").css("width",$("#footer").width());
		$("#background img").css("width",1900);
		if($(window).width() >= 974) $("#background img").css("left", ($(window).width()/2)-(1900/2));
	}

}

		$(document).ready(function() {
			
			$(".iframe").fancybox({
				'width'				: 680,
				'height'			: 455,
				'autoScale'			: false,
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',
				'type'				: 'iframe'
			});

		});


$(document).ready(function(){
$('#dropdown_marche').hide();	
$('#menu_marche').hover(function() {
	$('#dropdown_marche').fadeIn(100);
	$('#menu_marche').mouseleave(function() {$('#dropdown_marche').fadeOut(100);});
});
$('#dropdown_restaurant').hide();	
$('#menu_restaurant').hover(function() {
	$('#dropdown_restaurant').fadeIn(100);
	$('#menu_restaurant').mouseleave(function() {$('#dropdown_restaurant').fadeOut(100);});
});
$('#dropdown_motel').hide();	
$('#menu_motel').hover(function() {
	$('#dropdown_motel').fadeIn(100);
	$('#menu_motel').mouseleave(function() {$('#dropdown_motel').fadeOut(100);});
});



$('.product_box').mouseenter(function(e,o) {
	
	if($(e.currentTarget).is(":animated")) return;
	
	var div = $(e.currentTarget).find(".product_black");
	var div2 = $(e.currentTarget).find(".product_choisir");

	$('.product_box').find(".product_black").each(function(index,el){
	
	if($(el).css("opacity") < 0.4 || $(el).is(":animated"))$(el).animate({opacity: 0.5},{queue:false,duration:500});
	
	});
	
	$(div2).animate({opacity: 1},{queue:false,duration:600});
	$(div).animate({opacity: 0},{queue:false,duration:500});	
	
});

$('.product_box').mouseleave(function(e,o) {
	
	//var div = e.currentTarget;
	//$(div).find(".product_black").animate({opacity: 0}, 500);
	
	$('.product_box').find(".product_black").animate({opacity: 0}, {queue:false,duration:500});
	$('.product_box').find(".product_choisir").animate({opacity: 0}, {queue:true,duration:400});
	
	//$(o + ' .product_black').animate({background: "url(images/btn_choisir_produit.png) no-repeat",} 500);
});
});
