// ------------------------------ function for the slideshow
$(window).load(function() {
var total = $('#slider img').length;
var rand = Math.floor(Math.random()*total);
	$('#slider').nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:500, //Slide transition speed
		pauseTime:3000,
		startSlide:rand, //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
      controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:false, //Use left & right arrows
		pauseOnHover:false, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
});

//---------------------------function for the page 'spectacle'
function showText(id) {
	switch(id) {
		case "telepathie":
			$("#origContent").hide("slow");
			$("#6sens").hide("slow");
			$("#oracle").hide("slow");
			$("#"+id).show("slow");
		break;
		
		case "6sens":
			$("#origContent").hide("slow");
			$("#telepathie").hide("slow");
			$("#oracle").hide("slow");
			$("#"+id).show("slow");
		break;
		
		case "oracle":
			$("#origContent").hide("slow");
			$("#6sens").hide("slow");
			$("#telepathie").hide("slow");
			$("#"+id).show("slow");
		break;
		
		case "origContent":
			$("#telepathie").hide("slow");
			$("#6sens").hide("slow");
			$("#oracle").hide("slow");
			$("#"+id).show("slow");
		break;
	}
	
}

// ------------------------------ function for the page 'contact'
function verifNom(champ)
{
   if(champ.value.length < 2 || champ.value.length > 25)
   {
	   document.getElementById("errNom").style.visibility = "visible";
	   return false;
   }
   else
   {
	  document.getElementById("errNom").style.visibility = "hidden";
      return true;
   }
}

function verifEmail(champ)
{
   var regex = /^[a-zA-Z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/;
   if(!regex.test(champ.value))
   {
	   document.getElementById("errEmail").style.visibility = "visible";
		return false
		
   }
   else
   {
	document.getElementById("errEmail").style.visibility = "hidden";
	return true
	
   }
}
function verifMessage(champ) {
	if(champ.value == "") {
		document.getElementById("errMsg").style.visibility = "visible";
		return false
	}
	else {
		document.getElementById("errMsg").style.visibility = "hidden";
		return true
	}
}

/* fonction finale */

function verifForm(f)
{
   var nomOk = verifNom(f.nom);
   var emailOk = verifEmail(f.email);
   var messageOk = verifMessage(f.message);
   
   if(nomOk &&  emailOk && messageOk)
      return true;
   else
   {
	  document.getElementById("obligMsg").style.visibility = "visible";
      alert("merci de v\351rifier votre saisie");
	  
      return false;
   }
}
