
var path = '';
/** Variables JS contenant du texte **/





var lang = Array();

lang['msg_err_TXT']					= 'Champ obligatoire';
lang['msg_err_EURO']				= 'Saisissez un prix valide';
lang['msg_err_DATE']				= 'jj/mm/aaaa';
lang['msg_err_SELECT']				= 'Choisissez un élément !';
lang['msg_err_INT']				= 'Saisissez un entier';
lang['msg_err_FLOAT']				= 'Saisissez un nombre (, et . acceptés)';
lang['msg_err_MAIL']				= 'Saissez une adresse e-mail valide';
lang['msg_err_LINK']				= 'Saissez une adresse internet valide';
lang['champs_incorects']			= 'Certains champs n\'ont pas été remplis correctement';
lang['chosse_file']					= 'Choisissez un fichier !';
lang['loading_file']				= 'Chargement du fichier ...';
lang['fields_not_correct']			= "Certains champs n'ont pas été remplis correctement";
lang['type_an_expression']			= "Saissez une expression à rechercher";
lang['search_3_letters']			= 'Votre requête doit contenir au moin 3 caractères';
lang['dont_cut_tags']				= "Ne coupez les balises";
lang['enter_text_to_format']		= "Entrez le texte à mettre en forme";
lang['url']							= 'URL (Adresse internet)';
lang['type_log']					= 'Saisissez un login';
lang['type_pass']					= 'Saisissez un mot de passe';
lang['close']						= 'Fermer';
lang['open']						= 'Ouvrir';
lang['none']						= 'Aucun';
lang['read_more']					= 'en savoir +';
lang['confirm_delete_media']		= "Voulez-vous vraiment supprimer ce média ? Il est peut-être utilisé dans une autre partie du site ";
lang['gest_media_preview_title']	= 'Gestionnaire de média - prévisualisation';
lang['CANT_DELETE']					= "Vous ne pouvez pas effacer cette ligne ";
lang['ELEM_ASSOCIES']				= ' élement(s) lui est(sont) associé(s)';
lang['SELECTIONNE']					= 'Choisissez au moin un élément ';
lang['choose_cat']					= 'Choisissez une categorie';
lang['confirm_delete_thread']		= 'Voulez-vous effacer cette question ainsi que tous ces réponses ?';
lang['confirm_publish']				= 'Voulez-vous vraiment publier cet élément ?';
lang['confirm_unpublish']			= 'Voulez-vous vraiment dé-publier cet élément ?';
lang['confirm_archive']				= 'Voulez-vous vraiment archiver cet élément ?';
lang['confirm_unarchive']			= 'Voulez-vous vraiment dé-archiver cet élément ?';
lang['confirm_headline']			= 'Voulez-vous vraiment mettre cet élément à la une ?';
lang['confirm_unheadline']			= 'Voulez-vous vraiment supprimer cet élément de la une  \n Le nouvel élément à la une sera le plus récent';
lang['confirm_add_favorites']		= 'Voulez-vous vraiment ajouter cet élément à vos favoris ?';
lang['confirm_rem_favorites']		= 'Voulez-vous vraiment supprimer cet élément de vos favoris ?';
lang['confirm_effectuer_upload']	= 'Il y a un fichier en attente dans le formulaire \n Voulez-vous envoyer ce fichier ? \n\n Cliquez sur annuler pour continuer sans envoyer le fichier';
lang['extension_de_fichier_non_acceptee'] = 'Le fichier que vous voulez envoyer sur le serveur n\'est pas conforme :\n Les extensions autorisées pour ce champ sont les suivantes : \n\n ';

lang['cliquer_pour_aide'] = 'Cliquez pour obtenir de l\'aide ';



var TAB_jours = Array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
var TAB_mois = Array('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre');





/*
Séléctionner plusieurs lignes d'une liste dont un critere a une valeur donnée
*/
function lot_select(obj){
	// Remise à zéro
	LotCheckAll(false);
	for(var i=0; i<obj.options.length; i++){
		if(obj.options[i].selected){
			coche_lot(obj, i);
		}
	}
}

function coche_lot(obj, index){

	if(obj.options[index].value == 'all'){
		LotCheckAll(true);
	}
	else if(obj.options[index].value == 'none'){
		// LotCheckAll(false); // Déjà réinitialisé dans lot_select();
	}
	else{


		var Tinfo = obj.options[index].value.split(':');
		var champ = Tinfo[0];
		var val = Tinfo[1];
		var debug = '';


		liste_coche = document.getElementsByTagName('input');
		
		for(var i=0; i<liste_coche.length; i++){
			if(liste_coche[i].type == 'checkbox' && liste_coche[i].name == 'LOT'){
			input = document.getElementById('lot_' + champ + '_'+ liste_coche[i].value);
				if(input != null ){
					if(input.value == val){
						liste_coche[i].checked = true;
					}
				}
			}
		}
	}
}

function func_lot_advanced(bt){
	var op = bt.value;
	var mDiv = document.getElementById('div_mass_select');
	var mSel = document.getElementById('lot_mass_select');

	if(func_lot_advanced.arguments.length > 1){ op = '-'; }
 
	
	switch(op){
		case '+' :
			mSel.multiple = true;
			mSel.style.height = '150px';
		//	mSel.style.width = '120px';
		//	mDiv.style.position = 'absolute';
			bt.value = '-';
		break;

		case '-' :
			mSel.multiple = false;
			mSel.style.height = '16px';
	//		mSel.style.width = '120px';
			bt.value = '+';
		break;
	}

}


function assoStagiaireSession(id_session){
	inp = MM_findObj('id_session');
	
	if(inp){
		sep = (inp.value != '') ? ',' : '';
		inp.value += sep + id_session;
		submitit('formEdit');
	}
}

function modif_stage(){
	sel = MM_findObj('modif_stage_id_stage');
	var id_stage = sel.options[sel.selectedIndex].value;
	var url = 'index.asp?rub=522&op=edit&id_stage='+ id_stage;
	pop(url, 'width=750,height=545,status=yes');
}



function selection_session(id_session){
	var pref = window.parent.MM_findObj('prefer').checked;

	window.parent.opener.assoStagiaireSession(id_session);
	window.parent.opener.focus();
	window.parent.opener.submitit();

	if(pref){
		window.parent.setTimeout('self.close()', 500);
		window.parent.blur();
		self.document.location.href = 'index.asp?op=add_pref&rub='+GetVal('rub')+'&k=id_session&v='+ id_session +'&redirect=';
		if(!window.parent.opener.MM_findObj('id_session')){
			window.parent.opener.location.reload();
		}
	}
	else{
		window.parent.close();
	}



}

function assoStagiaireSessionFromPop(champ){
	var id_session = 0;
	radio = MM_findObj(champ);
	for(var i=0; i<radio.length; i++){
		if(radio[i].checked == true){
			id_session = radio[i].value;
			break;
		}
	}

	if(id_session == 0){
		alert('Choisissez une session');
	}
	else{
		window.opener.assoStagiaireSession(id_session);
		window.opener.focus();
		window.opener.submitit();
		self.close();
	}


}


function logout(){
	var url = self.document.location.href + '';
	url = BuildUrl(url, 'rub', 'ADM-CNX');
	url = BuildUrl(url, 'op', 'connexion');
	url = BuildUrl(url, 'deconnect', '1');

	self.document.location.href = url;
}


function navSelect(obj){
	var url = document.location.href + '';
	url = BuildUrl(url, obj.name, obj.options[obj.selectedIndex].value);
	document.location.href = url;
}


function onglet(ong, post){
	if(post == 1){
		submitit(formname, ong);
	}
	else{
		var url = self.document.location.href + '';
		url = BuildUrl(url, 'ong', ong);
		self.document.location.href = url;
	}
}


function onglet_lang(lang, post){
	var url = self.document.location.href + '';
	url = BuildUrl(url, 'form_lang', lang);
	self.document.location.href = url;
}


var ONGLETS_GEST_MEDIA = Array('IFRA', 'EDIT', 'SELECTION');

function openEDIT(champ){
	//var ifra = document.getElementById('i'+champ);
	var ifra = MM_findObj('i'+champ);
	//alert(ifra.id);
	var url = getIframeURL(ifra);

//	my_parent = GetVal('parent', url);
	rub = GetVal('rub', url);
	url = BuildUrl(url, 'op', 'edit');
	url = BuildUrl(url, champ, 0);
//	url = BuildUrl(url, 'value', document.getElementById(champ).value);
//	alert(document.getElementById(champ).value);
	load_iframe(MM_findObj('i'+champ), url);
	highlight_small_ong(champ, 'EDIT', ONGLETS_GEST_MEDIA, GetVal('max_media', url));
}


function openSELECTION(champ){
	//var ifra = document.getElementById('i'+champ);
	var ifra = MM_findObj('i'+champ);
	var url = getIframeURL(ifra);

	url = BuildUrl(url, 'op', 'selection');
	url = BuildUrl(url, 'value', document.getElementById(champ).value);
	load_iframe(MM_findObj('i'+champ), url);	
	highlight_small_ong(champ, 'SELECTION', ONGLETS_GEST_MEDIA, GetVal('max_media', url));
}


function openIFRA(champ){
	//var ifra = document.getElementById('i'+champ);
	var ifra = MM_findObj('i'+champ);
	var url = getIframeURL(ifra);

	url = BuildUrl(url, 'op', 'ifra');
	url = BuildUrl(url, 'value', document.getElementById(champ).value);
	load_iframe(MM_findObj('i'+champ), url);	
	highlight_small_ong(champ, 'IFRA', ONGLETS_GEST_MEDIA, GetVal('max_media', url));
}

var LISTE_NUM_ROWS;
function add_num_rows(val){
	LISTE_NUM_ROWS = val;
}


function getIframeURL(obj_Iframe){
	//alert(obj_Iframe.id);
	if(obj_Iframe.contentDocument == null){
		return obj_Iframe.document.location.href + '';
	}
	else{
		return obj_Iframe.contentDocument.location + '';
	}
}


function load_iframe(obj_Iframe, url){
	//alert(url);
	if(obj_Iframe.contentDocument == null){
		obj_Iframe.document.location.href = url;
	}
	else{
		obj_Iframe.contentDocument.location.href = url;
	}
}



function highlight_small_ong(champ, onglet, Longlets, max_media){
	ifra = MM_findObj('i'+ champ);
	var idz = GetVal('value', getIframeURL(ifra));
	if(idz == ''){
		nb_elems = 0;
	}
	else{
		idz = idz.replace('0,', '');
		idz = idz.replace('0', '');
		tidz = idz.split(',');
		nb_elems = tidz.length;
	}

	if(nb_elems == 0 && onglet == 'IFRA'){
		url = BuildUrl(getIframeURL(ifra), 'op', 'edit');
		url = BuildUrl(url, champ, 0);
		load_iframe(ifra, url);
	}

//	alert(GetVal('value', getIframeURL(MM_findObj('i'+ champ))) + ' - '+ nb_elems);
	
	for(var i=0; i<Longlets.length; i++){
		oOng = MM_findObj(Longlets[i] +'_'+ champ);

		if(oOng != null){
			oOng.className = MM_findObj(Longlets[i] +'_'+ champ).className.replace('1', '0');
		}

		if(nb_elems >= max_media && i > 0){
			if(oOng != null){
				oOng.style.display = 'none';
			}
		}
		else{
			if(oOng != null){
				oOng.style.display = 'inline';
			}
		}
	}

	MM_findObj(onglet +'_'+ champ).className = MM_findObj(onglet +'_'+ champ).className.replace('0', '1');

}

//Fonctions du tableau de bord

//Actions dse boutons du tableau de bord
function tb_link(type, param){
	switch (type){
		case "modif_profil":
			myAccount(param);
			break;

		case "contact_admin":
			url = "mailto:" + param;
			self.document.location.href = url;
			break;

		case "visu_amp":
			url = "index.asp?rub=" + param + "&op=liste";
			self.document.location.href = url;
			break;

		case "open_site":
			self.document.location.href = param;
			break;
	}
}



function diff_mass_suscribe(){
	var oProfil = self.document.getElementById('diff_id_t_profil');
	var oAction = self.document.getElementById('diff_op');

	var profil = oProfil.options[oProfil.selectedIndex].value;
	var action = oAction.options[oAction.selectedIndex].value;

	self.document.location.href = '?rub=311&op='+ action +'&profil='+ profil;


}
var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName = "Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName = "MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName = "UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName = "Linux";


var BROWSER = "Unknow browser"
//alert(navigator.appName);
if(navigator.appName.indexOf('Microsoft') > -1){ BROWSER = 'IE';}
if(navigator.appName.indexOf('Netscape') > -1){ BROWSER = 'NS';}



var SEPARATORS = Array();
SEPARATORS["Windows"] = "\\";
SEPARATORS["MacOS"] = "/";
SEPARATORS["UNIX"] = "/";
SEPARATORS["Linux"] = "/";
var DIR_SEP = SEPARATORS[OSName];


// Object renvoi l'object n du document
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; 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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


var SPAM_AT = '$';
var SPAM_DOT = '*';



/***** OUTILS DEBUG  *****/
eventSetup();

function eventSetup() {
  if (BROWSER == 'IE'){
    document.onkeydown = ImajeventD;
    document.onkeyup = ImajeventU;
  }
  if(BROWSER == 'NS'){
    document.captureEvents( Event.KEYDOWN );
    document.onkeydown = NmajeventD;
     document.onkeyup = NmajeventU;
  }
}

var k_c_mode = false;

function ImajeventD(){
	if (event.keyCode == 75){
	  k_c_mode = true; 
	}
	else{
		if(k_c_mode == true){
			KC_events(event.keyCode);
		}
	}
}
function ImajeventU(){k_c_mode = false;}

function NmajeventD(e){
	if (e.which == 75){
	  k_c_mode = true; 
	}
	else{
		if(k_c_mode == true){
			KC_events(e.which);
		}
	}
}
function NmajeventU(e){k_c_mode = false;}



function KC_events(key){
	k_c_mode = false;
	switch(key){
		case 87 : // k + w
			waitLayer(false);
		break;
	
		case 83 : // k + s
				url = BuildUrl(self.document.location.href, 'debug', '');
				url = BuildUrl(url, 'sql', 1);
				window.open(url, '', '');
		break;


		case 88 : // k + x
				url = BuildUrl(self.document.location.href, 'sql', '');
				url = BuildUrl(url, 'debug', 1);
				window.open(url, '', '');
		break;

		case 67 : // k + c
				var cooks = self.document.cookie.split(';');
				alert(cooks.join("\n"));
		break;

		default:
		//	alert(key);
		break;
	}
}
/***** FIN OUTILS DEBUG  *****/



/*********************************/
/* FONCTIONS JAVASCRIPT COMMUNES */
/*********************************/

function get_kDbug(){
//	alert(document.all.innerHTML);
}

function vide() {return;}

function checkFields(form){
	if(!checkString(MM_findObj(COOKIE_LOG).value)) {
		alert(lang['type_log']);
	}
	else {
		if(!checkString(MM_findObj(COOKIE_PWD).value)){
			alert(lang['type_pass']);
		}
		else {
			form.submit();
		}
	}
}
    
function checkString(entry) 
{
   for(var i = 0; i < entry.length; i++)
   {if (entry.charAt(i) != " ") {return true;}}
   return false;
}

//* Fonctions de pop up

function pop(url, param)
{
	if (url){
		var jour = new Date();
		var name = 'pop_'+jour.getHours()+''+jour.getMinutes()+''+jour.getSeconds();
		var loader = path + '_js/loader.html';
		winname = name + '';

		if(pop.arguments.length == 3)
			winname = window.name;
	
		if (window.opener != null && pop.arguments[2] != 'pop')
		{
			self.document.location.href = url;
		}

		else{
			eval(winname +" = window.open('"+ loader +"','"+name+"','"+param+"');");
	//		eval();
			setTimeout(winname +".document.location.href = '"+ url +"';", 100);
			eval("setTimeout('"+winname+".focus();',250);");
			if(pop.arguments.length == 2){return eval(name);}
		}
	}
}


function popup(url, params){
	var jour = new Date();
	var name = 'pop_'+jour.getHours()+''+jour.getMinutes()+''+jour.getSeconds();
	var loader = path + '_js/loader.html';
	eval(name +' = window.open(url, name, params);');
	setTimeout(name + '.focus()', 250);
}



function MyClose(){
	
	// IE6 vois toujours le opener comme un objet meme si la fenetre a été fermée
	// avec un timeout la pop up sera fermée même si une erreur se produit dans les lignes qui suivent
	setTimeout('self.close()', 600);

	if (window.opener != null){
		var ifra = GetVal('ifraRef');
		if(ifra != false){
			window.opener.MM_findObj(ifra).location.reload();
		}else{
			window.opener.location.reload();
		}
		window.opener.focus();
	}
	
}


function waitLayer(etat){
	if((loader = MM_findObj('loading_layer')) != null){
		loader.style.display = (etat) ? 'block' : 'none';
	}
}



// Fonctions des trims
function strim(val, crt){
  var txt = val;
  while (txt.substr(0, 1) == crt) {txt = txt.substr(1, txt.length);}
  while (txt.substr(txt.length-1, 1) == crt) {txt = txt.substr(0, txt.length-1);}

  return txt;
}
function trim(val){return  strim(val+'', " ");} // un simple alias ?



var TR_COLOR_BUFFER = Array;
function TRhl(obj, p){
	if(p){
		TR_COLOR_BUFFER[obj.id] = obj.style.backgroundColor;
		obj.style.backgroundColor = p;
	}
	else{
		obj.style.backgroundColor = TR_COLOR_BUFFER[obj.id];
	}

}


/**** FONCTIONS POUR LES TABLEAUX *****/

// Booleen : Vérifie si la valeur [val] est présente dans le tableau [l]
function inList(l, val){
  for (var i=0; i < l.length; i++)
   {if (l[i].toUpperCase()==val.toUpperCase()) {return true; break;}
   }
  return false;
}

//  ?
function isExist(id, li, nval, oval){
	inl = inList(li, nval);

	if ((inl) && (id == 0)) {return true;}
	if ((inl) && (id > 0) && ((nval).toUpperCase() != (oval).toUpperCase())) {return true;}
	return false;
}

