$(document).ready(function(){

	// Menu changement de langue
	$('#langue ul li img').hover(function(){
		$(this).css('cursor', 'pointer');
	});
	var open=false;
	$('#langue ul li img').click(function(){
		langEl = $("#langue ul");
		if(!open){
			langEl.css('background-image', 'url("/img/fond_lang_bis.png")');
			this.src = '/img/f_lang_bis.png';
			this.alt = '^';
			langEl.animate({ height: "63px" }, 'fast');
			open=true;
		}else{
			this.src = '/img/f_lang.png';
			this.alt = 'V';
			langEl.animate({ height: "21px" }, 'fast', '', function(){
				langEl.css('background-image', 'url("/img/fond_lang.png")');
			});
			open=false;
		}
	});
	
	// Nouvelle fenêtre
	$('a.newWindow').click(function(){
		window.open(this.href);
		return false;
	});
	
	// Diaporama Campings et Offres
	if( 0!=$('#s3slider').length ){
		$('#s3slider').s3Slider({
			timeOut: 4000
		});
	}
	
	// Médiathèque
	if( 0!=$('#milieu_mediatheque').length ){
		$('#milieu_mediatheque').jcarousel({
			scroll: 2
		});
		
		$('#milieu_mediatheque img').hover(function(){
			$(this).css('cursor', 'pointer');
		});
		
		$('#milieu_mediatheque img').click(function(){
			var vNav = $.browser.version;
			if($.browser.msie){
				// Chargement en cours...
				$('#video object').remove();
			}
			
			var idYT = $(this).attr('alt');
			var urlYT = 'http://www.youtube.com/v/';
			$('#video object').attr('data', urlYT+idYT);
			$('#video param').attr('value', urlYT+idYT);
			
			if($.browser.msie){
				// Chargement terminé
				var flash = '';
				flash = flash + '<object type="application/x-shockwave-flash" data="'+urlYT+idYT+'">';
				flash = flash + '<param name="movie" value="'+urlYT+idYT+'" />';
				flash = flash + '</object>';
				$('#video').html(flash);
			}
		});
	}
	
	// Map
	if( 0!=$('#map_vendee').length ){
		img = new Image();
		img.src = 'img/carte/carte_bocage.jpg';
		img.src = 'img/carte/carte_epesses.jpg';
		img.src = 'img/carte/carte_larochesuryon.jpg';
		img.src = 'img/carte/carte_lessables.jpg';
		img.src = 'img/carte/carte_littoralnord.jpg';
		img.src = 'img/carte/carte_littoralsud.jpg';
		img.src = 'img/carte/carte_maraisbreton.jpg';
		img.src = 'img/carte/carte_maraispoitevin.jpg';
		img.src = 'img/carte/carte_noirmoutier.jpg';
		
		$('#bocage').hover( 		function(){ $('#map_vendee').attr('src', 'img/carte/carte_bocage.jpg'); 		},function(){} );
		$('#epesses').hover( 		function(){ $('#map_vendee').attr('src', 'img/carte/carte_epesses.jpg'); 		},function(){} );
		$('#larochesuryon').hover( 	function(){ $('#map_vendee').attr('src', 'img/carte/carte_larochesuryon.jpg'); 	},function(){} );
		$('#lessables').hover( 		function(){ $('#map_vendee').attr('src', 'img/carte/carte_lessables.jpg'); 		},function(){} );
		$('#litnord').hover( 		function(){ $('#map_vendee').attr('src', 'img/carte/carte_littoralnord.jpg'); 	},function(){} );
		$('#litsud').hover( 		function(){ $('#map_vendee').attr('src', 'img/carte/carte_littoralsud.jpg'); 	},function(){} );
		$('#maraisbreton').hover( 	function(){ $('#map_vendee').attr('src', 'img/carte/carte_maraisbreton.jpg'); 	},function(){} );
		$('#maraispoitevin').hover( function(){ $('#map_vendee').attr('src', 'img/carte/carte_maraispoitevin.jpg'); },function(){} );
		$('#noirmoutier').hover( 	function(){ $('#map_vendee').attr('src', 'img/carte/carte_noirmoutier.jpg'); 	},function(){} );
	}
});
