/*

findObj(id, [ref]) ................................. Retourne l'objet portant l'id (ou name) fourni
																												 IN: n = id de objet ( syntaxe: objet[?frame] )
																												     d = reference, par defaut 'd = document'
																												OUT: retourne l'objet portant l'id (frame, formulaire, tag... tout quoi)

getSelectValue(obj) ................................ Retourne la valeur de la ligne selectionnée d'un select
																												 IN: obj = reference a un objet select
																												OUT: valeur de la ligne selectionnée

getTextboxValue(obj) ............................... Retourne la valeur d'un textbox
																												 IN: obj = reference a un objet textbox
																												OUT: valeur du textbox



loadSelect(sel, tab, tabi, [ini]) ............................. Rempli un select avec le contenu de deux tables, texts et values
loadSel(sel, sel2, tab, tabi, tab2, tab2i, ini, sansParent) ... Rempli 2 selects avec le contenu de deux tables, texts et values
loadSelInOne(sel, tab, tabi, tab2, tab2i, ini, vid) ........... Rempli un select avec un jeu de tableau sur 2 niveaux
selectToString(obj) ........................................... Renvoie les lignes selectionnées d'un select sous forme de chaine
selectMove(a, b) .............................................. Fait passer les éléments selectionnées du Select A vers le Select B


getStyle(id, prop, ref) ............................ Lit une propriete de l'objet style d'un objet
putStyle(id, prop, val, ref) ....................... Ecrit une propriete de l'objet style d'un objet
getProperty(id, prop, ref) ......................... Lit une propriete d'un objet
putProperty(id, prop, val, ref) .................... Ecrit une propriete d'un objet

toQuote(str, [type]) ............................... Ajuste les quotes pour le Javascript
toMaj(cbo) ......................................... Met le contenu du combo 'cbo' en majuscule
toMin(cbo) ......................................... Met le contenu du combo 'cbo' en minuscule	
toUFirst(cbo, [v]) ................................. Passe la premiere lettre d'un combo INPUT en majuscule, et le reste en minuscule (si v = true)

trim(str) .......................................... Enleve les espaces en debut et en fin de chaine
toEuros(x) ......................................... Convertit FF --> Euro
toFrancs(x) ........................................ Convertit Euro --> FF
toURL(x) ........................................... Convertit un texte dans le format URL

parseEmail(s) ...................................... Valide une eMail (R = true / false)
parseNumber(x) ..................................... Valide un nombre (R = nbr)
parseTel(tel) ...................................... Valide un numéro de téléphone (et sépare les nombres par des '.') (R = -1 si n° invalide / tel validé)
parseCP(cp) ........................................ Valide un code postal (5 chiffres obligatoires) (R = true / false)
parseWeb(w) ........................................ Valide une URL (R = URL validée)
parseDate(dt) ...................................... Valide une date (R= )
parseOpenBrace(n) .................................. Teste si une parenthèse ouverte est fermée

openWindow(win, nam, url, feat, [refresh]) ......... Ouvre une fenetre
closeAllWindows() .................................. Ferme toutes les fenetres éventuellements ouvertes
windowPrint() ...................................... Envoie l'ecran courant vers l'imprimante
openMap() .......................................... Ouvre la fenetre MAP

*/