// Cherche la valeur val dans le tableau tab et renvoi son index, renvoi FALSE si la valeur n'est pas trouvée
function in_array(val, tab){
	for(var i=0; i<tab.length; i++){
		if(tab[i] == val){
			return i;
		}
	}
return false;
}


// Booleen : Vérifie si la valeur [val] est présente dans les valeurs du tableau d'options [opt]
function inSelect(opt, val){
  for (var i=0; i < opt.length; i++)
   {if (opt[i].value.toUpperCase() == val.toUpperCase()) {return true; break;}
   }
  return false;
}

// Cherche la valeur val dans le tableau tab et renvoi TRUE si elle existe, renvoi FALSE si la valeur n'est pas trouvée
function in_array_bool(val, tab){
	for(var i=0; i<tab.length; i++){
		if(tab[i] == val){
			return true;
		}
	}
return false;
}

// booleen : Vérifit que la clef key existe dans le tableau tab
function is_array_key(key, tab){
	if(tab[key] != undefined) {
		return true;
	}
	else{
		return false;
	}
}
/*********************************/





/**************** URLs ***********/

// Retourne l'url [Qstr] en attribuant [val] à [champ]
function BuildUrl(Qstr, champ, val){
	if(Qstr.indexOf('#') > -1){ Qstr = Qstr.substr(0, Qstr.indexOf('#')); }

	if(typeof(param = GetVal(champ, Qstr)) != 'boolean'){
		return Qstr.replace(champ+'='+param, champ+'='+val);
	}
	else{
		var sep = '?';
		if(Qstr.indexOf(sep)>-1){
			sep = '&';
		}
	return Qstr+=sep+champ+'='+val;
	}
}


/*
Retourne la valeur de [val] passé en GET
False si la variable n'existe pas
*/
function GetVal(val){
	args = GetVal.arguments;
	if(args.length > 1){
		var Turl = args[1];
	}
	else{
		var Turl = self.document.location.href +'';
	}
	var deb = Turl.indexOf('&'+val+'=');
	if(deb == -1){
		var deb = Turl.indexOf('?'+val+'=');
	}


	var fin = 0;
	if(deb > -1)	{
		var sub1 = Turl.substring(deb+1,Turl.length+1)
		fin	 = sub1.indexOf('&');
		if (fin == -1)	fin = sub1.length+1;
		sub2 = sub1.substring(0,fin)
		return sub2.replace(val+'=','');
	}
	else {
		return false;
	}
}

function getLcheck(ifra, name){
	tth = "";
	for (var i = 0; i < ifra.elements.length; i++){
	  if ( (ifra.elements[i].type == 'checkbox') && (ifra.elements[i].name == name) )
	   {if (ifra.elements[i].checked) {tth += ifra.elements[i].value + ":";}}
	}
	
	if ((tth).length > 1) {tth = (tth).substr(0, (tth).length-1);}

	return tth;
}



/*********************************/






function update_url(obj){
	var id = obj.options[obj.selectedIndex].value;
	var url = self.document.location.href + '';
	var sel = GetVal('sel');
	var val = GetVal('val');

	sep = (sel && sel.indexOf(obj.name) == -1)? ':' : '';
	if(sep == ''){sel = '';val='';}
	
	sel += sep + obj.name;
	val += sep + id;

	url = BuildUrl(url, 'sel', sel);
	url = BuildUrl(url, 'val', val);

	self.document.location.href = url;

}


function getExtension(file){
	var t_file = file.split('.');
	return t_file[t_file.length-1];
}

/********************************/
/* LIBRAIRIE DE PAGES DES LISTE */
/********************************/
PAGE_FORM_NAME = 'pageForm';

RUBRIQUE_GESTION_BLOCKS = 299;
RUBRIQUE_GESTION_MEDIAS = 289;


/********* PARAMETRES **********/


/*******************************/



function change_filtre(alias, id){
	oSel = MM_findObj(alias);
	if(oSel){
		oSel.selectedIndex = get_option_value_index(oSel, id);
		jsFiltre(oSel);
	}else{
		var url = self.document.location.href + '';
		url = BuildUrl(url, 'sel', alias);
		url = BuildUrl(url, 'val', id);
		url = BuildUrl(url, 'op', 'liste');
		self.document.location.href = url;
	}
}


function hlTR(oTR,hover){
	if(! (BROWSER == 'IE')){
		if(hover){
			oTR.className = 'TRover';
		}else{
			oTR.className = 'TRout';
		}
	}
}

function liste_select(obj, id){
	var url = document.location.href + '';
	url = 'coche.asp?rub='+ GetVal('rub') +'&id='+ id +'&cochename='+ obj.name + '&cocheval='+ obj.options[obj.selectedIndex].value 
	url += (GetVal('orderby')) ? '&orderby='+ GetVal('orderby') : '';
	url += (GetVal('sel')) ? '&sel='+ GetVal('sel') : '';
	url += (GetVal('val')) ? '&val='+ GetVal('val') : '';

//	waitLayer(true);

	self.document.location.href = url;


}

// Fonctions de création de l'URL GET des tris
//[MODIF JU]
function jsFormFiltre(obj){ 
	PAGE_FORM_NAME = 'formEdit';
	LISTE_FILTRES = FORM_LISTE_FILTRES;
	jsFiltre(obj);
}


//[MODIF HUGUES}
function traitementLot(champ, params, form){
	idz = getPageLotChecked();
	if(idz == ''){
		alert("Choisissez au moin un élément à modifier");
	}
	else{
		url = 'index.asp?op=edit_lot&rub='+ GetVal('rub') +'&champ='+champ+'&form='+ form +'&id=0&idz='+ idz
		pop(url, params);
	}
}



function jsFiltre(obj){
	var research = '';

	idoc = MM_findObj(PAGE_FORM_NAME);
	research = '';
	if(idoc != null){
		if(idoc.research != null){
			research = trim(idoc.research.value);
		}
	}

	var tsel = LISTE_FILTRES.split(":");
	
	turlsel = ""; turlval = "";
	for (i=0; i<=tsel.length-1; i++){
 		var oSel = document.getElementById('sel_'+ tsel[i]);

		var ps = oSel.selectedIndex;
		var tps = oSel.options[ps].value;
		turlsel += tsel[i] + ":";
		turlval += tps + ":";
	}
	
	turlsel = strim(turlsel, ":");
	turlval = strim(turlval, ":");
	
	turl = document.location.href + '';
	Tturl = turl.split("?");
	turl = '?' + Tturl[1];

	turl = BuildUrl(turl, 'sel', turlsel);
	turl = BuildUrl(turl, 'val', turlval);
	turl = BuildUrl(turl, 'research', escape(research));
	turl = BuildUrl(turl, 'focus', 'liste');
	turl = BuildUrl(turl, 'page', 1);
	
	self.document.location.href = Tturl[0] + turl;
}

//* Change de pages 1/n
function topageget(num){
	idoc = MM_findObj(PAGE_FORM_NAME);
	if (idoc != null){
		if(idoc.research != null){
			var research = trim(idoc.research.value);
			research = escape(research);
		}else{
			research = '';
		}
	}
	
	turl = self.document.location.href+ '';
	qs = turl.split('?');


	turl = BuildUrl('?'+qs[1], 'page', num);
	turl = BuildUrl(turl, 'focus', 'liste');

	if (idoc != null){
		turl = BuildUrl(turl, 'research', escape(research));
	}

//	self.document.location.href = qs[0] + turl;
	setTimeout("self.document.location.href = '"+  qs[0] + turl +"';", 0);
}


// Tris la liste par orderby sens
function pgorderby(orderby, sens){
	var research = '';
	idoc = MM_findObj(PAGE_FORM_NAME);
	
	if(idoc.research != null){
		research = trim(idoc.research.value);
	}

	var url = self.document.location.href+ '';

	url = BuildUrl(url, 'orderby', orderby+ ":" + sens);
	url = BuildUrl(url, 'research', escape(research));
	setTimeout("self.document.location.href = '"+ url+"';", 0);
//	self.document.location.href = url;
}


function listeOp(obj){

	tt = obj.id.split('_');
	var op = tt[0];
	var id = tt[1];
	var url = self.document.location.href + '';

	switch(op){
		case 'SUPP' :
			url = BuildUrl(url, 'op', 'supp');
			url = BuildUrl(url, 'id', id);
			pgsupp(url, listeOp.arguments[1]);
			break;

		case 'NEW' :
			if(listeOp.arguments.length == 2){
				url = listeOp.arguments[1];
			}
			//url = BuildUrl(url, 'rub', rub);
			url = BuildUrl(url, 'op', 'edit');
			url = BuildUrl(url, 'id_'+ table, id);
			pop(url, pop_param, "new");
			break;

		case 'MODIF' :
			if(listeOp.arguments.length >= 2){
				url = listeOp.arguments[1];
			}
			if(listeOp.arguments.length >= 3){
				pop_param = listeOp.arguments[2];
			}
			//url = BuildUrl(url, 'rub', rub);
			url = BuildUrl(url, 'op', 'edit');
			url = BuildUrl(url, 'id_'+ table, id);
			pop(url, pop_param);
			break;

		case 'FORUMREP' :
			url = BuildUrl(url, 'op', 'edit');
			url = BuildUrl(url, 'id_'+ table, '0');
			url = BuildUrl(url, 'id_reponse', id);
			pop(url, pop_param);
			break;

		case 'MODIFASSOMUL' :
				url = 'index.asp?op=edit&rub='+ listeOp.arguments[1] + '&'+ listeOp.arguments[3] + '='+ listeOp.arguments[4];
				pop(url, listeOp.arguments[2]);
			break;

		case 'POP' : 
			//alert('Cette fonctionalité n\'est pas encore disponible');

			url = BuildUrl(url, 'op', 'preview');
			url = BuildUrl(url, 'sel', 'ID');
			url = BuildUrl(url, 'val', id);
			url = BuildUrl(url, 'ba', listeOp.arguments[1]);
			pop(url, prev_param);


			break;

		
		case 'POPURL' :
			if(listeOp.arguments.length == 2){
				url = listeOp.arguments[1];
			}

			pop(url, prev_param);
		break;

		
		case 'SUPPASSOMEDIA' :

			url = BuildUrl(url, 'op', 'suppasso');
			url = BuildUrl(url, 'id_'+ GetVal('ftable'), id);
		//	url = BuildUrl(url, 'id_'+ GetVal('table'),  GetVal('id'));
			url = BuildUrl(url, 'prev_op', GetVal('op'));
			url = BuildUrl(url, 'prev_rub', GetVal('rub'));
			if(confirm(tx_page_supp)){
				setTimeout("self.document.location.href = '"+url+"'", 0);
			}
			break;

		case 'MODIFASSO' :
			id_table = GetVal('id_'+ GetVal('table'));
			if(!id_table){id_table =  GetVal('id');}

			url = BuildUrl(url, 'rub', rub);
			url = BuildUrl(url, 'op', 'edit');
			url = BuildUrl(url, GetVal('champ'), id);
			url = BuildUrl(url, 'id',  id_table);
			url = BuildUrl(url, 'id_'+GetVal('table'), id_table);
			url = BuildUrl(url, 'table',  GetVal('ftable'));
			url = BuildUrl(url, 'ftable',  GetVal('table'));

			parent.highlight_small_ong(GetVal('champ'), 'EDIT', ONGLETS_GEST_MEDIA);

			setTimeout("self.document.location.href = '"+ url +"'", 0);
			break;


		case 'SUPPASSOMUL' :
/*
			url = BuildUrl(url, 'op', 'suppassomul');
			url = BuildUrl(url, 'id_'+ GetVal('asso'), id);
			url = BuildUrl(url, 'prev_op', GetVal('op'));
*/
			if(confirm(tx_page_supp)){
				window.parent.submitit('formEdit');

			//	setTimeout("self.document.location.href = '"+url+"'", 0);
			}
			break;


		case 'COPY' :
			url = BuildUrl(url, 'rub', rub);
			url = BuildUrl(url, 'op', 'edit');
			url = BuildUrl(url, 'id_'+ table, id);
			url = BuildUrl(url, 'copi', id);
			setTimeout("pop('"+ url +"', '"+ pop_param +"');", 0);
			
			break;

		case 'MODIFVERSION' :
			url = BuildUrl(url, 'rub', rub);
			url = BuildUrl(url, 'op', 'edit');
			url = BuildUrl(url, 'id_'+ table, id);
			url = BuildUrl(url, 'copi', id);
			url = BuildUrl(url, 'version', 1);
			setTimeout("pop('"+ url +"', '"+ pop_param +"');", 0);
			
			break;

		case 'PAGE' :
			url = BuildUrl(url, 'rub', 312);
			url = BuildUrl(url, 'op', 'page');
			url = BuildUrl(url, 'sel', 'ARBO');
			url = BuildUrl(url, 'val', id);
			setTimeout("self.document.location.href = '"+url+"'", 0);
			break;
		
		case 'ASC' :
			url = BuildUrl(url, 'rub', rub);
			url = BuildUrl(url, 'op', 'ordre');
			url = BuildUrl(url, 'id', id);
			url = BuildUrl(url, 'sens', op);
			setTimeout("self.document.location.href = '"+url+"'", 0);
			break;

		case 'DESC' :
			url = BuildUrl(url, 'rub', rub);
			url = BuildUrl(url, 'op', 'ordre');
			url = BuildUrl(url, 'id', id);
			url = BuildUrl(url, 'sens', op);
			setTimeout("self.document.location.href = '"+url+"'", 0);
			break;

		case 'COUNT' :
			url = BuildUrl(url, 'rub', rub);
			url = BuildUrl(url, 'op', 'ordre');
			url = BuildUrl(url, 'id', id);
			url = BuildUrl(url, 'sens', op);
			setTimeout("self.document.location.href = '"+url+"'", 0);
			break;

		case 'SUPPLOT' :
				url = BuildUrl(url, 'op', 'supp');

				idz = getPageLotChecked();

				if(window.parent){
					supp_lot_hidden(idz);
				}
				url = BuildUrl(url, 'ccoche', idz);
				pgsupp(url, 0);
			break;

	}
}


function supp_lot_hidden(idz){
	tidz = idz.split(':');
	narr = Array();
	j = 0;

	hidden_name = window.name.substr(1, window.name.length);

	// Verification de l'existance d'un hidden dans une fenetre parente
	if(input = window.parent.MM_findObj(hidden_name)){
		
		// Récupération des id de la table "associée" à partir des id de la table d'asso
		ftv = Array();
		for(var i=0; i<tidz.length; i++){
			ftv[i] = MM_findObj(hidden_name +':'+ tidz[i]).value;
		}

		T_vals = input.value.split(',');

		for(var k=0; k<T_vals.length; k++){
			if(!inList(ftv, T_vals[k])){
				narr[j] = T_vals[k];
				j++;
			}
		}
		input.value = narr.join(',');
	}
}

function getPageLotChecked(){
	var idz = '';
	var cbx = document.getElementsByTagName("INPUT");
	var sep = '';

	for(var i=0; i<cbx.length; i++){
		if(cbx[i].type == 'checkbox' && cbx[i].name == 'LOT' && cbx[i].checked){
			idz += sep + cbx[i].value;
			sep = ':';
		}

	}
return idz;
}


function selection_liste(obj){
	var url = self.document.location.href + '';
	var id = obj.id;
	id = id.replace('SEL_', '');

	var value = GetVal('value');

	if(value != ''){
		value += ',';
	}
	value += id;


	url = BuildUrl(url, 'value', value);
	url = BuildUrl(url, 'op', 'asso');
	url = BuildUrl(url, 'id_'+ GetVal('ftable'), id);
	url = BuildUrl(url, 'id', id);

	if(GetVal("rub") == RUBRIQUE_GESTION_MEDIAS){
		parent.highlight_small_ong(GetVal('champ'), 'IFRA', ONGLETS_GEST_MEDIA);
	}
		setTimeout("self.document.location.href = '"+url+"'", 0);
}

function ModifBlock(obj, zone, id_block_t_arbo, type, ong){

	if(ong == 'undefined'){ong = 0;}
	var url = self.document.location.href + '';
		url = BuildUrl(url, 'rub', RUBRIQUE_GESTION_BLOCKS);
		url = BuildUrl(url, 'op', 'edit');
		url = BuildUrl(url, 'sel', '');
		url = BuildUrl(url, 'val', '');
		url = BuildUrl(url, 'id_block_t_arbo', id_block_t_arbo);
		url = BuildUrl(url, 'id_t_arbo', GetVal('val'));
		url = BuildUrl(url, 'id_block', obj.id);
		url = BuildUrl(url, 'zone', zone);
		url = BuildUrl(url, 'type', type);
		url = BuildUrl(url, 'ong', ong);
		pop(url, pop_param);
}

function SelectBlock(obj, zone){
	var url = self.document.location.href + '';
		url = BuildUrl(url, 'rub', RUBRIQUE_GESTION_BLOCKS);
		url = BuildUrl(url, 'op', 'selection');
		url = BuildUrl(url, 'sel', '');
		url = BuildUrl(url, 'val', '');
		url = BuildUrl(url, 'id_t_arbo', GetVal('val'));
	//	url = BuildUrl(url, 'id_block', obj.id);
		url = BuildUrl(url, 'id', obj.id);
		url = BuildUrl(url, 'zone', zone);
		url = BuildUrl(url, 'ftable', 'block');
		url = BuildUrl(url, 'table', 't_arbo');
		pop(url,  "width=300,height=550,scrollbars=yes");
}

function supp_block(obj){

	if(confirm('Supprimer ce block de la page ?')){
		var url = self.document.location.href + '';
		url = BuildUrl(url, 'prev_rub', GetVal('rub'));
		url = BuildUrl(url, 'prev_op', GetVal('op'));
		url = BuildUrl(url, 'op', 'suppasso');
		url = BuildUrl(url, 'rub', RUBRIQUE_GESTION_BLOCKS);
		url = BuildUrl(url, 'id_block', obj.id);
		url = BuildUrl(url, 'id_t_arbo', GetVal("val"));
		url = BuildUrl(url, 'table', 'block');
		url = BuildUrl(url, 'ftable', 't_arbo');

		setTimeout("self.document.location.href = '"+url+"'", 0);
	}
}


