$(document).ready(function(){

	resize_background_image();

	// menu accueil
	if($(".blocAccueil"))
	{
		var duree = 400;
		var effect = 'easeInSine';
		$(".blocAccueil").hover(
		function(){
		   var hauteur = 0;
			$(".ssMenu li", this).each(function(i){
				hauteur += $(this).height();
			});
			$(".titreVisu", this).stop().animate({top:(hauteur+9)+'px'},{duration: duree,easing: effect});
			$(".ssMenu", this).stop().animate({height:hauteur+'px'},{duration: duree, easing: effect});
		},
		function(){
			$(".titreVisu", this).stop().animate({top:'9px'},{duration: duree,easing: effect});
			$(".ssMenu", this).stop().animate({height:'40px'},{duration: duree, easing: effect});
		});
	}
	
	//menu autres pages
	if($("#menu"))
	{
		var duree = 400;
		var effect = 'easeInSine';
		$("#menu li").hover(
		function(){
		   var hauteur = 0;
			$(".ssMenu li", this).each(function(i){
				hauteur += $(this).height();
			});
			$(".titreVisu", this).stop().animate({top:(hauteur+9)+'px'},{duration: duree,easing: effect});
			$(".ssMenu", this).stop().animate({height:hauteur+'px'},{duration: duree, easing: effect});
		},
		function(){
			$(".titreVisu", this).stop().animate({top:'9px'},{duration: duree,easing: effect});
			$(".ssMenu", this).stop().animate({height:'40px'},{duration: duree, easing: effect});
		});
	}

	$(".survolTourisme").hover(function(){
		$("a img",this).attr({src:"images/titre-tourisme-hover.gif"}); 
	},
		function(){
		$("a img",this).attr({src:"images/titre-tourisme.gif"});
	});

	if($("#gauche"))
	{
		$("#gauche").hover(function(){
		$("a img",this).attr({src:"images/titre-tourisme-hover.gif"}); 
		},
			function(){
			$("a img",this).attr({src:"images/titre-tourisme.gif"});
		});
	}
	
});

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

/*$(window).ready(function(){
	$('#visuel1').idwebFade({
		elements: '#visuel1 span',
		effet_in: {
			opacity: '1'
		},
		effet_out: {
			opacity: '0'
		}
	});

	$('#visuel2').idwebFade({
		duree_transition : 4300,
		elements: '#visuel2 span',
		effet_in: {
			opacity: '1'
		},
		effet_out: {
			opacity: '0'
		}
	});

	$('#visuel3').idwebFade({
		duree_transition : 5100,
		elements: '#visuel3 span',
		effet_in: {
			opacity: '1'
		},
		effet_out: {
			opacity: '0'
		}
	});
});*/

// fond sur toute la page suivant le redimensionnement
function resize_background_image()
{	
	var bg = $('#fond-image img');
	
	var ratio = 1280/831;
		
	$(bg).width($(window).width());
	$(bg).height($(window).width() / ratio);
	
	if ($(bg).height() < $(window).height()) {
		$(bg).height($(window).height());
		$(bg).width($(window).height() * ratio);
	}

	position_pied();

}

// position le pied d epage en bas de page
function position_pied()
{
	var withBrowser = $(window).width();
	var heightBrowser = $(window).height();
	var heightGlobal = $('#global').height();

	var marge = ((withBrowser-995)/2)+7;

	$('#pied').css('right',marge+'px');

	// si le contenu est plus grand que le navigateur
	if(heightBrowser<heightGlobal+64)
		$('#pied').css('top',(heightGlobal+44)+'px');	
	else
		$('#pied').css('top','');
}

