<!--


var chps_mr = '!titre!lien!texte!legende!', chemin, def, expreg, fileread = 'non', lien_visu, liste_fi_edit, mc_deb, mc_fin, mc_separ, nbre_chps, num_v = 0, poids_max = 0, status;
var elts_types = new Array();
var wo_s = new Array();


function WO_AffiMC(){
	
	var mc = '<br>' + mc_deb + '<br>', cxion_href;
	
	if(wo_s.length > 0){
		if(num_v > 0)  mc += mc_separ + '<a href="#" onclick="WO_NavigV(-1, def)" class="mc">&lt;&lt;</a>\n';
		else mc += mc_separ + '<a href="#" onclick="MessageAlerte(\'Version la plus ancienne!\')" class="mc_gris">&lt;&lt;</a>\n';
		mc += ' <span class="mc">Modifications</span> ';
		if(num_v < wo_s.length - 1) mc += '<a href="#" onclick="WO_NavigV(+1, def)" class="mc">&gt;&gt;</a>\n';
		else mc += '<a href="#" onclick="MessageAlerte(\'Version la plus récente!\')" class="mc_gris">&gt;&gt;</a>\n';
	}
	if(lien_visu){
		if(status == 'desactivation')	mc += mc_separ + '<a href="#" onclick="MessageAlerte(\'Publication désactivée\')" class="mc_gris">Version en ligne</a>\n';
		else mc += mc_separ + '<a href="' + lien_visu + '" target="_blank" class="mc">Version en ligne</a>\n';
		mc += mc_separ + '<a href="#" onclick="WO_TransfertCont(\'\',\'\',\'visu\',\'\',\'\',\'\')"class="mc">Version en cours d\'édition</a>\n';
	}
	if(wo.length < 2  || wo_s.length > 0) mc += mc_separ + '<a href="#" onclick="WO_AffiCont(\'\',\'\',\'\',\'sortie/edition\',\'\',\'\',\'\',\'\')" class="mc">Fin modification page</a>';
	else mc += mc_separ + '<a href="' + urlp.replace(/_form\.php$/, '.php') + '?' + vt + '&ip=' + ip + '" class="mc">Fin modification page</a>';
	mc += mc_separ + mc_fin;	

	// Affichage
	if(document.getElementById){
		document.getElementById('mc').innerHTML = mc;
		return true;
	}
	else {
		mc += '<br><br>La version de votre navigateur n\'est pas compatible avec cette application. Veuillez en télécharger une plus récente pour pouvoir utiliser celle-ci.';
		document.write(mc);
		return false
	}
}

function WO_NavigV(delta){
	
	if(num_v + delta > wo_s.length - 11 && num_v + delta < wo_s.length){
		if(num_v == wo_s.length) WO_EnregistV(0);
		num_v += delta;
		wo = wo_s[num_v];
	}
	WO_AffiCont('', '', '', '', '', '', '', '');
}

function WO_EnregistV(increment){
	
	var i, j;
	
	wo_s.splice(num_v, wo_s.length - num_v -1);
	wo_s[num_v] = new Array();
	
	// Limitation à 5 versions
	num_v -= Math.max(0, wo_s.length - 6);
	wo_s.splice(0, Math.max(0, wo_s.length - 6));
	
	for(i=1;i< wo.length;i++){
		wo_s[num_v][i] = new Array();
		for(j=0;j< wo[i].length;j++){
			wo_s[num_v][i][j] = new WO_Elts();
			wo_s[num_v][i][j] = wo[i][j];
		}
	}
	num_v += increment;
}

function WO_RechEltType(type_m, type_e){
	
	var i = -1;
	
	if(type_m == 'ajout' && type_e != 'col' && type_e != 'rub' && cl.length > 0 || type_m == 'cl'){
		i = 0;
		while(i< elts_types.length && elts_types[i].type != 'cl') i++;
	}
	if(i == -1 || i == elts_types.length){
		i = 0;
		while(i< elts_types.length && type_e != elts_types[i].type) i++;
	}
	if(i == elts_types.length) i = '';
	
	return i;
}

