﻿var BgColorInput = "#e3f1fb";

// Formulaire de Contact
function valideFormSiteAmi(Tchamp, email, email2){
	var cpt=0;
	
	//check champs vide
	for(i=0; i< Tchamp.length; i++)
	{
	    document.getElementById(Tchamp[i]).style.background="#FFFFFF";
	    document.getElementById(Tchamp[i]).style.border = "1px solid #a5acb2";

	    if(document.getElementById(Tchamp[i]).value == "")
	    { 
	        cpt++;
	        document.getElementById(Tchamp[i]).style.background= BgColorInput;
	        document.getElementById(Tchamp[i]).style.border = "1px solid #a5acb2";
	    }
	}
	//alert
	if(cpt != 0){alert("Veuillez remplir les champs obligatoires"); return false;}
	
	//check syntaxe email
	document.getElementById(email).style.background="#FFFFFF";
    document.getElementById(email).border = "1px solid #a5acb2";
    document.getElementById(email2).style.background="#FFFFFF";
    document.getElementById(email2).border = "1px solid #a5acb2";

	if ((document.getElementById(email).value.indexOf("@")>=0)&&(document.getElementById(email).value.indexOf(".")>=0)) 
	{
	    if((document.getElementById(email2).value.indexOf("@")>=0)&&(document.getElementById(email2).value.indexOf(".")>=0))
	    { 
	        return true;
	    }
	    else
	    {
	        alert ("mail invalide !!"); 
		    document.getElementById(email2).style.background= BgColorInput;
		    document.getElementById(email2).style.border = "1px solid #a5acb2";
		    return false;
	    }
	}
	else 
	{
		alert ("mail invalide !!"); 
		document.getElementById(email).style.background= BgColorInput;
		document.getElementById(email).style.border = "1px solid #a5acb2";
		return false;
	}
}