diff --git a/ecrire/inc/documenter.php b/ecrire/inc/documenter.php
index 9329b22b77d40a76ce3951fd65e5982399380266..e4f5da900a2367cb3ea59704c21fbb280870870e 100644
--- a/ecrire/inc/documenter.php
+++ b/ecrire/inc/documenter.php
@@ -63,6 +63,8 @@ function inc_documenter_dist(
 
 		$style = est_inclus($id_document) ? ' background-color: #cccccc;':'';
 
+		$deplier = in_array($id_document, explode('-', _request('show_docs')));
+
 		if (!$case)
 			$res .= "<tr style='border-top: 1px solid black;'>";
 		else if ($case == $bord_droit)
@@ -70,7 +72,7 @@ function inc_documenter_dist(
 		$res .= "\n<td  style='width:33%; text-align: $spip_lang_left; border-$spip_lang_left: 1px solid $couleur; border-bottom: 1px solid $couleur; $style' valign='top'>"
 		.  $tourner($id_document, $document, $script, $flag, $type)
 		. (!$flag  ? '' :
-		   $legender($id_document, $document, $script, $type, $document["id_$type"], $ancre))
+		   $legender($id_document, $document, $script, $type, $document["id_$type"], $ancre, $deplier))
 		. (!isset($document['info']) ? '' :
 		       ("<div class='verdana1'>".$document['info']."</div>"))
 		. "</td>\n";
diff --git a/ecrire/inc/documents.php b/ecrire/inc/documents.php
index 9f63fff8669b0624ef8f00d67a6bf0f03e304c33..2b05a07db444a75dbe89f12c3dcc08b209d21d44 100644
--- a/ecrire/inc/documents.php
+++ b/ecrire/inc/documents.php
@@ -114,7 +114,7 @@ function document_et_vignette($document, $url, $portfolio=false) {
 
 // http://doc.spip.org/@afficher_documents_colonne
 function afficher_documents_colonne($id, $type="article", $flag_modif = true) {
-	global $connect_id_auteur, $connect_statut, $options, $id_doc_actif;
+	global $connect_id_auteur, $connect_statut, $options;
 
 	// seuls cas connus : exec=articles_edit ou breves_edit
 	$script = $type.'s_edit';
@@ -151,7 +151,8 @@ function afficher_documents_colonne($id, $type="article", $flag_modif = true) {
 	echo "\n<p />";
 	while ($doc = spip_fetch_array($images_liees)) {
 		$id_document = $doc['id_document'];
-		afficher_case_document($id_document, $id, $script, $type, $id_doc_actif == $id_document);
+		$deplier = $id_document_actif==$id_document;
+		afficher_case_document($id_document, $id, $script, $type, $deplier);
 	}
 
 	/// Ajouter nouveau document
@@ -167,8 +168,9 @@ function afficher_documents_colonne($id, $type="article", $flag_modif = true) {
 		// Afficher les documents lies
 		echo "<p />\n";
 
-		foreach($documents_lies as $doc) {
-			afficher_case_document($doc, $id, $script, $type, $id_doc_actif == $doc);
+		foreach($documents_lies as $id_document) {
+			$deplier = $id_document_actif==$id_document;
+			afficher_case_document($id_document, $id, $script, $type, $deplier);
 		}
 	}
 }
@@ -201,14 +203,14 @@ function est_inclus($id_document) {
 //
 // Afficher un document sous forme de ligne depliable (pages xxx_edit)
 //
+// TODO: il y a du code a factoriser avec inc/documenter
 
 // http://doc.spip.org/@afficher_case_document
-function afficher_case_document($id_document, $id, $script, $type, $deplier = false) {
+function afficher_case_document($id_document, $id, $script, $type, $deplier=false) {
 	global $connect_id_auteur, $connect_statut;
 	global $options, $couleur_foncee, $spip_lang_left, $spip_lang_right;
 
 	charger_generer_url();
-	$flag_deplie = teste_doc_deplie($id_document);
 
 	$document = spip_fetch_array(spip_query("SELECT * FROM spip_documents WHERE id_document = " . intval($id_document)));
 
@@ -283,7 +285,7 @@ function afficher_case_document($id_document, $id, $script, $type, $deplier = fa
 
 			if ($options == "avancees" AND ($type_inclus == "embed" OR $type_inclus == "image") AND $largeur > 0 AND $hauteur > 0) {
 				echo "<div style='padding:2px; font-size: 10px; font-family: arial,helvetica,sans-serif'>";
-				echo "<b>"._T('info_inclusion_directe')."</b></br>";
+				echo "<b>"._T('info_inclusion_directe')."</b><br />";
 				echo "<div style='color: 333333'>"
 				. affiche_raccourci_doc('emb', $id_document, 'left')
 				. affiche_raccourci_doc('emb', $id_document, 'center')
@@ -298,7 +300,7 @@ function afficher_case_document($id_document, $id, $script, $type, $deplier = fa
 		}
 
 		$f = charger_fonction('legender', 'inc');
-		echo $f($id_document, $document, $script, $type, $id, "document$id_document");
+		echo $f($id_document, $document, $script, $type, $id, "document$id_document", $deplier);
 
 		fin_cadre_enfonce();
 		}
@@ -345,20 +347,10 @@ function afficher_case_document($id_document, $id, $script, $type, $deplier = fa
 			echo $raccourci_doc;
 
 		$f = charger_fonction('legender', 'inc');
-		echo $f($id_document, $document, $script, $type, $id, "document$id_document");
+		echo $f($id_document, $document, $script, $type, $id, "document$id_document", $deplier);
 		
 		fin_cadre_relief();
 	}
 }
 
-// http://doc.spip.org/@teste_doc_deplie
-function teste_doc_deplie($id_document) {
-	global $show_docs;
-	static $deplies;
-
-	if (!$deplies)
-		$deplies = split('-',$show_docs);
-
-	return in_array($id_document, $deplies);
-}
 ?>
diff --git a/ecrire/inc/legender.php b/ecrire/inc/legender.php
index 412bc6cd1179234be64fb0c03818e16a2b63d15f..f8d24bdc288b291db00597dfbeb0e66bdc731951 100644
--- a/ecrire/inc/legender.php
+++ b/ecrire/inc/legender.php
@@ -22,23 +22,24 @@ include_spip('inc/date');
 // (surtout si c'est un portfolio)
 
 // http://doc.spip.org/@inc_legender_dist
-function inc_legender_dist($id_document, $document, $script, $type, $id, $ancre) {
+function inc_legender_dist($id_document, $document, $script, $type, $id, $ancre, $deplier=false) {
 
 	// + securite (avec le script exec=legender ca vient de dehors)
 	if (!preg_match('/^\w+$/',$type, $r)) {
 	  return;
 	}
 
+	// premier appel
 	if ($document) {
-		// premier appel
-		$flag = teste_doc_deplie($id_document);
-	} else if ($id_document) {
-		// retour d'Ajax
+		$flag = $deplier;
+	} else
+	// retour d'Ajax
+	if ($id_document) {
 		$document = spip_fetch_array(spip_query("SELECT * FROM spip_documents WHERE id_document = " . intval($id_document)));
 		$flag = 'ajax';
-	} else {
-		return;
 	}
+	else
+		return;
 
 	$descriptif = $document['descriptif'];
 	$titre = $document['titre'];
@@ -111,7 +112,6 @@ function inc_legender_dist($id_document, $document, $script, $type, $id, $ancre)
 	. "\n\n\n\n"
 	. icone_horizontale($texte, $action, $supp, "supprimer.gif", false);
 
-
 	$corps = "<div class='verdana1' style='color: "
 	. $GLOBALS['couleur_foncee']
 	. "; border: 1px solid "