function WO_VerifElt(num_c, num_e, type_m, type_e, form){
	
	var i, index, j, message = '', nom, val;
	
	i = WO_RechEltType(type_m, type_e);
	
	if(type_e == 'rub' && rub.length > 0){
		message = 'Aucun choix sélectionné';
		for(i=0;i< rub.length;i++){
			if(form.titre[i].checked) message = '';
		}
	}
	else if(i < chps.length){
		for(j=2;j< chps.length;j++){
			if(nom = eval('elts_types[' + i + '].' + chps[j])){	
				if(chps[j].match(/^cl/) && nom.match(/[^*]+$/)){
					eval('index = form.' + chps[j] + '.selectedIndex');
					eval('val = form.' + chps[j] + '[index].value');
					if(!val) message += eval('elts_types[' + i + '].' + chps[j]) + ' manquant\n';
				}
				if(chps[j] == 'info_dev'){
					if(form.info_dev[0].checked){
						if(form.lien.value) message += 'Vous ne pouvez pas à la fois développer le sujet sur une nouvelle page et avoir un lien\n';
					}
					else if(WO_TryEval('wo[' + num_c + '][' + num_e + '].ip_dev')) message += 'Cette information est développée sur une autre page. Si vous souhaitez sélectionner cette option, vous devez supprimer cette page préalablement.\n';
				}
				else if(chps[j] != 'align' && nom.match(/[^*]+$/)){
					try{
						if(!eval('form.' + chps[j]).value) message += eval('elts_types[' + i + '].' + chps[j]) + ' manquant\n';
					}
					catch(e){
					}
				}
				try {
					if(type_e != 'doc' && chps[j] == 'fichier' && form.fichier.value && !form.fichier.value.match(/\.gif$/i) && !form.fichier.value.match(/\.jpg$/i) && !form.fichier.value.match(/\.png$/i)) message += elts_types[i].fichier + ' incorrect\n';
					if(chps[j] == 'echelle' && form.fichier.value){
						if(!form.echelle.value) message += elts_types[i].echelle + ' manquant\n';
						else if(!form.echelle.value.match(/^[0-9]{1,3}%$/)) message += elts_types[i].echelle + ' incorrecte\n';
					}
					if(chps[j] == 'legende' && nom && form.legende.value && !form.fichier.value) message += elts_types[i].fichier + ' manquant\n';
				}
				catch(e){
					if(!form.echelle.value.match(/^[0-9]{1,3}%$/)) message += elts_types[i].echelle + ' incorrecte\n';
				}
				if(chps[j] == 'lien'){
					if(type_e != 'mailto' && form.lien.value && !form.titre.value) message += elts_types[i].titre + ' manquant\n';
					else if(type_e == 'mailto' && form.lien.value && !form.lien.value.match(/^[^@ ]+@[^@ ]+\.[a-z]{2,}$/i)) message += elts_types[i].lien + ' incorrect\n';
				}
			}
		}
	}
	
	if(message) {
		alert(message);
		return false;
	}
	else {
		return true;
	}
}

