$(document).ready(function(){	
	$(window).resize(function(){
		centrageVertical2();
	});
	// ================== Menu
	$("#vins").hover(function(){ 
       $("#menu-vins").show(); 
    },function(){ 
       $("#menu-vins").hide(); 
    }); 

	$("#contact").hover(function(){ 
       $("#menu-contact").show(); 
    },function(){ 
       $("#menu-contact").hide(); 
    }); 

	$("#domaine").hover(function(){ 
       $("#menu-domaine").show(); 
    },function(){ 
       $("#menu-domaine").hide(); 
    }); 

	$("#actualites").hover(function(){ 
       $("#menu-actualites").show(); 
    },function(){ 
       $("#menu-actualites").hide(); 
    }); 

	$('#diaporama a.diapo').lightBox();

	$(".sousMenu").hover(function(){ 
       $(this).show(); 
	   var id = $(this).attr("id").substring(5);
	   $("#" + id).addClass("actif");
    },function(){ 
		var id = $(this).attr("id").substring(5);
       $(this).hide(); 
	   $("#" + id).removeClass("actif");
    }); 
	// =================== Menu
	
	// =================== Vins
	$(".savoirPlus").hide();
	$(".vinsBouteilles").hover(function(){
		var idvins = $(this).attr("id");
		$("#vins-" + idvins).show();
	},function(){
		var idvins = $(this).attr("id");
		$("#vins-" + idvins).hide();		
	});
	// =================== Vins

	// Slideshow
	if ($('#slideshow').length) setInterval( "slideSwitch('#slideshow')", 5000 );
	if ($('#slideshow2').length) setInterval( "slideSwitch('#slideshow2')", 5000 );

});


/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/
function slideSwitch(div) {
    var $active = $(div+' img.active');

    if ( $active.length == 0 ) $active = $(div+' img:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $(div+' img:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function validForm(monform){
	var reg_email = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/;

	if (monform.nom.value=="")
	{
		alert("Merci de saisir un nom !");
		monform.nom.focus();
		return(false);
	}

	if (monform.prenom.value=="")
	{
		alert("Merci de saisir un prénom !");
		monform.prenom.focus();
		return(false);
	}

	if(!reg_email.test(monform.email.value))
	{
		alert("Le format de votre adresse email est invalide !");
		monform.email.focus();
		return false;
	}
}

// CENTRAGE VERTICALES ======================
function centrage(){
	centrageVertical();
	$(window).resize(function() {
		centrageVertical();
	});
}

// centrage vertical pour résolutions > 800*600
function centrageVertical(){
    hauteurPage = document.getElementById("repere").offsetTop + 1;
    hauteurContenu = 700;
    
    if(hauteurPage > hauteurContenu){
            difference = hauteurPage - hauteurContenu;
            document.body.style.paddingTop = (difference/2) +"px";
    }
    else{
            document.body.style.paddingTop = 0;
    }
}
	
function centrageVertical2()	{
        hauteurPage = document.getElementById("repere").offsetTop + 1;
        hauteurContenu = 700;
        
        if(hauteurPage > hauteurContenu)        {
                difference = hauteurPage - hauteurContenu;
                document.body.style.paddingTop = (difference/2) +"px";
        }
        else{
                document.body.style.paddingTop = 0;
        }
}
// CENTRAGE VERTICALES ======================