var ID_CURRENT_BLOCK = 0;
var ID_CURRENT_BLOCK_T_ARBO = 0;
var HL_TimeOut;

function ini_deplace_block(obj, id_block_t_arbo){
	ID_CURRENT_BLOCK = obj.id;
	ID_CURRENT_BLOCK_T_ARBO = id_block_t_arbo;
	

	HL_TimeOut = window.setTimeout('Highlight_Zones()', 500);

}

function Highlight_Zones(){
	var zones = document.getElementsByTagName("label");
	for(var i=0; i<zones.length; i++){
		if(zones[i].className == 'zone' && Highlight_Zones.arguments.length == 0){
			zones[i].className = 'hlzone';
		}else{
			if(zones[i].className == 'hlzone'){
				zones[i].className = 'zone';
			}
		}
	}
	if( Highlight_Zones.arguments.length == 0){HL_TimeOut = window.setTimeout('Highlight_Zones()', 500);}
}

function deplace_block(obj, zone){
	if(ID_CURRENT_BLOCK > 0){
		zo = obj;
		zo.className = 'deplace';
		Highlight_Zones(false);
		window.clearTimeout(HL_TimeOut);
//		setTimeout("zo.className = 'zone'", 500);

		var url = self.document.location.href + '';
		url = BuildUrl(url, 'op', 'deplace_block');
		url = BuildUrl(url, 'id_block_t_arbo', ID_CURRENT_BLOCK_T_ARBO);
		url = BuildUrl(url, 'zone', zone);

		setTimeout("self.document.location.href = '"+url+"'", 0);

		ID_CURRENT_BLOCK = 0;
		ID_CURRENT_BLOCK_T_ARBO = 0;
	}


}



function ordre_block(id_block_t_arbo, sens){
	var url = document.location.href + '';
	url = BuildUrl(url, 'op', 'ordre_block');
	url = BuildUrl(url, 'id_block_t_arbo', id_block_t_arbo);
	url = BuildUrl(url, 's', sens);
	setTimeout("self.document.location.href = '"+url+"'", 0);
}


/*
// Ouvre une pop up et met le focus dessus après 250 milisecondes
function pop(url, param){
	if (url){
		var jour = new Date();		
		var name = 'pop_'+jour.getHours()+''+jour.getMinutes()+''+jour.getSeconds();
		var raz = false;
		if(pop.arguments.length == 3)
			name = window.name;
			
		eval(name+" = window.open('"+url+"','"+name+"','"+param+"');");
  		eval("setTimeout('"+name+".focus();',250);");
	}
}
*/

// Envoi vers la page de suppression [url] si cpt = 0
function pgsupp(url, cpt){
	if (cpt == 0)	{
		if (confirm(tx_page_supp)){
			setTimeout("self.document.location.href = '"+url+"'", 0);
		}
	}
	else{
		alert(lang['CANT_DELETE'] + cpt + lang['ELEM_ASSOCIES']);
	}
}

// Envoi vers la page de traitement des <select> de liste
function liste_select(obj, champ, id, table){
	var url = self.document.location.href + '';

	var url_refresh = url;

	url = BuildUrl(url, 'op', 'cocheSel');
	url = BuildUrl(url, 'oop', GetVal('op'));
	url = BuildUrl(url, 'id', id);
	url = BuildUrl(url, 'selname', champ);

	if(table != ''){
		url = BuildUrl(url, 'id_'+table, table);
		url = BuildUrl(url, 'otable', GetVal('table'));
		url = BuildUrl(url, 'table', table);
		url = BuildUrl(url, 'ap', 1);

	}

	if(liste_select.arguments.length > 4){
		url = BuildUrl(url, 'sval', liste_select.arguments[4]);
		url = BuildUrl(url, 'schamp', liste_select.arguments[5]);
		url = BuildUrl(url, 'ar_alias', liste_select.arguments[6]);
		
		if (liste_select.arguments.length > 6)
		{
			var get_spec_value = GetVal(liste_select.arguments[7]);
			url = BuildUrl(url, 'spec_champ', liste_select.arguments[7]);
			url = BuildUrl(url, 'spec_val', get_spec_value);
		}
	}

	url = BuildUrl(url, 'selval', obj.options[obj.selectedIndex].value);	

	//cookie pour stocker la page courante qui devra être rafraichie
//	document.cookie = "url_refresh=" + url_refresh;
//	alert(document.cookie);

	
//alert(url);
	self.document.location.href = url;

}


// Envoi vers la page de traitement des cases a cocher
function coche(obj, champ, id){
	var url = self.document.location.href + '';

	var oop = GetVal('op');

	url = BuildUrl(url , 'op', 'coche');	
	url = BuildUrl(url , 'oop', oop);
	url = BuildUrl(url , 'id', id);
	url = BuildUrl(url, 'cochename', champ);
	url = BuildUrl(url, 'cocheval', obj.value);

	if (coche.arguments.length > 4){
		url = BuildUrl(url, 'rub', coche.arguments[3]);
		url = BuildUrl(url, 'orub', coche.arguments[4]);
	}

	if (coche.arguments.length > 5){
		url = BuildUrl(url, 'where', coche.arguments[5]);
	}

	
	self.document.location.href = url;
}



//
function buildcoche(valcoche){
	idoc = MM_findObj(PAGE_FORM_NAME);
	tcoche = getLcheck(idoc, 'LOT');

	if (tcoche.length == 0){
		tcoche = (valcoche).toString();
	}
	else{
		var tlcoche = tcoche.split(":");
		if (valcoche != '')	{
			if (!inList(tlcoche, (valcoche).toString())){
				tcoche += ":"+ valcoche;
			}
		}
	}
return tcoche;
}


//
function supp_lot(val){
    	tcoche = buildcoche(val);

    	var ttlcoche = tcoche.split(":");
		
		if (ttlcoche.length <= 1) {tph = tx_js_supp;}
		else {tph = tx_js_supp_lot.replace("_#_", ttlcoche.length);}
		
		if (confirm(tph)) {

		var	url = document.location.href+'';
			url = url.replace('index.asp', 'supp.asp');
			url = BuildUrl(url, 'ccoche', tcoche);

		self.document.location.href = url;
		}
}


// un peu trop en dur ca !
function mGroup(rub){
	tcoche = buildcoche('');
	if (tcoche != ''){
			alert('En développement !');

		url = "../_groupe_edit/edit.asp?rub=" + rub + "&ccoche=" + tcoche;
	//	pop(url, 'width=600,height=300');
	}
	else{
		alert(lang['SELECTIONNE']);
	}
}

function LotCheckAll(op){
	var elements = document.getElementsByTagName('input');
	for(i=0; i<elements.length; i++){
		if(elements[i].type == 'checkbox' && elements[i].name == 'LOT'){
			elements[i].checked = op;
		}
	}
}

function checkall(ifra, val){
	for(var i = 0; i < ifra.elements.length; i++){
		if ((ifra.elements[i].type == 'checkbox') && (ifra.elements[i].name == 'ccase')){
			ifra.elements[i].checked = val;
		}
	}
}


function submitrech(){
	if(submitrech.arguments.length > 0){
		PAGE_FORM_NAME = submitrech.arguments[0];
	}
	var url = document.location + '';
	var idoc = MM_findObj(PAGE_FORM_NAME);
//	alert(PAGE_FORM_NAME);

	var research = trim(idoc.research.value);
	research = escape(research);
	
//	turl = JSR;
//	if (research != '') {
		url = BuildUrl(url, 'research', research);
//	}
	self.document.location.href = url;
	setTimeout("self.document.location.href = '"+  url +"';", 0);
}

// Chemin de l'arbo
function check_onedir(ifra, thch)
{
	for(var i = 0; i < ifra.elements.length; i++)
	{
		if ((ifra.elements[i].type == 'checkbox') && (ifra.elements[i].name == 'ccase'))
		{
			if (ifra.elements[i] != thch)
			{
				ifra.elements[i].checked = false;
			}
		}
	}
}


function k_export(exp_type){
	var page = GetVal('page');
	var url = self.document.location.href + '';
	url = BuildUrl(url, 'op', 'export');
	url = BuildUrl(url, 'exp_type', exp_type);
	
	if(page != -1){
		if(confirm("Voulez-vous étendre l'export à tous les résultats satisfaisant vos critères ?")){
			url = BuildUrl(url, 'page', -1);
		}
	}

//	alert(url);
	window.open(url, '');

}

// Fonction un peu en dur...
function ini_block_options(){
	if(GetVal('id_block') != false){
		Update_block_options(MM_findObj('id_block_type'), 'id_modele');
		
	}
}

// Restreint les options affichées aux templates qui commencent par les 4 premieres lettres du type de block.
function Update_block_options(obj, select_name){
	var prefix = obj.options[obj.selectedIndex].innerHTML.substr(0, 4).toUpperCase() + '_';
	var select = MM_findObj(select_name);

	if(select.options[select.selectedIndex].innerHTML.indexOf(prefix) !=0){
		select.selectedIndex = 0;
	}
	for(var i=0; i<select.options.length; i++){
		if(select.options[i].innerHTML.indexOf(prefix) != 0){
			select.options[i].style.display = 'none';
		}else{
			select.options[i].style.display = 'block';
		}
	}
}


function ini_media_onglets(){
	op = GetVal('op').toUpperCase();
	champ = GetVal('champ');
	if(op == 'IFRA'){
		check_media_liste_not_empty(op, champ);
	}

	idz = GetVal('value');
	idz = (idz)? idz : '';


	window.parent.highlight_small_ong(champ, op, ONGLETS_GEST_MEDIA, GetVal('max_media'));
	window.parent.MM_findObj(champ).value = idz;
//	alert(window.parent.MM_findObj(champ).value);

}

function check_media_liste_not_empty(op, champ){
	oTable = MM_findObj('admin_liste');
	
	childs = oTable.childNodes;
	for(i=0; i<childs.length; i++){
	//	alert(childs[i].innerHTML);
	}

}



function suppAssoMulId(champ, id){
	var fid;

	if(id){
		Tid = id.split('_');
		fid = Tid[1];

	}
	else{
		Tid = suppAssoMulId.arguments[2].split('_');
		fid = MM_findObj(champ +':'+ Tid[1]).value;
	}


	tvals = window.parent.MM_findObj(champ).value.split(',');
	nvals = Array();

	for(var i=0; i<tvals.length; i++){
		if(tvals[i] != fid){
			nvals[nvals.length] = tvals[i];
		}
	}

	window.parent.MM_findObj(champ).value = nvals.join(',');


}


function myAccount(cid){
	pop_param = 'width=600,height=500';
	pop('index.asp?rub=ADM-USERS&op=edit&id_contact='+ cid, pop_param);
}

function choix_lang(lang){
	var url = document.location.href + '';
	url = BuildUrl(url, 'language', lang);
	self.document.location.href = url;
}



/**** FORMULAIRE DES SESSIONS > LISTE DES STAGIAIRES **/
var ARRAY_ajax_liste_texte = Array();

function ajax_liste_text_blur(obj, url, data_type_check_func){
	obj.className = 'ajaxtxt_blur';

	valeur_ok = (data_type_check_func)? eval(data_type_check_func+'(obj)') : true;

	if(ARRAY_ajax_liste_texte[obj.name] != obj.value && valeur_ok ){

	//	MM_findObj('div_' + obj.name).innerHTML = 'Chargement...';
 
	ajax_loading_string_timer['div_'+ obj.name] = setInterval('ajax_loading_string_function("div_'+obj.name+'")', ajax_loading_string_timer_speed);


//		Tid_asso = obj.name.split('[');
//		id_asso = Tid_asso[1].replace(']', '');

		fill_element(url +"&value="+ obj.value, 'div_' + obj.name);
	}
}

function ajax_liste_text_focus(obj){
	obj.className = 'ajaxtxt_focus';
	ARRAY_ajax_liste_texte[obj.name] = obj.value;
}




/*** Calendrier combobox */

var CALjour, CALmois, CALannee;



// La possibilité de ne pas specifier de jour complique le code...
function gen_input_date(champ){

	var ini = Array(1, 1, 1);
	var use_jour = true; // Par defaut on presume qu'un jour est utilisé

	if(gen_input_date.arguments.length > 1){ // Si un second argument est passé (valeur prérenseignée)
		ini = gen_input_date.arguments[1].split('/');

		ini_jour = ini[0]; // Si le jour vaux 0 c'est qu'on ne le specifie pas,
		if(ini[0] == 0){ 
			ini_jour = 1; // on initialise qd meme la date au premier du mois.
			use_jour = false;
		}

		var today = new Date(ini[2], ini[1]-1, ini_jour); // Instanciation d'un objet date avec pour valeur la date passée en scond param
	}
	else{// Instanciation d'un objet date avec pour valeur la date actuelle
		var today = new Date(); 
	}

	
	// Mes selects
	oJour = MM_findObj(champ + '_j');
	oMois = MM_findObj(champ + '_m');
	oAnnee = MM_findObj(champ + '_a');

	// Si on a deja des options et 1 seul argument la fonction a été appellée sur onchange
	if(oJour.options.length > 0 && gen_input_date.arguments.length == 1){
		if(oJour.options[oJour.selectedIndex].value == 0 || ini[1] == 0){
			use_jour = false;
		}
		today.setFullYear(oAnnee.options[oAnnee.selectedIndex].value);
		today.setMonth(oMois.options[oMois.selectedIndex].value);
		if(use_jour){today.setDate(oJour.options[oJour.selectedIndex].value);}
	}

	// Si on a deja des options et 1 seul argument la fonction a été appellée sur onchange
	if(oJour.options.length > 0 && gen_input_date.arguments.length == 1){
	}

	// Fixe les valeurs séléctionnées
	if(use_jour){ CALjour = today.getDate();}
	CALmois = today.getMonth();
	CALannee = today.getFullYear();


	// Retire les options déjà présentes
	videOptions(oJour.name); 
	videOptions(oMois.name);
	videOptions(oAnnee.name);

	// Ajoute les nouvelles options
	gen_select_box(champ + '_j', gen_valeurs(0, dernier_jour_du_mois(CALmois, CALannee), 'jour'), CALjour);
	gen_select_box(champ + '_m', gen_valeurs(0, 11, 'mois'), CALmois);

	// Pour les années on propose l'année en cours + les 10 suivantes
	var oDate = new Date();
	an_deb = oDate.getFullYear() - 2000;

	gen_select_box(champ + '_a', gen_valeurs(an_deb, an_deb+10, 'annee'), CALannee);

	if(!use_jour){
		oJour.selectedIndex = 0;
	}
}


// Génére le tableau de valeurs pour les select
function gen_valeurs(min, max, typeval){
	var vals = Array();

	for(var i=min; i<=max; i++){

		switch(typeval){
			case 'jour' :
			//	var oDate = new Date(CALannee, CALmois, i);
				vals[i] = (i == 0)? '--' : i;
			break;

			case 'mois' :
				vals[i] = TAB_mois[i];
			break;

			case 'annee' :
				vals[2000 + i] = 2000 + i;
			break;
		}
	}
return vals;
}


// Affecte les options de champA à champB
function meme_date(champA, champB){

	oJour = MM_findObj(champA + '_j');
	oMois = MM_findObj(champA + '_m');
	oAnnee = MM_findObj(champA + '_a');

	mdate = oJour.options[oJour.selectedIndex].value + '/'+ (parseInt(oMois.options[oMois.selectedIndex].value)+1) + '/'+ oAnnee.options[oAnnee.selectedIndex].value;

	videOptions(champB+'_j');
	videOptions(champB+'_m');
	videOptions(champB+'_a');

	gen_input_date(champB, mdate);
}



function gen_select_box(nom, valeurs, selected){
	addOptionsArray(nom, valeurs, selected);
}


function dernier_jour_du_mois(val_mois, val_annee){
	var mois = val_mois + 0;
	var annee = val_annee + 0;

	for(var i=1; i<=31; i++){
		oDate = new Date(annee, mois, i);
		
		cDate = oDate.getDate() +'/'+ oDate.getMonth() +'/'+ oDate.getFullYear();
		cString = i +'/'+ mois +'/'+ annee;

		if(cDate != cString){
			return i-1;
			break;
		}
	}
	return i-1;
}

function addOptionsArray(destination, tableau, selected){
//	alert(destination +"\n" + tableau);
	oDestination = MM_findObj(destination);
	var j = 0;
	for(key in tableau){
		if(tableau[key] != ''){
			// C'est pas du DOM mais c'est la seule technique qui fonctionne sous ie 5.2 MAC !
			oDestination.options[j] = new Option(tableau[key], key, (key == selected));
			if(key == selected){ sel = j;} // Pour IE il faut affecter le selectedIndex à la fin de la boucle...
			j++;
		}
	}
	oDestination.selectedIndex = sel;
}

function videOptions(source){
	oSource = MM_findObj(source);
	for(var i=0; i<oSource.options.length; i++){
		oSource.options[i] = null; // C'est pas du DOM mais c'est la seule technique qui fonctionne sous ie 5.2 MAC !
	}
//	while(oSource.options.length > 0){ videOptions(source); } // il ne vide pas tout du premier coup ...
}




function second_date(obj, champA, champB){
	if(obj.checked){
		MM_findObj(champB + '_j').disabled = false;
		MM_findObj(champB + '_m').disabled = false;
		MM_findObj(champB + '_a').disabled = false;
		meme_date(champA, champB);
		MM_findObj('div_'+ champB).style.display = 'block';
	}
	else{
		MM_findObj(champB + '_j').disabled = true;
		MM_findObj(champB + '_m').disabled = true;
		MM_findObj(champB + '_a').disabled = true;
		MM_findObj('div_'+ champB).style.display = 'none';
	}
}


/******* LIBRAIRIE DE CONTROLES DES SAISIES ***********
	
	SOMMAIRE :

	- PARAMETRES
	- MOTEUR DES CONTRÔLES DE SAISIE
	- CONTRÔLES DE SAISIE
	- CONTRÔLES SUR LES VALEURS
	- FONCTIONS DHTML DIVERSES POUR LES FORMS
	- "POUBELLE"

/**************************************/