//-------------------------------------------------------------------------------------------------------
// Retourne l'objet portant l'id (ou name) fourni
//  IN: n = id de objet ( syntaxe: objet[?frame] )
//      d = reference, par defaut 'd = document'
// OUT: retourne l'objet portant l'id (frame, formulaire, tag... tout quoi)
function findObj(id, ref) {
  var nInt, i, obj;
	
	if (!ref) ref = document;

	n = id.indexOf("?");
	if ((n > 0) && parent.frames.length) {
		// Va chercher la frame
    ref = parent.frames[id.substring(n + 1)].document;
		id  = id.substring(0, nInt);
	}
	obj = ref[id];
	if ((!obj) && ref.getElementById) obj = ref.getElementById(id);
  if ((!obj) && ref.all) obj = ref.all[id];
	// NS4 ...
	for (i = 0; ((!obj) && (i < ref.forms.length)); i++) obj = ref.forms[i][id];																			// Dans les forms
//for (i = 0; ((!obj) && (i < ref.applets.length)); i++) obj = ref.applets[i][id];																// Dans les applets (PUTAIN CETTE MERDE DE REFERENCE MET LA MACHINE VIRTUELLE JAVA EN ROUTE !!!)
  for (i = 0; ((!obj) && (ref.layers) && (i < ref.layers.length)); i++) obj = findObj(id, ref.layers[i].document);	// On change de layer
	return obj;
}
//-------------------------------------------------------------------------------------------------------
// Retourne la valeur de la ligne selectionnée d'un select
//  IN: obj = reference a un objet select
// OUT: valeur de la ligne selectionnée
function getSelectValue(obj) {
	if (obj) {
		if ((obj.selectedIndex >= obj.length)||(obj.selectedIndex < 0)) return '';
		var v = obj.options[obj.selectedIndex].value;
		if (v == null) return '';
		//alert(obj.name + ' = ' + v);
		return v;
	} else return '';
}
//-------------------------------------------------------------------------------------------------------
// Retourne la valeur d'un textbox
//  IN: obj = reference a un objet textbox
// OUT: valeur du textbox
function getTextboxValue(obj) {
	if (!obj) return '';
	return obj.value;
}
//-------------------------------------------------------------------------------------------------------
// Rempli un select avec le contenu de deux tables, texts et values
//  IN:  sel = pointeur sur le select
//       tab = table des texts
//      tabi = table des values
//     [ini] = (optionel) value initiale
// OUT: true = ok, false le select n'existe pas
function iniSelect(sel, tab, tabi, ini) {
	if (sel) if (sel.options) {
		sel.options.length = 0;
		sel.options[0] = new Option('','');
		if (ini) return(loadSelect(sel, tab, tabi, ini));
		else     return(loadSelect(sel, tab, tabi));
	} else return false;
	return true
}
function loadSelect(sel, tab, tabi, ini) {
	if (sel) if (sel.options) {
		for (var i = 0; i < tab.length; i++) {
			sel.options[sel.options.length] = new Option(tab[i], tabi[i]);
			if (ini) if ((''+tabi[i]) == (''+ini)) sel.options[sel.options.length - 1].selected = true;
		}
	} else return false;
	return true;
}
//-------------------------------------------------------------------------------------------------------
// Rempli 2 selects avec le contenu de deux tables, texts et values
//  IN:   sel = pointeur sur le select 1
//       sel2 = pointeur sur le select 2
//        tab = table des texts du 1er niveau
//       tabi = table des values du 1er niveau
//       tab2 = table des texts du 2eme niveau
//      tab2i = table des values du 2eme niveau
//        ini = table des valeurs selectionnées (et donc passant dans le select 2)
//  sansParent= true / false = ? :) ché plus
// OUT: true = ok, false le select n'existe pas
//    (oCat) loadSel(oCat, oCat2, cat, cati, scat, scati, catSel);
function loadSel2(sel,  sel2,  tab, tabi, tab2, tab2i, ini, sansParent, ent) {
	var k = 0;
	var ii, t, c = 0;
	
	sel.options.length  = 0;
	sel2.options.length = 0;

	for (var i = 0; i < tab.length; i++) {
		
		if (!sansParent) {
			//if (ini[k] != tabi[i]) {
			if (loadSelIni(ini, tabi[i]) == -1) {
				sel.options[sel.options.length] = new Option(tab[i], tabi[i]);
			} else {
				sel2.options[sel2.options.length] = new Option(tab[i], tabi[i]);
				//k++;
			}
		}
		
		ii = tabi[i]; 
		if (tab2[ii]) {
			for (var j = 0; j < tab2[ii].length; j++) {
				t = tab[i];
				if (ent) if (ent[c] > 0) t = '[ '+ (5 - ent[c]) +' ] '+ t;
				
				//if (ini[k] != tab2i[ii][j]) {
				if (loadSelIni(ini, tab2i[ii][j]) == -1) {
					sel.options[sel.options.length]   = new Option(t +' - '+ tab2[ii][j], tab2i[ii][j]);
				} else {
					sel2.options[sel2.options.length] = new Option(t +' - '+ tab2[ii][j], tab2i[ii][j]);
					//k++;
				}
				c++;
			}
		}
		
	}
}
function loadSelIni(t, v) {
	var a = -1;
	for (var i = 0; (i < t.length)&&(a == -1); i++) if (t[i] == v) a = i;
	return a;
}

