// JavaScript Document
var testresults

function checkemail(mail){
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

var filter=/^((?:\w+\.)*\w[\w-]{0,66})@((?:\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 ='#f850c2';
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 = '#f850c2';
		return false
	}
}

function checkTxtMdp(){
	if (document.getElementById('mdp').value != "ekzogngr")
	{
		document.getElementById('mdp').style.backgroundColor = '#FFFFFF';
		return true
	}
	else
	{
		document.getElementById('mdp').style.backgroundColor = '#f850c2';
		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 = '#f850c2';
		return false
	}
}


function checktel(){
	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 = '#f850c2';
		return false
	}
}



function checkConnexion(){
	mail = checkemail('mail');
	mdp = checkTxtEmpty('mdp');
if (!(mail && mdp))
{
	document.getElementById('remplacer_connnexion').innerHTML = "Veuillez corriger les champs color&eacute;s <br />en rose !";
	return false ;
}
else {
	return true;
	}
}



function checkInscription(){
	mail = checkemail('email');
	mdp = checkTxtEmpty('emdp');
	prenom = checkTxtEmpty('prenom');
	sexe = checkTxtEmpty('sexe');
	age = checkTxtEmpty('age');
	cp = checkcp();
if (!(mail && mdp && prenom && sexe && age && cp))
{
	document.getElementById('remplacer_inscription').innerHTML = "Veuillez corriger les champs color&eacute;s <br />en rose !";
	return false ;
}
else {
	return true;
	}
}


function checkmdpO(){
	mail = checkemail('mailO');
if (!(mail))
{
	document.getElementById('remplacer_oublier').innerHTML = "Adresse email incorrecte !";
	return false ;
}
else {
	return true;
	}
}


function checkProposer(){
	adresseS = checkTxtEmpty('adresseS');
	mailS = checkemail('mailS');
	codeS = checkTxtEmpty('codeS');
if (!(adresseS && mailS && codeS))
{
	document.getElementById('remplacer_proposer').innerHTML = "Veuillez corriger les champs color&eacute;s en rose !";
	return false ;
}
else {
	return true;
	}
}


function checkAjoutS(){
	titreS = checkTxtEmpty('titreS');
	adresseS = checkTxtEmpty('adresseS');
	categorie = checkTxtEmpty('categorie');
if (!(titreS && adresseS && categorie))
{
	document.getElementById('remplacer_ajoutS').innerHTML = "Veuillez corriger les champs color&eacute;s en rose !";
	return false ;
}
else {
	return true;
	}
}
