// ----------------- animation des traces  ------------------- //
function anim(numero)
{
	$('#traces img').eq(numero).show()
}


$(document).ready(function()
{
	
	
		// ----------------- masque les éléments au chargement  ------------------- //
	
	
	$('#traces img').hide();$('.sous-infos').css("height",'0px');$('.sous-contact').css("height",'0px');$('.sous-snv').css("height",'0px');


	
	$("#programme-container").hide();
	
	$("a.popop").fancybox({
	'autoDimensions'	: false,
	'width' 		: '800',
	'height'		: '600'
});

	
$('#menu-infos').hover(
  function () {
	    $('.sous-contact').stop(true, true);
	 $('.sous-contact').css("height",'0px');
	     $('.sous-snv').stop(true, true);
	 $('.sous-snv').css("height",'0px');
	  $('.sous-infos').stop(true, true);
    $('.sous-infos').animate({ height: "40px" }, 200 )

  }, 
  function () {
	$( ".sous-infos" ).animate( { height: "40px" }, { queue: true, duration: 1000 })
     .animate({ height: "0" }, 200 );
  }
);

$('.sous-infos').hover(
  function () {
    $('.sous-infos').stop(true, true);
  }, 
  function () {
	
	$( ".sous-infos" ).animate( { height: "40px" }, { queue: true, duration: 1000 })
     .animate({ height: "0" }, 200 );
  
  }
);



$('#menu-contact').hover(
  function () {
	  $('.sous-infos').stop(true, true);
	 $('.sous-infos').css("height",'0px');
	   $('.sous-snv').stop(true, true);
	 $('.sous-snv').css("height",'0px');
	  $('.sous-contact').stop(true, true);
    $('.sous-contact').animate({ height: "40px" }, 200 )

  }, 
  function () {
	$( ".sous-contact" ).animate( { height: "40px" }, { queue: true, duration: 1000 })
     .animate({ height: "0" }, 200 );
  }
);

$('.sous-contact').hover(
  function () {
    $('.sous-contact').stop(true, true);
  }, 
  function () {
	
	$( ".sous-contact" ).animate( { height: "40px" }, { queue: true, duration: 1000 })
     .animate({ height: "0" }, 200 );
  
  }
);




$('#menu-snv').hover(
  function () {
	  $('.sous-infos').stop(true, true);
	 $('.sous-infos').css("height",'0px');
	  $('.sous-contact').stop(true, true);
	 $('.sous-contact').css("height",'0px');
	  $('.sous-snv').stop(true, true);
    $('.sous-snv').animate({ height: "40px" }, 200 )

  }, 
  function () {
	$( ".sous-snv" ).animate( { height: "40px" }, { queue: true, duration: 1000 })
     .animate({ height: "0" }, 200 );
  }
);

$('.sous-snv').hover(
  function () {
    $('.sous-snv').stop(true, true);
  }, 
  function () {
	
	$( ".sous-snv" ).animate( { height: "40px" }, { queue: true, duration: 1000 })
     .animate({ height: "0" }, 200 );
  
  }
);






$('.faq dd').hide();

$('dt a').toggle(
  function () {
    $(this).parents('dt').next('dd').slideDown();
	$(this).html('Masquer la réponse');
	return false;
  }, 
  function () {
	$(this).parents('dt').next('dd').slideUp();
	$(this).html('Lire la réponse');
  return false;
  }
);
	
	// ----------------- jParallax  ------------------- //
	
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
	 
}else{

	
	
	$('#test').jparallax({mouseport: $('html')}, {height: 232}, {width: 320});}
	
	


	// ----------------- animation des traces  ------------------- //
	
	setTimeout('anim(0)',500);
	setTimeout('anim(1)',1000);
	setTimeout('anim(2)',1500);
	setTimeout('anim(3)',2000);
	setTimeout('anim(4)',2500);
	setTimeout('anim(5)',3000);
	setTimeout('anim(6)',3500);
	setTimeout('anim(7)',4000);
	setTimeout('anim(8)',4500);
	setTimeout('anim(9)',5000);
	setTimeout('anim(10)',5500);
	
	
	// ----------------- titre des champs textes qui disparait en cliquant dedans ------------------- //
		
		function switchText()
			{
				if ($(this).val() == $(this).attr('title'))
					$(this).val('').removeClass('exampleText');
				else if ($.trim($(this).val()) == '')
					$(this).addClass('exampleText').val($(this).attr('title'));
			}
			$('input[type=text][title!=""]').each(function() {
				if ($.trim($(this).val()) == '') $(this).val($(this).attr('title'));
				if ($(this).val() == $(this).attr('title')) $(this).addClass('exampleText');
			}).focus(switchText).blur(switchText);




	// ----------------- shop ------------------- //





$(".cady").click(function() {
						  
						  var stock = $(this).parents('tr').find('td.stock').html();
						    var qte = $(this).parents('tr').find('input[name="Quantite"]').val();
if(parseInt(stock)<parseInt(qte)){
		alert('Le stock n\'est malheureusement pas assez suffisant, veuillez diminuer la quantité...');
		return false;
}
	});


});