function loadSel(sel,  sel2,  tab, tabi, tab2, tab2i, ini, sansParent, ent) {
	var k = 0;
	var ii, t, c = 0;
	
	sel.options.length  = 0;
	sel2.options.length = 0;
	
	for (var i = 0; i < tab.length; i++) {
		if (!sansParent) {
			if (ini[k] != tabi[i]) {
				sel.options[sel.options.length] = new Option(tab[i], tabi[i]);
			} else {
				sel2.options[sel2.options.length] = new Option(tab[i], tabi[i]);
				k++;
			}
		}
		
		ii = tabi[i]; 
		if (tab2[ii]) {
			for (var j = 0; j < tab2[ii].length; j++) {
				t = tab[i];
				if (ent) if (ent[c] > 0) t = '[ '+ (5 - ent[c]) +' ] '+ t;
				if (ini[k] != tab2i[ii][j]) {
					sel.options[sel.options.length]   = new Option(t +' - '+ tab2[ii][j], tab2i[ii][j]);
				} else {
					sel2.options[sel2.options.length] = new Option(t +' - '+ tab2[ii][j], tab2i[ii][j]);
					k++;
				}
				c++;
			}
		}
	}
}

//-------------------------------------------------------------------------------------------------------
// Rempli un select avec un jeu de tableau sur 2 niveaux
//  IN:   sel = pointeur sur le select
//        tab = table des texts du 1er niveau
//       tabi = table des values du 1er niveau
//       tab2 = table des texts du 2eme niveau
//      tab2i = table des values du 2eme niveau
//      [ini] = id de la ligne selectionnée
//      [vid] = true -> on laisse une ligne vide au debut, false sinon
// OUT: true = ok, false le select n'existe pas
    		//loadSelInOne(oLoc, esp, espi, sesp, sespi, '<%=critLocal%>', false);
function loadSelInOne(sel, tab, tabi, tab2, tab2i, ini, vid) {
	var k = 0, m;
	var ii;
	
	sel.options.length  = 0;
	if (vid) sel.options[0] = new Option('', '');
	
	for (var i = 0; i < tab.length; i++) {
	
		sel.options[sel.options.length] = new Option(tab[i], tabi[i]);
		if (ini == tabi[i]) sel.options[sel.options.length - 1].selected = true;
	
		ii = tabi[i];
		m  = (''+ii).indexOf(';');
		if (m > -1) ii = tabi[i].substr(0, m);
		
		if (tab2[ii]) {
			for (var j = 0; j < tab2[ii].length; j++) {
				sel.options[sel.options.length]   = new Option(tab[i] +' - '+ tab2[ii][j], tab2i[ii][j]);
				if (ini == tab2i[ii][j]) sel.options[sel.options.length - 1].selected = true;
			}
		}
		
	}
}
//-------------------------------------------------------------------------------------------------------
// Renvoie les lignes selectionnées d'un select sous forme de chaine 
// dont les éléments seront séparés par des ";"
//  IN:   obj = pointeur sur le select
//      [tab] = (optionnel) tableau de valeur a prendre
function selectToString(obj, tab) {
	var s = '';
	if (obj) {
		for (var i = 0; i < obj.options.length; i++) {
			if (!tab) {
				s += obj.options[i].value;
			} else {
				s += tab[i].value;
			}
			if (i < obj.options.length - 1) s += ';';
		}
	}
	return s;
}

//-------------------------------------------------------------------------------------------------------
function selectSort(sel, sens, typ) {
	var i, j, k;
	var o = new Array();
	var c = new Array();
	var x = new Array();
	
	for (i = 0; i < sel.options.length; i++) {
		o[i] = new Option(sel.options[i].text, sel.options[i].value);
		x[i] = i;
		if (!typ) {
			c[i] = sel.options[i].text;
		} else {
			c[i] = sel.options[i].value;
		}
	}
	
	for (i = 0; i < c.length; i++) {
		for (j = i; j < c.length; j++) {
			if (((!sens) && (c[i] > c[j])) || ((sens) && (c[i] < c[j]))) {
				k = c[i];
				c[i] = c[j];
				c[j] = k;
				k = x[i];
				x[i] = x[j];
				x[j] = k;
			}
		}
	}

	for (i = 0; i < sel.options.length; i++) sel.options[i] = new Option(o[x[i]].text, o[x[i]].value);
}

