// JavaScript Document
var testresults

function checkemail(){
var invalidcheck=0;
var str=document.getElementById('mail').value
var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str)){
var tempstring=str.split("@")
tempstring=tempstring[1].split(".")
if (invalidcheck!=1)
{
	document.getElementById('mail').style.backgroundColor ='#FFFFFF';
	testresults=true
}
else{
testresults=false
}
}
else{
document.getElementById('mail').style.backgroundColor ='#fe8383';
testresults=false
}
return (testresults)
}



function checkTxtEmpty(idElement){
	if (document.getElementById(idElement).value != "")
	{
		document.getElementById(idElement).style.backgroundColor = '#FFFFFF';
		return true
	}
	else
	{
		document.getElementById(idElement).style.backgroundColor = '#fe8383';
		return false
	}
}


function checkcp(){
	nbr = document.getElementById('cp').value
	if ((nbr.length == 5) && !isNaN(nbr))
	{
		document.getElementById('cp').style.backgroundColor = '#FFFFFF';
		return true
	}
	else
	{
		document.getElementById('cp').style.backgroundColor = '#fe8383';
		return false
	}
}


function checktel(){
	nbr1 = document.getElementById('tel1').value
	if (nbr1.length == 10 && !isNaN(nbr1))
	{
		document.getElementById('tel1').style.backgroundColor = '#FFFFFF';
		return true
	}
	else
	{
		document.getElementById('tel1').style.backgroundColor = '#fe8383';
		return false
	}
}


function checkCivilite(){
	if (document.form_f.civilite[0].checked || document.form_f.civilite[1].checked || document.form_f.civilite[2].checked)
	{
		document.getElementById('c1').style.color = '#000000'
		document.getElementById('c2').style.color = '#000000'
		document.getElementById('c3').style.color = '#000000'
		return true
	}
	else
	{
		document.getElementById('c1').style.color = '#ff0000'
		document.getElementById('c2').style.color = '#ff0000'
		document.getElementById('c3').style.color = '#ff0000'
		return false
	}
}



function checkTxtNom(){
	if (document.getElementById('nom').value != "Votre nom")
	{
		document.getElementById('nom').style.backgroundColor = '#FFFFFF';
		return true
	}
	else
	{
		document.getElementById('nom').style.backgroundColor = '#fe8383';
		return false
	}
}



function checktel2(){
	nbr1 = document.getElementById('tel').value
	if (nbr1.length == 10 && !isNaN(nbr1))
	{
		document.getElementById('tel').style.backgroundColor = '#FFFFFF';
		return true
	}
	else
	{
		document.getElementById('tel').style.backgroundColor = '#fe8383';
		return false
	}
}








function checkall(){
	civilite = checkCivilite();
	nom = checkTxtEmpty('nomb');
	prenom = checkTxtEmpty('prenom');
	adresse = checkTxtEmpty('adresse');
	cp = checkcp();
	ville = checkTxtEmpty('ville');
	tel = checktel();
	mail = checkemail();
	rs = checkTxtEmpty('rs');
	activite = checkTxtEmpty('activite');
	projet = checkTxtEmpty('projet');
	surface = checkTxtEmpty('surface');
	
if (!(civilite && nom && prenom && adresse && cp && ville && tel && mail && rs && activite && projet && surface))
{
	document.getElementById('remplacer_txt').innerHTML = "<span style='color:#f00;'>Veuillez remplir les champs marqu&eacute;s d'une étoile (*)</span>";
	return false ;
}
else {
	return true;
	}
}





















function checkallV(){
	nom = checkTxtNom();
	tel = checktel2();
	dd = checkTxtEmpty('dd');
	dd2 = checkTxtEmpty('dd2');
	
if (!(nom && tel && dd2))
{
	document.getElementById('remplacer_txtV').innerHTML = "<span style='color:#f00;'>Veuillez remplir les champs marqu&eacute;s en rouge</span>";
	return false ;
}
else {
	return true;
	}
}