/*********** PARAMETRES *********************************************************/

	var T_erreur = Array();
	var listeMsgErreur = Array(lang['msgchamp'], lang['msgerreurDATE'], lang['msgerreurSELECT'], lang['msgerreurMAIL']);
	var T_objects = Array();

	var k_asso_mul_s_type;


	// Liste des extensions acceptées
	var K_UPLOAD_EXTENSIONS = Array();
	
	// Images
	K_UPLOAD_EXTENSIONS[1] = Array('gif', 'jpg', 'jpe', 'jpeg', 'png', 'tiff', 'bmp');

	// Documents
	K_UPLOAD_EXTENSIONS[2] = Array("ppt", "doc", "pdf", "xls", "txt", "rtf", "zip", "rar", "ace", "gz", "tar", "htm", "html", "swf", "sql", "psd", "wnv", "mpg", "mpe","mpeg", "mp4", "avi", "rm", "ram", "mov", "qt", "asf", "vob", "ogm", "m1v", "mpa", "ivf", "wma", "wav", "mp3", "rm", "ogg", "mid", "mp2", "ra", "aif");

	// Variable globale pour afectation de valeurs des "sous champs"
	K_ASSO_MUL_CHILDS = Array();
/*******************************************************************************/




/************************** MOTEUR DES CONTRÔLES DE SAISIE *********************/


	/**
	 Objet champ Kcontain, permet de faire suivre les PROPRIÉTÉES PROPRIÉTAIRES Kcontain avec les prop standards.
	 La propriété ref est une référence à l'objet DOM du champ
	*/
	function kChamp(nom){
		
		if(is_array_key(nom, T_objects)){

			this.ref			= T_objects[nom].ref;			
			this.name			= T_objects[nom].name;			
			this.type			= T_objects[nom].type;			
			this.value			= T_objects[nom].value;			
			this.options		= T_objects[nom].options;		
			this.selectedIndex	= T_objects[nom].selectedIndex;	
			this.checked		= T_objects[nom].checked;		
			this.selected		= T_objects[nom].selected;		
			this.length			= T_objects[nom].length;			
			this.className		= T_objects[nom].className;		
			this.Ktype			= T_objects[nom].Ktype;			
			this.Ks_type		= T_objects[nom].Ks_type;		
			this.inputs			= T_objects[nom].inputs;			
			this.req			= T_objects[nom].req;			
			this.label			= T_objects[nom].label;			
			this.error			= T_objects[nom].error;			
			this.init_value		= T_objects[nom].init_value;
			this.old_style		= T_objects[nom].init_value; 
			this.old_req		= T_objects[nom].old_req; 
			this.erreur_message = T_objects[nom].erreur_message; 

		}
		else{
			// recherche de l'index du champ dans les tableaux générés coté serveur.
			for(var index=0; index<k_champs_liste.length; index++){
				if(k_champs_liste[index] == nom){ break; }
			}
		//	alert(nom);
			// Affectation de propriétés propriétaires et standard
			this.ref			= MM_findObj(nom);									
			this.name			= nom;
			this.type			= this.ref.type;
			this.value			= this.ref.value;
			this.options		= this.ref.options;
			this.selectedIndex	= this.ref.selectedIndex;
			this.checked		= this.ref.checked;
			this.selected		= this.ref.selected;
			this.length			= this.ref.length;
			this.className		= this.ref.className;
			this.Ktype			= k_champs_type[index];
			this.Ks_type		= k_champs_s_type[index];
			this.inputs			= k_asso_mul_inputs[index];
			this.req			= k_champs_req[index];
			this.label			= k_champs_nom[index];
			this.error			= false;
			this.init_value	= '';
			this.old_style	= '';
			this.old_req	= false; 
			this.erreur_message = ''; 

			T_objects[nom] = this;

			var test = 1;

		}

	}


	/**
	 Se charge de changer l'apparence des champs selon la validité renseignée par `err` (true|false)
	*/
	function displayErreur(obj, err){
		
		// Passage au statut "erreur"
		if(err){ 

			// Modification de la class CSS
			if(obj.className){
				obj.ref.className = obj.ref.className.replace('erreur', '');
				obj.ref.className += 'erreur';
			}

			switch(obj.Ktype){
				case "ASSO_SIM" :
					switch(obj.Ks_type){
						case "SELECT" : 
							obj.init_value = obj.ref.options[0].value;
							obj.ref.options[0].value = lang['msg_err_'+ obj.Ktype];

						break;

						case "RADIO" :
						break;
					}

				break;

				case "ASSO_MUL" :
				break;

				case "UPLOAD" :
				break;

				default :
					//alert(obj.Ktype);
					obj.init_value = (obj.ref.value == lang['msg_err_'+ obj.Ktype])? obj.init_value : obj.ref.value;				
					obj.ref.value = lang['msg_err_'+ obj.Ktype];
				break;
			}
		}

		// Sortie du statut "erreur"
		else{ 

			// Modification de la class CSS
			if(obj.className){
				obj.ref.className = obj.ref.className.replace('erreur', '');
			}

			switch(obj.Ktype){
				case "ASSO_SIM":
					switch(obj.Ks_type){
						case "SELECT" : 
							obj.ref.options[0].value = obj.init_value;
						break;

						case "RADIO" :
						break;
					}
				break;

				case "ASSO_MUL" :
				break;

				case "UPLOAD" :
				break;

				default :
					if(obj.ref.value == lang['msg_err_'+ obj.Ktype]){ obj.ref.value = obj.init_value; }
				break;
			}
		}
	T_objects[obj.name] = obj;
	return !err;
	}


	/**
	 Effectue sur chaque champ le contrôle de saisie qui lui est propre
	 retourne TRUE si le formulaire peut être posté, FALSE dans le cas contraire
	 L'appel aux controles de saisie déclanche les modifications dapparence des champs
	*/
	function valid(){
		var err = false;
		var exclus = Array();
		var x=0;
		for(var i=0; i<k_champs_liste.length; i++){
			if (is_array_key(k_champs_liste[i], k_asso_mul_inputs))
			{
				for(var j=0; j<k_champs_liste.length; j++){
					if (in_array_bool(k_champs_liste[j], k_asso_mul_inputs[k_champs_liste[i]]))
					{
						exclus[x] = k_champs_liste[j];						
						x++;
					}
				}
			}
		}

		for(var i=0; i<k_champs_liste.length; i++){
			if (!in_array_bool(k_champs_liste[i], exclus))
			{
				T_erreur[i] = !eval('verif'+ k_champs_type[i] +'(new kChamp(k_champs_liste[i]))');
				if(T_erreur[i]){
					err = true;
				}
			}
		}
		return !err;
	}




	/**
	 Post le formulaire `formname`, 
	 si l'argument optionnel `ong` est passé en parametre, modifit l'action du form pour que la validation redirrige sur un autre onglet.
	 Ce qui permet soit de changer d'onglet apres une validation normale, soit de valider le form en cours quand on change d'onglet.
	*/
	
	/* Déclaration de varaiables globales */
	var FORM_IS_SUBMITABLE = false;
	var CURRENT_SUBMITED_FORM;
	var FORM_STOPED = false;
	
	/* Déclaration de la focntion */
	function submitit(formname){
	//	alert(formname+' - '+FORM_STOPED+' - '+FORM_IS_SUBMITABLE);
		window.CURRENT_SUBMITED_FORM = formname;

		if(FORM_IS_SUBMITABLE){

			FORM_IS_SUBMITABLE = false;
			MM_findObj('mySubmit').className = 'bouton bouton_disabled';

			if(submitit.arguments.length > 1){
				ong = submitit.arguments[1];
				//alert(MM_findObj(formname).action);
				MM_findObj(formname).action += '&next='+ ong;
			}
			
			if(valid(formname)){
				//alert(MM_findObj(formname).action);
				if(!FORM_STOPED){
					waitLayer(true);
					MM_findObj(formname).submit();// meme chose
				}

			}
			else{
				alert_form();
				FORM_IS_SUBMITABLE = true;
				MM_findObj('mySubmit').className = 'bouton bouton_vert';
				if(window.parent != null){
					window.parent.FORM_IS_SUBMITABLE = true;
					MM_findObj('mySubmit', window.parent.document).className = 'bouton bouton_vert';
				}
			}
		}
	}

	/**
	 Affiche une alert explicative sur les erreurs (liste des champs)
	*/
	function alert_form(){
		var chaine = '';
		for(var i=0; i<k_champs_liste.length; i++){
			if(T_erreur[i]){
				chaine += "\n - " + k_champs_nom[i];
				if(T_objects[k_champs_liste[i]].erreur_message != ''){
					chaine +="\n\t"+ T_objects[k_champs_liste[i]].erreur_message;
				}
			}
		}
		alert(lang['champs_incorects'] +' :'+ chaine);
	}


	/**
	 EVENT exécutée `onfocus` : Rétabli la valeur saisie si obj.value contient un message d'arreur
	 N'est utilisé que sur certains types de champs (TXT & dérivés, TXTAREA...)
	*/
	function resetchamp(obj){
		if(obj.ref.value == lang['msg_err_'+ obj.Ktype]){
			obj.ref.value = obj.init_value;
			obj.ref.className = obj.ref.className.replace('erreur', '');
		}
	}

/*******************************************************************************/




/************************** CONTRÔLES DE SAISIE ********************************/

	function verif(obj){
		alert('verif : ' + obj.name);
	}

	function verifHIDDEN(obj){
		return true;
	}

	function verifORDRE(obj){
		return true;
	}


	function verifTXT(obj){
		if(verifTXT.arguments.length > 1){
			if(inList(k_uniques[obj.name], obj.ref.value)){
				alert('Cette valeur existe déjà dans la base !');
				return displayErreur(obj, true);
			}
		}
		if( obj.req && (trim(obj.ref.value) == '' || trim(obj.ref.value) == lang['msg_err_'+ obj.Ktype])){
			return displayErreur(obj, true);
		}
		else{
			return displayErreur(obj, false);
		}
	}

	
	function verifCOLOR_PIKER(obj){
		return verifTXT(obj);
	}



	function verifPWD(obj){
		var err = false;
		var champ_confirm = MM_findObj(obj.name +'_confirm');

		err = (obj.req && obj.ref.value == '');

	//	alert(champ_confirm.value +' != '+obj.ref.value);

		if(!err && champ_confirm != null ){
			err = (champ_confirm.value != obj.ref.value);
		}

		return !err;
	}


	function verifTXTAREA(obj){
		var obj_Iframe = MM_findObj(obj.ref.name+ '___Frame');
		if (obj_Iframe != null)
		{
			value = obj_Iframe.contentWindow.document.getElementById('eEditorArea').contentWindow.document.body.innerHTML;
		

			/* Sous Firefox 2 problèmes : 
				- La propriété innerText n'existe pas
				- Une balise <br> est présente par defaut dans le corp de l'iframe FCK
			*/
			value = (value == '<br>') ? '' : value;

			obj.ref.value = value;
			obj.value = obj.ref.value;
		}
		return verifTXT(obj);
	}


	function verifINT(obj){
		var val = trim(obj.ref.value);

		if( obj.req || (val != '' && val != lang['msg_err_'+ obj.Ktype])){
			return displayErreur(obj, !isInteger(val));
		}
		else{
			return displayErreur(obj, false);
		}
	}
	
	function verifFLOAT(obj){
		var error = false;
		for(var i=0; i < obj.ref.value.length; i++)  {
			if(!ismonetaire(obj.ref.value.charAt(i))) {
				return displayErreur(obj, true);
			}
		}
		if (obj.ref.value == '' && obj.req)
			return displayErreur(obj, true);	
		else
			return displayErreur(obj, false);
	}


	function verifASSO_MUL(obj){
		//alert(obj.name);
		switch(obj.Ks_type){
			case 'HIDDEN':
				break;

			case 'IFRAME':
				break;

			case 'COCHE':
				//getASSO_MUL_vals(obj.name, k_asso_mul_inputs[obj.name]);
				error = obj.req;
				for(var i=0; i<obj.ref.length; i++){
					if(obj.ref[i].checked){
						error = false;
					}
				}
				return displayErreur(obj, error);
				break;
		}
/*
		if(trim(MM_findObj(obj.name).value) == '' && obj.req){
			return displayErreur(obj, true);
		}
		else{
			return displayErreur(obj, false);
		}
*/
	return true;
	}

	function verifDOCSIMPLE(obj){
		if(trim(MM_findObj(obj.name).value) == '' && obj.req){
			return displayErreur(obj, true);
		}
		else{
			return displayErreur(obj, false);
		}
	}

	function verifASSO_SIM(obj){
		//alert(obj.name);
		if (document.getElementById(obj.name + "_input")){
			//alert("ok");
			var input_obj = new kChamp(obj.name + "_input");
			input_obj.req = obj.req;
			input_obj.Ktype = "TXT";
			return verifTXT(input_obj);
		}
		else{
			switch(obj.Ks_type){
				case "SELECT" :
					return verifSELECT(obj);
				break;

				case "RADIO" :
					return verifRADIO(obj);
				break;
				
				default: 
					return verifSELECT(obj);
				break;
			}
		}
	}

	function verifASSO_SIM_R(obj){
		return verifSELECT(obj);
	}

	function verifASSO_SELECT(obj){
		return displayErreur(obj, false);
	}




	// Commune à ASSO_SIM->SELECT et à ASSO_SIM_R
	function verifSELECT(obj){
		if(obj.ref.options[obj.ref.selectedIndex].value == 0 && obj.req){
			return displayErreur(obj, true);
		}
		else{
			return displayErreur(obj, false);
		}
	}


	function verifRADIO(obj){
		error = true;
		for(var i=0; i<obj.ref.length; i++){
			if(obj.ref[i].checked){
				error = false;
			}
		}
	return displayErreur(obj, error);
	}

	// CONTROLE DES CHAMPS "MAIL"
	function verifMAIL(obj){
		if(obj.ref.value == '' && !obj.req){
			return displayErreur(obj, false);
		}
		else{
			if(!isValidEmail(obj.ref.value)){
				return displayErreur(obj, true);
			}
			else {
				return displayErreur(obj, false);
			}
		}
	}


	// CONTROLE DES CHAMPS "EURO"
	function verifEURO(obj){
		return verifFLOAT(obj);
	}


	// CONTROLE DES CHAMPS "DATE" & "DATETIME"
	function verifDATE(obj){
		if(obj.ref.value == '' && obj.req){			
			return displayErreur(obj, true);
		}
		else{			
			if(isDateValid(obj.ref.value)){				
				return displayErreur(obj, false);
			}
			else{				
				if( obj.req){					
					return displayErreur(obj, true);
				}
				else return displayErreur(obj, false);

			}
		}
	}


	// CONTROLE DES CHAMPS "DATETIME"
	function verifHEURE(obj, required){


		var val = obj.ref.value;
		var error = false;
		var dstr = val.split('');
		if( (!isNumber(dstr[0])) || (!isNumber(dstr[1])) || (dstr[2] != ':') || (!isNumber(dstr[3])) || (!isNumber(dstr[4]))  ){
			error = true;
		}
		else{
			var heure = dstr[0]+''+dstr[1];
			if(heure > 23){
				error = true;
			}
			var minute = dstr[3]+''+dstr[4];
			if(minute > 59){
				error = true;
			}
		}

		if(error){
			obj.value = msgerreurHEURE;
			obj.className += 'erreur';
			return false;
		}
		else{
			obj.className = obj.className.replace('erreur', '');
			return true;
		}
	}

	// CONTROLE DES CHAMPS "MULTI_CHAMP"
	function verifMULTI_CHAMP(obj){
		if (obj.ref.value == '' && obj.req)
			return displayErreur(obj, true);	
		else
			return displayErreur(obj, false);
	}

	// EVENT exécutée `onkeyup` sur l'un des deux champs constituant un "DATETIME" Concatene les valeurs date et heure
	function datetime_upd(name){
		MM_findObj(name).value = MM_findObj(name+'_date').value +' '+MM_findObj(name+'_heure').value;
	}

	var verifMEDIA_TIMER;
	function verifMEDIA(obj){
		var submit_normal = true;

		ifra = eval('i'+obj.name);
		
		// Vérification de l'etat de l'iframe
		file = ifra.document.forms[0].med_path;

		
		
		// Si on est sur le formulaire d'ajout
		if(file != null){
			// Si il y a un fichier en attente
			if(file.value != ''){
				submit_normal = false;
				hidden_value = obj.ref.value+'';

				if(confirm(lang['confirm_effectuer_upload'])){
					ifra.submitit('formEdit');

					FORM_STOPED = true;

					if(ifra.FORM_IS_SUBMITABLE == false){
						verifMEDIA_TIMER = setInterval('CB_verifMEDIA("'+hidden_value+'","'+obj.name+'")', 500);
					}

					return true;
				}
				else{
					clearInterval(verifMEDIA_TIMER);
				}
			}
			else{
				FORM_STOPED = false;
			}
		}
		// Vérification standard sur le hidden
		if(submit_normal){
			return verifTXT(obj);
		}
	}

		function CB_verifMEDIA(val_ini, name){
			champ = new kChamp(name);
			if(val_ini != champ.ref.value){
				//alert('ok');
				FORM_STOPED = false;
				FORM_IS_SUBMITABLE = true;
				submitit(CURRENT_SUBMITED_FORM);
				clearInterval(verifMEDIA_TIMER);
			}
		}

	function verifDOC_SIMPLE_UNIQUE(obj){
		return verifTXT(obj);
	}

	function verifUPLOAD(obj){
		// Vérification du type de fichier basée sur l'extension
		if(obj.ref.value != ''){
			var ext = getExtension(obj.ref.value);
			var type_attendu = GetVal('type_media');
			if(!inList(K_UPLOAD_EXTENSIONS[type_attendu], ext)){
				obj.erreur_message = lang['extension_de_fichier_non_acceptee'] + K_UPLOAD_EXTENSIONS[type_attendu].join(', ');
				return displayErreur(obj, true);
			}
		}

		if( obj.req && trim(obj.ref.value) == ''){
			return displayErreur(obj, true);
		}
		else{
			return displayErreur(obj, false);
		}
	}

	function verifLINK(obj){
		if(!obj.req && obj.ref.value == ''){
				return displayErreur(obj, false);
		}
		vlink = isValidLink(obj.ref.value);
		
		if(vlink === false){
			return displayErreur(obj, true);
		}
		else{
			if(vlink !== true){
				obj.value = vlink;
				obj.ref.value = vlink;
			}
			return displayErreur(obj, false);
		}
	}

	function verifCODE_POSTAL(obj){
		return verifTXT(obj);
	}


	function verifCOCHE(obj){
		return true;
	}


	function verifGOOGLE_MAP(obj){
		return true;
	}


