function tpl_compte_ExpandCollapse(id_commun, mode)
{
	var id_image	= id_commun+"_IMAGE";
	var id_contenu	= id_commun+"_CONTENU";
	
	if (document.getElementById(id_contenu))
	{
		if ((!mode && document.getElementById(id_contenu).style.display == 'none')|| mode==1)
		{
			document.getElementById(id_contenu).style.display = 'block';
			document.getElementById(id_image).src = APPLI_URL+'_module/compte/images/reduire.gif';
			
		}
		else
		{
			document.getElementById(id_contenu).style.display = 'none';		
			document.getElementById(id_image).src = APPLI_URL+'_module/compte/images/agrandir.gif';
		}
	}
}

function tpl_compte_wrong_msg(txt, obj)
{
	alert(txt);
	if (obj) obj.focus();
	return false;
}

function tpl_compte_verif_login()
{
	var f = document.form_login;

	if (f.tpl_login.value.length<2)				return tpl_compte_wrong_msg("Vous devez entrer votre LOGIN.",			f.tpl_login);

	if (f.tpl_pass.value.length<2)				return tpl_compte_wrong_msg("Vous devez entrer votre MOT DE PASSE.",	f.tpl_pass);
	
	return true;
}

function tpl_compte_verif_clef()
{
	var f = document.form_login;
	if (f.tpl_login.value.length<2)				return tpl_compte_wrong_msg("Vous devez entrer votre LOGIN.",			f.tpl_login);

	if (f.tpl_clef.value.length<2)				return tpl_compte_wrong_msg("Vous devez entrer la CLEF fourni dans le mail.",	f.tpl_clef);

	if (f.tpl_pass.value.length<6)				return tpl_compte_wrong_msg("Vous devez choisir un MOT DE PASSE d'au moins 6 charactères.",	f.tpl_pass);
	
	return true;
}

function tpl_compte_verif_new()
{
	var f = document.form_login;
	if (f.tpl_login.value.length<5)				return tpl_compte_wrong_msg("Vous devez choisir un LOGIN d'au moins 5 charactères.",		f.tpl_login);

	if (f.tpl_pass.value.length<6)				return tpl_compte_wrong_msg("Vous devez choisir un MOT DE PASSE d'au moins 6 charactères.",	f.tpl_pass);
	if (f.tpl_pass.value!=f.tpl_verif.value)	return tpl_compte_wrong_msg("La vérification du MOT DE PASSE est invalide.",				f.tpl_pass);
	
	if (f.tpl_prenom.value.length<2)			return tpl_compte_wrong_msg("Vous devez préciser votre PRENOM.",				f.tpl_prenom);
	if (f.tpl_email.value.length<2)				return tpl_compte_wrong_msg("Vous devez préciser votre E-MAIL.",				f.tpl_email);

	
	return true;
}

function tpl_compte_verif_modif()
{
	var f = document.form_login;
	
	if (f.tpl_prenom.value.length<2)			return tpl_compte_wrong_msg("Vous devez préciser votre PRENOM.",				f.tpl_prenom);
	if (f.tpl_email.value.length<2)				return tpl_compte_wrong_msg("Vous devez préciser votre E-MAIL.",				f.tpl_email);
	
	return true;
}

function tpl_compte_groupe_verif()
{
	var f = document.form_groupe_edit;

	if (f.code.value=='')
	{
		alert('Tous les champs sont obligatoires...');
		return false;
	}	
	if (f.nom.value=='')
	{
		alert('Tous les champs sont obligatoires...');
		return false;
	}	
	if (f.descr.value=='')
	{
		alert('Tous les champs sont obligatoires...');
		return false;
	}	
	
	tpl_compte_action = false;
	return true;		
}

function tpl_compte_groupe_modifier(profil_id)
{
	var f = document.form_groupe_edit;
	f.faire.value	= 'profilmodifier';
	f.id.value		= profil_id;
	f.code.value	= document.getElementById('groupe_code_'+profil_id).value;
	f.nom.value		= document.getElementById('groupe_nom_'+profil_id).value;
	f.descr.value	= document.getElementById('groupe_descr_'+profil_id).value;
	f.enregistrer.value = 'Modifier';
	document.getElementById('groupe_titre_action').innerHTML = 'Modifier';

	tpl_compte_ExpandCollapse('profil_edit', 1);
	return true;
}

function tpl_compte_groupe_annuler(profil_id)
{
	var f = document.form_groupe_edit;
	f.faire.value	= 'profilajouter';
	f.id.value		= '';
	f.code.value	= '';
	f.nom.value		= '';
	f.descr.value	= '';
	f.enregistrer.value = 'Enregistrer';
	document.getElementById('groupe_titre_action').innerHTML = 'Ajouter';

	return true;
}

function tpl_compte_groupe_supprimer(profil_id)
{
	if (confirm('Etes-vous sur de vouloir supprimer le profil "'+document.getElementById('groupe_nom_'+profil_id).value+'" ?'))
	{
		tpl_compte_action = false;
		var f = document.form_groupe_edit;
		f.faire.value	= 'profilsupprimer';
		f.id.value		= profil_id;
		HTTPObject_SendForm(f);
	}
}

function tpl_compte_activer_user(id)
{
	var profil = document.getElementById('profil_'+id).value;
	if (profil== '')
	{
		alert("Vous devez choisir un profil...");
		return false;
	}
	
	greyLoad(CURRENT_URL+'?mod=compte&section=admin_user&faire=compteactiver&login='+id+'&profil='+profil, true);
	return true;
}	
function tpl_compte_user_deconnect()		{ greyLoad(CURRENT_URL+'?mod=compte&section=user_deconnect');	}
function tpl_compte_user_connect()		{ greyLoad(CURRENT_URL+'?mod=compte&section=user_connect');	}
function tpl_compte_user_create()		{ greyLoad(CURRENT_URL+'?mod=compte&section=user_create');	}
function tpl_compte_user_lost()			{ greyLoad(CURRENT_URL+'?mod=compte&section=user_lost');	}
function tpl_compte_user_profil()		{ greyLoad(CURRENT_URL+'?mod=compte&section=user_profil');	}
function tpl_compte_admin_groupe()		{ greyLoad(CURRENT_URL+'?mod=compte&section=admin_groupe');	}
function tpl_compte_admin_user()		{ greyLoad(CURRENT_URL+'?mod=compte&section=admin_user');	}
function tpl_compte_admin_user_tri(nom, ord)	{ greyLoad(CURRENT_URL+'?mod=compte&section=admin_user&TRI_NOM='+nom+'&TRI_ORD='+ord, true);	}
function tpl_compte_admin_user_profil(id)	{ greyLoad(CURRENT_URL+'?mod=compte&section=admin_user_profil&login='+id, true);	}
function tpl_compte_admin_user_desactive(id)	{ greyLoad(CURRENT_URL+'?mod=compte&section=admin_user&login='+id+'&faire=comptedesactiver', true);	}

