// Classe d'objets classeFormsMini




function classeFormsMini(_nomobjjs,_urlajax,_filepath) {	
	this.UrlAjax   = _urlajax;
	this.IdAjax    = '';
	this.nomobjjs  = _nomobjjs;
	this.jsPrefix    = 'CFM_';

	this.FormIsLocked    = true;	// au depart le formulaire est bloque jusqu'a l'ordre frm_Fermer();

	this.BtnOkPrefix     = this.jsPrefix+'BtnOk';
	this.BtnCancelPrefix = this.jsPrefix+'BtnCancel';
	this.BtnCancelState  = this.jsPrefix+'BtnCancelState';
	this.ContainerPrefix = this.jsPrefix+'Container';
	
	this.DebugZone       = this.jsPrefix+'DebugZone';  // zone des champs de debuggage
	this.objDebugZone    = false;
	this.ZoneLogs        = this.jsPrefix+'LogsZone';
	this.objZoneLogs     = false;
	this.ZoneXML         = this.jsPrefix+'XmlZone';
	this.objZoneXML      = false;

	this.BtnOkLib             = 'Valider';
	this.BtnCancelLibRetablir = 'Retablir';
	this.BtnCancelLibQuitter  = 'Quitter';
	this.BtnRazEvents         = 'RAZ LOGS';

	this.DebugColor1          = '#CC0000';
	
	this.FilePath  = _filepath;
	this.opacite   = 30;
	this.police    = 'font-family: Verdana, Arial, Helvetica, sans-serif;';
	this.general_keyname_keyvalue  = '';
	this.table_type     = new Array(); // TYPE DE L'OBJET  
	this.table_objets   = new Array(); // NOM  DE L'OBJET
	this.table_attrib   = new Array();
	this.table_valeurs  = new Array();

	this.table_instances  = new Array();
	this.nbre_instances   = 0;
	this.AjaxModeDebug    = false;
	this.AjaxModeDebuglevel = 0;
	
	this.CFM_mode_forms   = false;
	this.CFM_form_after_ok     = '';
	this.CFM_form_after_cancel = '';
	this.CFM_hide_mode         = 2;	// 1=Visible 2=Display none
	
	this.IconeOffsetParam       = 3;  // nombre de parametres pour chaque icone
	this.IconesRadioOffsetParam	= 4;  // pour les icones radio

	this.icon_searching  = this.FilePath+'images/ajax-loader_16.gif';
	this.icon_nodisabled = this.FilePath+'images/warning2_off.gif';
	this.icon_nodisabled_title = 'Attention l\'objet n\'a pas d\'image définie pour l\'état inactif (attribut disabledicon)';
	this.icon_valeurnontrouvee_title = 'Attention la valeur donnee à l\'objet n\'est pas dans la liste';
	this.ListeTitreParDefautUneLigne = "--Choisir une option dans la liste--";
	this.tipszonelogs                = "Zone d'affichage des evenements en vue du debuggage ( methode : frm_AfficherEvenements() )";

	this.couleurchampnormal      = '#FFFFFE' ;
	this.couleurchampobligatoire = '#FFFFFE' ;
	this.couleurchamperreur      = '#FFFFFE' ;
	this.couleurchampRO          = '#FFFFFE' ;
	this.couleurtitre            = '#FFFFFE' ;


	// PASSER EN MODE GESTION FORMULAIRE
	this.CFM_init_mode_forms	= function(_after_ok,_after_cancel) {
		this.CFM_form_after_ok     = _after_ok;
		// si la page appelee par quitter est vide alors on prend la meme que pour la validation
		if (_after_cancel=='') _after_cancel = _after_ok;
		this.CFM_form_after_cancel = _after_cancel;
		this.CFM_mode_forms   = true;		
	}


	// mode d'invisibilité 1=espace concervé 2=espace comprimé
	this.CFM_init_hide_mode	= function(_hide_mode) {
		this.CFM_hide_mode = _hide_mode;
	}

	// mode d'invisibilité 1=espace concervé 2=espace comprimé
	this.CFM_LibBoutons	= function(_ok,_cancel,_quit) {
		this.BtnOkLib             = _ok;
		this.BtnCancelLibRetablir = _cancel;
		this.BtnCancelLibQuitter  = _quit;
	}

	// MEMORISER LA CLEF ET SA VALEUR
	this.CFM_init_key = function(_keyname,_keyvalue) {
		this.general_keyname  = _keyname;
		this.general_keyvalue = _keyvalue;
		this.multi_ids = true;
		this.multi_ids = (_keyvalue=='');

	}

	// APPEL A LA PROCEDURE STANDARD POUR TROUVER UN OBJET
	this.CFM_findObj = function(n) {
  		var i,x, d=document; 
		for (i=0;!x&&i<d.forms.length;i++) 
			x=d.forms[i][n];
  		for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
			x=this.CFM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById) x=d.getElementById(n); 
		return x;		
	}

	this.CFM_preloadImages = function(fic_image) { //v3.0
		if (fic_image=='') return;
		var d=document; 
		if(d.images){ 
			if(!d.CFM_memo_images) d.CFM_memo_images=new Array();
	 		var i,j=d.CFM_memo_images.length; 
			d.CFM_memo_images[j]=new Image; 
			d.CFM_memo_images[j++].src=fic_image;
			return j-1;
		}
	}

	// MEMORISER UN IDENTIFIANT PASSE EN REQUETE AJAX
	this.CFM_id = function(_id) {
		this.IdAjax = _id;
	}

	// MEMORISER UN IDENTIFIANT PASSE EN REQUETE AJAX
	this.CFM_mode_debug = function(_level) {
		this.AjaxModeDebug = true;
		this.AjaxModeDebuglevel = _level;
	}


	// MEMORISER UN IDENTIFIANT PASSE EN REQUETE AJAX
	this.CFM_post_key = function(KN,KV,FN,FV,ACTION) {
		this.POST_KN = KN;
		this.POST_KV = KV;
		this.POST_FN = FN;
		this.POST_FV = FV;
		this.POST_ACTION = ACTION;
	}

	// INITIALISATION DES COULEURS
	this.CFM_css_init = function(couleurchampnormal,couleurchampobligatoire,couleurchamperreur,couleurtitre) {
		this.couleurchampnormal      = couleurchampnormal ;
		this.couleurchampobligatoire = couleurchampobligatoire ;
		this.couleurchamperreur      = couleurchamperreur;
		this.couleurtitre            = couleurtitre ;				
	}
	// MEMORISATION DE LA DEFINITION DE L'OBJET LISTE	
	this.CFM_ObjetListe = function(nomchamp,t_attrib,t_list) {
		this.table_type[this.table_type.length]       = 'LISTE';
		this.table_objets[this.table_objets.length]   = nomchamp;
		this.table_attrib[this.table_attrib.length]   = t_attrib;
		this.table_valeurs[this.table_valeurs.length] = t_list;
	}

	// MEMORISATION DE LA DEFINITION DE L'OBJET LISTE	
	this.CFM_ObjetBoutonsRadio = function(nomchamp,t_attrib,t_list) {
		this.table_type[this.table_type.length]       = 'RADIO';
		this.table_objets[this.table_objets.length]   = nomchamp;
		this.table_attrib[this.table_attrib.length]   = t_attrib;
		this.table_valeurs[this.table_valeurs.length] = t_list;
	}

	// MEMORISATION DE LA DEFINITION DE L'OBJET COCHE
	this.CFM_ObjetCoche = function(nomchamp,t_attrib) {
		this.table_type[this.table_type.length]       = 'COCHE';
		this.table_objets[this.table_objets.length]   = nomchamp;
		this.table_attrib[this.table_attrib.length]   = t_attrib;
		this.table_valeurs[this.table_valeurs.length] = new Array();
	}

	// MEMORISATION DE LA DEFINITION DE L'OBJET TEXTE
	this.CFM_ObjetChampTexte	 = function(nomchamp,t_attrib) {
		this.table_type[this.table_type.length]       = 'TEXTE';
		this.table_objets[this.table_objets.length]   = nomchamp;
		this.table_attrib[this.table_attrib.length]   = t_attrib;
		this.table_valeurs[this.table_valeurs.length] = new Array();
	}


	// MEMORISATION DE LA DEFINITION DE L'OBJET ICONE
	this.CFM_ObjetIcone = function(nomchamp,t_attrib,t_list) {
		this.table_type[this.table_type.length]       = 'ICONE';
		this.table_objets[this.table_objets.length]   = nomchamp;
		this.table_attrib[this.table_attrib.length]   = t_attrib;
		var icon_path = this.CFM_FindAttribWithKey(this.table_attrib.length-1,'iconpath');
		// transformation des chemins des icones : on ajoute le chemin a l'icone sauf si commence par "." ou "/"
		if (icon_path!='') {
			for (var i=0;i<t_list.length;i+=this.IconeOffsetParam) {
				// on memorise l'indice
				image = this.CFM_IconeAjouterChemin(t_list[i+1],icon_path);				
				this.CFM_preloadImages(image);
				t_list[i+1] = image
			}			 
		}
		this.table_valeurs[this.table_valeurs.length] = t_list;	
	}

	// MEMORISATION DE LA DEFINITION DE L'OBJET ICONES RADIO
	this.CFM_ObjetIconesRadio	 = function(nomchamp,t_attrib,t_list) {
		this.table_type[this.table_type.length]       = 'ICONESRADIO';
		this.table_objets[this.table_objets.length]   = nomchamp;
		this.table_attrib[this.table_attrib.length]   = t_attrib;
		var icon_path = this.CFM_FindAttribWithKey(this.table_attrib.length-1,'iconpath');
		this.CFM_preloadImages( this.CFM_FindAttribWithKey(this.table_attrib.length-1,'icondisabled') );
		// transformation des chemins des icones : on ajoute le chemin a l'icone sauf si commence par "." ou "/"
		if (icon_path!='') {
			for (var i=0;i<t_list.length;i+=this.IconesRadioOffsetParam) {
				var image = this.CFM_IconeAjouterChemin(t_list[i+1],icon_path);
				this.CFM_preloadImages(image);				
				t_list[i+1] = image;
				image = this.CFM_IconeAjouterChemin(t_list[i+2],icon_path);
				this.CFM_preloadImages(image);				
				t_list[i+2] = image;
			}			 
		}
		this.table_valeurs[this.table_valeurs.length] = t_list;	
	}



	// ajoute le chemin aux images
	this.CFM_IconeAjouterChemin = function(une_icone,_icon_path) {
		if (une_icone=='' || _icon_path=='') return une_icone;
		regexp = new RegExp("^[/|.]","g");
		if (!une_icone.match(regexp)) {
			une_icone = _icon_path+une_icone;
		} 
		return une_icone;
	}




	this.CFM_AfficheBtnValider = function(h_attrib) {
		var buffer='';
		if (typeof h_attrib !='undefined') {
			keyname    = h_attrib['keyname'];
			keyvalue   = h_attrib['keyvalue'];
		}
		if (typeof keyname  =='undefined')    keyname=this.general_keyname;
		if (typeof keyvalue =='undefined')    keyvalue=this.general_keyvalue;
		_suffixe = this.CFM_GetSuffixeBtn(keyname,keyvalue);
		// si une url en cas d'annulation a ete definie
		if (this.CFM_form_after_cancel=='') {
			_btncancel = this.BtnCancelLibRetablir;
		} else {
			_btncancel = this.BtnCancelLibQuitter;
		}

		buffer += '<input type="button" value="'+this.BtnOkLib+'" disabled="disabled" id="'+this.BtnOkPrefix+_suffixe+'" onClick="'+this.nomobjjs+'.CFM_ajaxbtn(true,this,\''+keyname+'\',\''+keyvalue+'\')" class="CFMbouton">';
		buffer += '&nbsp;<input type="button" value="'+_btncancel+'" id="'+this.BtnCancelPrefix+_suffixe+'" onClick="'+this.nomobjjs+'.CFM_ajaxbtn(false,this,\''+keyname+'\',\''+keyvalue+'\')" class="CFMbouton">';	
		buffer += '<input type="hidden" value="0" id="'+this.BtnCancelState+_suffixe+'">';	

		document.write(buffer);
	}

	// FONCTIONS SPECIFIQUES DE NOMMAGE DES BOUTONS
	this.CFM_GetSuffixeBtn = function(keyname,keyvalue) {
		return '_KN'+keyname+'_KV'+keyvalue;
	}		


	// DEBUGGAGE DES EVENEMENTS
	this.CFM_AfficherEvenements = function(tx,ty) {	
		document.write('<span id="'+this.DebugZone+'"');
		if (!this.AjaxModeDebug) {
			document.write(' style="display:none"');
		}
		// ZONE D'AFFICHAGE DES CHAMPS DE DEBUGGAGE
		document.write('><span class="CFMlabel">Evenements :<br></span>');
		document.write('<textarea id="'+this.ZoneLogs+'" class="CFMzoneLogs" style="width:'+tx+'; height:'+ty+'" readonly="readonly" title="'+this.tipszonelogs+'"></textarea>');
		document.write('<br><input type="button" value="'+this.BtnRazEvents+'" onClick="'+this.nomobjjs+'.CFM_RazLogsXML()" class="CFMbouton"');
		this.objZoneLogs = this.CFM_findObj(this.ZoneLogs);
		document.write('<br><span class="CFMlabel">XML en retour :<br></span>');
		document.write('<textarea id="'+this.ZoneXML+'" class="CFMzoneLogs" style="width:'+tx+'; height:'+ty+'" readonly="readonly" title="'+this.tipszonelogs+'"></textarea>');
		this.objZoneXML = this.CFM_findObj(this.ZoneXML);		
		document.write('</span>');
		this.objDebugZone = this.CFM_findObj(this.DebugZone);
		
	}


	
	this.CFM_AjouterEvenements = function(evtlib,noalert) {		
		if (this.objZoneLogs) {
			this.objZoneLogs.value = evtlib+"\n"+this.objZoneLogs.value;
		} else if (!noalert) {
			alert(evtlib);
		}
	}

	this.CFM_RazLogsXML = function() {		
		this.objZoneLogs.value = '';
		this.objZoneXML.value = '';
	}


	this.CFM_AfficherObjet = function(nomchamp,valeur,h_attrib) {
		var indice = this.CFM_FindIndiceWithName(nomchamp);
		if (indice==-1) {
			alert('ClasseFormsMini.php : TENTATIVE D\'AFFICHAGE D\'UN CHAMP NON DEFINI ('+nomchamp+')');
			return;
		}
		// si la valeur n'existe pas on prend l'attribut "default"
		if (valeur=='') {			
			valeur = this.CFM_FindAttribWithKey(indice,'default');
		}
		var _defdisabled = this.CFM_FindAttribWithKey(indice,'disabled');
		var _defhidden   = (this.CFM_FindAttribWithKey(indice,'hidden')=='1');
		if (h_attrib) {
			var keyname    = h_attrib['keyname'];
			var keyvalue   = h_attrib['keyvalue'];
			var h_script   = h_attrib['script'];
			var h_disabled = h_attrib['disabled'];
			var h_hide     = h_attrib['hidden'];
		}
		if (typeof keyname    == 'undefined')   keyname=this.general_keyname;
		if (typeof keyvalue   == 'undefined')   keyvalue=this.general_keyvalue;
		if (typeof h_script   == 'undefined')   h_script='';
		if (typeof h_disabled == 'undefined') { h_disabled=_defdisabled; }
		if (typeof h_hide     == 'undefined') { h_hide=_defhidden; }

		// le nom JS du champ est calcule en fonction de 3 parametres
		_id = this.CFM_SetNameJSobj(nomchamp,keyname,keyvalue);
		// memorisation dans la tables des instances des valeurs initiales
		this.table_instances[this.table_instances.length] = {id:_id, name:nomchamp, type:this.table_type[indice], kn:keyname, kv:keyvalue, init_value:valeur, init_disabled:h_disabled, init_hidden:h_hide};
		// entourer l'objet
   		this.CFM_OpenObjectContainer(this.nbre_instances,h_hide);
		this.nbre_instances++;
		switch (this.table_type[indice]) {
			case 'LISTE':
				this.CFM_AfficherObjetListe(_id,indice,nomchamp,valeur,keyname,keyvalue,h_script,h_disabled,h_hide)
				break;
			case 'RADIO':
				this.CFM_AfficherObjetBoutonsRadio(_id,indice,nomchamp,valeur,keyname,keyvalue,h_script,h_disabled)
				break;
			case 'COCHE':
				this.CFM_AfficherObjetCoche(_id,indice,nomchamp,valeur,keyname,keyvalue,h_script,h_disabled)
				break;
			case 'ICONE':
				this.CFM_AfficherObjetIcone(_id,indice,nomchamp,valeur,keyname,keyvalue,h_script,h_disabled)
				break;
			case 'ICONESRADIO':
				this.CFM_AfficherObjetIconesRadio(_id,indice,nomchamp,valeur,keyname,keyvalue,h_script,h_disabled)
				break;
			case 'TEXTE':
				this.CFM_AfficherObjetTexte(_id,indice,nomchamp,valeur,keyname,keyvalue,h_script,h_disabled)
				break;

		}
   		this.CFM_CloseObjectContainer();
	}






	this.CFM_AfficherObjetListe = function(id,indice,nomchamp,valeur,keyname,keyvalue,script,disabled) {
		var _style     = '';
		var _attributs = '';
		var _nbreoptions = this.table_valeurs[indice].length;
		var width = this.CFM_FindAttribWithKey(indice,'width');
		if (width!='') { 
			_style+='width:'+width+'; '; 
		}
		all_disabled = this.CFM_FindAttribWithKey(indice,'disabled');
		if (all_disabled=='1' || disabled=='1') { 
			_attributs+=' disabled="disabled" ' 
			_class='CFMchampRO'; 
		} else {
			_class='CFMchamp'; 
		}
		var rows = this.CFM_FindAttribWithKey(indice,'rows');
		if (rows=='') rows = '1';		
		var title = '';
		if (rows=='1' && valeur=='') {
			title = this.CFM_FindAttribWithKey(indice,'title');
			if (title=='') {
				title = this.ListeTitreParDefautUneLigne;
			}
		} 
		_attributs+=' size="'+rows+'" ';
		
		obj_js  = '<select name="'+id+'" '+_attributs+' style="'+_style+'" class="'+_class+'" onChange="return '+this.nomobjjs+'.CFM_ajaxcall(\''+nomchamp+'\',this,\'\',\''+keyname+'\',\''+keyvalue+'\')">';
		if (_nbreoptions>0) {
			if (title!='') {				
				obj_js += '<option value=""';
				if (valeur=='') {
					obj_js += ' selected';
				}
				obj_js += '>'+title+'</option>';
			}
			for (var i=0;i<_nbreoptions;i+=2) {
				_selected = (valeur==this.table_valeurs[indice][i]) ? ' selected' : '';
				obj_js += '<option value="'+this.table_valeurs[indice][i]+'"'+_selected+'>'+this.table_valeurs[indice][i+1]+'</option>';
			}
		}
		obj_js += '</select>';
		document.write(obj_js);

	}







	this.CFM_AfficherObjetBoutonsRadio = function(id,indice,nomchamp,valeur,keyname,keyvalue,script,p_disabled) {
		var style = '';
		all_disabled = this.CFM_FindAttribWithKey(indice,'disabled');
		if (all_disabled=='1' || p_disabled=='1') { style+=' disabled="disabled" ' }

		orientation = this.CFM_FindAttribWithKey(indice,'orientation');
		if (orientation=='V') { 
			libavant  = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr align="left" valign="top"><td>';
			libinter  = '<br>';
			libapres  = '</td></tr></table>';
		} else {
			libavant  = '';
			libinter  = '';
			libapres  = '';
		}
		
		obj_js = libavant;
		obj_js += '<input type="hidden" name="'+id+'" value="'+valeur+'">';
		for (var i=0;i<this.table_valeurs[indice].length;i+=2) {
			_checked = (valeur==this.table_valeurs[indice][i]) ? ' checked="checked" ' : '';
			obj_js += '<input type="radio" '+style +'  name="'+id+'_" id="'+this.CFM_GetRadioId(id,this.table_valeurs[indice][i])+'" value="'+this.table_valeurs[indice][i]+'" tabindex="'+i+'" '+_checked+' onClick="var obj_hidden='+this.nomobjjs+'.CFM_findObj(\''+id+'\');if (obj_hidden.value==this.value) { return false; } obj_hidden.value=this.value;return '+this.nomobjjs+'.CFM_ajaxcall(\''+nomchamp+'\',obj_hidden,\'\',\''+keyname+'\',\''+keyvalue+'\')" /><label for="radiobutton" class="CFMlabel">'+this.table_valeurs[indice][i+1]+'</label>'+libinter;
		}
		obj_js += libapres;		
		document.write(obj_js);		
	}






	this.CFM_AfficherObjetCoche = function(id,indice,nomchamp,valeur,keyname,keyvalue,script,disabled) {
		var attributs = '';
		if (valeur=='1') {
			attributs += ' checked="checked" ';		
		}
		_title = this.CFM_FindAttribWithKey(indice,'title');
		if (_title!='') {
			attributs += ' title="'+_title+'" ';
		}
		all_disabled = this.CFM_FindAttribWithKey(indice,'disabled');
		if (all_disabled=='1' || disabled=='1') { attributs+=' disabled="disabled" ' }		
		obj_js  = '<label id="'+this.CFM_GetNameLabelCoche(id)+'" class="CFMlabel" style="display:inline"><input type="checkbox" value="'+valeur+'" name="'+id+'" '+attributs+' onClick="return '+this.nomobjjs+'.CFM_ajaxcall(\''+nomchamp+'\',this,\'\',\''+keyname+'\',\''+keyvalue+'\')">';
		var label = this.CFM_FindAttribWithKey(indice,'label');
		obj_js += label+'</label>';
		document.write(obj_js);
	}





	this.CFM_AfficherObjetTexte = function(id,indice,nomchamp,valeur,keyname,keyvalue,script,disabled) {
		var _attributs = '';
		var _style    = '';
		all_disabled = this.CFM_FindAttribWithKey(indice,'disabled');
		if (all_disabled=='1' || disabled=='1') { 
			_attributs +=' disabled="disabled" '; 
			_class='CFMchampRO'; 
		} else {
			_class='CFMchamp'; 
		}
		var width = this.CFM_FindAttribWithKey(indice,'width');
		if (width!='') { _style+='width:'+width+'; '; }
		var maxlength = this.CFM_FindAttribWithKey(indice,'maxlength');
		if (maxlength!='') { _attributs+='maxlength="'+maxlength+'" '; }
		var attrib = this.CFM_FindAttribWithKey(indice,'attrib');
		if (attrib!='') { 
			if (attrib.match(/U/g)) {
				_style+='text-transform: uppercase; ';
			}
			if (attrib.match(/I/g)) {
				_style+='text-transform: capitalize; ';
			}
			if (attrib.match(/L/g)) {
				_style+='text-transform: lowercase; ';
			}
			
		}
 		
		obj_js  = '<input type="text" name="'+id+'" '+_attributs+' style="'+_style+'" class="'+_class+'" ';
		// en mode formulaire on desactive l'evaluation "onBlur" du champ pour ne faire qu'une moodification de l'etat des boutons
		if (this.CFM_mode_forms) {
			obj_js += ' onkeypress="'+this.nomobjjs+'.CFM_ActionSurBtnOk(\''+keyname+'\',\''+keyvalue+'\',true)"';
		} else {
			obj_js += ' onBlur="return '+this.nomobjjs+'.CFM_ajaxcall(\''+nomchamp+'\',this,\'\',\''+keyname+'\',\''+keyvalue+'\')"';
		}
		// fin de l'objet
		obj_js += '>';
		document.write(obj_js);
		// alert(obj_js);
		var obj = this.CFM_findObj(id);
		if (obj) {
			obj.value = valeur;
		}
	}





	this.CFM_AfficherObjetIcone = function(id,indice,nomchamp,valeur,keyname,keyvalue,script,disabled) {
		var _attributs = '';
		var _style     = '';
		var objdisabled = (this.CFM_FindAttribWithKey(indice,'disabled')=='1' || disabled=='1');
		_attrib = this.CFM_FindAttribWithKey(indice,'width');
		if (_attrib!='') {
			_attributs += ' width="'+_attrib+'" ';
		}

		// dans tous les cas on verifie la bonne valeur		
		var t_valeurs = this.table_valeurs[indice];
		var indice_element = this.CFM_FindRangListeValeur(indice,valeur,this.IconeOffsetParam);		
		if (indice_element==-1) {
			_icone = this.icon_nodisabled;
			_title = this.icon_valeurnontrouvee_title+' (='+valeur+') et la valeur par defaut est mauvaise aussi' ;
			_value = '';
		} else {
			// la valeur en parametre est dans ma liste on la prend
			var _value = t_valeurs[indice_element];
			// si l'objet est inactif au moment de sa definition
			if (objdisabled) {
				var _class  = 'CFMImgDisabled';
				var _disabled = ' disabled="disabled" ';
				_title    = '';
			} else {
				var _class  = 'CFMImgEnabled';
				var _disabled = '';
				_title = t_valeurs[indice_element+2];
				if (_title=='') {
					_title = this.CFM_FindAttribWithKey(indice,'title');
				}
			}
			_icone = t_valeurs[indice_element+1];
			
		}
		_title = ' title="'+_title+'" ';
		obj_js  = '<input type="hidden" name="'+id+'" '+_disabled+' value="'+_value+'">';
		obj_js += '<img src="'+_icone+'" id="'+this.CFM_GetNameIcon(id)+'"'+_title+_attributs+' style="'+_style+'" class="'+_class+'" onClick="'+this.nomobjjs+'.CFM_ajaxcall(\''+nomchamp+'\','+this.nomobjjs+'.CFM_findObj(\''+id+'\'),\'\',\''+keyname+'\',\''+keyvalue+'\')">';
		document.write(obj_js);
//		alert(obj_js);
	}




	this.CFM_AfficherObjetIconesRadio = function(id,indice,nomchamp,valeur,keyname,keyvalue,script,disabled,hidden) {
		var objdisabled = (this.CFM_FindAttribWithKey(indice,'disabled')=='1' || disabled=='1');
		// si on veut voir le choix meme si l'objet est inactif
		var viewdisabled = (this.CFM_FindAttribWithKey(indice,'viewdisabled')=='1');
		var separator    = this.CFM_FindAttribWithKey(indice,'separator');
		// si l'objet est inactif
		if (objdisabled) {
			_disabled = ' disabled="disabled" ';
		} else {
			_disabled = '';
		}
		obj_js  = '';
		var _j = 0;
		var _offset = 0;
		var _trouve = 0;
		var _class  = 'CFMImgEnabled';
		for (var i=0;i<this.table_valeurs[indice].length;i+=this.IconesRadioOffsetParam) {
			valeur_indice = this.table_valeurs[indice][i];
			if (valeur_indice==valeur) {
				_trouve++;
				if ( (viewdisabled && objdisabled) || !objdisabled) {
					_offset = 1;
				} else {
					_offset = 2;
				}
			} else {
				_offset = 2;
			}
			if (objdisabled) {
				_class  = 'CFMImgDisabled';
			} else {
				_title = this.table_valeurs[indice][i+4];
				if (_title=='') {
					_title = this.CFM_FindAttribWithKey(indice,'disabledtitle');
				}
				_title = ' title="'+_title+'" ';				
			}
			// pour toutes images sauf la 1er on insere le separateur
			if (_j>0) obj_js+=separator;
			obj_js += '<img src="'+this.table_valeurs[indice][i+_offset]+'" id="'+this.CFM_GetNameIconsRadio(id,_j)+'"'+_title+' class="'+_class+'" onClick="'+this.nomobjjs+'.CFM_ajaxcall(\''+nomchamp+'\','+this.nomobjjs+'.CFM_findObj(\''+id+'\'),\''+valeur_indice+'\',\''+keyname+'\',\''+keyvalue+'\')">';
			_j++;
		}
		// si la valeur n'a pas ete trouvee alors on l'annule
		if (_trouve==0) {
			valeur = '';
		}
		obj_js  += '<input type="hidden" name="'+id+'" '+_disabled+' value="'+valeur+'">';
		document.write(obj_js);
	}




	this.CFM_MajIconesAvecValeur = function(indice,champ,obj,valeur,desactiver_tout) {
		// recuperation de la valeur du champ cache
		var _j = 0;
		var champlong = obj.name;
		for (var i=0;i<this.table_valeurs[indice].length;i+=this.IconesRadioOffsetParam) {
			if (this.table_valeurs[indice][i]==valeur) {					
				var viewdisabled = (this.CFM_FindAttribWithKey(indice,'viewdisabled')=='1');
				if (desactiver_tout && !viewdisabled) {
					_offset = 2;
				} else {
					_offset = 1;
				}
			} else {
				_offset = 2;
			}
			
			var obj = this.CFM_findObj(this.CFM_GetNameIconsRadio(champlong,_j));
			if (obj) {
				obj.src=this.table_valeurs[indice][i+_offset];
				if (desactiver_tout) {
					obj.title = '';
					this.CFM_css_opacite(obj,true);
				} else {
					obj.title = this.table_valeurs[indice][i+3];
					this.CFM_css_opacite(obj,false);
				}
			}
			_j++;
		}
	}

	this.CFM_GetRadioId = function(idchamp,rang) {
		return idchamp+'_'+rang;
	}
	// FONCTIONS SPECIFIQUES DE GESTION DES COCHES
	this.CFM_GetNameLabelCoche = function(nomchamp) {
		return nomchamp+'_LABEL';
	}

	// FONCTIONS SPECIFIQUES DE GESTION DES ICONES
	this.CFM_GetNameIcon = function(nomchamp) {
		return nomchamp+'_ICO';
	}

	this.CFM_GetNameIconsRadio = function(nomchamp,rang) {
		return nomchamp+'_IDX_'+rang;
	}
	
	
	this.CFM_SetNameJSobj = function(nomchamp,keyname,keyvalue) {
		return this.jsPrefix+nomchamp+'_'+keyname+'_'+keyvalue;
	}



	// juste en fin de formulaire
	this.CFM_InitFormulaire = function() {
		this.CFM_ajaxcall_init();
	};
	
	
	

	// quand on clique sur un des boutons Valider ou Annuler/Quitter
	this.CFM_ajaxbtn = function(_validation,_objbtn,_kn,_kv) {
		var _suffixe = this.CFM_GetSuffixeBtn(_kn,_kv);
		if (_validation) {
			if (this.AjaxModeDebug) this.CFM_AjouterEvenements("CFM_ajaxbtn() --> VALIDATION",true);
			this.FormIsLocked = true;
			_objbtn.disabled  = true;
			var obj = this.CFM_findObj(this.BtnCancelPrefix+_suffixe);
			obj.disabled = true;
			/*
			------------------------------------------------------------
			 VALIDATION DU FORMULAIRE
			------------------------------------------------------------
			*/
			var Requete = this.POST_ACTION+'=OK&OBJECT='+encodeURIComponent(_objbtn.id)+'&'+this.POST_FN+'=*&'+this.POST_FV+'=*&'+this.POST_KN+'='+_kn+'&'+this.POST_KV+'='+_kv;
			for (var i=0;i<this.table_instances.length;i++) {
				// on filtre les champs qui sont rattaché a la clef actuelle
				if ( this.table_instances[i].kn==_kn &&  this.table_instances[i].kv==_kv) {
					var obj = this.CFM_findObj(this.table_instances[i].id);
					if (obj) {
						Requete += '&'+this.POST_FN+'#'+i+'='+encodeURIComponent(this.table_instances[i].name);
						Requete += '&'+this.POST_FV+'#'+i+'='+encodeURIComponent(obj.value);
					}
				}
			}

			if (this.IdAjax!='') {
				Requete += '&ID='+this.IdAjax;
			}
			if (this.AjaxModeDebug) {
				Requete += '&URL='+_url_cible+'&MODEDEBUG=1';
			}

			// LA REQUETE PEUT MAINTENANT COMMENCER		
			var XmlDoc = CFM_HttpRequest();		
			var _obj_to_call    = this.nomobjjs;
			var _obj_ZoneXML    = this.objZoneXML
			var _AjaxModeDebug  = this.AjaxModeDebug;
			// On défini ce qu'on va faire quand on aura la réponse
			XmlDoc.onreadystatechange = function() {
				// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
				if(XmlDoc.readyState == 4 && XmlDoc.status == 200) {
					reponse = CFM_DOM_clean(XmlDoc.responseXML.documentElement);
					//------------------------------------------------------------------		
					// on va controler si des warnings sont remonte 
					// et si OUI alors on affiche qque soit le mode de debuggage
					if (_AjaxModeDebug || reponse.getElementsByTagName('warning').length>0) {
						if (_obj_ZoneXML) {
							_obj_ZoneXML.value = XmlDoc.responseText;
						} else {
							alert(XmlDoc.responseText); 
						}
					}
					// analyse en retour de l'evenement declencheur
					x=reponse.getElementsByTagName('event');				
					if (x[0].childNodes[0]) {					
						_sourcetype = x[0].childNodes[0].nodeValue;
						if (_sourcetype=='FIELD') {
						}
					}
					var _field      = x[0].attributes.getNamedItem("fieldname").nodeValue;
					var _field_name = x[0].attributes.getNamedItem("object").nodeValue;
					var _call_kn    = x[0].attributes.getNamedItem("keyname").nodeValue;
					var _call_kv    = x[0].attributes.getNamedItem("keyvalue").nodeValue;
					eval(_obj_to_call+'.CFM_after_ajaxbtn()');

					//------------------------------------------------------------------
				}
			} // fin de methode "onreadystatechange" modifie pour le debuggage
		
			XmlDoc.open("POST",_url_cible,true); // appel asynchrone
			XmlDoc.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8"); 
			XmlDoc.send(Requete);
			
			
			
		} else {
			if (this.AjaxModeDebug) this.CFM_AjouterEvenements("CFM_ajaxbtn() --> ANNULATION",true);
			var obj = this.CFM_findObj(this.BtnCancelState+_suffixe);
			if (obj.value=='1') {
				// ------------------
				//     ANNULER
				// ------------------
				// on va retablir les valeurs d'origine et l'état de tous les objets
				this.CFM_ajaxcall_init();
				for (var i=0;i<this.table_instances.length;i++) {
					var instance     = this.table_instances[i]
					var indice       = this.CFM_FindIndiceWithName(instance.name);
					var _norestore   = this.CFM_FindAttribWithKey(indice,'norestore');
					var _initoptions = (this.CFM_FindAttribWithKey(indice,'initoptions')=='1');
					// on filtre les champs qui sont rattaché a la clef actuelle
					if ( instance.kn==_kn &&  instance.kv==_kv && _norestore!='1') {
						// on commence par remettre la valeur initiale
						this.CFM_ChangerValeur(instance.name,instance.id,instance.init_value,true);
						//  puis ensuite l'etat initial
						var etat_initial = instance.init_disabled;
						if (etat_initial=='1') {
							this.CFM_ObjetDesactiver(instance.name,instance.id);							
						} else {
							this.CFM_ObjetActiver(instance.name,instance.id);
						}
						// restauration de l'etat visible ou invisible
						this.CFM_HideObject(i,instance.init_hidden);
					}
				}
				// desactiver les boutons
				this.CFM_ActionSurBtnOk(_kn,_kv,false);
			} else {
				// QUITTER
				this.FormIsLocked = true; // on verrouille le formulaire
				document.location.href = this.CFM_form_after_cancel;
			}
		}
	}
	


	this.CFM_after_ajaxbtn = function() {
		document.location.href = this.CFM_form_after_ok;
	}
		
		



		

	// fonction pour initialiser tous les objets du formulaire
	this.CFM_ajaxcall_init = function() {
		if (this.objZoneLogs) {
			if (this.AjaxModeDebug) this.CFM_AjouterEvenements("CFM_ajaxcall_init() ",true);
		}

		// PREPARATION DE LA REQUETE		
		var kn = this.general_keyname;
		var kv = this.general_keyvalue;
		var Requete = this.POST_ACTION+'=INIT&'+this.POST_KN+'='+kn+'&'+this.POST_KV+'='+kv;
		for (var i=0;i<this.table_instances.length;i++) {
			// on filtre les champs qui sont rattaché a la clef actuelle
			if ( this.table_instances[i].kn==kn &&  this.table_instances[i].kv==kv) {
				var obj = this.CFM_findObj(this.table_instances[i].id);
					if (obj) {
						Requete += '&'+this.POST_FN+'#'+i+'='+encodeURIComponent(this.table_instances[i].name);
						Requete += '&'+this.POST_FV+'#'+i+'='+encodeURIComponent(this.table_instances[i].init_value);
					}
				}
			}
		if (this.IdAjax!='') {
			Requete += '&ID='+this.IdAjax;
		}
		if (this.AjaxModeDebug) {
			Requete += '&URL='+this.UrlAjax+'&MODEDEBUG=1';
		}
		
		// LA REQUETE PEUT MAINTENANT COMMENCER		
		var XmlDoc = CFM_HttpRequest();		
		var _obj_to_call    = this.nomobjjs;
		var _obj_ZoneXML    = this.objZoneXML		
		var _AjaxModeDebug  = this.AjaxModeDebug;
		// On défini ce qu'on va faire quand on aura la réponse
		XmlDoc.onreadystatechange = function() {
			// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
			if(XmlDoc.readyState == 4 && XmlDoc.status == 200) {
				var reponse = CFM_DOM_clean(XmlDoc.responseXML.documentElement);
				//------------------------------------------------------------------		
				// on va controler si des warnings sont remonte 
				// et si OUI alors on affiche qque soit le mode de debuggage
				if (_AjaxModeDebug || reponse.getElementsByTagName('warning').length>0) {
					if (_obj_ZoneXML) {
						_obj_ZoneXML.value = XmlDoc.responseText;
					} else {
						alert(XmlDoc.responseText); 
					}
				}

				var x=reponse.getElementsByTagName('event');				

				var _field      = x[0].attributes.getNamedItem("fieldname").nodeValue;
				var _field_name = x[0].attributes.getNamedItem("object").nodeValue;
				var _call_kn    = x[0].attributes.getNamedItem("keyname").nodeValue;
				var _call_kv    = x[0].attributes.getNamedItem("keyvalue").nodeValue;

				var x=reponse.getElementsByTagName('action');
				// SUPPRESSION DES SAUT DE LIGNE
				var exprSansCR   = new RegExp("\n", "g");
				var cpt_action = 0;
				var liste_actions = '';
				for (i=0;i<x.length;i++) {
					if (x[i].childNodes[0]) {
						// recuperation de l'attribut qui contient "type" de l'option
						var obj = x[i].attributes.getNamedItem("type");
						if (obj) {
							_type   = obj.nodeValue;
							obj = x[i].attributes.getNamedItem("fieldname");
							_target = (obj) ? obj.nodeValue : '';
							// recuperation de l'attribut optionnel qui contient la clef de l'enreistrement
							obj = x[i].attributes.getNamedItem("keyname");
							_keyname = (obj) ? obj.nodeValue : '';
							obj = x[i].attributes.getNamedItem("keyvalue");
							_keyvalue = (obj) ? obj.nodeValue : '';
							// recuperation de la valeur "value"
							obj = x[i].childNodes[0];
							_value = (obj) ? obj.nodeValue : '';
							liste_actions += ',\''+_type+'\',\''+_target+'\',\''+_keyname+'\',\''+_keyvalue+'\',\''+_value+'\'';
							// cas des options
							if (_type=='CHANGEOPTIONS') {
								var maj_options = _obj_to_call+'.CFM_after_ajax_options(\''+_target+'\',\''+_call_kn+'\',\''+_call_kv+'\',\''+_value+'\'';
								// on va descendre au noveau du tag "option"
								var nodes=x[i].childNodes;
								// on part du 2e fils, le 1er etant le nom du champ cible
								for(var k=1; k<nodes.length; k++) {
									_value = nodes[k].attributes.getNamedItem("value").nodeValue;
									_text  = nodes[k].childNodes[0].nodeValue;									
									maj_options += ',\''+CFM_EscQuotes(_value)+'\',\''+CFM_EscQuotes(_text)+'\'';
								}
                       			maj_options += ')';
								eval(maj_options);
							}
							cpt_action++;
						}
					}
				}
				eval(_obj_to_call+'.CFM_after_ajax(\'I\',\''+_field+'\',\''+_field_name+'\',\''+_call_kn+'\',\''+_call_kv+'\''+liste_actions+')');
				//------------------------------------------------------------------
			}
		} // fin de methode "onreadystatechange" modifie pour le debuggage
		
		XmlDoc.open("POST",this.UrlAjax,true); // appel asynchrone
		XmlDoc.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8"); 
		XmlDoc.send(Requete);
	}






	this.CFM_ajaxcall = function(champ,idobj,valeurs_selection,keyname,keyvalue) {
		// si le formulaire est bloque ou en attente de reponse on ne fait rien
		if (this.AjaxModeDebug) {
			this.CFM_AjouterEvenements('CFM_ajaxcall('+champ+') ',true);
		}
		if (this.FormIsLocked) {
			if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION sur champ '+champ+' refusee, le formulaire est bloque');
			return false;
		} else if (idobj.disabled) {
			if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION sur champ '+champ+' refusee, l\'objet est inactif');
			return false;
		}
		// on bloque le formulaire jusqu'au retour de la reponse et son traitement
		this.FormIsLocked = true;
		
		// on recupere les parametres pour travailler avec une copie (sinon serait ecrase par un autre appel)
		var ac_champ    = champ;
		var ac_idobj    = idobj;
		var ac_valeurs_selection = valeurs_selection;
		var ac_keyname  = keyname;
		var ac_keyvalue = keyvalue;
		
		// si l'attribut "confirm" est défini on demande confirmation
		var _confirm = (this.CFM_FindAttribWithKey(this.CFM_FindObjWithName(ac_champ),'confirm'));					
		if (_confirm!='') {
			if (!confirm(_confirm)) {
				this.FormIsLocked = false;
				return true;	
			}
		}
		// PREPARATION DE LA REQUETE
		var indicechamp = this.CFM_FindIndiceWithName(ac_champ);
		// 1) quelle est l'url cible
		_url_cible = (this.CFM_FindAttribWithKey(indicechamp,'url'));		
		if (_url_cible=='') {
			_url_cible = this.UrlAjax;
		}
		// 1) on determine le type de champ
	 	var type_champ = this.CFM_FindTypeObjWithName(ac_champ);
		switch (type_champ) {
			case 'COCHE':
				var _value = (ac_idobj.checked) ? '1': '0';
				ac_idobj.value = _value;
				break;

			case 'RADIO':
				var _value = ac_idobj.value;
				break;

			case 'ICONE':
				// avec une icone on modifie l'image avant l'appel a la requete
				var obj_ico    = this.CFM_findObj(this.CFM_GetNameIcon(ac_idobj.name));
				if (ac_idobj.disabled) {
					if (this.AjaxModeDebug) this.CFM_AjouterEvenements('INFO : le champ '+ac_champ+' de type '+type_champ+' est inactif !');
					this.FormIsLocked = false;
					return false;
				}
				// alert('valeur actuelle="'+valeur_actuelle);
				var valeur_actuelle = ac_idobj.value;
				var t_valeurs = this.table_valeurs[indicechamp];
				// on va chercher la valeur suivante de la liste
				var indice_element = this.CFM_FindRangListeValeur(indicechamp,valeur_actuelle,this.IconeOffsetParam);
				if (indice_element==-1) {
					indice_element = 0;
				} else {
					indice_element+=this.IconeOffsetParam;
				}
				// pour le dernier de la liste on revient a zero
				if (typeof this.table_valeurs[indicechamp][indice_element] == 'undefined') {
					indice_element = 0;
				}
				_value = t_valeurs[indice_element];
				_icone = t_valeurs[indice_element+1];
				_title = t_valeurs[indice_element+2];
				if (_title=='') {
					_title = this.CFM_FindAttribWithKey(indicechamp,'title');
				}
				ac_idobj.value = _value;
				if (obj_ico) {
					obj_ico.src   = _icone;
					if (_title!='') {
						obj_ico.title = _title;
					}
				}
				break;
				
				
				
			case 'ICONESRADIO':
				// si objet inactif on sort
				if (ac_idobj.disabled) {
					if (this.AjaxModeDebug) this.CFM_AjouterEvenements('INFO : le champ '+ac_champ+' de type '+type_champ+' est inactif !');
					this.FormIsLocked = false;
					return false;
				}
				// attention ac_idobj est dans ce cas l'indice de l'objet selectionné
				var _value= ac_valeurs_selection;
				// si on clique sur la meme option on ne fait rien
				if (ac_idobj.value==_value) {
					if (this.AjaxModeDebug) this.CFM_AjouterEvenements('INFO : le champ '+ac_champ+' de type '+type_champ+' etait deja selectionne !');
					this.FormIsLocked = false;
					return false;
				}
				ac_idobj.value = _value;
// alert('avant ajax ='+ac_valeurs_selection);				
				this.CFM_MajIconesAvecValeur(indicechamp,ac_champ,ac_idobj,ac_valeurs_selection,false);
				break;
				
			default:
				var _value = ac_idobj.value;
		}
		
		var kn = (ac_keyname=='')  ? this.general_keyname  : ac_keyname;
		var kv = (ac_keyvalue=='') ? this.general_keyvalue : ac_keyvalue;
		var Requete = this.POST_ACTION+'=FIELD&OBJECT='+encodeURIComponent(ac_idobj.name)+'&'+this.POST_FN+'='+encodeURIComponent(ac_champ)+'&'+this.POST_FV+'='+encodeURIComponent(_value)+'&'+this.POST_KN+'='+kn+'&'+this.POST_KV+'='+kv;
		if (this.IdAjax!='') {
			Requete += '&ID='+this.IdAjax;
		}
		if (this.AjaxModeDebug) {
			Requete += '&URL='+_url_cible+'&MODEDEBUG=1';
		}
		
		// alert(Requete);
		
		// LA REQUETE PEUT MAINTENANT COMMENCER		
		// transformation du bouton de recherche en bouton animé
		var XmlDoc = CFM_HttpRequest();		
		var _obj_to_call    = this.nomobjjs;
		var _obj_ZoneXML    = this.objZoneXML				
		var _AjaxModeDebug  = this.AjaxModeDebug;
		// On défini ce qu'on va faire quand on aura la réponse
		XmlDoc.onreadystatechange = function() {
			// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
			if(XmlDoc.readyState == 4 && XmlDoc.status == 200) {
				reponse = CFM_DOM_clean(XmlDoc.responseXML.documentElement);
				//------------------------------------------------------------------		
				// on va controler si des warnings sont remonte 
				// et si OUI alors on affiche qque soit le mode de debuggage
				if (_AjaxModeDebug || reponse.getElementsByTagName('warning').length>0) {
					if (_obj_ZoneXML) {
						_obj_ZoneXML.value = XmlDoc.responseText;
					} else {
						alert(XmlDoc.responseText); 
					}
				}
				// analyse en retour de l'evenement declencheur
				x=reponse.getElementsByTagName('event');				

				var _field      = x[0].attributes.getNamedItem("fieldname").nodeValue;
				var _field_name = x[0].attributes.getNamedItem("object").nodeValue;
				var _call_kn    = x[0].attributes.getNamedItem("keyname").nodeValue;
				var _call_kv    = x[0].attributes.getNamedItem("keyvalue").nodeValue;

				var x=reponse.getElementsByTagName('action');
				// SUPPRESSION DES SAUT DE LIGNE
				var exprSansCR   = new RegExp("\n", "g");
				cpt_action = 0;
				liste_actions = '';
				for (i=0;i<x.length;i++) {
					if (x[i].childNodes[0]) {
						// recuperation de l'attribut qui contient "type" de l'option
						var obj = x[i].attributes.getNamedItem("type");
						if (obj) {
							_type   = obj.nodeValue;
							// _target = x[i].childNodes[0].nodeValue;
							obj = x[i].attributes.getNamedItem("fieldname");
							_target = (obj) ? obj.nodeValue : '';
							// recuperation de l'attribut optionnel qui contient la clef de l'enreistrement
							obj = x[i].attributes.getNamedItem("keyname");
							_keyname = (obj) ? obj.nodeValue : '';
							obj = x[i].attributes.getNamedItem("keyvalue");
							_keyvalue = (obj) ? obj.nodeValue : '';
							// recuperation de la valeur "value"
							obj = x[i].childNodes[0];
							_value = (obj) ? CFM_EscQuotes(obj.nodeValue) : '';
							liste_actions += ',\''+_type+'\',\''+_target+'\',\''+_keyname+'\',\''+_keyvalue+'\',\''+_value+'\'';
							// cas des options
							if (_type=='CHANGEOPTIONS') {
								var maj_options = _obj_to_call+'.CFM_after_ajax_options(\''+_target+'\',\''+_call_kn+'\',\''+_call_kv+'\',\''+_value+'\'';
								// on va descendre au noveau du tag "option"
								var nodes=x[i].childNodes;
								// on part du 2e fils, le 1er etant le nom du champ cible
								for(var k=1; k<nodes.length; k++) {
									_value = nodes[k].attributes.getNamedItem("value").nodeValue;
									_text  = nodes[k].childNodes[0].nodeValue;									
									_target = _target.replace(exprSansCR,'');
									maj_options += ',\''+CFM_EscQuotes(_value)+'\',\''+CFM_EscQuotes(_text)+'\'';
								}
                       			maj_options += ')';
								eval(maj_options);
							}
							cpt_action++;
						}
					}
				}
				eval(_obj_to_call+'.CFM_after_ajax(\'A\',\''+_field+'\',\''+_field_name+'\',\''+_call_kn+'\',\''+_call_kv+'\''+liste_actions+')');
				//------------------------------------------------------------------
			}
		} // fin de methode "onreadystatechange" modifie pour le debuggage
		
		XmlDoc.open("POST",_url_cible,true); // appel asynchrone
		XmlDoc.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8"); 
		XmlDoc.send(Requete);
	}



	// fonction appelee pour changer les options d'une liste
	this.CFM_after_ajax_options = function( _target, _call_kn, _call_kv, _value) {
		if (this.AjaxModeDebug) this.CFM_AjouterEvenements('CFM_after_ajax_options() : Changer les options du champ '+_target+' puis sa valeur ('+_value+')');
		var args = this.CFM_after_ajax_options.arguments;
		// _target(0) _keyname(1) _keyvalue(2) _value(3)
		var indice=this.CFM_FindObjWithName(_target);
		var type_champ = this.CFM_FindTypeObjWithName(_target);
		var _nbreoptions = (args.length-4)/2;
		switch (type_champ) {
			case 'LISTE':
				var _obj = this.CFM_findObj(this.CFM_SetNameJSobj(_target,_call_kn,_call_kv));
				if (_obj) {				
					var _id = 0;
					_obj.length=1;
					// TRAITEMENT CAS LISTE DEROULANTE
					var _rows = this.CFM_FindAttribWithKey(indice,'rows');
					if (_rows=='1' && _value=='' && _nbreoptions>0) {
						var _title = this.CFM_FindAttribWithKey(indice,'title');
						if (_title=='') {
							_title = this.ListeTitreParDefautUneLigne;
						}
						_obj.options[0].value = '';
						_obj.options[0].text  = _title;
						_obj.options[0].selected = true;
						_obj.length++;
						_id++;
					}
					_obj.length = _nbreoptions+_id; 
					for (var i=4;i<args.length;i+=2) {
						_obj.options[_id].value = args[i];
						_obj.options[_id].text  = args[i+1];
						_obj.options[_id].selected = (args[i]==_value);
						_id++;
					}
				}
				break;
		}
	}





	// fonction appelee en fin de requete AJAX
	this.CFM_after_ajax = function(_action,_field, _field_name, _call_kn, _call_kv) {
		var args = this.CFM_after_ajax.arguments;
		if (this.objZoneLogs) {			
			if (this.AjaxModeDebug) {
				this.CFM_AjouterEvenements("CFM_after_ajax("+_field+")");
			}
		}
		// 1) on determine le type de champ
		var indicechamp = this.CFM_FindIndiceWithName(_field);
		// recuperation du script si il existe
		var _script = (this.CFM_FindAttribWithKey(indicechamp,'script'));
		if (_script!='') {
			eval(_script);
		}
		var indiceinstance = this.CFM_FindNameWithObj(_field_name);
		// activation si il existe du bouton OK, on ne le fait pas en phase d'initialisation AJAX
		if (this.CFM_FindAttribWithKey(indicechamp,'norestore')!='1' && _action=='A') {
			this.CFM_ActionSurBtnOk(_call_kn,_call_kv,true);
		}
		
		// _action(0) _type(1) _target(2) _keyname(3) _keyvalue(4) _value+(5)
		var cpt_actions = 0;
		for (var i=5;i<args.length;i+=5) {
			nomobjJS = this.CFM_SetNameJSobj(args[i+1],args[i+2],args[i+3]);
			// en fonction de l'action on appele la bonne fonction
			switch(args[i]) {
				case 'DISABLE':
					this.CFM_ObjetDesactiver(args[i+1],nomobjJS);
					break;
				case 'ENABLE':
					this.CFM_ObjetActiver(args[i+1],nomobjJS);
					break;
				case 'HIDE':
					this.CFM_ObjetCacher(nomobjJS,true);
					break;
				case 'SHOW':
					this.CFM_ObjetCacher(nomobjJS,false);
					break;
				case 'CHANGEVALUE':
					this.CFM_ChangerValeur(args[i+1],nomobjJS,args[i+4],false,false);
					break;					
				case 'RESTOREVALUE':
					this.CFM_ChangerValeur(args[i+1],nomobjJS,'',false,true);
					break;					
				case 'FOCUS':
					this.CFM_SeDeplacerSurObjet(args[i+1],nomobjJS);
					break;					
				case 'MESSAGE':
					this.CFM_AfficherMessage(args[i+4]);
					break;					
				case 'DEBUGENABLE':
					if (this.objDebugZone) {
						this.objDebugZone.style.display="inline"; 
						this.CFM_AjouterEvenements("Le mode debug est actif");						
					}
					this.AjaxModeDebug = true;
					break;					
				case 'DEBUGDISABLE':
					if (this.objDebugZone) {
						this.objDebugZone.style.display="none"; 
					}
					alert('Le Mode debug est desactive !');
					this.AjaxModeDebug = false;
					break;					
				case 'CHANGEOPTIONS':
					// on ne fait rien pour cette action
					break;
				default:
					if (this.AjaxModeDebug) alert('CFM_after_ajax() TYPE D\'ACTION NON DEFINI : '+args[i]);
			}
			cpt_actions++;
		}
		if (cpt_actions==0) {
			this.CFM_AjouterEvenements("--> AUCUNE ACTION EN RETOUR",true);
		} else {
			this.CFM_AjouterEvenements("--> "+cpt_actions+" ACTION(s) EN RETOUR",true);
			
		}
		// deblocage du formulaire
		this.FormIsLocked = false;
		// alert('apelé depuis l\'objet'+_field_id+','+this.table_instances[id]['type']+','+this.table_instances[id]['name'] );
	}





	this.CFM_ActionSurBtnOk = function(_kn,_kv,_activer) {
		var _suffixe = this.CFM_GetSuffixeBtn(_kn,_kv);
		var obj = this.CFM_findObj(this.BtnOkPrefix+_suffixe);
		// SI BOUTON NON DEFINI
		if (!obj) return;
		if (_activer) {
			obj.disabled = false;
			this.CFM_findObj(this.BtnCancelPrefix+_suffixe).value = this.BtnCancelLibRetablir;
			this.CFM_findObj(this.BtnCancelState+_suffixe).value = '1';
		} else {
			obj.disabled = true;
			this.CFM_findObj(this.BtnCancelPrefix+_suffixe).value = this.BtnCancelLibQuitter;
			this.CFM_findObj(this.BtnCancelState+_suffixe).value = '0';
		}
	}




	this.CFM_ObjetDesactiver = function(nomchamp, nomchampJS) {
		var _obj = this.CFM_findObj(nomchampJS);
		// recuperation du type de champ
	 	var type_champ = this.CFM_FindTypeObjWithName(nomchamp);
		switch (type_champ) {
			case 'RADIO':
				var indice = this.CFM_FindIndiceWithName(nomchamp);			
				for (var i=0;i<this.table_valeurs[indice].length;i+=2) {
					var obj = this.CFM_findObj(this.CFM_GetRadioId(nomchampJS,this.table_valeurs[indice][i]));
					if (obj) {
						obj.disabled = true;
					}
					this.CFM_findObj(nomchampJS).disabled = true;
				}
				break;
			
			case 'ICONE':
				var indice = this.CFM_FindIndiceWithName(nomchamp);			
				var obj_ico  = this.CFM_findObj(this.CFM_GetNameIcon(nomchampJS));
				if (obj_ico) {
						obj_ico.title='';
						this.CFM_css_opacite(obj_ico,true);
				}
				break;
				
			case 'ICONESRADIO':
				var indice = this.CFM_FindIndiceWithName(nomchamp);		
				this.CFM_MajIconesAvecValeur(indice,nomchamp,_obj,_obj.value,true);
				var _j = 0;
				for (var i=0;i<this.table_valeurs[indice].length;i+=this.IconesRadioOffsetParam) {
					var obj = this.CFM_findObj(this.CFM_GetNameIconsRadio(nomchampJS,_j));
					if (obj) {
						obj.title = '';
						this.CFM_css_opacite(obj,true);
					}
					_j++;
				}
				break;
				
			case 'TEXTE':
			case 'LISTE':				
				if (_obj) {
					_obj.className = 'CFMchampRO';
				}
				break;
				
			// case 'COCHE':
			default:
		}
		var _obj = this.CFM_findObj(nomchampJS);
		if (_obj) { 
			$liberr = '. ACTION : Desactiver le champ '+nomchamp+' ('+nomchampJS+')';
			if (this.AjaxModeDebug) this.CFM_AjouterEvenements($liberr);		
			_obj.disabled=true; 
		} else {
			if (this.AjaxModeDebug) this.CFM_AjouterEvenements('- ERREUR ACTION : Desactiver un champ inexistant ('+nomchamp+')');
		}
		
		 
	};





	this.CFM_ObjetActiver = function(nomchamp, nomchampJS) {
		var _obj = this.CFM_findObj(nomchampJS);
		
		// recuperation du type de champ
	 	var type_champ = this.CFM_FindTypeObjWithName(nomchamp);
		switch (type_champ) {
			case 'RADIO':
				var indice = this.CFM_FindIndiceWithName(nomchamp);			
				for (var i=0;i<this.table_valeurs[indice].length;i+=2) {
					var obj = this.CFM_findObj(this.CFM_GetRadioId(nomchampJS,this.table_valeurs[indice][i]));
					if (obj) {
						obj.disabled = false;
					}
					// champ cache
					this.CFM_findObj(nomchampJS).disabled = false;
				}
				break;

			
			case 'ICONE':
				// prendre la valeur du champ cache
				var valeur_actuelle = _obj.value;
				// retrouver son indice dans la liste
				var indicechamp = this.CFM_FindIndiceWithName(nomchamp);
				var indice_element = this.CFM_FindRangListeValeur(indicechamp,valeur_actuelle,this.IconeOffsetParam);
				if (indice_element==-1) {
					indice_element = 0;
				}
				var t_valeurs = this.table_valeurs[indicechamp];
				_value = t_valeurs[indice_element];
				_icone = t_valeurs[indice_element+1];
				_title = t_valeurs[indice_element+2];
				if (_title=='') {
					_title = this.CFM_FindAttribWithKey(indice,'title');
				}

				var obj_ico  = this.CFM_findObj(this.CFM_GetNameIcon(nomchampJS));
				if (obj_ico) {
						obj_ico.src=_icone;
						obj_ico.title=_title;
						this.CFM_css_opacite(obj_ico,false);						
				}
				break;
				
			case 'ICONESRADIO':
				var indice = this.CFM_FindIndiceWithName(nomchamp);
				// alert(nomchamp+'activer '+_obj.name+' , avec '+_obj.value);
				this.CFM_MajIconesAvecValeur(indice,nomchamp,_obj,_obj.value,false);
				break;

			case 'TEXTE':
			case 'LISTE':
				if (_obj) {
					_obj.className = 'CFMchamp';
				}
				break;	
				
			default:
		}
		if (_obj) { 
			if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION : Activer le champ '+nomchamp+' ('+nomchampJS+')');
			_obj.disabled=false; 			
		} else {
			if (this.AjaxModeDebug) this.CFM_AjouterEvenements('- ERREUR ACTION : Activer un champ inexistant ('+nomchamp+')');
		}
	};



	this.CFM_ObjetCacher = function(nomchampJS,_cacher) {
		this.CFM_HideObject(this.CFM_FindNameWithObj(nomchampJS),_cacher);
		if (_cacher) { 
			if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION : Cacher le champ '+nomchampJS);
		} else {
			if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION : Montrer le champ '+nomchampJS);
		}
	}

	// fonaction appelee par ObjetCacher mais aussi par le bouton ANNULER
	this.CFM_HideObject = function(instance,_cacher) {
		// localisation de la balise SPAN qui encadre l'objet
		var obj = this.CFM_findObj(this.ContainerPrefix+instance);
		if (!obj) return;
		switch (this.CFM_hide_mode) {
			
			case 1:
				if (_cacher) {
					obj.style.visibility="hidden"; 
				} else {
					obj.style.visibility="visible"; 
				}		
				break;
				
			case 2:
				if (_cacher) {
					obj.style.display="none"; 
				} else {
					obj.style.display="inline"; 
				}		
				break;
		}
	}
	
	
	
	
	this.CFM_SeDeplacerSurObjet = function(nomchamp,nomchampJS) {
	 	type_champ = this.CFM_FindTypeObjWithName(nomchamp);
		switch (type_champ) {
			case 'ICONE':  // sans effet sur une icone
				return;
				break;
			default:
				obj = this.CFM_findObj(nomchampJS);
				if (obj) { 
					if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION : prendre le focus vers le champ : '+nomchamp);
					obj.focus();
				} else {
					if (this.AjaxModeDebug) this.CFM_AjouterEvenements('- ERREUR ACTION : focus vers un champ inexistant ('+nomchamp+')');
				}
		}
	}

	this.CFM_AfficherMessage = function(message) {
		alert(message);
	}
	
	
	this.CFM_ChangerValeur = function(nomchamp, nomchampJS,_newvalue,_force, _restore) {
		
		var indice = this.CFM_FindIndiceWithName(nomchamp);
	 	var type_champ = this.table_type[ indice ];
		var obj = this.CFM_findObj(nomchampJS);
		// sert aussi a restaurer la valeur d'origine
		if (_restore) {			
			_newvalue = this.table_instances[this.CFM_FindNameWithObj(nomchampJS)]['init_value'];
		}
		// si le champ n'est pas actif et que l'on ne force pas la valeur on ne fait rien
		// (on force pour retablir la valeur initiale du champ)
		if (obj.disabled && !_force) return;
		if (obj) { 
			switch (type_champ) {
				case 'RADIO':
					if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION : Changer la valeur du champ "RADIO" : '+nomchamp+' ('+nomchampJS+') = '+_newvalue);
					obj.value = _newvalue; // champ caché
					// puis champ radio visible
					var obj = this.CFM_findObj(nomchampJS+'_');
					indicerad = this.CFM_IndiceRadio(obj,_newvalue);
					if (indicerad==-1) {
						// toutes les options a "non selectionnee"
						for (var i=0;i<this.table_valeurs[indice].length/3;i++) {
							obj[i].checked=false;
						}
					} else {
						obj[indicerad].checked=true;
					}
					break;
				case 'COCHE':
					if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION : Changer la valeur du champ "COCHE" : '+nomchamp+' ('+nomchampJS+') = '+_newvalue);
					obj.checked=(_newvalue=='1');
					break;
				case 'LISTE':
					if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION : Changer la valeur du champ "LISTE" : '+nomchamp+' ('+nomchampJS+') = '+_newvalue);
					obj.value=_newvalue; 
					break;
				case 'TEXTE':
					if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION : Changer la valeur du champ "TEXTE" : '+nomchamp+' ('+nomchampJS+') = '+_newvalue);
					obj.value=_newvalue; 
					break;
					
				case 'ICONE':
					if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION : Changer la valeur du champ "ICONE" : '+nomchamp+' ('+nomchampJS+') = '+_newvalue);
					// retrouver son indice dans la liste
					var indicechamp    = this.CFM_FindIndiceWithName(nomchamp);
					var indice_element = this.CFM_FindRangListeValeur(indicechamp,_newvalue,this.IconeOffsetParam);
					// si je ne trouve pas la nouvelle valeur je ne fais rien
					if (indice_element==-1) {
						break;
					}
					var t_valeurs = this.table_valeurs[indicechamp];
					_value = t_valeurs[indice_element];
					_icone = t_valeurs[indice_element+1];
					_title = t_valeurs[indice_element+2];
					if (_title=='') {
						_title = this.CFM_FindAttribWithKey(indice,'title');
					}
					var obj_ico  = this.CFM_findObj(this.CFM_GetNameIcon(nomchampJS));
					if (obj_ico) {
						obj_ico.src=_icone;
						obj_ico.title=_title;
					}
					// et enfin la value du champ cache
					obj.value=_newvalue; 
					break;
					
				case 'ICONESRADIO':
					if (this.AjaxModeDebug) this.CFM_AjouterEvenements('. ACTION : Changer la valeur du champ ICONES RADIO '+nomchamp+' ('+nomchampJS+') = '+_newvalue);
					var indice = this.CFM_FindObjWithName(nomchamp);					
					obj.value=_newvalue; 
					this.CFM_MajIconesAvecValeur(indice,nomchamp,obj,_newvalue,false);
					break;
					
				default:
					alert('CFM_ChangerValeur() : type de champ non defini ('+type_champ+')' );
			}
		}
	};

	this.CFM_IndiceRadio = function(objradio,valeur_a_trouver) {
		for (var i=0;i<objradio.length;i++) {
			if (objradio[i].value==valeur_a_trouver) return i;
		}
		return -1;
	}





	// a la creation de l'objet on l'affiche ou non
	this.CFM_OpenObjectContainer = function(num_instance,_cacher) {
		var _style = '';
		switch (this.CFM_hide_mode) {
			case 1:
				if (_cacher) {				
					_style = 'display:inline; visibility:hidden; '; 
				} else {
					_style = 'display:inline; visibility:visible; '; 
				}		
				break;
			case 2:
				if (_cacher) {
					_style = 'display:none; '; 
				} else {
					_style = 'display:inline; '; 
				}		
				break;
		}
		document.write('<span id="'+this.ContainerPrefix+num_instance+'" style="'+_style+'">');
	};
	
	// a la creation de l'objet on l'affiche ou non
	this.CFM_CloseObjectContainer = function() {
		document.write('</span>');
	};





	// retour du numero de l'instance de l'objet en fonction du nom
	this.CFM_FindObjWithName = function(idchamp) {
		for (var i=0;i<this.table_instances.length;i++) {		
			if (idchamp==this.table_instances[i]['name']) return i;
		}
		return -1;
	};
	
	// retour de l'indice de la definition de l'objet en fonction du nom
	this.CFM_FindIndiceWithName = function(nomchamp) {
		for (var i=0;i<this.table_objets.length;i++) {		
			if (nomchamp==this.table_objets[i]) return i;
		}
		return -1;
	};
	
	// recherche dans la liste la valeur d'un attribut
	this.CFM_FindAttribWithKey = function(indice,nomattrib) {
		var tabobj = this.table_attrib[indice];
		if (tabobj) {
			for (var i=0;i<tabobj.length;i+=2) {		
				if (nomattrib==tabobj[i]) return tabobj[i+1];
			}
		}
		return '';
	};


	// retour du numero d'objet en fonction du nom de champ JS
	this.CFM_FindNameWithObj = function(nomchampJS) {
		for (var i=0;i<this.table_instances.length;i++) {		
			if (nomchampJS==this.table_instances[i]['id']) return i;
		}
		return -1;
	};

	// retour de l'indice dans la table des valeurs, a defaut la valeur "default"
	this.CFM_FindRangListeValeur = function(indiceobj,valeur,offset) {
		for (var i=0;i<this.table_valeurs[indiceobj].length;i+=offset) {
			if (this.table_valeurs[indiceobj][i]==valeur) return i;
		}
		var valeur_defaut = this.CFM_FindAttribWithKey(indiceobj,'default');
		for (var i=0;i<this.table_valeurs.length;i+=offset) {
			if (this.table_valeurs[indiceobj][i]==valeur_defaut) return i;
		}		
		return -1;
	}
	
	// retourne le type de champ en fonction de son nom
	this.CFM_FindTypeObjWithName = function(nomchamp) {
		var _instance = this.CFM_FindObjWithName(nomchamp);
		if (_instance==-1) { 
			return '';
		} else {
		 	return this.table_instances[_instance]['type'];	 
		}
	}
	