/*******************************************************************************/



/******************** CONTRÔLES SUR LES VALEURS ********************************/

	/**
		Vérifit que `chaineDate`est une date valide.
		Retourne un booleen
	*/
	function isDateValid(chaineDate) {

	   if (chaineDate == "") return false;
	   if (chaineDate.length != 10) return false;
	   // date formatée en JJ/MM/AAAA
	   var ladate = (chaineDate).split("/"); 
		// Si je n'ai pas récupéré trois éléments ou bien s'il ne s'agit pas d'entiers, pas la peine d'aller plus loin
	   if ((ladate.length != 3) || isNaN(parseInt(ladate[0])) || isNaN(parseInt(ladate[1])) || isNaN(parseInt(ladate[2]))) return false;
		// Sinon, on créer la date correspondante. Attention, les mois sont étalonnés de 0 à 11
	   var unedate = new Date(eval('"'+ladate[2]+'"'), eval('"'+ladate[1]+'"')-1, eval('"'+ladate[0]+'"'));
		// Bug de l'an 2000 oblige, lorsque je récupère l'année, je n'ai pas toujours 4 chiffres selon les navigateurs, je rectifie donc ici le tir.
	   var annee = unedate.getYear()
	   if ((Math.abs(annee)+"").length < 4) annee = annee + 1900
		// Il ne reste plus qu'à vérifier si le jour, le mois et l'année obtenus sont les mêmes que ceux saisis par l'utilisateur.
	   return ((unedate.getDate() == eval(ladate[0])) && (unedate.getMonth() == eval(ladate[1])-1) && (annee == eval(ladate[2])))
	}




	/**
		Vérifit que `val` exprime un montant monétaire
		Retourne un booleen
	*/
	function ismonetaire(val){
		var string = "1234567890,.";
		if(string.indexOf(val) != -1){return true;}
		return false;
	}


	function isDigitDate(num) {
		var string="1234567890/";
		if (string.indexOf(num) != -1) {return true;}
		return false;
	}

	function isInteger(val){
		for (var i=0; i < val.length; i++) 
		  {if (!isNumber(val.charAt(i))) {return false;}}
		return true;
	}

	function isNumber(num){
		var string="1234567890";
		if (string.indexOf(num) != -1) {return true;}
		return false;
	}



	/**
		Vérifit que `emailStr` est une adresse mail valide : 
		La fonction originale documentée est dispo sur http://javascript.internet.com/forms/check-email.html
		This is an e-mail address validation function.
		It allows the usual user@domain syntax, but in addition allows user@[ip] format as well as "User with Spaces"@domain or [ip],
		all of which are legal syntax, according to W3C.
		It also checks that the user hasn't done anything silly like having multiple @'s or continuous .'s in the address (e.g. jim@b@c.com and jim@c..b.co.uk).

		Retourne un booleen
	*/
	function isValidEmail(emailStr){

		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null){return false;}
		var user=matchArray[1];
		var domain=matchArray[2];
		if (user.match(userPat)==null) {return false;}
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null){for(var i=1;i<=4;i++){if(IPArray[i]>255){return false;}}return true;}
		var domainArray=domain.match(domainPat)
		if (domainArray==null){return false;}
		var atomPat=new RegExp(atom,"g");
		var domArr=domain.match(atomPat);
		var len=domArr.length;
		if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {return false;}
		if (len<2) {return false;}
	return true;
	}


	/**
		Vérifit qu'une adresse internet est valide :
		Retourne true si l'adresse est valide
		Si l'adresse n'est pas valide la function tente de concatener le protocole par defaut, 
		si le résultat est une adresse valide cette nouvelle adresse est retournée,
		sinon la fonction retourne false.
	*/
	function isValidLink(linkStr){
		var default_protocole = 'http';

		var pattern = /^(http|ftp|irc|udp)(:\/\/)([a-zA-Z0-9\.])*([\.])+[a-zA-Z0-9\.\/\-\_?&=]+[a-zA-Z0-9]+$/
		matchArray = linkStr.match(pattern);
		if (matchArray==null){

			val = default_protocole + '://' + linkStr;
			matchArray = val.match(pattern);
			if (matchArray==null){
				return false;
			}
			else{

				return val;
			}
		}
		else{

			return true;
		}


	}



/*******************************************************************************/






/******************** FONCTIONS DHTML DIVERSES POUR LES FORMS **********/

	/**
	Affiche une image representant le fichier selectionné dans un input de type file.
	*/
	function previewUPLOAD(obj, type){
		img = MM_findObj('PREV_'+ obj.name);

		switch(type){
			case 1 :
				previewUPLOAD_IMG(obj, img);
				break;

			case 2 :
				previewUPLOAD_DOC(obj, img);
				break;
		}

	}

	function previewUPLOAD_IMG(obj, img){
		if(obj.value == ''){
			img.src = '../_pics/noimage.gif';
		}
		else{
			img.src = '../_pics/uploadimage.gif';
		}
	}

	function previewUPLOAD_DOC(obj, img){

		if(img != null){
			if(obj.value == ''){
				img.src = '../_pics/nodoc.gif';
			}
			else{
				typedoc = obj.value.split('.');
				img.src = '../_pics/doc_'+ typedoc +'.gif';
			}
		}
	}


	/**
	 Créer un lien mailto: a partir de la valeur du champ `nch`
	*/
	function icomailto(obj, nch){
		var txmail = MM_findObj(nch).value;
		if(isValidEmail(txmail)){
			obj.href = 'mailto:'+txmail;
		}else{
			alert(lang['msg_err_MAIL']);
		}
	}


	function icoLINK(obj, nch){
		var txLINK = MM_findObj(nch).value;
		vlink = isValidLink(txLINK) 
		if(vlink === false){
			alert(lang['msg_err_LINK']);
		}
		else{
			if(vlink !== true){
				MM_findObj(nch).value = vlink;
				txLINK = vlink;
			}
			popup(txLINK, '');
		}
	}

	
	/**
		Post un document dans les champs de type  UPLOAD_DOC_SIMPLE_xxxx
	*/
	function upload_simple(formname,champ){
		if( MM_findObj(champ).value != ''){
			MM_findObj('info_'+ champ).innerHTML = lang['loading_file']	;
			MM_findObj(formname).submit();
		}
		else{
			alert(lang['chosse_file']);
		}
	}


	function refreshListeCBX(champ){
		elems = MM_findObj('formulaire').elements;
		var error = true;

		for(var i=0; i<elems.length; i++){

			if(elems[i].type == 'checkbox' && elems[i].name.indexOf(champ) > -1 ){

				var id			= CBX_id(elems[i], champ);
				var tbody		= MM_findObj('tb_'+ id);
				var id_parent	= CBX_parent(tbody);

				if(id_parent != 0){
					if(MM_findObj(champ +'['+ id_parent +']').checked){
						switchTBODY('tb_'+ id, true);
						
					}
					else{
						elems[i].checked = false;
						switchTBODY('tb_'+ id, false);
					}
				}

				if(elems[i].checked){error = false;}
			}
		}

		if(error){
			MM_findObj('div_'+ champ).className = 'ifraLikeerreur';
			return false;
		}
		else{
			MM_findObj('div_'+ champ).className = 'ifraLike';
			return true;
		}

	}


	function CBX_id(obj, champ){
		var id = obj.name + '';
		id = id.replace(champ, '');
		id = id.replace('[', '');
		id = id.replace(']', '');

	return id;
	}

	function CBX_parent(tbody){
		id_parent = tbody.align;
		if(id_parent == ''){
			id_parent = tbody.parent;
		}
	return id_parent;
	}



	function switchTBODY(id, statut){
		var show = (statut)? '' : 'none';
		MM_findObj(id).style.display = show;
	}




	function asso_mul_inputs(obj){
		if(obj.checked){
			MM_findObj("tr_"+ obj.value).className = 'AssoMulRow1';
			MM_findObj("inputs_"+ obj.value).style.display = 'block';

		}else{
			MM_findObj("tr_"+ obj.value).className = 'AssoMulRow0';
			MM_findObj("inputs_"+ obj.value).style.display = 'none';
		}

	}

	function getASSO_MUL_vals(champ_name, inputs){
		var sep = '';
		var idz = '';
		var oth = Array;

		Tinput = inputs.split(':');
		Tinput = inputs.split(':');
		for(var j=0; j<Tinput.length; j++){
			oth[Tinput[j]] = '';
		}
		var ifra = eval('i'+ champ_name);
		var oForm = ifra.document.forms[0];

		for(var i=0; i<oForm.elements.length; i++){
			if(oForm.elements[i].type == 'checkbox' && oForm.elements[i].name == 'c_'+ champ_name){
				if(oForm.elements[i].checked){
					idz += sep + oForm.elements[i].value

					for(var j=0; j < Tinput.length; j++){
						nom = Tinput[j] +'['+ oForm.elements[i].value +']';
						elem = ifra.MM_findObj(nom);
						if(elem != null){
							switch(elem.type){
								case 'select-one' :
									oth[Tinput[j]] += sep + elem.options[elem.selectedIndex].value;
									break;
								default:
									oth[Tinput[j]] += sep + elem.value;
									break;
							}	
						}
					}
				sep = ':';
				}
			}
		}

		MM_findObj(champ_name).value = idz;
		for(i=0; i<Tinput.length; i++){
			MM_findObj(champ_name +':'+ Tinput[i]).value = oth[Tinput[i]];
		}


	}

	function ASSO_MUL_ASSOaddElement(champ){
		var sel = MM_findObj('sel_'+ champ);
		var id = sel.options[sel.selectedIndex].value;
		var ie = true;
		if(id == 0){ alert(lang['msgerreurSELECT']); }

		else{
			ifra = MM_findObj('i'+ champ)
			var url = ifra.src;
			if(!url){ie = false; url = ifra.document.location.href + ''; }

			url = BuildUrl(url, 's_op', 'add');
			url = BuildUrl(url, 'add', id);

			if(ie){
				ifra.src = url;
			}else{
				ifra.document.location.href = url;
			}

			sel.options[sel.selectedIndex] = null;

		}
	}


	function cocheASSO_MUL(obj){

		var input_stock = window.top.MM_findObj(obj.name);
		var oForm = obj.form;
		var nval = '';
		var sep = '';

		for(var i=0; i<oForm.elements.length; i++){
			if(oForm.elements[i].type == 'checkbox' && oForm.elements[i].name == obj.name && oForm.elements[i].checked){
				nval += sep + oForm.elements[i].value
					sep = ':'
			}
		}
		input_stock.value = nval;
	}


	function ini_ASSO_MUL(champ){
//		var input_stock = window.top.MM_findObj(champ);
		var oForm = document.forms[0];
//		var vals = input_stock.value.split(':');
		for(var i=0; i<oForm.elements.length; i++){
			if(oForm.elements[i].type == 'checkbox' && oForm.elements[i].name == champ && in_array(oForm.elements[i].value, vals) !== false ){
				oForm.elements[i].checked = true;
			}
		}
	}



	/**
		Active le bouton de validation du formaulaire une fois la page chargée
	*/

	var FormLoaded_timeout_status = false;


	function FormLoaded(libelle){
	//	alert('test');

		if(FormLoaded.arguments.length == 1){

			if (MM_findObj('mySubmit') != null) //[MODIF JU]
			{
				MM_findObj('mySubmit').innerTXT = ' - ' + libelle + ' - ';
				MM_findObj('mySubmit').className = 'bouton bouton_vert';
			}

			var cal_pos = in_array('CALENDRIER', k_champs_s_type);
			
			if(cal_pos !== false ){
 				if (is_array_key(k_champs_liste[cal_pos], k_calendrier) !== false){
					initCalendrier(k_calendrier[k_champs_liste[cal_pos]][0], k_calendrier[k_champs_liste[cal_pos]][1]);
				}
				else{
					initCalendrier(KC3_gnoo_calendar_default['min'], KC3_gnoo_calendar_default['max']);
				}
			}
			else{
				if(k_asso_mul_s_type){
					for(key in k_asso_mul_s_type){

					var cal_pos = in_array('CALENDRIER', k_asso_mul_s_type[key]);
					if (is_array_key(k_champs_liste[cal_pos], k_calendrier) !== false){
							initCalendrier(k_calendrier[k_champs_liste[cal_pos]][0], k_calendrier[k_champs_liste[cal_pos]][1]);
						}
						else{
							initCalendrier(KC3_gnoo_calendar_default['min'], KC3_gnoo_calendar_default['max']);
						}
					}
				}
			}


			if(k_champs_condition.length > 0){
				refreshCondition();
	/*
				for(var i=0; i<k_champs_condition.length; i+=2){
					form_condition(new kChamp(k_champs_condition[i][0]), k_champs_condition[i][1], k_champs_condition[i][2], k_champs_condition[i][3]);
				}
	*/
			}

			if (typeof(k_champs_onload) != 'undefined'){
				if(k_champs_onload.length > 0){
					for(var i=0; i<k_champs_onload.length; i++){
						if (k_champs_onload[i] != '')
							eval(k_champs_onload[i]);				
					}
				}
			}
		}


		var really_loaded = true;

		//alert('ok');

		if(in_array('TXTAREA', k_champs_type) !== false){
			for(var n=0; n<k_champs_type.length; n++){
				if(k_champs_type[n] == 'TXTAREA'){
					var oEditor = FCKeditorAPI.GetInstance(k_champs_liste[n]);

					if(oEditor.Status != FCK_STATUS_COMPLETE ){
						really_loaded = false;
						clearTimeout(FormLoaded_timeout_status);
						FormLoaded_timeout_status = setTimeout('FormLoaded("'+libelle+'")', 500);
						break;
					}

					if (MM_findObj(k_champs_liste[n]).className != ''){
						oEditor.EditorDocument.body.className = MM_findObj(k_champs_liste[n]).className + '';
					}



				}
			}
		}
		
		if(really_loaded){
			waitLayer(false);
			FORM_IS_SUBMITABLE = true;
			clearTimeout(FormLoaded_timeout_status);
		}
		else{
		//	FormLoaded(libelle, true);
		}
	}


	/* Encapsulation de la lib tooltip (tooltip.js) */

	/*** Version pour Tool tip ***/


	function AideContext(obj, op){
		if (BROWSER == 'NS'){
				if(op){
					tooltip.show(obj);
				}
				else{
					tooltip.hide(obj);
				}
		}
		else{
				if(op){
						obj.style.cursor = 'pointer';
						obj.tmp = obj.title + '';
						obj.title = '';
				}
				else{
						obj.title = obj.tmp + '';
				}
		}
	}
	
	function AideContextIE(obj){
		if (BROWSER == 'IE'){
				aide = window.open('', 'aide', 'width=300,height=150,resizable=yes,scrollbars=yes');
				aide.document.open();
				aide.document.write('<style>body{background: #F9F6E0;font-family:Verdana, Arial, Sans-serif;font-size:11px;}</style>');
				aide.document.write(obj.tmp);
				aide.document.write('<h3 style="text-align:center;"><a style="color:black;" href="javascript:self.close();">'+ lang['close'] +'</a></h3>');
				aide.document.close();
		}
		
	}




	/****************************************************************************/
	/* Fonctions de gestion des champs de type 'MULTI_CHAMP' */
	/****************************************************************************/

	// Séparateurs
	var MC_SEP_LIGNE = "||";
	var MC_SEP_CHAMP = "_&|";
	var MC_SEP_IDVAL = "|:_";

	/* Affiche la valeur sélectionnée (dans un select) dans l'input associé */
	function SelectToInput(obj){
		var form = document.forms[0];
		var cible = form.elements[obj.id + "_input"];		
		var i_selected = 0;
		for (var i=0; i < obj.options.length; i++)
		{
			if (obj.options[i].selected)			
				i_selected = i;			
		}
		if (obj.options[i_selected].value != "0")
			cible.value = obj.options[i_selected].innerHTML;
	}

	/* Fonctions de gestion de la liste dynamique */
	/**********************************************/
	var MCHAMP_SELECTED = ""; //id de la ligne sélectionnée (utile pour la modif & la suppr)
	var MCHAMP_DISABLE_SUPPR = true; //spécifie si le bouton supprimer est actif
	
	function MchampSubmit(key, bouton){
		if(MchampValid(key)){
			if (MCHAMP_SELECTED == "" && !MchampExist(key, k_asso_mul_inputs[key]))
				MchampAjout(key, k_asso_mul_inputs[key]);	
			else if (MCHAMP_SELECTED != ""){	
				if (bouton.id == 'ajout_modif')
					MchampModif(key, k_asso_mul_inputs[key]);
				else
					MchampSuppr(key, k_asso_mul_inputs[key]);
			}
		}
		MchampRefreshTab(key);
		MchampRazLigne(key + "_table", "");
	}

	function MchampInit(key){
		for(var i=0; i<k_asso_mul_inputs[key].length; i++){
			MchampReset(document.getElementById(k_asso_mul_inputs[key][i]), "");
		}
		MchampRazLigne(key + "_table", "");
	}

	/* Vérifie si les champs sont valides */
	function MchampValid(key){
		var err = false;
		for(var i=0; i<k_asso_mul_inputs[key].length; i++){
			//alert(k_asso_mul_inputs[key][i]);
			T_erreur[i] = !eval('verif'+ k_asso_mul_type[key][i] +'(new kChamp(k_asso_mul_inputs[key][i]))');
			if(T_erreur[i]){
				err = true;
			}
		}
		return !err;
	}

	//Vérifie si la nouvelle entrée existe déjà
	function MchampExist(hid, liste_champs){
		var input_list = new Array();
		var exist = false;
		for (var i=0 ; i < liste_champs.length ; i++)
		{
			if (k_asso_mul_type[hid][i] != "EURO")
			{
				var tag = document.getElementById(liste_champs[i]).tagName
				var recup_input;
				var id_input;
				switch (tag)
				{
					case "SELECT":
						id_input = liste_champs[i] + "_input";																	
						break;
					case "INPUT":
						id_input = liste_champs[i];
						break;
					default:
						alert("tag non géré: " + tag);
						break;
				}			
				recup_input = document.getElementById(id_input);
				if(recup_input)
					input_list[i] = recup_input.value;
			}			
		}
		
		var input_hidden = document.getElementById(hid);
		var lignes = (new String(input_hidden.value)).split(MC_SEP_LIGNE);

		for (var i=0; i<lignes.length; i++)
		{
			var ligne = new String(lignes[i]);
			ligne = ligne.substr(ligne.indexOf("]")+1);
			var cells = ligne.split(MC_SEP_CHAMP);
			for (var j=0; j < input_list.length; j++)
			{
				if (cells[j]){
				var cell = cells[j].substr(cells[j].indexOf(MC_SEP_IDVAL)+1); 
				if (cell == input_list[j] && (exist || j == 0))
					exist = true;
				else
					exist = false;
				}
			}
			if (exist){
				alert("Cette entrée existe déjà.");
				return exist;
			}
		}
		return exist;
	}

	//Ajoute une ligne dans le tableau
	function MchampAjout(hid, liste_champs){
		var input_hidden = document.getElementById(hid);
		var hid_value_tmp = "";
		var hid_l_separ = "";
		var input_list = new Array();
		var id_ligne = 'a' + Math.round((10000*(Math.random()/Math.random())));
		if (input_hidden.value != "")
			hid_l_separ = MC_SEP_LIGNE;
		
		for (var i=0 ; i < liste_champs.length ; i++)
		{
			if (document.getElementById(liste_champs[i]))
			{
				input_list[liste_champs[i] + "_[id]"] = MchampGetValue(liste_champs[i], "id");
				input_list[liste_champs[i] + "_[value]"] = MchampGetValue(liste_champs[i], "value");

				//Insertion des couples id:valeur des champs dans le hidden
				if (i > 0)
					hid_value_tmp += MC_SEP_CHAMP;		
				hid_value_tmp += input_list[liste_champs[i] + "_[id]"] + MC_SEP_IDVAL + input_list[liste_champs[i] + "_[value]"];

				MchampReset(document.getElementById(liste_champs[i]), "id_fr_critere");
			}
		}
		input_hidden.value = input_hidden.value + hid_l_separ + "[" + id_ligne + "]" + hid_value_tmp;
	}

	//Modifie une ligne du tableau
	function MchampModif(hid, liste_champs){
		var input_list = new Array();
		for (var i=0 ; i < liste_champs.length ; i++)
		{
			input_list[liste_champs[i] + "_[id]"] = MchampGetValue(liste_champs[i], "id");
			input_list[liste_champs[i] + "_[value]"] = MchampGetValue(liste_champs[i], "value");	
			MchampReset(document.getElementById(liste_champs[i]), "id_fr_critere");
		}
		var input_hidden = document.getElementById(hid);
		var lignes = (new String(input_hidden.value)).split(MC_SEP_LIGNE);
		var nb_lignes = lignes.length;
		input_hidden.value = "";


		//Parcours du hidden et mise à jour
		for (var i=0; i<lignes.length; i++){
			var ligne = new String(lignes[i]);
			var id_ligne = 'TR_'+ ligne.slice(ligne.indexOf("[")+1, ligne.indexOf("]"));
			ligne =  ligne.substr(ligne.indexOf("]")+1);

			if (i > 0)
				input_hidden.value += MC_SEP_LIGNE;	
			
			if (id_ligne == MCHAMP_SELECTED){
				input_hidden.value += "[" + id_ligne.replace('TR_', '') + "]";
				for (var j=0; j<liste_champs.length; j++){
					if (j > 0)
						input_hidden.value += MC_SEP_CHAMP;					
					input_hidden.value += input_list[liste_champs[j] + "_[id]"] + MC_SEP_IDVAL + input_list[liste_champs[j] + "_[value]"];
				}					
			}
			else input_hidden.value += lignes[i];
		}


	}	
	
	//Supprime une ligne du tableau
	function MchampSuppr(hid, liste_champs){
		var input_hidden = document.getElementById(hid);
		var lignes = (new String(input_hidden.value)).split(MC_SEP_LIGNE);
		var nb_lignes = lignes.length;
		var suppr_i = -1;
		input_hidden.value = "";

		for (var i=0 ; i < liste_champs.length ; i++)
			MchampReset(document.getElementById(liste_champs[i]), "id_fr_critere");

		//Parcours du hidden et mise à jour
		for (var i=0; i<lignes.length; i++){
			var ligne = new String(lignes[i]);
			var id_ligne = 'TR_' + ligne.slice(ligne.indexOf("[")+1, ligne.indexOf("]"));
			ligne = ligne.substr(ligne.indexOf("]")+1);
			
			if (id_ligne != MCHAMP_SELECTED){
				if (i > 0 && (suppr_i != i-1 || suppr_i != 0))
					input_hidden.value += MC_SEP_LIGNE;	
				input_hidden.value += lignes[i];
			}else
				suppr_i = i;
		}
		//alert(input_hidden.value);
	}

	//Renvoie les données des input
	function MchampGetValue(champ, type){
		var tag = document.getElementById(champ).tagName
		curr_input = document.getElementById(champ);
	//	alert(champ + ' '+ curr_input +' '+type);

		switch (tag)
		{
			case "SELECT":
				var id_input = champ + "_input";

				input_text_lie = document.getElementById(id_input);


				var select_id = 0;						
				if (input_text_lie != null){
					var select_txt = document.getElementById(id_input).value;
					for (var j=0; j < curr_input.options.length ; j++){
						if (curr_input.options[j].innerHTML == select_txt)
							//select_id = j;
							select_id = curr_input.options[j].value;
					}
				}
				else{
					select_id = curr_input.options[curr_input.selectedIndex].value;
				}

				if (type == "id"){
					return select_id;
				}
				else{
					if (input_text_lie != null){
						return select_txt;
					}else{
						return curr_input.options[curr_input.selectedIndex].innerHTML;
					}
				}
			break;

			case "INPUT":
				if (type == "id")
					return 0;
				else
					return document.getElementById(champ).value;
				break;
			default:
				alert("tag non géré: " + tag);
				break;
		}
	}

	//Rafraichit le tableau dynamique par rapport au contenu du hidden
	function MchampRefreshTab(hid){
		if (!hid)
			var hid = "id_t_arbo_profil";
		
		//source
		var input_hidden = document.getElementById(hid);
		var lignes = (new String(input_hidden.value)).split(MC_SEP_LIGNE);

		//alert(input_hidden.value);
		//sortie
		var view_table = document.getElementById(hid + "_table");
		
		var nb_lignes = lignes.length;
		if ((view_table.getElementsByTagName("TR")).length > 1){	
			if ((view_table.getElementsByTagName("TR")).length > nb_lignes)
				nb_lignes = (view_table.getElementsByTagName("TR")).length;			
			for (var i=1; i<nb_lignes; i++){
				view_table.deleteRow(1);
			}
		}
		
		if (lignes[0] != "")
		{
			//Création des lignes dans le tableau
			for (var i=0; i<lignes.length; i++)
			{
				var ligne = new String(lignes[i]);
				var id_ligne = "TR_"+ ligne.slice(ligne.indexOf("[")+1, ligne.indexOf("]"));
				ligne = ligne.substr(ligne.indexOf("]")+1);
				var new_tr = view_table.insertRow(i+1);
				var cells = ligne.split(MC_SEP_CHAMP);
				new_tr.setAttribute("id",  id_ligne);
				for (var j=0; j<cells.length; j++)
				{	
					var infos = cells[j].split(MC_SEP_IDVAL);
					var td = document.createElement("td");
					td.setAttribute("style", "");
					td.className = "pointeur";
					td.id_ligne = id_ligne;
					td.id = infos[0];
					td.onclick = function() {
						MchampSelectLigne(this.id_ligne, hid, k_asso_mul_inputs[hid]);
					}
					//cells[j] = cells[j].substr(cells[j].indexOf(":")+1); 
					if (k_asso_mul_type[hid][j] == "EURO" && infos[1] != ""){
						td.style.color = "#D64F41";
						td.style.textAlign = "right";
						infos[1] += " €";
					}
					var td_txt = document.createTextNode(infos[1]);
					td.appendChild(td_txt);
					new_tr.appendChild(td);
				}
			}
		}
	}

	//Vide tous les champs et réinitialise le select
	function MchampReset(champ, except){
		var tag = champ.tagName
		if (champ.id != except)
		{
			switch (tag)
			{
				case "SELECT":
					var id_input = champ.id + "_input";
					var select_input = document.getElementById(id_input);
					if (select_input){
						select_input.value = "";
					}
					champ.selectedIndex = 0;
					break;
				case "INPUT":
					champ.value = "";
					break;
				default:
					champ.value = "";
			}
		}
	}

	//Switche entre les boutons "Ajouter" et "Modifier"
	function MchampSwitchBouton(mode){
		var bouton_am = document.getElementById("ajout_modif");
		var bouton_s = document.getElementById("suppr");

		if (mode == "modif"){		
			bouton_am.innerHTML = "Modifier";
			bouton_s.className = "bouton bouton_rouge";
		//alert(bouton_s.className);
			MCHAMP_DISABLE_SUPPR = false;
		}else{
			//alert("ajout");
			bouton_am.innerHTML = "Ajouter";										
			bouton_s.className = "bouton bouton_disabled";
			MCHAMP_DISABLE_SUPPR = true;
		}
	}

	//Traitements lorsque une ligne du tableau dynamique est sélectionnée
	function MchampSelectLigne(id_ligne, key, liste_champs){
		var ligne = document.getElementById(id_ligne);
		MchampRazLigne(key + "_table",id_ligne);
	//	alert(id_ligne);
		if (MchampHighlightLigne(ligne, false)){
			MchampPutData(ligne, liste_champs, key);
			MchampSwitchBouton("modif");
			MCHAMP_SELECTED = id_ligne;
		}
		else{ 
			MchampSwitchBouton("ajout");
			MchampInit(key);
			MCHAMP_SELECTED = "";
		}
	}

	//Enlève les highlight des lignes
	function MchampRazLigne(id_table, id_ligne){
		table = document.getElementById(id_table);
		var ligne_list = table.getElementsByTagName("TR");
		for (var i=1; i<ligne_list.length; i++){	
			if (ligne_list[i].id != id_ligne){

				MchampHighlightLigne(ligne_list[i], true);
			}
		}	
		if (id_ligne == "")
			MchampSwitchBouton("ajout");
		MCHAMP_SELECTED = "";
	}

	//Surligne la ligne sélectionnée
	function MchampHighlightLigne(ligne, init){
		var cells = ligne.getElementsByTagName("TD");

		if (!cells[0].style.backgroundColor && !init)
		{
			for (var i=0; i<cells.length; i++)
				cells[i].style.backgroundColor = "#FAF9B9";
			return true;
		}
		else{
			for (var i=0; i<cells.length; i++)
				cells[i].style.backgroundColor = "";	
			return false;
		}
	}

	//Renseigne les champs avec les valeurs de la ligne sélectionnée
	function MchampPutData(ligne, liste_champs, key){
		var cells = ligne.getElementsByTagName("TD");

		for (var i=0; i<liste_champs.length; i++)
		{
			var tag = document.getElementById(liste_champs[i]).tagName
			switch (tag)
			{
				case "SELECT":
					var id_input = liste_champs[i] + "_input";
					var select_input = document.getElementById(id_input);
					if(select_input != null){
						select_input.value = cells[i].innerHTML;
					}else{
						//alert(document.getElementById(liste_champs[i]));
						curr_input = document.getElementById(liste_champs[i]);
						s_index = 0;
						for(var m=0; m<curr_input.options.length; m++){
							if(curr_input.options[m].value == cells[i].id){
								s_index = m;
								break;
							}
						}
						curr_input.selectedIndex = s_index;
					}
					break;
				case "INPUT":
					var input = document.getElementById(liste_champs[i]);
					if (k_asso_mul_type[key][i] == "EURO"){
						var val = new String(cells[i].innerHTML);
						input.value = val.substring(0,val.length - 2);
					}
					else
						input.value = cells[i].innerHTML;
					break;
				default:
					alert("tag non géré: " + tag);
					break;
			}			
		}
	}

