i1 = new Image;
i1.src = "images/blanc-80.png";
i2 = new Image;
i2.src = "images/blanc-90.png";
i3 = new Image;
i3.src = "images/recherche_submit_hover.png";
i4 = new Image;
i4.src = "images/fleche-haut-hover.png";
i5 = new Image;
i5.src = "images/home-hover.png";
i6 = new Image;
i6.src = "js/jcarousel/bouton-droite-hover.png";
i7 = new Image;
i7.src = "js/jcarousel/bouton-gauche-hover.png";
i8 = new Image;
i8.src = "js/fancybox/bouton-droite-hover.png";
i9 = new Image;
i9.src = "js/fancybox/bouton-gauche-hover.png";
i10 = new Image;
i10.src = "images/lien-moins.png";

$(function(){
	/*TEMP BLOG*/
	//$('#lien-blog').hover(function(){$("#avenir").show();}, function(){$("#avenir").hide();});
	/*ACTUS*/
	$('#actus-ouvrir').click(function(event){event.preventDefault();$(this).hide();$("#actus-suite").show();});
	/*ACCUEIL BANDEAU*/
	$('#slider').nivoSlider({animSpeed:500,pauseTime:4000,directionNav:false,pauseOnHover:true,effect:'fade'});
	/*PLUS*/
	$("#lien-plus").toggle(
		function(event){
			event.preventDefault();
			$(this).find("img").attr("src","images/lien-moins.png");
			$("#cache-plus").show(0,function(){$('html,body').animate({scrollTop: 7000}, 'slow');});
		},
		function(event){
			event.preventDefault();
			$(this).find("img").attr("src","images/lien-plus.png");
			$("#cache-plus").hide();
		}
	);
	/*OVER FONDUS*/
	$('.lienfondu')
		.mouseover(function(){
			$(this).animate({opacity:0.8}, 200);
		})
		.mouseout(function(){
			$(this).animate({opacity:1}, 200);
		});
	/*ANCRES ET SCROLL*/
	$('#retour-haut').click(function(event){
		event.preventDefault();
		$('html,body').animate({scrollTop: 0}, 600);
	});
	$('.retour-haut').click(function(event){
		event.preventDefault();
		$('html,body').animate({scrollTop: 0}, 600);
	});
	/*LIGHTBOX*/
	$("a.fancybox").fancybox({overlayColor:'#FFF', titlePosition:'inside'});
	/*TOOLTIP*/
	$("a.tooltip-lien").tooltip({relative:"true", delay:"0"});
	$("a.lien-en").tooltip({delay:"0"});
	/*CAROUSEL*/
	$("#carousel1").jcarousel({scroll:2, visible:2,auto:6,wrap:'circular', animation:'slow'});
	$("#carousel2").jcarousel({scroll:2, visible:2,auto:4,wrap:'circular', animation:'slow'});
	/*HOVER*/
	$("#lien-home")
		.mouseover(function(){
			$(this).find("img").attr("src","images/home-hover.png");
		})
		.mouseout(function(){
			$(this).find("img").attr("src","images/home.png");
		})
	/*METIERS (onglets) */
	var uriCourant = document.location.href;
	var indiceDepart = uriCourant.lastIndexOf('#')+1;
	var indiceArrivee = uriCourant.length;
	var ancre = uriCourant.substring(indiceDepart, indiceArrivee);
	$(".tab_content").hide();
	if(indiceDepart!=0){
		$("ul.tabs li#li-"+ancre).addClass("active").show().children('.picto-off').hide().siblings('div').show();
		var activeTab = $("ul.tabs li#li-"+ancre).find("a").attr("href");
		$("a#sf-lien"+ancre).addClass("selected");
		$(activeTab).show();
	}
	else{
		$("ul.tabs li:first").addClass("active").show().children('.picto-off').hide().siblings('div').show();
		$(".tab_content:first").show();
		$("a#sf-lien1").addClass("selected");
	}
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active").children('.picto-off').show().siblings('div').hide();
		$(this).addClass("active").children('.picto-off').hide().siblings('div').show();
		$(".tab_content").hide();
		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		var idsf=$(this).find("a").attr('id');
		$(".sf-lien").removeClass("selected");
		$("#sf-lien"+idsf).addClass("selected");
		return false;
	});
	$(".sf-lien").click(function() {
		var idlien=$(this).attr("id");
		idsf=idlien.substring(7, 8);
		$("ul.tabs li").removeClass("active").children('.picto-off').show().siblings('div').hide();
		$("#li-"+idsf).addClass("active").children('.picto-off').hide().siblings('div').show();
		$(".tab_content").hide();
		var activeTab = $("#li-"+idsf).find("a").attr("href");
		$(activeTab).fadeIn();
		$(".sf-lien").removeClass("selected");
		$("#sf-lien"+idsf).addClass("selected");
		return false;
	});
});

/*MENU*/
ddsmoothmenu.init({
	mainmenuid: "menu", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

/*CONTACT*/
function validerContact()
{
	var form = document.formContact;
	var valid = 1;
	var message = '';
	if(document.getElementById('nom').value == '' || document.getElementById('nom').value == 'Pr&eacute;nom & nom' || document.getElementById('nom').value == 'Pr&eacute;nom & nom / Soci&eacute;t&eacute;')
	{
		message += "- Prénom & nom \n";
		valid = 0;
	}
	if(document.getElementById('email').value == '' || document.getElementById('email').value == 'E-mail')
	{
		message += "- E-mail \n";
		valid = 0;
	}
	if(document.getElementById('message').value == '' || document.getElementById('message').value == 'Message')
	{
		message += "- Message \n";
		valid = 0;
	}
	if(valid==1){
			return true;
	}
	else {
		alert("Les champs suivants sont obligatoires :\n\n"+message);
		return false;
	}
}
/*NEWSLETTER*/
function validerNewsletter(){
	if(document.getElementById('newsletter_email').value=="" || document.getElementById('newsletter_email').value=="Votre e-mail"){
		alert("Veuillez renseigner votre e-mail dans le champ 'Votre e-mail'.");
		return false;
	}
	else{
		document.getElementById('newsletter-desinscription').href='http://www.nutrikeo.com/newsletter.php?action=newsletter_supprime&newsletter_email='+document.getElementById('newsletter_email').value;
		return true;
	}
}