//-------------------------------------------------------------------------------------------------------
// Fait passer les éléments selectionnées du Select A vers le Select B
//  IN:   a = pointeur sur le select de départ
//        b = pointeur sur le select de d'arrivée
function selectMove(a, b) {
	var i = 0;
	var j = 0;
	for (var i = 0; i < a.options.length; i++) {
		if (!a.options[i].selected) {
			// Si pas selectionné 
			if (i != j) a.options[j] = new Option(a.options[i].text, a.options[i].value);
			j++;
		} else {
			// Si selectionné 
			o = new Option(a.options[i].text, a.options[i].value);
			selectMoveIn(b, o);
		}
	}
	for(i = a.options.length - 1; i >= j; i--) a.options[i] = null;
}
//----------------------
function selectMoveIn(s, o) {
	var p = -1;
	for (var i = 0; (i < s.options.length)&&(p < 0); i++) if (o.value < s.options[i].value) p = i;
	if (p != -1) {
		for (i = s.options.length; i > p; i--) s.options[i] = new Option(s.options[i - 1].text, s.options[i - 1].value);
		s.options[p] = new Option(o.text, o.value);
	} else {
		s.options[s.options.length] = new Option(o.text, o.value);
	}
}





//-------------------------------------------------------------------------------------------------------
// Lit une propriete de l'objet style d'un objet
function getStyle(id, prop, ref) {
	if (ref == null) var obj = findObj(id); else obj = findObj(id, ref);
	var r;
	
	if (B.ns4) eval('r = obj.'+ prop);
	else if (obj.style) eval('r = obj.style.'+ prop);

	return r;
}
//-------------------------------------------------------------------------------------------------------
// Ecrit une propriete de l'objet style d'un objet
function putStyle(id, prop, val, ref) {
	if (ref == null) var obj = findObj(id); else obj = findObj(id, ref);
	var r = false;
	
	if ((B.ns4)&&(obj)) eval('r = true; obj.'+prop+'="'+val+'"');
	else if (obj.style) eval('r = true; obj.style.'+prop+'="'+val+'"');
	
	return r;
}
//-------------------------------------------------------------------------------------------------------
// Lit une propriete d'un objet
function getProperty(id, prop, ref) {
	if (ref == null) var obj = findObj(id); else obj = findObj(id, ref);
	var r = false;
	
	if (obj) eval('r = obj.'+prop);

	return r;
}
//-------------------------------------------------------------------------------------------------------
// Ecrit une propriete d'un objet
function putProperty(id, prop, val, ref) {
	if (ref == null) var obj = findObj(id); else obj = findObj(id, ref);
	var r = false;
	
	if (obj) eval('r = true; obj.'+prop+'="'+val+'"');
	
	return r;
}






//-------------------------------------------------------------------------------------------------------
// Ajuste les quotes pour le Javascript
// Si typ précisé, c'est le caractere qui sera précédé du \
function toQuote(str, typ) {
	var s = '';
	 
	if (!typ) typ = "'";
	for (var i = 0; i < str.length; i++) {
		if (str.substring(i, i + 1) != typ) s += str.substring(i, i + 1);
		else s += '\\'+ s.substring(i,i+1);
	}
	
	return s;
}
//-------------------------------------------------------------------------------------------------------
// Met la valeur de l'objet en majuscule
function toMaj(cbo) {
	cbo.value = trim(cbo.value.toUpperCase());
}
//-------------------------------------------------------------------------------------------------------
// Met la valeur de l'objet en minuscule
function toMin(cbo) {
	cbo.value = trim(cbo.value.toLowerCase());
}
//-------------------------------------------------------------------------------------------------------
// Passe la premiere lettre d'un combo INPUT en majuscule, et le reste en minuscule (si v = true)
function toUFirst(cbo, v) {
	cbo.value = trim(cbo.value);
	if (v) cbo.value = cbo.value.substr(0, 1).toUpperCase() + cbo.value.substr(1).toLowerCase();
	else   cbo.value = cbo.value.substr(0, 1).toUpperCase() + cbo.value.substr(1);
}