/*******************************************************************************/

	/**********************************************************************************/
	/* Fonctions de gestion des champs de type 'ASSO_SIM''RADIO' ou 'ASSO_MUL''COCHE' avec 'CHILD' activé  */
	/**********************************************************************************/

	function AssoXChild(id_liste, id_cur, input_type){	
		//alert("id_liste: " + id_liste + "; id_cur: " + id_cur);
		var liste = document.getElementById(id_liste); //ul parent
		var cur = document.getElementById(id_cur); //li contenant l'input

		var childs_liste = liste.getElementsByTagName("INPUT");
		var childs_liste_txt = liste.getElementsByTagName("SPAN");
		var childs_cur = cur.getElementsByTagName("INPUT");
		var childs_cur_txt = cur.getElementsByTagName("SPAN");
		var input_niveau = childs_cur[0].alt; //récupère le niveau d'imbrication de l'input courant dans l'arborescence
		var input_name = childs_cur[0].name;

		if (input_type == "COCHE" && childs_cur[0].checked == "")
			childs_cur_txt[0].style.color = "";
		else
			childs_cur_txt[0].style.color = "#D72E2E";

		//alert(input_name);
		if (input_type == "COCHE")
		{
			if (childs_cur[0].checked == "") //on decoche tous les fils
			{
				for (var i=0; i < childs_cur.length ; i++)
				{
					//alert(childs_cur[i].checked);
					if (childs_cur[i].checked && childs_cur[i].name != input_name)
					{
						childs_cur[i].checked = "";
						childs_cur_txt[i].style.color = "";
					}
				}
			}
			else if (childs_cur.length > 1) //on coche le 1er fils par défaut (fils obligatoire)
			{
				fils_checked = false;
				for (var i=1; i < childs_cur.length ; i++) //on vérifie s'il y a des fils déjà cochés (childs_cur[0] représente le 1er input)
				{					
					if (childs_cur[i].checked)
						fils_checked = true;
				}
				//alert("taille: " + childs_cur.length + "; input_name: " + input_name);
				if (!fils_checked && childs_cur[1].name != input_name)
				{
					childs_cur[1].checked = "checked";
					childs_cur_txt[1].style.color = "#D72E2E";				
				}
			}
		}

		//alert("childs_liste: " + childs_liste.length + "; childs_cur: " + childs_cur.length);
		if (childs_liste && input_type == "RADIO") //parcours de tous les li parents pour décocher les input fils (sauf celui sélectionné)
		{
			for (var i=0; i < childs_liste.length ; i++)
			{
				var id_compar = childs_liste[i].value + "_" + childs_cur[0].name;
				//alert("id_cur: " + id_cur + "; id_compar: " + id_compar);
				if (id_cur != id_compar && childs_liste[i].alt == input_niveau)
				{
					//alert(childs_liste[i].value);
					childs_liste[i].checked = "";
					childs_liste_txt[i].style.color = "";
				}else if (childs_liste[i].alt > input_niveau)
				{
					isChild = false;
					//alert(child_test.id);
					for (var j=0; j < childs_cur.length; j++)
					{
						//alert(childs_cur[j].value);
						if (childs_cur[j].value == childs_liste[i].value)
							isChild = true;						
					}
					if (!isChild)
					{
						//alert("not child:" + childs_liste[i].alt);
						childs_liste[i].checked = "";
						childs_liste_txt[i].style.color = "";
					}
					else if (childs_liste[i].name == childs_cur[0].name)
					{
						childs_liste_txt[i].style.color = "";
					}
				}
			}
		}
	}

	function AssoXChildChild(id_ul, id_li_parent, id_li_cur, input_type){
		li_parent = document.getElementById(id_li_parent);
		li_cur = document.getElementById(id_li_cur);
		input_parent = li_parent.getElementsByTagName("INPUT");
		input_cur = li_cur.getElementsByTagName("INPUT");
		txt_parent = li_parent.getElementsByTagName("SPAN");
		txt_cur = li_cur.getElementsByTagName("SPAN");

		var fils_checked = false;
		for (var i=1; i < input_parent.length; i++) //vérifie si il y a des input fils cochés
		{
			if (input_parent[i].checked)
				fils_checked = true;
		}

		if (fils_checked)
		{
			if (input_parent[0].name != input_cur[0].name)
				input_parent[0].checked = "checked"; //coche le radio parent

			txt_parent[0].style.color = "#D72E2E";		
			txt_cur[0].style.color = "#D72E2E";
		}
		else if(input_parent[0].name != input_cur[0].name){
			input_parent[0].checked = "";
			txt_parent[0].style.color = "";		
			txt_cur[0].style.color = "";
		}
		//alert(input_parent[0].innerHTML);

		input_parent[0].onclick(); 
		AssoXChild(id_ul, id_li_cur, input_type);
	}

	//Colore les radio/checkbox sélectionnés lors de l'édition
	function AssoXChildInit(id_ul_racine){		
		racine = document.getElementById(id_ul_racine);
		input_liste = racine.getElementsByTagName("INPUT");
		for (var i=0; i < input_liste.length; i++)
		{
			if (input_liste[i].checked != "")
				input_liste[i].onclick();				
		}
	}