function WO_EnregistElt(num_c, num_e, type_m, type_e, x_pos, y_pos, opt){
	
	var diff = 0, elt, form = document.form_pal, i, imgd, imgf, index, j, k, nbre, val;
	
	if(WO_VerifElt(num_c, num_e, type_m, type_e, form)){
		
		i = WO_RechEltType(type_m, type_e);
		
		elt = new WO_Elts();
		
		elt.type = type_e;
		if(type_m == 'ajout') elt.tpl = 'amds';
		else {
			elt.ip_dev = wo[num_c][num_e].ip_dev;
			elt.tpl = wo[num_c][num_e].tpl;
		}
		elt.fichier = '';
		
		if(i < chps.length){
			for(j=2;j< chps.length;j++){
				if(eval('elts_types[' + i + '].' + chps[j])){
					if(chps[j] == 'fichier'){
						try {
							elt.fichier = form.fichier.value;
							elt.width = '';
							elt.height = '';
							elt.poids = '';
							if(elt.fichier.match(/\.gif$/i) || elt.fichier.match(/\.jpg$/i) || elt.fichier.match(/\.png$/i)){	
								if(fileread == 'oui'){
									document.getElementById('cache').innerHTML = '<img name="dim" src="' + elt.fichier + '">';
									elt.width = document.dim.width;
									elt.height = document.dim.height;
								}
							}
							else {
								elt.echelle = '100%';
							}
						}
						catch(e){
							elt.fichier = wo[num_c][num_e].fichier;
							elt.width = wo[num_c][num_e].width;
							elt.height = wo[num_c][num_e].height;
							elt.poids = wo[num_c][num_e].poids;
						}
					}
					else {
						if(chps[j] == 'info_dev'){
							if(form.info_dev[0].checked) val = form.info_dev[0].value;
							else val = form.info_dev[1].value;
						}
						else if(type_e == 'rub' && rub.length > 0){
							for(k=0;k< rub.length;k++){
								if(form.titre[k].checked) val = form.titre[k].value;
							}
						}
						else if(chps[j] == 'align'){
							if(form.align[0].checked) val = form.align[0].value;
							else if(form.align[1].checked) val = form.align[1].value;
							else val = form.align[2].value;
						}
						else if(chps[j].match(/^cl/)){
							eval('index = form.' + chps[j] + '.selectedIndex');
							eval('val = form.' + chps[j] + '[index].value');
						}
						else {
							val = eval('form.' + chps[j] + '.value');
						}
						eval('elt.' + chps[j] + ' = val');
					}
				}
				else if(type_m != 'ajout'){
					eval('elt.' + chps[j] + ' = wo[' + num_c + '][' + num_e + '].' + chps[j]);
				}
				
				imgd = WO_TryEval('tpl_' + type_e + '_' + chps[j] + '_imgd');
				imgf =  WO_TryEval('tpl_' + type_e + '_' + chps[j] + '_imgf');
				
				eval('elt.' + chps[j] + ' = imgd + elt.' + chps[j] + '.replace(/\\n/g, \'<br>\').replace(/\\r/g, \'\') + imgf');
			}
			
			if(type_m == 'ajout'){
				
				diff = 1;
				WO_EnregistV(1);
				
				if(num_e > 0){
					nbre = wo[num_c].length;
					for(j=nbre-1;j>=num_e;j--) wo[num_c][(j+1)] = wo[num_c][j];
					wo[num_c][num_e] = new WO_Elts();
					wo[num_c][num_e] = elt_init;
				}
				else {
					if(!num_c){
						num_c = wo.length;
						wo[num_c] = new Array();
					}
					if(!num_e) num_e = 0;
					wo[num_c][num_e] = new WO_Elts();
					wo[num_c][num_e] = col_init;
				}
			}
			else {
				for(j=0;j< chps.length;j++){
					if(eval('elts_types[' + i + '].' + chps[j])){
						if(eval('wo[' + num_c + '][' + num_e + '].' + chps[j] + ' != elt.' + chps[j])) diff = 1;
					}
				}
				if(diff > 0) WO_EnregistV(1);
				wo[num_c][num_e] = new WO_Elts();
			}
			wo[num_c][num_e] = elt;
		}
		
		if(opt) WO_AffiCont('', num_c, num_e, 'modif', type_e, x_pos, y_pos, opt);
		else if(diff > 0 && elt.fichier && !elt.fichier.match(/^http/i) && fileread == 'non') WO_TransfertCont(num_c, num_e, type_m, type_e, x_pos, y_pos);
		else if(type_m == 'ajout' && elts_types[i].type == 'cl') WO_AffiCont('', num_c, num_e, 'modif', type_e, x_pos, y_pos, '');
		else WO_AffiCont('', '', '', '', '', '', '', '');
	}
}

