
/* -------------------------------------------------- */
/* Fonction appelée lors d'une tentative de connexion */
/* -------------------------------------------------- */

function login_front(msg, lib_mail, lib_mdp)
{
	var message = "";
	
	// Email
	if(window.document.getElementById("login_email").value.search(/^[-a-zA-Z0-9._]*[-a-zA-Z0-9_]@[-a-zA-Z0-9_]+(\.[-a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/) < 0)
	{
		message += " - "+lib_mail+" \r\n";
	}

	// Mot de passe
	if(window.document.getElementById("login_mdp").value == "")
	{
		message += " - "+lib_mdp;
	}

	if(message != "")
	{
		alert(msg+" : \r\n"+message);
	}
	else
	{
		window.document.mon_compte.submit();
	}
}

/* ----------------------------------------------------------- */
/* Fonction appelée lors d'une création/modification de compte */
/* ----------------------------------------------------------- */

function creamodifcpt(msg, lib_nom, lib_prenom, lib_societe, lib_adresse, lib_cp, lib_ville, lib_pays, lib_email, lib_confemail, lib_emaildiff, lib_mdp, lib_confmdp, lib_mdpdiff, lib_tel)
{
	var message = "";

	// Nom
	if(window.document.getElementById("creamodifcpt_nom").value == "")
	{
		message += " - "+lib_nom+" \r\n";
	}

	// Prénom
	if(window.document.getElementById("creamodifcpt_prenom").value == "")
	{
		message += " - "+lib_prenom+" \r\n";
	}

	// Société
	if(window.document.getElementById("creamodifcpt_societe").value == "")
	{
		message += " - "+lib_societe+" \r\n";
	}

	// Adresse
	if(window.document.getElementById("creamodifcpt_adresse").value == "")
	{
		message += " - "+lib_adresse+" \r\n";
	}

	// CP
	if(window.document.getElementById("creamodifcpt_cp").value == "")
	{
		message += " - "+lib_cp+" \r\n";
	}

	// Ville
	if(window.document.getElementById("creamodifcpt_ville").value == "")
	{
		message += " - "+lib_ville+" \r\n";
	}

	// Ville
	if(window.document.getElementById("creamodifcpt_pays").value == "")
	{
		message += " - "+lib_pays+" \r\n";
	}

	// Email
	if(window.document.getElementById("creamodifcpt_email").value.search(/^[-a-zA-Z0-9._]*[-a-zA-Z0-9_]@[-a-zA-Z0-9_]+(\.[-a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/) < 0)
	{
		message += " - "+lib_email+" \r\n";
	}

	// Confirmation Email
	if(window.document.getElementById("creamodifcpt_confemail").value.search(/^[-a-zA-Z0-9._]*[-a-zA-Z0-9_]@[-a-zA-Z0-9_]+(\.[-a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/) < 0)
	{
		message += " - "+lib_confemail+" \r\n";
	}
	else
	{
		// Email et confirmation email (identiques)
		if(window.document.getElementById("creamodifcpt_email").value != window.document.getElementById("creamodifcpt_confemail").value)
		{
			message += " - "+lib_emaildiff+" \r\n";
		}
	}

	// Mot de passe
	if(window.document.getElementById("creamodifcpt_mdp").value == "")
	{
		message += " - "+lib_mdp+" \r\n";
	}

	// Confirmation Mot de passe
	if(window.document.getElementById("creamodifcpt_confmdp").value == "")
	{
		message += " - "+lib_confmdp+" \r\n";
	}
	else
	{
		// Mot de passe et confirmation Mot de passe (identiques)
		if(window.document.getElementById("creamodifcpt_mdp").value != window.document.getElementById("creamodifcpt_confmdp").value)
		{
			message += " - "+lib_mdpdiff+" \r\n";
		}
	}

	// Tel
	if(window.document.getElementById("creamodifcpt_tel").value == "")
	{
		message += " - "+lib_tel+" \r\n";
	}

	if(message != "")
	{
		alert(msg+" : \r\n"+message);
	}
	else
	{
		window.document.creation_modif_compte.submit();
	}	
}

/* -------------------------------------------------------- */
/* Fonction appelée lors d'une création de compte simplifié */
/* -------------------------------------------------------- */

function creamodifcptsimpl(msg, lib_nom, lib_prenom, lib_societe, lib_email, lib_confemail, lib_emaildiff, lib_tel)
{
	var message = "";

	// Nom
	if(window.document.getElementById("creamodifcptsimpl_nom").value == "")
	{
		message += " - "+lib_nom+" \r\n";
	}

	// Prénom
	if(window.document.getElementById("creamodifcptsimpl_prenom").value == "")
	{
		message += " - "+lib_prenom+" \r\n";
	}

	// Société
	/*if(window.document.getElementById("creamodifcptsimpl_societe").value == "")
	{
		message += " - "+lib_societe+" \r\n";
	}*/

	// Email
	if(window.document.getElementById("creamodifcptsimpl_email").value.search(/^[-a-zA-Z0-9._]*[-a-zA-Z0-9_]@[-a-zA-Z0-9_]+(\.[-a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/) < 0)
	{
		message += " - "+lib_email+" \r\n";
	}

	// Confirmation Email
	if(window.document.getElementById("creamodifcptsimpl_confemail").value.search(/^[-a-zA-Z0-9._]*[-a-zA-Z0-9_]@[-a-zA-Z0-9_]+(\.[-a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/) < 0)
	{
		message += " - "+lib_confemail+" \r\n";
	}
	else
	{
		// Email et confirmation email (identiques)
		if(window.document.getElementById("creamodifcptsimpl_email").value != window.document.getElementById("creamodifcptsimpl_confemail").value)
		{
			message += " - "+lib_emaildiff+" \r\n";
		}
	}

	// Tel
	if(window.document.getElementById("creamodifcptsimpl_tel").value == "")
	{
		message += " - "+lib_tel+" \r\n";
	}

	if(message != "")
	{
		alert(msg+" : \r\n"+message);
	}
	else
	{
		window.document.creation_modif_compte_simplifie.submit();
	}	
}

/* ------------------------------------------------- */
/* Fonction appelée lors de la demande de mdp oublié */
/* ------------------------------------------------- */

function demande_mdp(msg, lib_mail)
{
	var message = "";
	
	// Email
	if(window.document.getElementById("mdpoublie_mail").value.search(/^[-a-zA-Z0-9._]*[-a-zA-Z0-9_]@[-a-zA-Z0-9_]+(\.[-a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/) < 0)
	{
		message += " - "+lib_mail+" \r\n";
	}

	if(message != "")
	{
		alert(msg+" : \r\n"+message);
	}
	else
	{
		window.document.mdpoublie.submit();
	}
}

/* Mise en majuscule du champ passé en paramètre (id) */
function maj(champ)
{
	var chaine = window.document.getElementById(champ).value;
	window.document.getElementById(champ).value = chaine.toUpperCase();
}