/*******************************************************************************/


	/********************************************************************************************/
	/* Fonctions de gestion des champs de case a cocher recursif sans child activé */
	/********************************************************************************************/

	/*
	Affiche ou masque et décoche les case à cocher filles de la case à cocher `obj`
	*/
	function ASSO_MUL_CHILDS(obj){
		// Recherche d'une liste fille
		if(fils = MM_findObj(obj.name + '_'+ obj.value)){

			// Si la case est cochée on affiche la liste fille
			if(obj.checked){
				fils.style.display = 'block';
			}
			else{
				// Si la case n'est pas cochée on cache la liste fille
				fils.style.display = 'none';
				//  et on décoche toutes les checkbox qu'elle contient
				cbx = fils.getElementsByTagName('input');
				for(var i=0; i<cbx.length; i++){
					cbx[i].checked = false;
					// Appel récursif pour décocher les cases 'filles des filles'
					ASSO_MUL_CHILDS(cbx[i]);
				}
			}
		}
	}

	/*
	Affiche les listes filles si le parent est coché
	@oName string : attribut id d'un élément <ul> contenant des checkbox
	La focntion parcours toutes les checkbox de la liste ce qui n'est pas optimal,
	il suffirait de ne parcourir que les listes de premier niveau
	*/
	function init_ASSO_MUL_CHILDS(oName){
		var obj = MM_findObj(oName);
		var cbx = obj.getElementsByTagName('input');
		for(var i=0; i<cbx.length; i++){
			ASSO_MUL_CHILDS(cbx[i]);
		}
	}



	/*
	Affiche ou masque les champs "childs" d'une case à cocher
	*/
	function ASSO_MUL_CHILDS_INPUTS(obj){
		var cur_li = obj.parentNode.parentNode;
		var childs = cur_li.getElementsByTagName('div');

		for(var i=0; i<childs.length; i++){
			if(childs[i].className == 'champ'){
				// change le nom du champ fils en incluant une référence au champ parent (la valeur de l'attribut value)
				change_child_input_name(childs[i], obj);

				if(obj.checked){
					childs[i].style.display = 'block';
				}
				else{
					childs[i].style.display = 'none';
				}
			}
		}
	}

	function init_ASSO_MUL_CHILDS_INPUTS(oName){
		var obj = MM_findObj(oName);
		for(var i=0; i<obj.length; i++){
			ASSO_MUL_CHILDS_INPUTS(obj[i]);
		}
	}

	function change_child_input_name(oDiv, obj){
		// Iputs
		CB_change_child_input_name_n_val(obj, oDiv, "input");

		// Select
		CB_change_child_input_name_n_val(obj, oDiv, "select");

	}

	function CB_change_child_input_name_n_val(oParent, oFils, tag){

		var inputs = oFils.getElementsByTagName(tag);

		for(var i=0; i<inputs.length; i++){
			if(inputs[i].name.indexOf('[]') > -1){
				var original_name = inputs[i].name + '';
				inputs[i].name = oParent.name + '*' + inputs[i].name.replace('[]', '_'+ oParent.value);
				
				if( K_ASSO_MUL_CHILDS[oParent.name][original_name]){
					if( K_ASSO_MUL_CHILDS[oParent.name][original_name][oParent.value] ){

						switch(tag){
							case 'input' :
									inputs[i].value = K_ASSO_MUL_CHILDS[oParent.name][original_name][oParent.value];
						//			alert(inputs[i].name);
								break;

							case 'select' :
									inputs[i].selectedIndex = get_option_value_index(inputs[i], K_ASSO_MUL_CHILDS[oParent.name][original_name][oParent.value]);
								break;
						}
					}
				}
			}
		}
	}

	function get_option_value_index(oSel, val){
		for(var i=0; i<oSel.options.length; i++){
			if(oSel.options[i].value == val){
				return i;
			}
		}
		return false;
	}


/*******************************************************************************/




/*************** "POUBELLE" ****************************************************/

	function isSelected(l){
		var i = l.selectedIndex;
		var il = l.options[i].value;
		
		return il;
	}


	// Affecte une variable et soumet le formulaire (idoc est declaré globalement dans le doc deja...)
	function setrubpost(val){
		idoc = document.forms[0];
		idoc.newrub.value = val;
		submitit(idoc.name);
	}

/*******************************************************************************/




function get_CHECKED(obj){
	var elems = document.getElementsByTagName('input');
	var rs = Array();
	var index = 0;

	for(var i=0; i<elems.length; i++){
		if(elems[i].type == 'checkbox' && elems[i].name == obj.name){
			if(elems[i].checked){
				rs[index] = elems[i].value;
				index++;
			}
		}
	}
	return rs;
}


function refreshCondition(){
	//	alert(k_champs_condition);
	for(var i=0; i<k_champs_condition.length; i++){
		form_condition(new kChamp(k_champs_condition[i][0]), k_champs_condition[i][1], k_champs_condition[i][2], k_champs_condition[i][3]);
	}
}

function form_condition(obj, input_name, val, statut){
	

	if(obj.Ktype == 'undefined'){
		obj = new kChamp(obj.name);
	}

	switch(obj.Ktype){
		case 'ASSO_MUL' :
				switch(obj.Ks_type){
					case 'COCHE' :
						var match = (in_array(val, get_CHECKED(obj)) !== false);
					break;
				}
			break;
		case 'ASSO_SIM' :
			var match = (obj.ref.options[obj.ref.selectedIndex].value == val);
			break;

		case 'ASSO_SIM_R' :
			var match = (obj.ref.options[obj.ref.selectedIndex].value == val);
			break;
	}
	
	oInput = new kChamp(input_name);
//	oDiv1 = oInput.ref.parentNode;
	oDiv = document.getElementById('conteneur_'+ input_name);




	switch(statut){
		case 'show' :
			if(match){
				oDiv.style.display = (oInput.old_style) ? oInput.old_style : 'block' ;
				oInput.req = (oInput.old_req) ? oInput.old_req : false ;
			}
			else{
				if(!oInput.old_style){oInput.old_style = oDiv.style.display;}
				oDiv.style.display = 'none';
				oInput.req = false ;
			}
			break;
	}

}

/*******************************************************************************/

	/**********************************************************************************/
	/* Fonctions d'ajout de valeur à un input d'association  */
	/**********************************************************************************/

function ajoutFromForm(params, rub, table, desc, champ){
	var url = 'index.asp?rub='+ rub +'&op=edit&id_'+ table +'=0&edit_redirect=opened_from_form&desc='+desc+'&champ='+champ;
	pop(url, params, "pop");
}

function addASSO_VALUE(qs, id, table, desc, champ){
	input = new kChamp(champ);
	var val = GetVal(desc, qs);

//	alert(val + ' '+ desc + '\n'+ qs);

	switch(input.Ktype){

		case 'ASSO_SIM':
			opt = document.createElement("OPTION")
			opt.setAttribute("value", id);
			opt.innerHTML = val;
			input.ref.appendChild(opt);

			if(document.all){
				input.ref.selectedIndex = (input.ref.options.length + 0);
			}

			for(var i=0; i<input.ref.options.length; i++){
				if(input.ref.options[i].value == id){input.ref.selectedIndex = i;break;}
			}
		break;
	}
}
/*******************************************************************************/


	/**********************************************************************************/
	/* ASSO SELECT  */
	/**********************************************************************************/


//Retourne l'objet select
function getSelectObjet(context, id){
	var select_list = context.getElementsByTagName("SELECT");
	
	for (var j=0; j < select_list.length ; j++)
	{
		if (select_list[j].id == id)
			return select_list[j];
	}
	return null;
}

//Initialisation de la liste réceptrice (init de la valeur de l'hidden à partir de la liste)
function MyImpExp_init_hidden(id_liste){
	var liste = getSelectObjet(document, id_liste + "_m");
	var hid = document.getElementById(id_liste);

	var sep = "";
	for (var i=0; i < liste.options.length; i++){
		hid.value += sep + liste.options[i].value;
		sep = ",";
	}

}

//Initialisation de la liste contenue dans l'Iframe (désactivation des enregistrements déjà associés)
function MyImpExp_init_option(id_source, id_dest){
	var source = getSelectObjet(document, id_source);
	var dest = getSelectObjet(parent.document, id_dest + "_m");

	for (var i=0; i < source.options.length; i++)
	{
		if (inSelect(dest.options, source.options[i].value)){
			source.options[i].selected = "";
			source.options[i].disabled = true;
			source.options[i].style.color = "#ACA899";
		}
	}
}

//Fonction pour les boutons d'import/export entre 2 select multiple (export = iframe_2_parent)
function MyImpExp(id_source, id_dest, mode){
	switch (mode)
	{
		case "export":
			var src_context = document;
			var dest_context = parent.document;

			var hid = dest_context.getElementById(id_dest);			
			id_dest = id_dest + "_m";
			break;

		case "import":
			var src_context = parent.document;
			//var dest_context = window.frames[0].document;
			var dest_context = document;

			var hid = src_context.getElementById(id_source);
			id_source = id_source + "_m";
			break;
	}

	var source = getSelectObjet(src_context, id_source);
	var dest = getSelectObjet(dest_context, id_dest);

	switch (mode)
	{
		case "export":
			for (var i=0; i < source.options.length; i++)
			{
				if (source.options[i].selected && dest != null)
				{
					if (!inSelect(dest.options, source.options[i].value))
					{
						var new_option = dest_context.createElement("option");
						new_option.setAttribute("value", source.options[i].value);
						new_option.text = source.options[i].innerHTML;
									
						if (navigator.appName!="Microsoft Internet Explorer")				
							dest.add(new_option, null);
						else
							dest.add(new_option);						
						
						source.options[i].selected = "";
						source.options[i].disabled = true;
						source.options[i].style.color = "#ACA899";
					}
				}
			}
			//alert(dest);
			MyImpExp_maj_hid(hid, dest);
			break;

		case "import":
			for (var i=source.options.length - 1; i >= 0; i--)
			{
				if (source.options[i].selected && dest != null)
				{
					for (var x=0; x < dest.options.length; x++)
					{
						if (dest.options[x].value == source.options[i].value)
						{
							dest.options[x].disabled = false;
							dest.options[x].style.color = "";
						}
					}
					source.remove(i);	
				}
			}
			MyImpExp_maj_hid(hid, source);
			break;
	}
	
}

//Mise à jour du hidden contenant les id du select multiple
function MyImpExp_maj_hid(hid, select_m){
	var sep = ",";
	
	hid.value = "";
	for (var i=0; i < select_m.options.length; i++)
	{
		if (i > 0) 
			hid.value = hid.value + sep;		
		hid.value = hid.value + select_m.options[i].value;
	}
	//alert(hid.value);
}




function cptIncrPlus_std(obj,champ){
	var input = MM_findObj(champ);
	input.value = parseInt(input.value) + 1;
}

function cptIncrMoins_std(obj,champ){
	var input = MM_findObj(champ);
	input.value = (parseInt(input.value) > 0) ? parseInt(input.value) - 1 : 0;
}


var totaux = Array();

function cptIncrPlus(obj,champ){
	var input = MM_findObj(champ + obj.id.replace('plus_', ''));
	info = get_eval_info(input.name, champ);

	if(champ == 'cpt_eval'){
		if(parseInt(input.value) < parseInt(MM_findObj('cpt_contact').value)){
			input.value = parseInt(input.value) + 1;
		}
	}
	else if(totaux['quest'][info[1]] < parseInt(MM_findObj('cpt_eval').value)){
		input.value = parseInt(input.value) + 1;
	}

	EOS_EVALUATION_update_cpt(champ);
}

function cptIncrMoins(obj,champ){
	var input = MM_findObj(champ + obj.id.replace('moins_', ''));
	input.value = (parseInt(input.value) > 0) ? parseInt(input.value) - 1 : 0;
	EOS_EVALUATION_update_cpt(champ);
}



function verifINTEVAL(obj, champ){
	var val = trim(obj.value);

	if(parseInt(val).toString() == 'NaN'){
		alert('Veuillez saisir un entier');
		obj.value = 0;
	}
	else{
		EOS_EVALUATION_update_cpt(champ);
		info = get_eval_info(obj.name, champ);

		if(totaux['quest'][info[1]] > parseInt(MM_findObj('cpt_eval').value)){
			obj.value = parseInt(MM_findObj('cpt_eval').value) - (totaux['quest'][info[1]] - obj.value);
			EOS_EVALUATION_update_cpt(champ);
			//alert('trop gros');
		}
	}
}



function popA(obj, params){
	var href = obj.href;
	pop(href, params);
	return false;
}


function reg_newsletter(){
	var champ = document.getElementById('reg_nl_email');
	var ok = false;

	if(champ.value != ''){
		if(isValidEmail(champ.value)){
			ok = true;
		}
	}

	if(ok){
		oForm = MM_findObj('form_mailinglist');
		oForm.submit();
	}
	else{
		alert(lang['msg_err_MAIL']);
	}
	return false;
}


function changeLangue(id_lang){
	var url = self.document.location.href + '';
	url = BuildUrl(url, 'language', id_lang);
	self.document.location.href = url;
}



function version_imprimable(){
	var url = self.document.location.href + '';
	url = BuildUrl(url, 'imprimer', 1);
	imprim = window.open(url, 'imprim', 'width=670,height=600,menubar=yes,resizable=yes,scrollbars=yes');
	imprim.focus();
}



function submitForm(form){
	oForm = MM_findObj(form);

	if(valid(form)){
		oForm.submit();
	}
	else{
		alert(lang['fields_not_correct']);
	}
}

function navSelect(obj, param){
	var url = document.location.href + '';
	sel = obj.options[obj.selectedIndex].value;
	url = BuildUrl(url, param, sel);

	document.location.href = url;
}


function nospam(adresse){
	adresse = adresse.replace(SPAM_AT, '@');
	while(adresse.indexOf(SPAM_DOT) > -1){	adresse = adresse.replace(SPAM_DOT, '.'); }

//	adresse_aff = truncateBR(adresse, 40);
	adresse_aff = adresse;

	document.open();
	document.write(adresse_aff.link('mailto:'+adresse));
	document.close();
}

function truncate(val, len){
	if(val.length > len){
		val = val.substr(0, len)+ '...';
	}
return val;
}

function truncateBR(str, len){
	val = str + '';

	tval = Array();
	tlen = 0;
	vlen = val.length;
	i = 0;

	while (tlen < vlen){
		tval[i] = val.substr(0, len);
		tlen += tval[i].length;
		val = val.substr(len, val.length);
		i++;
	}

	val = tval.join('<br />');

return val;
}


/*** Librairie / boutique **/
function btq_Add(item){
	oForm = MM_findObj(item);
	oForm.submit();
}

function btq_update_qte(item){
	oForm = MM_findObj(item);
}


function Site_recherche(form){
	oForm = MM_findObj(form);
	if(oForm.recherche){
		if(oForm.recherche.value != ''){
		//	oForm.submit();
			self.document.location.href = "?arbo=resultats-de-la-recherche&research="+ oForm.recherche.value;
		}
	}
	else{
		alert("Saisissez une expression à rechercher");
	}
}

/*** Scripts spécifiques à l'AMP */
function change_pays(obj){
	var id = obj.options[obj.selectedIndex].value;
	var url = self.document.location.href + '';
	var sel = GetVal('sel');
	var val = GetVal('val');

	sep = (sel && sel.indexOf(obj.name) == -1)? ':' : '';
	if(sep == ''){sel = '';val='';}
	
	sel += sep + obj.name;
	val += sep + id;

	url = BuildUrl(url, 'arbo', 'fiche-pays');
	url = BuildUrl(url, 'sel', sel);
	url = BuildUrl(url, 'val', val);

	if(id ==0){
		url = '?arbo=aires-marines-protegees-par-pays';
	}

	self.document.location.href = url;
}

function open_actu(arbo, actu_id){
	var url = self.document.location.href + '';
/*
	var sel = GetVal('sel');
	var val = GetVal('val');

	sep = (sel && sel.indexOf("ID") == -1)? ':' : '';
	if(sep == ''){sel = '';val='';}
	
	sel += sep + "ID";
	val += sep + actu_id;
*/
	sel = "ID";
	val = actu_id;

	url = BuildUrl(url, 'arbo', arbo);
	url = BuildUrl(url, 'sel', sel);
	url = BuildUrl(url, 'val', val);

	self.document.location.href = url;
}

function open_doc(arbo){
	var url = self.document.location.href + '';

	url = BuildUrl(url, 'arbo', arbo);
	url = BuildUrl(url, 'sel', '');
	url = BuildUrl(url, 'val', '');

	self.document.location.href = url;
}

/*** Forum */

var RUB_FORUM_THEME = "736";
var RUB_FORUM_SUJET = "732";
var RUB_FORUM_MESSAGE = "738";

/* consultation des sujets d'un thème */
function forum_open_theme(id_theme){
	//var url = document.location.href + '';
	var url = '';

	url = BuildUrl(url , 'rub', RUB_FORUM_SUJET);
	url = BuildUrl(url , 'op', 'forum_liste_sujet');
	url = BuildUrl(url, 'sel', 'F_THEME');
	url = BuildUrl(url, 'val', id_theme);
	url = BuildUrl(url, 'research', '');
	url = BuildUrl(url, 'focus', 'liste');
	url = BuildUrl(url, 'page', 1);

	self.document.location.href = url;
}

/* consultation des messages d'un sujet */
function forum_open_sujet(id_theme, id_sujet){
	//var url = document.location.href + '';
	var url = '';
	
	url = BuildUrl(url , 'rub', RUB_FORUM_MESSAGE);
	url = BuildUrl(url , 'op', 'forum_liste_message');
	url = BuildUrl(url, 'sel', 'F_THEME:F_SUJET');
	url = BuildUrl(url, 'val', id_theme + ':' + id_sujet);
	url = BuildUrl(url, 'research', '');
	url = BuildUrl(url, 'focus', 'liste');
	url = BuildUrl(url, 'page', 1);

	self.document.location.href = url;
}

/* consultation des sujets auxquels l'utilisateur à contribué */
function forum_open_sujet_contrib(){
	var url = '';

	url = BuildUrl(url , 'rub', RUB_FORUM_SUJET);
	url = BuildUrl(url , 'op', 'forum_liste_sujet_contrib');
	url = BuildUrl(url, 'sel', '');
	url = BuildUrl(url, 'val', '');
	url = BuildUrl(url, 'research', '');
	url = BuildUrl(url, 'focus', 'liste');
	url = BuildUrl(url, 'page', 1);

	self.document.location.href = url;	
}

/* Revenir à la liste des thèmes */
function forum_back_theme(){
	//var url = document.location.href + '';
	var url = '';
	
	url = BuildUrl(url , 'rub', RUB_FORUM_THEME);
	url = BuildUrl(url , 'op', 'forum_liste_theme');	
	url = BuildUrl(url, 'sel', '');
	url = BuildUrl(url, 'val', '');
	url = BuildUrl(url, 'research', '');
	url = BuildUrl(url, 'focus', 'liste');
	url = BuildUrl(url, 'page', 1);

	self.document.location.href = url;
}