function WO_DeplacElt(num_c, num_e, delta, type_m, x_pos, y_pos){
	
	var elt, i;
	
	WO_EnregistV(1);
	
	if(num_e + delta > 0 && num_e + delta < wo[num_c].length){
		for(i=Math.min(0, delta);i< Math.max(0, delta); i++){
			elt = new WO_Elts();
			elt = wo[num_c][(num_e+i)];
			wo[num_c][(num_e+i)] = new WO_Elts();
			wo[num_c][(num_e+i)] = wo[num_c][(num_e+i+1)];
			wo[num_c][(num_e+i+1)] = new WO_Elts();
			wo[num_c][(num_e+i+1)] = elt;
		}
		num_e += delta;
	}
	
	WO_AffiCont('', num_c, num_e, type_m, '', x_pos, y_pos, '');
}

function WO_SuppElt(num_c, num_e){
	
	var i, nbre;
	
	if(confirm('Souhaitez-vous supprimer cet élément ?')){
	
		WO_EnregistV(1);
		
		if(num_e == 0){
			nbre = wo.length;
			for(i=num_c+1;i<nbre;i++) wo[(i-1)] = wo[i];
			wo.splice((nbre-1), 1);
		}
		else {
			nbre = wo[num_c].length;
			for(i=num_e+1;i<nbre;i++) wo[num_c][(i-1)] = wo[num_c][i];
			if(wo[num_c].length <= 2) wo[1][1] = elt_init;
			wo[num_c].splice((nbre-1), 1);
		}
	}
	
	WO_AffiCont('', '', '', '', '', '', '', '');
}

