/*
 *      lib_identification.js
 *      
 *      Auteur : Marc FREREBEAU <marc.frerebeau@agama.fr>
 *      Société : Agama, www.agama.fr
 *      
 *      Licence : GPL
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 *      
 *      
 *      Application : Monplannnig
 *      Version : 2.0 
 *      
 *      Nom module : connexion
 *      Description :
 *      	
 *      	
 *      Nécessite : 
 *      	
 *      	
 *      Date : 12/10/2011
 *      Version : 0.1
 *      
 *      RESTE A FAIRE
 *      - 
 *      
  */

function envoyer_identifiants(form)
{
	// Récupère l'identifiant et le mot de passe
	mot_de_passe = lib_identification_trim(form.mot_de_passe.value);
	identifiant = form.identifiant.value;
	// Vérifie que les identifiants sont ok
	if( ( identifiant != '' ) && ( mot_de_passe != '' ) )
	{
		mot_de_passe = SHA1( mot_de_passe );
		// Remplace le mot de passe par celui crypté dans le formulaire
		form_envoi = document.getElementById('formulaire_envoi');
		form_envoi.mot_de_passe.value = mot_de_passe;
		form_envoi.identifiant.value = identifiant;
		form_envoi.submit();
	}
	else
		alert('Remplissez l\'identifiant et le mot de passe pour vous identifier.');
	return false;
}

	
//////////////////////////////////////////////////////////////////////
// Fonction lib_identification_trim
//
// Description :
//		retourne la chaîne chaine, après avoir supprimé les caractères 
//		invisibles en début et fin de chaîne.
//  * ' ' (ASCII 32  (0x20)), un espace ordinaire.
//  * '\\t' (ASCII 9 (0x09)), une tabulation.
//  * '\\n' (ASCII 10 (0x0A)), une nouvelle ligne (line feed).
//  * '\\r' (ASCII 13 (0x0D)), un retour chariot (carriage return).
//  * '\\0' (ASCII 0 (0x00)), le caractère NUL.
//  * '\\x0B' (ASCII 11 (0x0B)), une tabulation verticale.
// Entrées :
//		@chaine (string) : chaine de cractère
// Sorties :
//		@Néant
// Valeur de retour :
//		* (string) : La chaîne de caractères coupée. 
// Auteurs : Marc FREREBEAU
// Date dernière modification : 11/05/2010
// Commentaires :
//		
//////////////////////////////////////////////////////////////////////
function lib_identification_trim( chaine )
{
	chaine = chaine.replace( /[ \t\n\r\0]+$/g, '' ); 
	return chaine.replace( /^[ \t\n\r\0]+/g, '' ); 
}