//-------------------------------------------------------------------------------------------------------
// Enleve les espaces en debut et en fin de chaine
function trim(str) {
	var a, b, i;

	// Va chercher le premier caractere != ' '
	i = 0;
	while ((i < str.length)&&(str.charAt(i) == ' ')) i++;
	if (i > str.length) return '';
	a = i;
	
	// Va chercher le dernier caractere != ' '
	i = str.length - 1;
	while ((i >= 0)&&(str.charAt(i) == ' ')) i--;
	b = i;
	
	return str.substring(a, b + 1);	
}
//-------------------------------------------------------------------------------------------------------
// Convertit FF --> Euro
function toEuros(x) {
	var y = parseNumber(x / 6.56);
	return((y == 0)?'':y);
}
//-------------------------------------------------------------------------------------------------------
// Convertit Euro --> FF
function toFrancs(x) {
	var y = parseNumber(x * 6.56);
	return((y == 0)?'':y);
}
//-------------------------------------------------------------------------------------------------------
// Convertit dans un format URL
function toURL(x) {
	var s = '', c;
	for (var i = 0; i < x.length; i++) {
		c = x.charAt(i);
		if (c == ' ') c = '+';
		s += c;
	}
	return s;
}









//-------------------------------------------------------------------------------------------------------
// Teste la validité d'un email
function parseEmail(s) {
	nom = false;
	machine = false;
	domaine = false;
	for (i = 0; i < s.length; i++) {
		if (s.charAt(i) == '@' && i > 0) nom = true;
		if (s.charAt(i) == '.' && nom) {
			machine = true;
			j = i;
		}
		if (machine && ((i - j) > 1)) domaine = true;
	}
	return (nom & machine & domaine);
}
//-------------------------------------------------------------------------------------------------------
// Valide un nombre
function parseNumber(x) {
	if (isNaN(x)) return '';
	s  = ''+ x;
	rt = '';
	j  = s.length;
	for (i = 0; i < s.length; i++) {
		if ( (s.charAt(i) == '.') | (s.charAt(i) == ',') ) {
			j   = i;
			rt += '.';
		} else {
			rt += s.charAt(i);
		}
		if ((i - j) == 2) return rt;
	}
	return rt;
}
//-------------------------------------------------------------------------------------------------------
// Valide un numéro de téléphone
function parseTel(tel) {
	var o = new Array();
	var c = '';
	var n = 0;
	var r = '';
	
	for (var i = 0; i < tel.length; i++) {
		while ( (tel.charAt(i) == ' ') || ( (parseNumber(tel.charAt(i)) == '') && (i < tel.length) ) ) i++;
		if (i < tel.length) {
			c += tel.charAt(i);
			n++;
			if (n == 2) {
				o[o.length] = c;
				c = '';
				n = 0;
			}
		}
	}
	
	for (i = 0; i < o.length; i++) r += o[i]+'.';
	r = r.substr(0, r.length - 1);
	
	if ((r.length != 14)||(c != '')) return -1;
	return r;
}
//-------------------------------------------------------------------------------------------------------
// Valide un code postal
function parseCP(cp) {
	if (isNaN(cp)) return false;
	var s = ''+cp;
	if (s.length != 5) return false;
	return true;
}
//-------------------------------------------------------------------------------------------------------
// Valide un lien HTTP
function parseWeb(w) {
	w = trim(w);
	if (w.substr(0, 7) != 'http://') w = 'http://'+ w;
	return w;
}
//-------------------------------------------------------------------------------------------------------
// Valide une date
function parseDate(dt){
	s   = '';
	tmp = '';
	
	if (dt == '') return 'La date doit etre renseignée';
	
	_jour = '';
	_mois = '';
	_annee= '';
	
	jour = false;
	mois = false;
	annee= false;
	nope = false;
	
	for (i = 0; i < dt.length; i++) {
		if (dt.charAt(i) == '/') {
			if (jour) {
				if (mois) {
					if (annee) nope = true;
					else {annee = true; _annee = tmp; tmp = '';}
				} else {mois  = true; _mois = tmp; tmp = '';}
			} else {jour  = true; _jour = tmp; tmp = '';}
		} else tmp += dt.charAt(i);
	}
	
	if (mois) {annee = true; _annee = tmp; tmp = '';}

	if (!(jour & mois & annee & !nope)) s = 'La date doit être au format jj/mm/(aa)aa';

	nb_jours = new Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	if (isNaN(_jour) || isNaN(_mois) || isNaN(_annee)) {
		if (s == '') {
			s = 'La date doit être au format numérique';
		} else {
			s +=', la date doit être au format numérique';
		}
		return s;
	}
	
	j = eval(_jour);
	m = eval(_mois);
	if ( (m > 12) || (m < 1) || (!m) ) {
		if (s == '') {
			s = 'Le mois doit être compris entre 1 et 12';
		} else {
			s +=', le mois doit être compris entre 1 et 12';
		}
	}
	
	a = eval(_annee);
	if ( ((j > (nb_jours[m] + isBissextile(a))) || (j < 1))	&& (m <= 12) && (m >= 1) ) {
		if (j < 1) {
			if (s == '') {
				s = "Le numéro du jour est invalide";
			} else {
				s +=", le numéro du jour est invalide";
			}
		} else {
			if (s == '') {
				s = "Il n'y a que " + nb_jours[m] + " jours pour le mois " + _mois;
			} else {
				s +=", il n'y a que " + nb_jours[m] + " jours pour le mois " + _mois;
			}
		}
	}
	return s;
}