function WO_ImgEdit(fichier){
	
	var i, fichier2, zone = '';
	
	fichier2 = fichier.replace(/^http_\//, '');
	fichier2 = fichier2.replace(/\//g, '\\/')
	expreg = eval('/' + fichier2 + '/;');
	if(liste_fi_edit.match(expreg)) zone = 'edition';
	else if(status == 'desactivation') zone = 'desactivation';
	if(zone){
		it = fichier.split('/');
		it[it.length-3] = zone;
		fichier = it[0];
		for(i=1;i<it.length;i++) fichier += '/' + it[i];
	}
	//alert(fichier + '(' + liste_fi_edit + ')');
	return fichier;
}

function WO_FormatValue(type_m, type_e, val){
	
	if(typeof(val) == 'string'){
		if(type_m == 'modif' || type_m == 'cl' || type_m == 'ajout'){
			if(type_e == 'rub') val = val.replace(/^ *<[^>]+ *>/, '');
			val = val.replace(/<br>/g, '\n');
		}
		val = val.replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
	}
	
	return val;
}

function WO_LienMenu(num_c, num_e, type_m, type_e, x_pos, y_pos){
	
	return '<a href="#" onclick="WO_AffiCont(\'\', \'' + num_c + '\',\'' + num_e + '\',\'' + type_m + '\',\'' + type_e + '\',\'' + x_pos + '\',\'' + y_pos + '\', \'\')" class="interf_fct">';
}

function WO_AffiInterf(num_c, num_e, type_m, type_e, x_pos, y_pos, opt){
	
	var elt, h, i, j, k, l, nbre, nom, tc, te, val, x0, xe0, x1, xe1, y0, ye0, y1, ye1;
	var interf = '<table width="100%" border="0" cellspacing="0" cellpadding="5"><tr><td><table width="100%" border="0" cellspacing="0" cellpadding="1"><tr><td align="right">' + WO_LienMenu('', '', '', '', '', '') + 'Fermer</a></td></tr><tr><td class="interf_fct_gris">';
	
	if(type_m == 'sortie'){
		//interf += '<a href="#" OnClick="MessageAlerte(\'Souhaitez-vous annuler les modifications ?\', \'confirm\', \'\', \'\', \'' + urlp.replace(/\.php$/, '_enregist.php') + '\', \'' + vt + '&ip=' + ip + '\', \'pcs1\', \'annul\')" class="mc">Annuler modifications</a><br>';
		interf += '<a href="#" OnClick="MessageAlerte(\'Souhaitez-vous poursuivre les modifications plus tard ?\', \'confirm\', \'\', \'\', \'' + urlp.replace(/\.php$/, '_enregist.php') + '\', \'' + vt + '&ip=' + ip + '\')" class="mc">Poursuivre plus tard</a><br>';
		interf += '<a href="#" OnClick="MessageAlerte(\'Souhaitez-vous mettre en ligne les modifications ?\', \'confirm\', \'\', \'\', \'' + urlp.replace(/\.php$/, '_enregist.php') + '\', \'' + vt + '&ip=' + ip + '\', \'pcs1\', \'publi\')" class="mc">Mettre en ligne modifications</a><br>';
	}
	else if(type_m == 'sortie/edition'){
		interf += '<a href="#" onclick="WO_TransfertCont(\'\',\'\',\'annul\',\'\',\'\',\'\')\" class="mc">Annuler modification de la page</a><br>';
		interf += '<a href="#" onclick="WO_TransfertCont(\'\',\'\',\'pause\',\'\',\'\',\'\')\" class="mc">Poursuivre plus tard</a><br>';
		interf += '<a href="#" onclick="WO_TransfertCont(\'\',\'\',\'valid\',\'\',\'\',\'\')\" class="mc">Valider modification de la page</a><br><br>';
	}
	else if(type_m == 'ajout' && !type_e){
		interf += WO_LienMenu(num_c, num_e, type_m, 'rub', x_pos, y_pos) + 'Titre de rubrique</a><br>';
		interf += WO_LienMenu(num_c, num_e, type_m, 'par', x_pos, y_pos) + 'Paragraphe (avec visuel)</a><br>';
		interf += WO_LienMenu(num_c, num_e, type_m, 'img', x_pos, y_pos) + 'Visuel seul</a><br>';
		interf += WO_LienMenu(num_c, num_e, type_m, 'doc', x_pos, y_pos) + 'Document à télécharger</a><br>';
		interf += WO_LienMenu(num_c, num_e, type_m, 'lien', x_pos, y_pos) + 'Lien vers une page web</a><br>';
		interf += WO_LienMenu(num_c, num_e, type_m, 'mailto', x_pos, y_pos) + 'Contact email</a><br><br>';
	}
	else if(type_e){
		elt = new WO_Elts();
		elt.poids = '';
		if(type_m == 'ajout' && type_e == 'col'){
			elt.left = wo[num_c][0].left * 1 + wo[num_c][0].width * 1 + 10;
			elt.top = wo[num_c][0].top * 1;
			//elt.width = wo[num_c][0].width * 1;
			elt.width = Math.min(screen.width - elt.left * 1 - 10, wo[num_c][0].width * 1);
			elt.height = wo[num_c][0].height;
			xe0 = elt.left;
			xe1 = xe0 + elt.width * 1;
			ye0 = elt.top;
			ye1 = elt.top + elt.heigth * 1;
			for(i=1;i< wo.length;i++){
				x0 = wo[i][0].left * 1;
				x1 = x0 + wo[i][0].width * 1;
				y0 = wo[i][0].top * 1;
				y1 = y0 + wo[i][0].heigth * 1;
				if((x0 >= xe0 && x0 <= xe1 || x1 >= xe0 && x1 <= xe1) && (y0 >= ye0 && y0 <= ye1 || y1 >= ye0 && y1 <= ye1)) elt.top = Math.max(elt.top, wo[i][0].top * 1 + wo[i][0].height * 1 + 10);
			}
			num_c = '\'\'';
			x_pos = elt.left + dx0;
			y_pos = elt.top + dy0;
		}	
		else if(type_m == 'modif' || type_m == 'cl'){
			elt = wo[num_c][num_e];
		}
		
		if(type_e == 'rub' && rub.length > 0){
			for(i=0;i< rub.length;i++){
				interf += '<tr><td class="cont_rub"><input type="radio" name="titre" value="' + WO_FormatValue(type_m, type_e, rub[i]) + '"';
				if(elt.rub == rub[i]) interf += ' checked';
				interf += '>' + rub[i] + '</td></tr>';
			}
		}
		else {
			i = WO_RechEltType(type_m, type_e);
			
			if(i < chps.length){
				if(type_m != 'cl' && poids_max > 0 && elt.poids > poids_max) interf += '<tr><td class="interf_champ" class="interf_mes">L\'image est trop lourde. Elle ne doit pas dépasser ' + (poids_max/1000) + 'Ko</td></tr><tr><td>';
				for(j=2;j< chps.length;j++){
					if(nom = eval('elts_types[' + i + '].' + chps[j])){
						if(type_m == 'modif' || type_m == 'cl' || type_m == 'ajout' && type_e == 'col') val = WO_FormatValue(type_m, type_e, eval('elt.' + chps[j]));
						else val = '';
						if(chps[j] == 'echelle' && !val) val = '100%';
						interf += '<tr><td class="interf_champ">' + nom;
						if(chps[j] == 'fichier' && val){
							if(opt == 'chgtfi') interf += '&nbsp;&nbsp;<span class="interf_fct">[<a href="#" onclick="WO_AffiCont(\'\', ' + num_c + ', ' + num_e + ', \'' + type_m + '\', \'' + type_e + '\', \'' + x_pos + '\', \'' + y_pos + '\', \'\')" class="interf_fct">Remettre précédent</a>]</span>\n';
							else interf += '&nbsp;&nbsp;<span class="interf_fct">[<a href="#" onclick="WO_EnregistElt(' + num_c + ', ' + num_e + ', \'' + type_m + '\', \'' + type_e + '\', \'' + x_pos + '\', \'' + y_pos + '\', \'chgtfi\')" class="interf_fct">Changer</a>]</span>\n';
						}
						interf += '</td></tr><tr><td class="interf_donnee">';
						if(chps[j] == 'texte') interf += '<textarea name="texte" rows="3" cols="27">' + val + '</textarea>';
						else if(chps[j] == 'fichier'){
							if(val && opt != 'chgtfi'){
								if(type_e == 'doc') interf += '<a href="' + elt.fichier + '" target="_blank">' + elt.titre + '</a>';
								else interf += WO_AffiImg('edit/form/interf', num_e, elt, 120, 90);
							}
							else {
								interf += '<input type="file" name="fichier" size="20">';
							}
						}
						else if(chps[j] == 'info_dev'){
							interf += '<input type="radio" name="info_dev" value="oui"';
							if(val == 'oui') interf += ' checked';
							interf += '> oui - ';
							interf += '<input type="radio" name="info_dev" value="non"';
							if(!val || val == 'non') interf += ' checked';
							interf += '> non';
						}
						else if(chps[j] == 'align'){
							interf += '<input type="radio" name="align" value="left"';
							if(val == 'left') interf += ' checked';
							interf += '> gauche - ';
							if(type_e == 'img'){
								interf += '<input type="radio" name="align" value="center"';
								if(val == 'center') interf += ' checked';
								interf += '> centre - ';
							}
							interf += '<input type="radio" name="align" value="right"';
							if(!val || val == 'right') interf += ' checked';
							interf += '> droite';
						}
						else if(chps[j].match(/^cl/)){
							interf += '<select name="' + chps[j] + '">';
							nbre = chps[j].replace(/[^0-9]/g, '');
							for(k=1;k< cl[nbre].length;k++){
								interf += '<option value="' + cl[nbre][k] + '"';
								if(val == cl[nbre][k]) interf += ' selected';
								interf += '>' + cl[nbre][k];
							}
							interf += '</select>';
						}
						else if(type_e == 'col' || chps[j] == 'echelle'){
							interf += '<input type="text" name="' + chps[j] + '" value="' + val + '" size="4" maxlength="4">';
						}
						else {
							interf += '<input type="text" name="' + chps[j] + '" value="' + val + '" size="35">';
						}
						interf += '</td></tr>\n';
					}
				}
			}
		}
		interf += '<tr><td height="10"></td></tr><tr><td align="center"><a href="#" onclick="WO_EnregistElt(' + num_c + ', ' + num_e + ', \'' + type_m + '\', \'' + type_e + '\', \'' + x_pos + '\', \'' + y_pos + '\', \'\')"><img src="' + cxs + '/' + chemin + '/custom/' + def + '/ressource/w!_valider.gif" border="0" width="100" height="20"></a>\n';
	}
	else {
		tc = wo[num_c][0].tpl;
		te = wo[num_c][num_e].tpl;
		if(te.match(/a/)){
			interf += WO_LienMenu(num_c, num_e, 'ajout', '', x_pos, y_pos) + 'Insérer élément en dessus</a><br>';
			interf += WO_LienMenu(num_c, (num_e+1), 'ajout', '', x_pos, y_pos) + 'Insérer élément en dessous</a><br>';
		}
		if(te.match(/m/)){
			interf += WO_LienMenu(num_c, num_e, 'modif', wo[num_c][num_e].type, x_pos, y_pos) + 'Modifier cet élément</a><br>';
			if(cl.length > 0) interf += WO_LienMenu(num_c, num_e, 'cl', wo[num_c][num_e].type, x_pos, y_pos) + 'Modifier sa classification</a><br>';
		}
		if(te.match(/d/)){
			if(num_e > 1 && wo[num_c].length > 2) interf += '<a href="#" onclick="WO_DeplacElt(' + num_c + ', ' + num_e + ', -1, \'gal\', \'' + x_pos + '\', \'' + y_pos + '\')" class="interf_fct">Monter cet élément</a><br>';
			else interf += 'Monter cet élément<br>';
			if(type_e < wo[num_c].length  && wo[num_c].length > 2) interf += '<a href="#" onclick="WO_DeplacElt(' + num_c + ', ' + num_e + ', 1, \'gal\', \'' + x_pos + '\', \'' + y_pos + '\')" class="interf_fct">Descendre cet élément</a><br>';
			else interf += 'Descendre cet élément<br>';
		}
		if(te.match(/s/)) interf += '<a href="#" onclick="WO_SuppElt(' + num_c + ', ' + num_e + ')" class="interf_fct">' + 'Supprimer cet élément</a><br><br>';
		if(tc && te) interf += '<br>';
		if(tc.match(/a/)) interf += WO_LienMenu(num_c, '0', 'ajout', 'col', x_pos, y_pos) + 'Ajouter colonne </a><br>';
		if(tc.match(/[ms]/)) interf += WO_LienMenu(num_c, '0', 'modif', 'col', x_pos, y_pos) + 'Modifier dimension colonne</a><br>';
		if(tc.match(/s/))interf += WO_LienMenu(num_c, '0', 'supp', '', x_pos, y_pos) + 'Supprimer la colonne</a><br><br>';
	}
	
	interf = '<div id="interf" style="position:absolute; left: ' + x_pos + 'px; top: ' + y_pos + 'px; width:250px; z-index:1; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000">' + interf + '</td></tr></table></td></tr></table></div>';
	
	return interf;
}

function WO_FormatTransf(wo, v){
	
	var cont = '', i, j, k, val;
	
	for(i=1;i< wo.length;i++){
		if(v != 'mr') cont += 'wo' + v  + '[' + i + '] = new Array();\n';
		for(j=0;j< wo[i].length;j++){
			if(v != 'mr') cont += 'wo' + v  + '[' + i + '][' + j + '] = new WO_Elts(';
			for(k=0;k< chps.length;k++){
				val = eval('wo[' + i + '][' + j + '].' + chps[k]);
				if(fileread == 'oui' && !v && chps[k] == 'fichier' && val && !val.match(/^http/i)){
					cont = '<input type="file" name="' + v + 'c' + i + 'e' + j + '_' + chps[k] + '" value="' + val + '">' + cont;
				}
				if(v != 'mr') cont += '\'';
				if(v != 'mr' || eval('chps_mr.match(/!' + chps[k].replace(/[0-9]+$/, '') + '!/)')){
					try{
						cont += val.replace(/\'/g, '\\\'').replace(/"/g, '\"');
						if(val && v == 'mr') cont += ' ';
						
					}
					catch(e){
					}
				}
				if(v != 'mr') cont += '\',';
			}
			if(v != 'mr') cont = cont.replace(/,$/, '') + ');\n';
		}
	}
	
	return WO_FormatValue('', '', cont);
}

function WO_TransfertCont(num_c, num_e, type_m, type_e, x_pos, y_pos){
	
	var cont = '', i, j, k, l, cont_chps, trans = 1, val;
	
	if(type_m == 'annul'){
		if(!confirm('Souhaitez-vous annuler les modifications venant d\'être réalisées sur cette page ?')) trans = 0;
	}
	else if(type_m == 'pause'){
		if(!confirm('Souhaitez-vous poursuivre les modifications de cette page plus tard ?')) trans = 0;
	}
	else if(type_m == 'valid'){
		if(!confirm('Souhaitez-vous enregistrer les modifications réalisées sur cette page ?')) trans = 0;
	}
	
	if(trans == 1){
		
		if(type_m == 'annul'){
			if(wo_s.length > 0) wo = wo_s[0];
		}
		
		if(num_c){
			cont += '<input type="hidden" name="num_c" value="' + num_c + '">';
			cont += '<input type="hidden" name="num_e" value="' + num_e + '">';
			cont += '<input type="hidden" name="type_m" value="' + type_m + '">';
			cont += '<input type="hidden" name="type_e" value="' + type_e + '">';
			cont += '<input type="hidden" name="x_pos" value="' + x_pos + '">';
			cont += '<input type="hidden" name="x_pos" value="' + y_pos + '">';
		}
		else if(type_m == 'visu'){
			cont += '<input type="hidden" name="type_m" value="' + type_m + '">';
		}
		
		cont_chps = 'chps = Array('
		for(i=0;i< chps.length;i++) cont_chps += '\'' + chps[i] + '\',';
		cont_chps = cont_chps.replace(/,$/, '') + ');\n' 
		
		cont += '<input type="hidden" name="liste_fi" value="';
		for(i=1;i< wo.length;i++){
			for(j=0;j< wo[i].length;j++){
				val = wo[i][j].fichier;
				if(val.match(/^http_/)){
					val = val.replace(/.*\//, '')
					cont += '\'' + val.replace(/[^0-9]*$/, '') + '\',';
				}
			}
		}
		cont = cont.replace(/,$/, '') + '">';
		
		if(i = WO_RechEltType('cl', '')){
			for(j=0;j< cl.length;j++){
				cont += '<input type="hidden" name="cl' + j + '" value="!' + WO_FormatValue(type_m, type_e, eval('elts_types[' + i + '].cl' + j)) + '!';
				for(k=1;k< wo.length;k++){
					for(l=0;l< wo[k].length;l++){
						val = eval('wo[' + k + '][' + l + '].cl' + j);
						if(val) cont +=  WO_FormatValue(type_m, type_e, val) + '!';
					}
				}
				cont += '">';
			}
		}
		cont += '<input type="hidden" name="cont_mr" value="' + WO_FormatTransf(wo, 'mr') + '">';
			
		if(type_m != 'annul' && type_m != 'valid'){
			cont += '<input type="hidden" name="script_s" value="num_v = ' + num_v + ';\n' + cont_chps;
			for(i=0;i< wo_s.length;i++) cont += 'wo_s[' + i  + '] = new Array();\n' + WO_FormatTransf(wo_s[i], '_s[' + i + ']');
			cont += '">';
		}
		
		cont += '<input type="hidden" name="script" value="' + cont_chps + WO_FormatTransf(wo, '') + 'WO_AffiCont(\'\', \'\', \'\', \'\', \'\', \'\', \'\', \'\');\n">';
		
		document.getElementById('cache').innerHTML = cont;
		if(type_m == 'visu') document.form_pal.target= '_blank';
		else document.form_pal.target= '';
		document.form_pal.submit();
	}
}
	

//-->