function surligne(champ, erreur) {
	if (erreur) {
		champ.style.backgroundColor = "#fba";
		document.getElementById('verif_contact').style.display = "block";
	}
	else {
		champ.style.backgroundColor = "";
		document.getElementById('verif_contact').style.display = "";
	}
}

function verifnom_vote (champ) {
	var regex = /^[a-zA-Z-\s]{2,25}$/;
	if (!regex.test(champ.value)) {
		surligne (champ, true);
		return false;
	}
	else {
		surligne (champ, false);
		return true;
	}
}
		
					
function verifmail_vote (champ) {
	var regex = /^[a-zA-Z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/;
	if (!regex.test(champ.value)) {
		surligne (champ, true);
		return false;
	}
	else {
		surligne (champ, false);
		return true;
	}
}

function veriftel_vote (champ) {
	var regex = /^(0[1-8])(?:[ _.-]?(\d{2})){4}$/;
	if (champ.value) {
	if (!regex.test(champ.value)) {
		surligne (champ, true);
		return false;
	}
	else {
		surligne (champ, false);
		return true;
	}
	} 
}

function verifdpt_vote (champ) {
	var regex = /^[0-9]{1,3}$/;
	if (!regex.test(champ.value)) {
		surligne (champ, true);
		return false;
	}
	else {
		surligne (champ, false);
		return true;
	}
}

function verifradio_vote (champ) {
	var regex = /^pour|contre$/;
	if (!regex.test(champ.value)) {
		surligne (champ, true);
		return false;
	}
	else {
		surligne (champ, false);
		return true;
	}
}


function veriform_vote (f) {
	var nomOk = verifnom_vote (f.nom_vot);
	var prenomOk = verifnom_vote (f.prenom_vot);
	var mailOk = verifmail_vote (f.mail_vot);
	var telOk = veriftel_vote (f.tel_vot);
	var dptOk = verifdpt_vote (f.dpt_vot);
	var radio1Ok = verifradio_vote(f.ask_1);
	var radi21Ok = verifradio_vote(f.ask_2);
	var radio3Ok = verifradio_vote(f.ask_3);
	var radio4Ok = verifradio_vote(f.ask_4);
	var radio5Ok = verifradio_vote(f.ask_5);

	
	if (nomOk && prenomOk && mailOk && telOk && dptOk/* && radio1Ok && radio2Ok && radio3Ok && radio4Ok && radio5Ok*/)
		return true;
	else {
		document.getElementById('verif_contact').style.display = "block";
		return false;
	}
}