function isBissextile(an) {
	return ((an%4 == 0) && (an%100 != 0) || (an%400 == 0))?1:0;
}

//-------------------------------------------------------------------------------------------------------
// Teste si une parenthese ouverte est fermée.
//  Si fermée, alors on renvoie le parametre
//  Si non fermée, alors on coupe le parametre, et on renvoie le texte avant l'ouverture de fenetre
function parseOpenBrace(n) {
	var t = false;
	for (var i = n.length; ((i > 0)&&(!t)); i--) if (n.charAt(i) == '(') t = true;
	if (!t) return n;
	
	var k = i;
	for (var j = i; ((j < n.length)&&t); j++) if (n.charAt(i) == ')') t = false;
	if (!t) return n;
	
	return n.substr(0, k);
}


//--------------------------------------------------------------------------------------------------------
// FONCTION UTILES POUR ROLLOVER D IMAGE


//----------------------------------------------------------------------------------------------------------


















//-------------------------------------------------------------------------------------------------------
// Ouvre une fenetre
//  win : pointeur de la fenetre
//  nam : nom de la fenetre
//  url : url de la fenetre
//  [refresh] :  True  = rafraichit dans tous les cas la fenetre avec l'url
//              *False = si la fenetre est déja ouverte, ne fait qu'un focus
//  Renvoie le nouveau pointeur de la fenetre passé en tant que 'win'
var winNam = new Array();
var winObj = new Array();
function openWindow(win, nam, url, feat, refresh) {
	if ((!win)||(win.closed)) {
		// Rafraichit la fenetre ou l'ouvre
		//alert(feat);
		win = window.open(toURL(url), nam, feat, true);
		win.name = nam;
	} else if (refresh) win.document.location.href = toURL(url);
	
	// Met a jour la table des fenetres
	var f;
	for (var i = 0; i < winNam.length; i++) if (win.name == winNam[i]) {
		winObj[i] = win;
		winNam[i] = win.name;
		f = true;
	}
	// Ajoute la nouvelle fenetre si elle n'existait pas
	if (!f) {
		winObj[winObj.length] = win;
		winNam[winNam.length] = win.name;
	}
	// Donne le focus a coup sur
	win.focus();
	
	// Renvoie la nouvelle fenetre
	return win;
}
//-------------------------------------------------------------------------------------------------------
// Ferme toutes les fenetres éventuellements ouvertes
function closeAllWindows() {
	for (var i = 0; i < winObj.length; i++) if (winObj[i]) if (!winObj[i].closed) winObj[i].close();
	winObj.length = 0;
	winNam.length = 0;
}
//-------------------------------------------------------------------------------------------------------
// Envoie l'ecran courant vers l'imprimante
var windowPrintFlag = false;
function windowPrint() {
	if (B.ns) {
		// Si Netscape
		window.print();
		
	} else {
		// Autres navigateurs sous windows ...
		if (!windowPrintFlag) {
			var webBrowser = '<OBJECT ID="IDwebBrowser" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
			document.body.insertAdjacentHTML('beforeEnd', webBrowser);
			windowPrintFlag = true;
		}
		IDwebBrowser.ExecWB(6, 2);
	}
}

