
document.getElementById('nom').focus();

function valid_input(id,name)
{
	if( document.getElementById(id) )
	{
		document.getElementById(id).style.color='black';
		if( document.getElementById(id).value == '' )
		{
			alert('Le champ "'+name+'" est obligatoire');
			document.getElementById(id).focus();
			document.getElementById(id).style.color='red';
			return false;
		}
	}
	return true;
}

function check_input()
{
	if(!valid_input('nom','Nom')) {return false;}
	if(!valid_input('prenom','Pr\351nom')) {return false;}
	if(!valid_input('courriel','Courriel')) {return false;}
	

	if(document.getElementById('ville'))
	{
		if(!valid_input('telephone','T\351l\351phone')) {return false;}
		if(!valid_input('ville','Ville')) {return false;}
		if(!valid_input('sujet','Sujet')) {return false;}
		if(!valid_input('description','Description')) {return false;}
	}
	
	if(document.getElementById('message'))
	{
		if(!valid_input('sujet','Sujet')) {return false;}
		if(!valid_input('message','Message')) {return false;}
	}
	
	if(document.getElementById('nas'))
	{
		if(!valid_input('nas','Num\351ro d\'Assurance Sociale')) {return false;}
		if(!valid_input('adresse','Adresse')) {return false;}
		if(!valid_input('telephone','T\351l\351phone')) {return false;}
		if(!valid_input('ne_annee','Ann\351e de Naissance')) {return false;}
		if(!valid_input('ne_mois','Mois de Naissance')) {return false;}
		if(!valid_input('ne_jour','Jour de Naissance')) {return false;}
	}
	
	var expr=new RegExp(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
	if( !document.getElementById('courriel').value.match(expr) )
	{
		alert('Email non valide');
		document.getElementById('courriel').focus();
		document.getElementById('courriel').style.color='red';
		return false;
	}
	else { return true; }
}