// cette fonction est appelée pour evaluer un eventuel script
	this.CFM_css_show = function() {
		document.writeln( "<style type=\"text/css\">\n<!--" );

		document.writeln( ".CFMchamp {" );
		document.writeln( this.police );
		document.writeln( "	font-size: 9px;" );
		document.writeln( "	background-color: "+this.couleurchampnormal+";" );		
		document.writeln( "}" );

		document.writeln( ".CFMchampRO{" );
		document.writeln( this.police );
		document.writeln( "	font-size: 9px;" );
		document.writeln( "	background-color: "+this.couleurchampRO+";" );		
		document.writeln( "}" );

		document.writeln( ".CFMzoneLogs{" );
///		document.writeln( 'font-family: "Courier New", Courier, monospace; ' );
		document.writeln( this.police );
		document.writeln( 'color: #FFFFFF; ' );
		document.writeln( 'font-size: 10px; ' );
		document.writeln( 'font-style: normal; ' );
		document.writeln( 'line-height: normal; ' );
		document.writeln( 'font-weight: bold; ' );
		document.writeln( 'background-color: '+this.DebugColor1+'; ' );		
		document.writeln( "}" );


		document.writeln( ".CFMlabel {" );
		document.writeln( this.police );
		document.writeln( "	font-size: 9px;" );
		document.writeln( "}" );

		document.writeln( ".CFMdivcontainer {" );
		document.writeln( "	display: inline;" );
		document.writeln( "}" );

		document.writeln( ".CFMbouton {" );
		document.writeln( this.police );
		document.writeln( "	font-size: 10px;" );
		document.writeln( "	cursor:hand;" );		
		document.writeln( "	font-weight: bold;" );
		document.writeln( "	width: 100px;" );
		document.writeln( "}" );
		
		document.writeln( '.CFMImgDisabled {' );
		document.writeln( '	filter : alpha(opacity='+this.opacite+');' );
		document.writeln( '	-moz-opacity : '+this.opacite/100+';' );
		document.writeln( '	opacity : '+this.opacite/100+';' );
		document.writeln( '}' );

		document.writeln( ".CFMImgEnabled {" );
		document.writeln( "	filter : alpha(opacity=100);" );
		document.writeln( "	-moz-opacity : 1;" );
		document.writeln( "	opacity : 1;" );
		document.writeln( "}" );

		document.writeln( "	background-color: #FFFFFE;" );
	document.writeln( "}" );
			
	document.writeln( ".classeformschampnormal {" );
	document.writeln( this.police );
	document.writeln( "	font-size: "+this.taillepolice+"px;" );
	document.writeln( "}" );

		document.writeln( "-->\n</style>" );
	
	}

	this.CFM_css_opacite = function(obj_opacite,desactivation) {
		if (obj_opacite) {
			if (desactivation) {
				var _opac = this.opacite;
			} else {
				var _opac = 100;
			}
			obj_opacite.style.filter = 'alpha(opacity='+_opac+')';
		//	obj_opacite.style.-moz-opacity = _opac/100;
			obj_opacite.style.opacity = _opac/100;
		}
			
	}
	
	
};   // Fin de classe classeFormsMini




  



