
	/*
	*@brief : Classe javascript qui recupère tous les formulaires d'une page et traite toutes les champs de chaque formulaire 
	*    	cette classe s'associe avec la classe d'execution des scripts javascripts
	*		
	*@usage :
		var oDataForm = new DataForm();
		oDataForm.sendAllForm();
	*/
	
	
	/*	------------------------------------------------------------------------------------------------------------------------------------------------------------
	* @brief : Méthode constructeur : 
	*/
	function DataForm(){
	
		/* -------- Propriétés de classe DataForm ---------- */
		this._tagForm				= "form";
		this._tagInput			= "input";
		this._tagTextarea		= "textarea";
		this._tagCheckBox		= "checkbox";
		this._tagSelect			= "select";
		
		this.a_listForms		= new Array();
		this.a_listParameters 	= new Array();	// tableau 2 dimensions des 
		
		
	}  // end construct 
	
	/*
	* @brief : Méthode qui va renvoyer un tableau de tous les parametres à poster via ajax 
	* @param (no param)
	* @return (array)
	*/
	DataForm.prototype.sendAllForm = function (){
		
		this.getFormPage();	// recup de tous les formulaires 
		
		for ( _i = 0; _i < this.a_listForms.length ; _i++){
			
			this.getInputForm(this.a_listForms[_i],this._tagInput,"text");					// recupération des tags type hidden 
			this.getInputForm(this.a_listForms[_i],this._tagInput,"hidden");				// recupération des tags type hidden 
			this.getInputForm(this.a_listForms[_i],this._tagInput,this._tagCheckBox);		// recupération des tags type checkbox
			this.getInputForm(this.a_listForms[_i],this._tagTextarea,this._tagTextarea);	// recupération des tags type  textarea
			this.getSelectForm();															// recupération des tags type select 
		}
		
		return this.a_listParameters ;
		
	} // end function
	

	/*
	* @brief : Méthode qui récupère tous les formulaires d'une page 
	* @param (no param)
	* @return (array)
	*/
	DataForm.prototype.getFormPage = function (){
		
		// on récupére tous les tags de type form 
		var a_listTagForms 	= document.getElementsByTagName(this._tagForm);
		
		for ( _cpt = 0; _cpt < a_listTagForms.length ; _cpt++){ // listing de tous les formulaires 
			this.a_listForms[_cpt] = a_listTagForms[_cpt] ;	
		} // end for 
		
		return this.a_listForms ; // on retourne le tableau d'objet form
				
	} // end function
	
	/*
	* @brief : Méthode qui récupere toutes les valeurs des balises formulaires pour en récupere les valeurs 
	* @param (object)	objet formulaire
	* @return (array)
	*/
	DataForm.prototype.getInputForm = function ( o_Form , s_nameTag , s_typeTag  ){
		
		// on récupére tous les tags de type form 
		var a_listTagForms 	= o_Form.getElementsByTagName(s_nameTag);
		
		for ( _j = 0; _j < a_listTagForms.length ; _j++){ // listing de tous les tags du formulaire O_Form 
			
			var objectInput	= a_listTagForms[_j] ;	// on traite 1 object input à la fois 
			
			if ( s_typeTag && objectInput.type == s_typeTag){ 
					
				switch(s_typeTag){
				
					case "text":
					case "hidden":
					
						if (objectInput.type == s_typeTag){
							this.a_listParameters[objectInput.name] = objectInput.value ;	// incrémentation ds la liste des parametres à renvoyer 
						}
						break;
					
					case "checkbox":
						if (objectInput.checked == true){
							this.a_listParameters[objectInput.name] = objectInput.value ;	// incrémentation ds la liste des parametres à renvoyer 
						}
						break;
						
					case "textarea":
						this.a_listParameters[objectInput.name] = objectInput.value ;	// incrémentation ds la liste des parametres à renvoyer 
						break;
					
				} // end switch
				
			} 
		} // end for 
		
		return this.a_listParameters ; // on retourne le tableau d'objet form
				
	} // end function
	
	/*
	* @brief : Méthode qui récupére toutes les valeurs des balises <select> identifié par leur id 
	*/
	
	DataForm.prototype.getSelectForm = function (){
		
		// recup de toutes les balises Form
		var _aListTagSelect = document.getElementsByTagName(this._tagSelect);
		
		for ( _h = 0; _h < _aListTagSelect.length ; _h++){
			
			var _oTagSelect 	= _aListTagSelect[_h] ;	// on recupere l'objet select
			/*var _idInputSelect 	= _oTagSelect.id ;		// on trouve le nom de son id ( <select id="NomSelect" name="NomSelect"> ... </select>																	   .
			var _elementSelect	= GetId();s*/
			//alert(_oTagSelect.options[_oTagSelect.selectedIndex].value);
			this.a_listParameters[_oTagSelect.name]	= _oTagSelect.options[_oTagSelect.selectedIndex].value ;
		} // end for 
	}
	/*- ------------------------------------------------------------------------------------------------------------------------------------------------------ */
	

	
