function redirection(url_de_redirection,delai) 
{ 	
	delai=delai*1000;
	var action= 'self.location.href = \''+url_de_redirection+'\'';
	self.setTimeout(action,delai); 
}

function valider_formulaire(thisForm)
{	
	if( thisForm.nom.value == '' )
	{
		alert('Le champ "Nom" doit \352tre rempli');
		thisForm.nom.focus();
		return false;
	}

	if( thisForm.prenom.value == '' )
	{
		alert('Le champ "Pr\351nom" doit \352tre rempli');
		thisForm.prenom.focus();
		return false;
	}
	
	if( thisForm.ville.value == '' )
	{
		alert('Vous devez pr\351ciser votre ville');
		thisForm.ville.focus();
		return false;
	}
	
	if( thisForm.telephone.value == '' )
	{
		alert('Vous devez pr\351ciser votre t\351l\351phone');
		thisForm.telephone.focus();
		return false;
	}
	
	if( thisForm.email.value == '' )
	{
		alert('Le champ "E-Mail" doit \352tre rempli');
		thisForm.email.focus();
		return false;
	}
	
	if( thisForm.comment.value == '0' )
	{
		alert('Merci de s\351lectionner une r\351ponse');
		thisForm.comment.focus();
		return false;
	}
	
	if( thisForm.message.value == '' )
	{
		alert('Vous devez \351crire un message');
		thisForm.message.focus();
		return false;
	}
	
	if( thisForm.code.value == '' )
	{
		alert('Merci de recopier le code de s\351curit\351 anti-spam');
		thisForm.code.focus();
		return false;
	}

	thisForm.email.value;
	var mailtype = /^[\w\-]+(\.[\w\-]+)*@[\w\-]+(\.[\w\-]+)*\.[\w\-]{2,}$/;
	var champs   = thisForm.email;
	var reponse  = mailtype.test(champs.value);
	
	if( reponse )
		thisForm.submit();
	else
	{
		alert('Le champ "E-Mail" est invalide\n Veuillez saisir une adresse mail correcte\n( exemple: fdupont@gmail.com )');
		thisForm.email.focus();
		return false;
	}	
}

//centre la page verticalement
function align()
{
	var lmt = document.getElementById('content');
	var container = document.documentElement;

	if(lmt && container)
	{
	    var containerHeight;
	    if (container.innerWidth)
	    {
            containerHeight = container.innerHeight;		
		}
		else
		{
            containerHeight = container.clientHeight;
		}
	    var lmtHeight;
	    if (lmt.innerWidth)
	    {
            lmtHeight = lmt.innerHeight;
		}
		else
		{
            lmtHeight = lmt.offsetHeight;
		}
		var y = Math.ceil((containerHeight - lmtHeight) / 2);
		if(y < 0)
		{
			y = 0;
		}
		lmt.style.position = "relative";
		lmt.style.top = y + "px";
	}
	if (document.getElementById)
	{
		document.body.style.visibility = 'visible';
	}
}

function addevent(obj,evt,fn,capt){

	if(obj.addEventListener)
	{
		obj.addEventListener(evt, fn, capt);
		return true;
	}
	else if(obj.attachEvent)
	{
		obj.attachEvent('on'+evt, fn);
		return true;
	}
	else return false;
}

if (document.getElementById && document.getElementsByTagName)
{	
	addevent(window, 'load', align, false);
	addevent(window, 'resize', align, false);
}
