var iOpacity = 0;
var idFade = "";
var timer = 0;

function UnFadeById(id) {
	idFade = id;
	iOpacity = 1;
	clearInterval(timer);
	timer = setInterval("FadeOut()", 30);
}

function FadeById(id) {
	idFade = id;
	iOpacity = 0;
	clearInterval(timer);
	timer = setInterval("FadeIn()", 30);
}

function FadeIn() {
	var elem = document.getElementById(idFade);
	if (iOpacity >= 1) {
		iOpacity = 0;
		clearInterval(timer);
		timer = 0;
		return;
	}
	iOpacity += 0.1;
	elem.style.opacity = iOpacity;
	elem.style.MozOpacity = iOpacity;
	elem.style.KhtmlOpacity = iOpacity;
	elem.style.filter = "alpha(opacity=" + iOpacity * 100 + ")";
}

function FadeOut() {
	var elem = document.getElementById(idFade);
	if (iOpacity == 0) {
		iOpacity = 1;
		clearInterval(timer);
		timer = 0;
		return;
	}
	iOpacity -= 0.1;
	elem.style.opacity = iOpacity;
	elem.style.MozOpacity = iOpacity;
	elem.style.KhtmlOpacity = iOpacity;
	elem.style.filter = "alpha(opacity=" + iOpacity * 100 + ")";
}

function date()
{
	var dayarray=new Array("dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi");
	var montharray=new Array("janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre");
	var mydate=new Date();
	var day=mydate.getDay();
	var month=mydate.getMonth();
	var daym=mydate.getDate();
	var hours=mydate.getHours();
	var minutes=mydate.getMinutes();
	if (minutes<=9)
	{
		minutes="0"+minutes;
	}
	var cdate=dayarray[day]+" "+daym+" "+montharray[month]+", "+hours+":"+minutes;
	return(cdate);
}

function antispam(nom,domaine)
{
	document.write('<a id=\"mail\" href=\"mailto:' + nom + '@' + domaine + '\"' + '>' + nom + '@' + domaine +'<\/a>');
}

function antispam_texte(nom,domaine)
{
	document.write('<a href=\"mailto:' + nom + '@' + domaine + '\"' + 'class=\"texte\">' + nom + '@' + domaine +'<\/a>');
}

function lien_viamichelin()
{
	document.write('<a id=\"plan\" href=\"http:\/\/www.viamichelin.com\/viamichelin\/fra\/dyn\/controller\/mapPerformPage?strAddress=Rue+Notre-Dame&strLocation=Marienthal&strCP=67500&strCountry=1424&mapId=-to3mjfyz7usubp\" target=\"_blank\">Plan d\'accès<\/a>');
}

function viamichelin_debut()
{
	document.write('<a href=\"http:\/\/www.viamichelin.com\/viamichelin\/fra\/dyn\/controller\/mapPerformPage?strAddress=Rue+Notre-Dame&strLocation=Marienthal&strCP=67500&strCountry=1424&mapId=-to3mjfyz7usubp\" target=\"_blank\" class=\"opacity\">');
}

function viamichelin_fin()
{
	document.write('<\/a>');
}

function verification()
{
	if(document.formulaire.nom.value == "")
	{
		alert("Veuillez entrer votre nom svp.");
		document.formulaire.nom.focus();
		return false;
	}
		
	//verif. de l'E-Mail
	if(document.formulaire.email.value == "")
	{
		alert("Veuillez entrer votre adresse e-mail svp.");
		document.formulaire.email.focus();
		return false;
	}
	if(document.formulaire.email.value.indexOf('@') == -1)
	{
		alert("L'adresse e-mail indiquée n'est pas valide, vérifiez la svp.");
		document.formulaire.email.focus();
		return false;
	}
	
	//verif. du sujet
	if(document.formulaire.sujet.value == "")
	{
		alert("Veuillez indiquer un sujet svp.");
		document.formulaire.sujet.focus();
		return false;
	}
	
	//verif. du choix du rappel
	rappeloption = -1;
	for(i=0; i<document.formulaire.rappel.length; i++)
	{
		if(document.formulaire.rappel[i].checked)
		{
			rappeloption = i;
		}
	}
	if (rappeloption == -1)
	{
		alert("Veuillez indiquer si vous souhaitez être rappelé svp.");
		return false;
	}
	
	//verif du numero de telephone
	if ((rappeloption == 1 || rappeloption == 2) && document.formulaire.tel.value == "")
	{
		alert("Veuillez entrer votre numéro de téléphone svp.");
		document.formulaire.tel.focus();
		return false;
	}
	if ((rappeloption == 1 || rappeloption == 2) && document.formulaire.tel.value.length < 10)
	{
		alert("Le numéro de téléphone indiqué n'est pas valide, vérifiez le svp.");
		document.formulaire.tel.focus();
		return false;
	}
	if ((rappeloption == 1 || rappeloption == 2) && isNaN(document.formulaire.tel.value))
	{
		alert("Le numéro de téléphone doit être uniquement constitué de chiffres (ex: 0388739940), vérifiez le svp.");
		document.formulaire.tel.focus();
		return false;
	}
	
	//verif. du corps du message
	if(document.formulaire.texte.value == "") 
	{
		alert("Veuillez entrer le texte de votre message svp.");
		document.formulaire.texte.focus();
		return false;
	}
	
return true;
}

function prechargement()
{
	// on précharge les images
	var image1 = new Image(); 
	image1.src = "images/bg_header.png";
	var image2 = new Image(); 
	image2.src = "images/bg_header.gif";
	var image3 = new Image(); 
	image3.src = "images/logo.gif";
	var image4 = new Image(); 
	image4.src = "images/google_white.gif";
	var image5 = new Image(); 
	image5.src = "images/loupe_orange.png";
	var image6 = new Image(); 
	image6.src = "images/world.png";
}