//-------------------------------------------------------------------------------------------------------
// Ouvre une pop-up spécialisée pour les messages relatifs au système job
function openPageMessage(page,wSize,hSize){
	void(window.open(page,'popup','toolbar=no,scrollbars=yes,width=' + wSize + ',height=' + hSize));	
}























































// Retourne l'objet formulaire ------------------------------------
//  IN: chaine
// OUT: retourne 0 si NaN returné, ou le nombre est une partie de la chaine, comme 100px...
function getForm(id) {
	// NS4
	if (B.ns4) {
		alert('demande = '+id);
		var a = eval('document.'+id);
		if (a) {alert('trouve = '+a.name); return a;}
		else {a = getFormInLayer(id); alert('trouve (R) '+a.name); return a}
	}
	// DOM (IE 5+, NS6)
  if (document.getElementById && document.getElementsByName) { 
    if (document.getElementById(id))    return document.getElementById(id);					// Soit par ID
    if (document.getElementsByName(id)) return document.getElementsByName(id)[0];		// Soit par NAME
  }
	// IE4
  if (B.ie4up) {
    var r = eval('document.all.' + id);
    return r;
  }
	return false;
}
function getFormInLayer(obj, id) {
	// Traitement du premier appel
	if (id == null) {
		id = obj;
		obj = document.layers;
	} else {
		// Objet a la con... on quitte (improbable)
		if (!obj.document) return false;
	}
	
	// On balaye tous les layers de ce niveau
	var a, i, j, r, ret;
	for (i = 0; i < obj.length; i++) {
		if (obj[i].document) {
			if (obj[i].document.forms) {
				// On scanne les formulaire de ce layer
				alert('---> '+obj[i].id+' sur '+obj.length);
				for (j = 0; j < obj[i].document.forms.length; j++) {
					r = obj[i].document.forms[j];
					if (r) if ((r.name == id)||(r.id == id)) return r;
				}
				// S'il y a des layers interne, on va scanner
				if (obj[i].document.layers.length > 0) {
					ret = getFormInLayer(obj[i].document.layers, id);
					if (ret) return ret;
				}
			}
		}
	}
	
	return false;
}

//javascript:alert(getForm('optionalForm'))












// --- Va chercher l'objet par l'id (ou name) de sa balise -----
//  IN: id   = id de la balise
//      form = (optionnel) id du formulaire dans lequel serait l'objet (ou null si aucun)
//      div  = (optionnel) id du div contenant (pr NS4)
// OUT: objet correspondant à l'id, ou False si inexistant
function getObj(id, form, div) {
	// NS4
	if (B.ns4) return 'CHIOTTE NS4';
	
	// DOM (IE 5+, NS6)
  if (document.getElementById && document.getElementsByName) {
    if (document.getElementById(id))    return document.getElementById(id);					// Soit par ID
    if (document.getElementsByName(id)) return document.getElementsByName(id)[0];		// Soit par NAME
  }
	
	// IE4
  if (B.ie4up) {
    var r = eval('document.all.' + divid);
    return r;
  }
	
	return false;
}



var winReac;
function newWindow(rubrique,NomObjet,idObjet,pj,idUser,espace) 
{
	var url = '../ReacArt/PopUp.asp?rubrique='+rubrique+'&idObjet='+idObjet+'&NomObjet='+NomObjet+'&pj=' + pj + '&idUser=' + idUser +'&espace='+ espace;
	var feat = 'toolbar=no,location=no,width=600,height=450,top=85,left=100';
	winReac = openWindow(winReac, 'Réaction', url, feat, false);
}