/* Revenir à la liste des sujets */
function forum_back_sujet(id_theme){
	//var url = document.location.href + '';
	var url = '';
	
	url = BuildUrl(url , 'rub', RUB_FORUM_SUJET);
	url = BuildUrl(url , 'op', 'forum_liste_sujet');	
	if (id_theme != ''){
		url = BuildUrl(url, 'sel', 'F_THEME');
		url = BuildUrl(url, 'val', id_theme);
	}
	url = BuildUrl(url, 'research', '');
	url = BuildUrl(url, 'focus', 'liste');
	url = BuildUrl(url, 'page', 1);

	self.document.location.href = url;
}

/* Modif du theme à partir de la liste des messages */
function forum_modif_theme(obj){
	forum_back_sujet(obj.options[obj.selectedIndex].value);
}

/* Insère le message auxquel fait référence la réponse */
function forum_init_repondre(txt_id, auteur){
	var txt = document.getElementById(txt_id);

	msg = txt.value

	txt.value = "<blockquote>";
	txt.value += "<span class='auteur'>" + auteur + " a écrit :</span><br/>"
	txt.value += msg
	txt.value += "</blockquote><br/>";
}




/*
Retourne l'objet XMLHttpRequest quel que soit le navigteur, ou false si les fonctionalités ne sont pas disponnibles 
Source & doc : http://openweb.eu.org/articles/objet_xmlhttprequest/
*/
function getHTTPObject()
{
  var xmlhttp = false;

  /* Compilation conditionnelle d'IE */
  /*@cc_on
  @if (@_jscript_version >= 5)
     try
     {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     }
     catch (e)
     {
        try
        {
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (E)
        {
           xmlhttp = false;
        }
     }
  @else
     xmlhttp = false;
  @end @*/

  /* on essaie de créer l'objet si ce n'est pas déjà fait */
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
  {
     try
     {
        xmlhttp = new XMLHttpRequest();
     }
     catch (e)
     {
        xmlhttp = false;
     }
  }

  if (xmlhttp)
  {
	  /*
     // on définit ce qui doit se passer quand la page répondra
     xmlhttp.onreadystatechange=function()
     {
        if (xmlhttp.readyState == 4) // 4 : état "complete"
        {
           if (xmlhttp.status == 200) // 200 : code HTTP pour OK 
           {
              //     Traitement de la réponse.
              //Ici on affiche la réponse dans une boîte de dialogue.
              
             xmlhttp.responseXML = xmlhttp.responseXML;
           }
        }
     }
	 */
  }
  return xmlhttp;
}

/// http://forum.alsacreations.com/topic-3-11805-1.html
function XSLTtransform(xml, xsl, id){

  try {

    // navigateur basé sur Gecko

    if (window.XSLTProcessor)

    {

      var fragment;
      var xsltProcessor = new XSLTProcessor();

	  xsltProcessor.importStylesheet(xsl);

      fragment = xsltProcessor.transformToFragment(xml, document);

      var target = document.getElementById(id);

      target.appendChild(fragment);

      document.appendChild(target);

      // ActiveX pour Internet Explorer

    }
	else if (window.ActiveXObject) {

      var target = document.getElementById(id);
      return xml.transformNode(xsl);
    }

  } catch (e) {

    return e;

  }
}


function fill_element(url, element_id){
	var xmlhttp = getHTTPObject(); 
	xmlhttp.onreadystatechange= function(){
        if (xmlhttp.readyState == 4){ // 4 : état "complete"
          if (xmlhttp.status == 200){ // 200 : code HTTP pour OK 
			//purgeDOM(MM_findObj(element_id).childNodes)
			//MM_findObj(element_id).innerHTML = xmlhttp.responseText;

 			clearInterval(ajax_loading_string_timer[element_id]);
			replaceNodeContent(MM_findObj(element_id), xmlhttp.responseText);
			//replaceNodeContent(MM_findObj(element_id), nodeCleaner(xmlhttp.responseXML.documentElement));
		   }
		}
	}
	xmlhttp.open("GET", url ,true); 
	xmlhttp.send(null); 
}


function replaceNodeContent(obj, xmlData){

	childs = obj.childNodes;
	if(BROWSER == 'IE' && obj.tagName == 'SELECT'){
		obj2 = duplicate_DOM(obj);
		obj2.innerHTML = xmlData;
		obj.outerHTML = obj2.outerHTML;
	}
	else{
		obj.innerHTML = xmlData;
	}
}


	/*
		Copie un noeud et ses enfant, comme le fait cloneNode à la différence qu'ici la methode createElement est utilisée
		Ca ralentit enormement le traitement mais c'est necessaire pour IE qui ne permet d'inserrer des noeuds dans une iframe, que si ils viennent de cette même iframe.
		l'arborescence du noeud est donc copiée element par enfants par enfant, attribut par attribut...
	*/

	function duplicate_DOM(obj){
		myDoc = (duplicate_DOM.arguments.length > 1) ? duplicate_DOM.arguments[1] : self.document ;

		var elem = myDoc.createElement(obj.nodeName);
		elem.innerText = this_node_text(obj);
		
		// Attributs
		for(var i=0; i<obj.attributes.length; i++){
			// Certains attributs / propriétés dont on a pas besoin ici provoquent des erreurs
			try{
				if(obj.getAttribute( obj.attributes[i].nodeName ) != null && obj.getAttribute( obj.attributes[i].nodeName ) != ''){
						elem.setAttribute(obj.attributes[i].nodeName, obj.getAttribute( obj.attributes[i].nodeName ) );
				}
			}
			catch(err){
				//alert('Erreur : '+ err.description +' '+ obj.attributes[i].nodeName);
			}
		}
			
		
		/* Cas particuliers : class et style
			- l'attribut class correspond à la propriété className
			- l'attribut style correspond à la propriété style qui est en fait un objet
		*/
		if(obj.className != ''){ elem.className = obj.className; }
		if(typeof(obj.style) == 'object'){
			
			for(prop in obj.style ){
				if(eval('obj.style.'+ prop) != ''){
					eval('elem.style.'+ prop +' = obj.style.'+prop);
				}
			}
		}

		// Noeuds enfants		
		if(obj.hasChildNodes()){
			for(var i=0; i<obj.childNodes.length; i++){
				if(obj.childNodes[i].nodeName != '#text'){
					elem.appendChild( duplicate_DOM( obj.childNodes[i], myDoc ) );
				}
			}
		}

	return elem;
	}



function donneOption(source, destination){
	oSource			= MM_findObj(source);
	oDestination	= MM_findObj(destination);
	

	if(oSource.selectedIndex > -1 ){
		var oOption = document.createElement("OPTION");
		oDestination.options.add(oOption);

		oOption.innerHTML	= oSource.options[oSource.selectedIndex].innerHTML;
		oOption.value		= oSource.options[oSource.selectedIndex].value;

		oSource.remove(oSource.selectedIndex);
	}
	if(oSource.selectedIndex > -1 ){
		donneOption(source, destination);
	}
}

function updateSelectOptions(obj, destination, ifra){
	var url = 'hidsrc.php?op=questions_liees&th='+ obj.options[obj.selectedIndex].value;
	MM_findObj(ifra).src = url;
}


function videOptions(source){
	destination = false;
	if(videOptions.arguments.length >1){
		destination = videOptions.arguments[1];
	}


	oSource = MM_findObj(source);
	for(var i=0; i<oSource.options.length; i++){
		if(destination){
			oSource.options[i].selected = true;
		}
		else{
			oSource.remove(i);
		}
	}
//	while(oSource.options.length > 0){ videOptions(source); } // il ne vide pas tout du premier coup ...
	if(destination){
		donneOption(source, destination);
	}else{
		while(oSource.options.length > 0){ videOptions(source); } // il ne vide pas tout du premier coup ...
	}
}


function addOptionsArray(destination, tableau){
	oDestination = MM_findObj(destination);

	for(key in tableau){
		var oOption = document.createElement("OPTION");
		oDestination.options.add(oOption);
		oOption.innerHTML	= tableau[key];
		oOption.value = key;
	}
}



function reactive_event_listener(obj){
	var a = obj.attributes;
	for(var i=0; i<a.length; i++){
		if(a[i].type === 'function'){
		alert(a[i].name+ ' '+ a[i].value + ' '+ a[i].type);
		}
	}
}

/**
	Fonction pour parer aux pb de gestion de memoire sous IE
	Source : http://www.crockford.com/javascript/memory/leak.html
*/

function purgeDOM(d) {
    var a = d.attributes, i, l, n;
    if (a) {
        l = a.length;
        for (i = 0; i < l; i += 1) {
            n = a[i].name;
            if (typeof d[n] === 'function') {
                d[n] = null;
            }
        }
    }
    a = d.childNodes;
    if (a) {
        l = a.length;
        for (i = 0; i < l; i += 1) {
            purge(d.childNodes[i]);
        }
    }
}


function nodeCleanerGo(c){
	if(!c.data.replace(/\s/g,''))
		c.parentNode.removeChild(c);
}

function nodeCleaner(d){
	var bal=d.getElementsByTagName('*');
	for(i=0;i<bal.length;i++){
		a=bal[i].previousSibling;
		if(a && a.nodeType==3)
			nodeCleanerGo(a);
		b=bal[i].nextSibling;
		if(b && b.nodeType==3)
			nodeCleanerGo(b);
	}
	return d;
}




var ajax_loading_string_timer = Array();
var ajax_loading_string_timer_speed = 100;
var ajax_loading_string_value;
var ajax_loading_string_array = Array('/', '--', '\\', '|');
//var ajax_loading_string_array = Array('', '.', '..', '...', '....', '.....');

function fill_field(url, element_id, post_vars){
	var reponse = '--';
	var xmlhttp = getHTTPObject(); 

	var	objCible = (typeof(element_id) == 'string')? MM_findObj(element_id) : element_id;
	var originalClassName = objCible.className + '';
	
	ajax_loading_string_timer[element_id] = setInterval('ajax_loading_string_function("'+element_id+'")', ajax_loading_string_timer_speed);

	xmlhttp.onreadystatechange= function(){
        if (xmlhttp.readyState == 4){ // 4 : état "complete"
          if (xmlhttp.status == 200){ // 200 : code HTTP pour OK 
			clearInterval(ajax_loading_string_timer[element_id]);
			objCible.value = xmlhttp.responseXML.documentElement.childNodes[0].nodeValue;
			objCible.className = originalClassName;
		   }
		}
	}
	post_string = array_2_poststring(post_vars);

	//alert(post_string + '-FIN-');
	
	objCible.className = originalClassName+'_loading';

	xmlhttp.open("POST", url, true); 
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');	
	xmlhttp.send(post_string); 
}


function ajax_loading_string_function(objname){
	var obj = MM_findObj(objname);
	var v = obj.innerHTML;
	var i = in_array(v, ajax_loading_string_array);
	var n = i+1;
	if(n>ajax_loading_string_array.length-1){
		n = 0;
	}

	obj.innerHTML = ajax_loading_string_array[n];
//	ajax_loading_string_timer = setTimeout('ajax_loading_string_function("'+objname+'")', ajax_loading_string_timer_speed);
}
/**
 *
 * Can show a tooltip over an element
 * Content of tooltip is the title attribute value of the element
 * copyright 2004 Laurent Jouanneau. http://ljouanneau.com/soft/javascript
 * release under LGPL Licence
 * works with dom2 compliance browser, and IE6. perhaps IE5 or IE4.. not Nestcape 4
 *
 * To use it :
 * 1.include this script on your page
 * 2.insert this element somewhere in your page
 *       <div id="tooltip"></div>
 * 3. style it in your CSS stylesheet (set color, background etc..). You must set
 * this two style too :
 *     div#tooltip { position:absolute; visibility:hidden; ... }
 * 4.the end. test it ! :-)
 *
 */


// create the tooltip object
function tooltip(){}

// setup properties of tooltip object
tooltip.id="tooltip";
tooltip.offsetx = 10;
tooltip.offsety = 10;
tooltip.x = 0;
tooltip.y = 0;
tooltip.snow = 0;
tooltip.tooltipElement=null;
tooltip.title_saved='';
tooltip.saveonmouseover=null;
tooltip.ie4 = (document.all)? true:false;		// check if ie4
tooltip.ie5 = false;
if(tooltip.ie4) tooltip.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0 || navigator.userAgent.indexOf('MSIE 6')>0);
tooltip.dom2 = ((document.getElementById) && !(tooltip.ie4||tooltip.ie5))? true:false; // check the W3C DOM level2 compliance. ie4, ie5, ns4 are not dom level2 compliance !! grrrr >:-(


/**
* Open ToolTip. The title attribute of the htmlelement is the text of the tooltip
* Call this method on the mouseover event on your htmlelement
* ex :  <div id="myHtmlElement" onmouseover="tooltip.show(this)"...></div>
*/
tooltip.show = function (htmlelement) {

   if ( this.ie4 || this.dom2 ) {
      // we save text of title attribute to avoid the showing of tooltip generated by browser
      text=htmlelement.getAttribute("title");
      this.title_saved=text;
      htmlelement.setAttribute("title","");
   }
	if(this.dom2){
		this.tooltipElement = document.getElementById(this.id);
      this.saveonmouseover=document.onmousemove;
		document.onmousemove = this.mouseMove;
	}else if ( this.ie4 ) {
      this.tooltipElement = document.all[this.id].style;
      this.saveonmouseover=document.onmousemove;
      document.onmousemove = this.mouseMove;
	}

   if ( this.ie4 || this.dom2 ) {
      if(this.ie4) document.all[this.id].innerHTML = text;
      else if(this.dom2) document.getElementById(this.id).innerHTML=text;

      this.moveTo(this.x + this.offsetx , this.y + this.offsety);

      if(this.ie4) this.tooltipElement.visibility = "visible";
      else if(this.dom2) this.tooltipElement.style.visibility ="visible";
   }
   return false;
}

/**
* hide tooltip
* call this method on the mouseout event of the html element
* ex : <div id="myHtmlElement" ... onmouseout="tooltip.hide(this)"></div>
*/
tooltip.hide = function (htmlelement) {
	if ( this.ie4 || this.dom2 ) {
      htmlelement.setAttribute("title",this.title_saved);
      this.title_saved="";

		if(this.ie4) this.tooltipElement.visibility = "hidden";
      else if(this.dom2) this.tooltipElement.style.visibility = "hidden";

      document.onmousemove=this.saveonmouseover;
	}
}



// Moves the tooltip element
tooltip.mouseMove = function (e) {
   // we don't use "this", but tooltip because this method is assign to an event of document
   // and so is dreferenced

   if(tooltip.ie4 || tooltip.dom2){

      if(tooltip.dom2){
         tooltip.x = e.pageX;
         tooltip.y = e.pageY;
      }else{
         if(tooltip.ie4) { tooltip.x = event.x; tooltip.y = event.y; }
         if(tooltip.ie5) { tooltip.x = event.x + document.body.scrollLeft;
               tooltip.y = event.y + document.body.scrollTop; }
      }
      tooltip.moveTo( tooltip.x +tooltip.offsetx , tooltip.y + tooltip.offsety);
   }
}

// Move the tooltip element
tooltip.moveTo = function (xL,yL) {
	if(this.dom2){
		this.tooltipElement.style.left = xL +"px";
      this.tooltipElement.style.top = yL +"px";
	}else if(this.ie4){
      this.tooltipElement.left = xL;
      this.tooltipElement.top = yL;
   }
}

/*** GnooCalendar */
var CLtab = new Array();
var CLtab_idz = new Array();

var KC3_gnoo_calendar_default = new Array();
KC3_gnoo_calendar_default['min'] = 5;
KC3_gnoo_calendar_default['max'] = 5;

function initCalendrier(min, max , indice, val)
{

//	alert(val);

	var itab = 1;
	var iDate;
	var motif = /date/;

	if(!indice)
	{
		indice = 0;
	}
		//	CLtab_idz[0] = "ok";
/*------ Modif pour Kcontain */
	for(var i=0; i<k_champs_s_type.length; i++){

		if(k_champs_s_type[i] == 'CALENDRIER'){
			if ( !min )
				min = 2;
			if ( !max )
				max = 10;
			CLtab[itab] = new GnooCalendar(itab, "CLtab["+itab+"]", min, max, val);
			CLtab[itab].init("div_CL"+itab, MM_findObj(k_champs_liste[i]), val);
			CLtab[itab].isDragable(false);
			CLtab[itab].setTitle("Calendrier");
			CLtab_idz[CLtab_idz.length] = itab;
			itab++;
		}
	}

/*
	if (document.forms[indice])
	{
		for (var i=0; i < document.forms[indice].length; i++)
		{
			if (motif.test(document.forms[indice].elements[i].name) && document.forms[indice].elements[i].type != 'hidden')
			{
				if ( !min )
					min = 2;
				if ( !max )
					max = 10;
				CLtab[itab] = new GnooCalendar(itab, "CLtab["+itab+"]", min, max);
				CLtab[itab].init("div_CL"+itab, document.forms[indice].elements[i]);
				CLtab[itab].isDragable(false);
				CLtab[itab].setTitle("Calendrier");
				itab++;
			}
		}
	}
	*/

/*------ /modif pour Kcontain */
}

function closeOthersCld(tab, curr_id)
{ //alert(tab);
	for (var i=0; i<tab.length; i++)
	{
		if(curr_id != tab[i]){
			var div_tmp = "div_CL" + tab[i]; 
			if(document.getElementById(div_tmp).style.visibility == 'visible')
			{
				CLtab[tab[i]].hide();
			}
		}
	}
	return;
}

function GnooCalendar(id, n, min, max, val)
{


	// Ajout Hugues 06/01/2006 : Pour affecter une date donnée à un objet gnnoCalendar 
	this.gnoo_affect_date = function (val){
	//	alert(val);
		if(val != false && val != '' && val != null){
			tval = val.split('/');
			this.date.setFullYear(tval[2],tval[1]-1,tval[0]);
		}
		this.curYear = new Number(this.date.getFullYear());
		return;
	}
	
	this.target= null;
	this.id = id;
	this.nam