﻿
//jquery

$(document).ready(function() {
	$("#contenu p").not(":first").hide();
	$("#contenu>div").not(":first").hide();

	$("ul#nav li").click(function() {
	
		$("#contenu p").hide();
		$("#contenu>div").hide();
	
		var i = $(this).index();
		
		$("#contenu p:eq("+i+")").fadeIn("slow");
		$("#contenu>div:eq("+i+")").fadeIn("slow");
		
	});

	//slideshow
	$("#contenu #slideshow img").not(":first").hide();
	$("#prev").hide();
	$("#next").hide();
	$("#slideshow").hover(
		function () {
					$("#prev").fadeIn("slow");
					$("#next").fadeIn("slow");
		},
		function () {
					$("#prev").fadeOut("slow");
					$("#next").fadeOut("slow");
		}
	
	);
	
	$("#next").click(function() {
		var $currentImg = $("#slideshow img:visible");
		$currentImg.hide();
		$nextImage = $currentImg.next();
		if ($nextImage.length < 1){
				$nextImage = $("#slideshow img:first");
		}
			$nextImage.fadeIn("slow");
	
		return false;
	
	});
		$("#prev").click(function() {
		var $currentImg = $("#slideshow img:visible");
		$currentImg.hide();
		$nextImage = $currentImg.prev();
		if ($nextImage.length < 1){
				$nextImage = $("#slideshow img:last");
		}
			$nextImage.fadeIn("slow");
	
		return false;
	
	});
	function auto() {
		
		$("#slideshow #prev").trigger("click");
	}
	
	
	setInterval(auto,4000);
	
	//selection vin
	$("#contenu #ficheVins img").not(":first").hide();
	$("#prec").hide();
	$("#suivant").hide();
	$("#ficheVins").hover(
		function () {
					$("#ficheVins #prec").fadeIn("slow");
					$("#ficheVins #suivant").fadeIn("slow");
		},
		function () {
					$("#prec").fadeOut("slow");
					$("#suivant").fadeOut("slow");
		}
	
	);
	
	$("#suivant").click(function() {
		var $currentImg = $("#ficheVins img:visible");
		$currentImg.hide();
		$nextImage = $currentImg.next();
		if ($nextImage.length < 1){
				$nextImage = $("#ficheVins img:first");
		}
			$nextImage.fadeIn("slow");
	
		
	
	});
		$("#prec").click(function() {
		var $currentImg = $("#ficheVins img:visible");
		$currentImg.hide();
		$nextImage = $currentImg.prev();
		if ($nextImage.length < 1){
				$nextImage = $("#ficheVins img:last");
		}
			$nextImage.fadeIn("slow");
	
		
	
	});
});
