function returnFalse() { return false; };
nbNews = 4; // POUR LES ACTUALITES
$(document).ready(function(){	
	
	
  $(function() { $(".lavaLamp").lavaLamp({ fx: "easeOutExpo", speed: 700 })});
	
	var versionNav = navigator.appVersion;
	if ((navigator.appName == 'Microsoft Internet Explorer') && (versionNav.search('MSIE 6')))	
 	{
		$('.lavaLamp li.back').css('background','url("salon-des-vins/lava.gif") no-repeat 30% 0');	
		
		$('#menu .sousMenuPresentationSDV').css('margin','50px 0 0 -170px');		
		$('#menu .sousMenuInfosPratiquesSDV').css('margin','50px 0 0 -405px');		
		$('#menu .sousMenuExposantsSDV').css('margin','50px 0 0 -295px');		
	}

	if ((screen.height > 700) && !((navigator.appName == 'Microsoft Internet Explorer') && versionNav.search('MSIE 6')))	
 	{
		$('#bottomBouteille').css('bottom',0);
		$('#bottomBouteille').css('position','fixed');
		
	}

	if ((navigator.appName == 'Microsoft Internet Explorer') && (versionNav.search('MSIE 8')))	
	{
		$('#menu .sousMenuPresentationSDV').css('margin','50px 0 0 -120px');		
		$('#menu .sousMenuInfosPratiquesSDV').css('margin','50px 0 0 -355px');		
		$('#menu .sousMenuExposantsSDV').css('margin','50px 0 0 -245px');		
	}
 
	/* -++-+-+-+-+-+-+- CONTACT FORM +-+-+-++-+-+- */

	$('#submit .button').bind('click', returnFalse);
	var nom = false;
	var prenom = false;	
	var emailFrom = false;
	var postal = false;
	
	$('#txtName').blur(function(){
		if ($('#txtName').val() == '')
		{
			$('#alertName').append('<p class="red">* Veuillez indiquer votre nom </p>');
			nom = false;
		}
		else {
			$('#alertName').append('<p class="green">* Nom renseigné </p>');	
			nom = true;
		}		

		if (emailFrom && nom && prenom && postal)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});

	$('#txtFirstName').blur(function(){
		if ($('#txtFirstName').val() == '')
		{
			$('#alertFirstName').append('<p class="red">* Veuillez indiquer votre prénom </p>');
			prenom = false;
		}
		else {
			$('#alertFirstName').append('<p class="green">* Prénom renseigné </p>');	
			prenom = true;
		}		

		if (emailFrom && nom && prenom && postal)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});



	$('#txtPostal').blur(function(){
		if ($('#txtPostal').val() == '')
		{
			$('#alertPostal').append('<p class="red">* Veuillez indiquer le code postal</p>');	
			postal = false;
		}
		else {
			$('#alertPostal').append('<p class="green">* Code postal renseigné</p>');	
			postal = true;
		}		

		if (emailFrom && nom && prenom && postal)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});

	var filter=/^.+@.+\..{2,3}$/;
	$('#txtEmailFrom').blur(function(){
		if ($('#txtEmailFrom').val() == '')
		{
			$('#alertEmailFrom').append('<p class="red">* Veuillez indiquer votre email</p>');	
			emailFrom = false;
		}
		else if (filter.test($('#txtEmailFrom').val())) {
			$('#alertEmailFrom').append('<p class="green">* Email valide</p>');	
			emailFrom = true;
		}
		else {
			$('#alertEmailFrom').append('<p class="orange">* Veuillez indiquer une adresse email valide svp</p>');	
			emailFrom = false;
		}		
		
		if (emailFrom && nom && prenom && postal)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});

	$('#txtEmailFrom').focus(function(){
		$('#alertEmailFrom').empty();	
	});	
	
	$('#txtName').focus(function(){
		$('#alertName').empty();	
	});		

	$('#txtFirstName').focus(function(){
		$('#alertFirstName').empty();	
	});		

	$('#txtPhone').focus(function(){
		$('#alertPhone').empty();	
	});	

	$('#txtAddress').focus(function(){
		$('#alertAddress').empty();	
	});	

	$('#txtPostal').focus(function(){
		$('#alertPostal').empty();	
	});	

	$('#txtCity').focus(function(){
		$('#alertCity').empty();	
	});	
	

	$('#submit .button').click(function(){
		if (emailFrom && nom && prenom && postal)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	 
	});	
	
		
 /* FIN CONTACT */

	var hauteurBody = $('#footer').offset().top + 100;
	
	$('#bottomH1').css('margin-top', hauteurBody);
	


// +-+-+-+-+-+-+-+- TOP IMAGE 	

	var currentTopImage = $('#imageTopImage01');

	var direction = 'next';
	var timer = setInterval (function () {
	
		if (currentTopImage.attr('id') != undefined )
		{		
			
			//alert(currentTopImage.prev('.imageTopImage').attr('class'));
				if ((currentTopImage.next('.imageTopImage').attr('class') == undefined) || ((direction == 'previous') && (currentTopImage.prev('.imageTopImage').attr('class') != undefined)))
			{
				
				
				currentTopImage = currentTopImage.prev('.imageTopImage'); 
				id = currentTopImage.attr('id');
				id = id.substring(id.length - 2, id.length);	 
				currentTopImage.show(function(){currentTopImage.fadeTo('slow', 1);});
				$('#legende div').fadeTo('fast', 0);
				$('#legendeGallery div').fadeTo('fast', 0);
				$('#legende'+id).fadeTo('slow', 1);
				direction = 'previous';
			}
			else
			{
				
				currentTopImage.fadeTo('slow', 0, function(){$(this).hide();});
				currentTopImage = currentTopImage.next('.imageTopImage');
				id = currentTopImage.attr('id');
				id= id.substring(id.length - 2, id.length);
				$('#legende div').fadeTo('fast', 0);
				$('#legendeGallery div').fadeTo('fast', 0);
				$('#legende'+id).fadeTo('slow', 1);
				direction = 'next'; 
				
				
			}
		}
		
	}, 4500 );
	
	
// +-+-+-+-+-+- LIST PAGE

			$('.textItem').hide();
			$('#item1').slideDown('slow');
			$('#items h3').click(function() {

				if ($(this).next('.textItem:visible').length != 0)
				{
					$('.textItem').stop().slideUp('fast');
					$(this).next('.textItem').stop().slideUp('slow');
				}			
				else 
				{
					$('.textItem').stop().slideUp('fast');
					$(this).next('.textItem').stop().slideDown('slow');
				}
			});
			
			
			
// +-+-+-+-+-+-+- CARTE DES EXPOSANTS
	$('.lienCarte img').bind('click', returnFalse);
	$('.lienCarte').bind('mouseenter', function() { 
		$('.legendeCarte').slideUp('fast', 'easeOutExpo');										
		$(this).next('img').attr('src','salon-des-vins/repere-carte-over.png');
		$(this).next('.legendeCarte').slideDown('slow', 'easeOutExpo');
	});
	
	/* $('.lienCarte').bind('mouseleave', function() { 
		$('.lienCarte img').attr('src','salon-des-vins/repere-carte.png');
		$('.legendeCarte').slideUp('fast', 'easeOutExpo');
	
	}); */
	
	
	
	$('.lavaLamp li.presentationSDV').stop().bind('mouseenter', function() {
		$('.sousMenuPresentationSDV').fadeIn(500);										  
	});
	$('.lavaLamp li.presentationSDV').stop().bind('mouseleave', function() {
		$('.sousMenuPresentationSDV').fadeOut(500);										  
	});
	
	
	$('.lavaLamp li.infosPratiquesSDV').stop().bind('mouseleave', function() {
		$('.sousMenuInfosPratiquesSDV').fadeOut(500);										  
	});
	
	$('.lavaLamp li.infosPratiquesSDV').stop().bind('mouseenter', function() {
		$('.sousMenuInfosPratiquesSDV').fadeIn(500);										  
	});
	
	$('.lavaLamp li.ExposantsSDV').stop().bind('mouseenter', function() {
		$('.sousMenuExposantsSDV').fadeIn(500);										  
	});
	$('.lavaLamp li.ExposantsSDV').stop().bind('mouseleave', function() {
		$('.sousMenuExposantsSDV').fadeOut(500);										  
	});
	


/* CONTACT LETTRE INFO COLONNE CAUCHE */

	$('#submitLettreInfo').bind('click', returnFalse);	
	var nomLettreInfo = false;
	var emailLettreInfo = false;


	$('#txtNomLettreInfo').blur(function(){
		if ($('#txtNomLettreInfo').val() == '')
		{
			//$('#alertNomLettreInfo').append('<p class="red">* Veuillez indiquer vos nom et prénom </p>');
			nomLettreInfo = false;
		}
		else {
			//$('#alertNomLettreInfo').append('<p class="green">* Champ nom et prénom valide </p>');	
			nomLettreInfo = true;
		}		

		if (emailLettreInfo && nomLettreInfo)
		{
			$('#submitLettreInfo').unbind('click', returnFalse);
		}	
	});


	var filter=/^.+@.+\..{2,3}$/;
	$('#txtEmailLettreInfo').blur(function(){
		if ($('#txtEmailLettreInfo').val() == '')
		{
			//$('#alertEmailLettreInfo').append('<p class="red">* Veuillez indiquer votre email</p>');	
			emailLettreInfo = false;
		}
		else if (filter.test($('#txtEmailLettreInfo').val())) {
			//$('#alertEmailLettreInfo').append('<p class="green">*  Champ email complet</p>');	
			emailLettreInfo = true;
		}
		else {
			//$('#alertEmailLettreInfo').append('<p class="orange">* Rentrer une adresse email valide svp</p>');	
			emailLettreInfo = false;
		}		
		
		if (emailLettreInfo && nomLettreInfo)
		{
			$('#submitLettreInfo').unbind('click', returnFalse);
		}	
	});
	
	
/* FIN CONTACT LETTRE INFO COLONNE GAUCHE */

});