/* 
	ENSEMBLE DE FONCTION POUR REALISER DES APPELS ASYNCHRONES TYPE "AJAX"
*/

		
function CFM_HttpRequest() {
	var XmlDoc = null;
	if(window.ActiveXObject){ // Internet Explorer 
		try {
			XmlDoc = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) {
			XmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
		}
	} else if (window.XMLHttpRequest){ // Firefox et autres
		XmlDoc = new XMLHttpRequest(); 
		XmlDoc.overrideMimeType('text/xml'); 
	} else { // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	   XmlDoc = false; 
	} 
	return XmlDoc;
}

// Node cleaner
function CFM_DOM_cleanNode(c){
	if(!c.data.replace(/\s/g,'')) {
		c.parentNode.removeChild(c);
	}
}

function CFM_DOM_clean(d){
	var bal=d.getElementsByTagName('*');
	for(i=0;i<bal.length;i++){
		a=bal[i].previousSibling;
		if(a && a.nodeType==3)
			CFM_DOM_cleanNode(a);
		b=bal[i].nextSibling;
		if(b && b.nodeType==3)
			CFM_DOM_cleanNode(b);
	}
	return d;
} 



function CFM_DOM_traverse(tree) {
        if(tree.hasChildNodes()) {
                document.write('<ul><li>');
                document.write('<b>'+tree.tagName+' : </b>');
                var nodes=tree.childNodes.length;
                for(var i=0; i<tree.childNodes.length; i++)
                        traverse(tree.childNodes(i));
                document.write('</li></ul>');
        }
        else
                document.write(tree.text);
}



// echappement de toutes les quotes
function CFM_EscQuotes(chaine_in) {	
	if (!chaine_in)    return '';
	if (chaine_in=='') return '';
	var exprEscQuote = new RegExp("'", "g");
	return chaine_in.replace(exprEscQuote,'\\\'');
}

function CFM_handleEnter (field, event) {  
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;  
		if (keyCode == 13) {  
			var i; 
			for (i = 0; i < field.form.elements.length; i++) { 
			    // pointage du champ passe en parametre 
				if (field == field.form.elements[i]) break;  
			} 
			i = (i + 1) % field.form.elements.length;  
			j = i; 
			while ( true ) { 
				if (j==field.form.elements.length) j=0; 
				objet = field.form.elements[j]; 
				if (objet.type=='text'||objet.type=='textarea'||objet.type=='radio'||objet.type=='checkbox'||objet.type=='select-one') { 
					if (!objet.readOnly) { 
						if (!objet.disabled) { 
							objet.focus();  
							return false; 
						} 
					}
				} 
				j++; 
			} 
			return false; 
		}   
		else  
		return true;  
}  


