$(document).ready(function() {
/*********************************************************MENU**********************************************************************************/

	$('#menu ul li a').mouseenter(function(){		
		$(this).parent('li').css({ background: 'url("images/web/menu_left.png") no-repeat left 1px'});
	});
	
	$('#menu ul li a').mouseleave(function(){		
		$(this).parent('li').css({ background: 'none'});
		$(this).parent('.currentpage').css({ background: 'url("images/web/menu_left.png") no-repeat left 1px'});
	});
	
/**********************************************************MENU-FOOTER***********************************************************************/

	$('#direct-link').mouseenter(function(){
		if ($('#in-footer-top').is(':visible'))
		{
			$(this).css({ backgroundPosition: '-67px 2px', width: '19px', height: '0px' });
			$('#in-footer-top').slideToggle('200');
		}
		else
		{
			$(this).css({ backgroundPosition: '0 -61px', width: '145px', height: '50px' });
			$('#in-footer-top').slideToggle('200');
		}
	});
	
/********************************************************BOUTONS*********************************************************************************/
	if($("#decouvertes").length > 0)
	{
		$('#decouvertes ul #menus').mouseenter(function(){		
			$(this).css({ backgroundPosition: '0 -46px'});
			$(this).children("a").css({ textDecoration: 'underline'});
		});
		
		$('#decouvertes ul #menus').mouseleave(function(){		
			$(this).css({ backgroundPosition: '0 0'});
			$(this).children("a").css({ textDecoration: 'none'});
		});
		
		$('#decouvertes ul #vins').mouseenter(function(){		
			$(this).css({ backgroundPosition: '-200px -46px'});
			$(this).children("a").css({ textDecoration: 'underline'});
		});
		
		$('#decouvertes ul #vins').mouseleave(function(){		
			$(this).css({ backgroundPosition: '-200px 0'});
			$(this).children("a").css({ textDecoration: 'none'});
		});
		
		$('#decouvertes ul #reservation').mouseenter(function(){		
			$(this).css({ backgroundPosition: '-400px -46px'});
			$(this).children("a").css({ textDecoration: 'underline'});
		});
		
		$('#decouvertes ul #reservation').mouseleave(function(){		
			$(this).css({ backgroundPosition: '-400px 0'});
			$(this).children("a").css({ textDecoration: 'none'});
		});
	}
	
	if($(".content-cartes #content-right ul").length > 0)
	{
		$('.content-cartes #content-right ul li.vins').mouseenter(function(){		
			$(this).css({ backgroundPosition: '-281px 0'});
			$(this).children("a").css({ textDecoration: 'underline'});
		});
		
		$('.content-cartes #content-right ul li.vins').mouseleave(function(){		
			$(this).css({ backgroundPosition: '0 0'});
			$(this).children("a").css({ textDecoration: 'none'});
		});
		
		$('.content-cartes #content-right ul li.menus').mouseenter(function(){		
			$(this).css({ backgroundPosition: '-281px -46px'});
			$(this).children("a").css({ textDecoration: 'underline'});
		});
		
		$('.content-cartes #content-right ul li.menus').mouseleave(function(){		
			$(this).css({ backgroundPosition: '0 -46px'});
			$(this).children("a").css({ textDecoration: 'none'});
		});
		
		$('.content-cartes #content-right ul li.galerie').mouseenter(function(){		
			$(this).css({ backgroundPosition: '-281px -92px'});
			$(this).children("a").css({ textDecoration: 'underline'});
		});
		
		$('.content-cartes #content-right ul li.galerie').mouseleave(function(){		
			$(this).css({ backgroundPosition: '0 -92px'});
			$(this).children("a").css({ textDecoration: 'none'});
		});
	}

/**************************************************************GALLERY***********************************************************************/	
	
	if($("#content-gallery").length > 0)
	{
		$('#content-gallery #content-left #menu-gallery ul li').prepend('<span class="puce">&nbsp;</span>');
			
		$("#slider").easySlider({
			prevText: '&nbsp;',
			nextText: '&nbsp;',
			auto: true,
			continuous: true,
			speed: 1000,
			pause: 4000
		});
	}
	
	if($("#wrapper-home").length > 0)
	{			
		$('.slideshow').cycle({
			fx: 'scrollHorz',
			speed: 1500,
			timeout: 4000,
			next:   '#next', 
			prev:   '#prev'
		}); 
	}
	
	if($("#gallery ul li").length > 0)
	{
		$('#gallery ul li').opacityrollover();
		$("#gallery ul").quickPager({pageSize: 16});	
	}
	
	
	

/**************************************************************NEWSLETTER***********************************************************************/	

	if($(".newsletterOK").length > 0)
	{	
		alert("Merci ! Votre formulaire a ete recu.");
	}

});


/**************************************************************CARTE***********************************************************************/	

$(window).load(function() {
	if($(".content-cartes").length > 0)
	{	
		$(".produit").each(function(i){
			var $w = $(this).width();
			var $wname = $(this).children('span.name').width();
			var $wprice = $(this).children('span.price').width();
			var $weuro = $(this).children('span.euro').width();
			var $marge = "12";
			var $wdot = $w - $wname - $wprice - $weuro - $marge;
			
			$(this).children('span.pointille').css({ paddingRight: $wdot});
		});
	}
});
