// 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 ='#FF0000';
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 = '#FF0000';
		return false
	}
}

function checktel(){
	nbr = document.getElementById('tel').value
	if (!isNaN(nbr) && nbr!="")
	{
		document.getElementById('tel').style.backgroundColor = '#FFFFFF';
		return true
	}
	else
	{
		document.getElementById('tel').style.backgroundColor = '#FF0000';
		return false
	}
}


function checkall(){
	nom = checkTxtEmpty('nom');
	prenom = checkTxtEmpty('prenom');
	mail = checkemail();
	tel = checktel();
	adress = checkTxtEmpty('adress');
	ville = checkTxtEmpty('ville');
	pays = checkTxtEmpty('pays');
	date1xx = checkTxtEmpty('date1xx');
	message = checkTxtEmpty('message');
	
if (!(nom && prenom && mail && tel && adress && ville && pays && date1xx && message))
{
	document.getElementById('erreur').style.visibility = 'visible';
	return false ;
}
else {
	return true;
	}
}
