diff --git a/htdocs/ecm/ecmdirectory.class.php b/htdocs/ecm/ecmdirectory.class.php
index 6b141d65d0125912eb1825f39a6fddf9664c47cd..f8a17f66992e13449eab9532b2ebca9ccbe2203d 100644
--- a/htdocs/ecm/ecmdirectory.class.php
+++ b/htdocs/ecm/ecmdirectory.class.php
@@ -431,7 +431,7 @@ class EcmDirectory // extends CommonObject
   	}
   	
   	/**
-	* 	\brief		Load this->motherof array
+	* 	\brief		Load this->motherof that is array(id_son=>id_parent, ...)
 	*	\return		int		<0 if KO, >0 if OK
 	*/
 	function load_motherof()
@@ -469,9 +469,14 @@ class EcmDirectory // extends CommonObject
 	*				id_mere = id de la categorie mere
 	*				id_children = tableau des id enfant
 	*				label = nom de la categorie
-	*				fulllabel = nom avec chemin complet de la categorie
-	*				fullpath = chemin complet compose des id
-	* 	\param		force		Force reload of full arbo even if already loaded
+	*				cachenbofdoc = nb of documents
+	*				date_c = date creation
+	* 				fk_user_c = user creation
+	*  				login_c = login creation
+	* 				fullpath	Full path (Added by build_path_from_id_categ call)
+	* 				fulllabel	Full label (Added by build_path_from_id_categ call)
+	* 				level		Level of line (Added by build_path_from_id_categ call)
+	*  	\param		force		Force reload of full arbo even if already loaded
 	*	\return		array		Tableau de array
 	*/
 	function get_full_arbo($force=0)
@@ -481,8 +486,8 @@ class EcmDirectory // extends CommonObject
 			return $this->cats;
 		}
 		
-		// Init this->motherof array
-		$this->load_motherof();
+		// Init this->motherof that is array(id_son=>id_parent, ...)
+		$this->load_motherof();	
 
 		// Charge tableau des categories
 		$sql = "SELECT c.rowid as rowid, c.label as label,";
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index bde92b547a2f66c312c6ae5b1ff6a5aa03f1c957..3394c571e4524dec25bda3814c0b554d22fef0a1 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -17,16 +17,17 @@
  */
 
 /**
-    	\file       htdoc/ecm/index.php
-		\ingroup    ecm
-		\brief      Main page for ECM section area
-		\version    $Id$
-		\author		Laurent Destailleur
-*/
+ \file       htdoc/ecm/index.php
+ \ingroup    ecm
+ \brief      Main page for ECM section area
+ \version    $Id$
+ \author		Laurent Destailleur
+ */
 
 require("./pre.inc.php");
 require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
 require_once(DOL_DOCUMENT_ROOT."/lib/ecm.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
 require_once(DOL_DOCUMENT_ROOT."/lib/treeview.lib.php");
 require_once(DOL_DOCUMENT_ROOT."/ecm/ecmdirectory.class.php");
 
@@ -46,15 +47,15 @@ $user->getrights('ecm');
 // Get parameters
 $socid = isset($_GET["socid"])?$_GET["socid"]:'';
 $action = isset($_GET["action"])?$_GET["action"]:$_POST['action'];
+$section=isset($_GET["section"])?$_GET["section"]:$_POST['section'];
+if (! $section) $section=0;
 
-$section=$_GET["section"];
-if (! $section) $section='misc';
 $upload_dir = $conf->ecm->dir_output.'/'.$section;
 
 $page=$_GET["page"];
 $sortorder=$_GET["sortorder"];
 $sortfield=$_GET["sortfield"];
- 
+
 $limit = $conf->liste_limit;
 $offset = $limit * $page ;
 if (! $sortorder) $sortorder="ASC";
@@ -73,10 +74,79 @@ if (! empty($_REQUEST["section"]))
 
 
 /*******************************************************************
-* ACTIONS
-*
-* Put here all code to do according to value of "action" parameter
-********************************************************************/
+ * ACTIONS
+ *
+ * Put here all code to do according to value of "action" parameter
+ ********************************************************************/
+
+// Envoie fichier
+if ( $_POST["sendit"] && $conf->upload != 0)
+{
+	$result=$ecmdir->fetch($_REQUEST["section"]);
+	if (! $result > 0)
+	{
+		dolibarr_print_error($db,$ecmdir->error);
+		exit;
+	}
+	$relativepath=$ecmdir->getRelativePath();
+	$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
+	
+	if (! is_dir($upload_dir))
+	{
+		$result=create_exdir($upload_dir);
+	}
+	 
+	if (is_dir($upload_dir))
+	{
+		$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
+		if ($result > 0)
+		{
+			//$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
+			//print_r($_FILES);
+			$result=$ecmdir->changeNbOfFiles('+');
+		}
+		else if ($result < 0)
+		{
+			// Echec transfert (fichier depassant la limite ?)
+			$langs->load("errors");
+			$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
+			// print_r($_FILES);
+		}
+		else
+		{
+			// File infected by a virus
+			$langs->load("errors");
+			$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWith",$result).'</div>';
+		}
+	}
+	else
+	{
+		// Echec transfert (fichier depassant la limite ?)
+		$langs->load("errors");
+		$mesg = '<div class="error">'.$langs->trans("ErrorFailToCreateDir",$upload_dir).'</div>';
+	}
+}
+
+// Remove file
+if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
+{
+	$result=$ecmdir->fetch($_REQUEST["section"]);
+	if (! $result > 0)
+	{
+		dolibarr_print_error($db,$ecmdir->error);
+		exit;
+	}
+	$relativepath=$ecmdir->getRelativePath();
+	$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
+	$file = $upload_dir . "/" . urldecode($_GET["urlfile"]);
+
+	$result=dol_delete_file($file);
+
+	$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
+
+	$result=$ecmdir->changeNbOfFiles('-');
+	$action='file_manager';
+}
 
 // Action ajout d'un produit ou service
 if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
@@ -109,10 +179,10 @@ if ($_POST['action'] == 'confirm_deletesection' && $_POST['confirm'] == 'yes')
 
 
 /*******************************************************************
-* PAGE
-*
-* Put here all code to do according to value of "action" parameter
-********************************************************************/
+ * PAGE
+ *
+ * Put here all code to do according to value of "action" parameter
+ ********************************************************************/
 
 llxHeader();
 
@@ -143,11 +213,14 @@ print $langs->trans("ECMAreaDesc")."<br>";
 print $langs->trans("ECMAreaDesc2")."<br>";
 print "<br>\n";
 
+// Confirm remove file
+if ($_GET['action'] == 'delete')
+{
+	$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"].'&amp;urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
+	print '<br>';
+}
 
-print '<table class="notopnoleftnoright" width="100%"><tr><td width="50%">';
-
-// Left area
-
+if ($mesg) { print $mesg."<br>"; }
 
 // Tool bar
 $selected='file_manager';
@@ -155,14 +228,18 @@ if (eregi('search',$action)) $selected='search_form';
 $head = ecm_prepare_head_fm($fac);
 dolibarr_fiche_head($head, $selected, '', 1);
 
-print '<table class="noborder" width="100%"><tr><td>';
+
+print '<table class="border" width="100%"><tr><td width="40%">';
+
+// Left area
+print '<table class="nobordernopadding" width="100%"><tr><td>';
 
 if (eregi('search',$action))
 {
 	//print_fiche_titre($langs->trans("ECMManualOrg"));
-	
+
 	print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
-	print '<table class="noborder" width="100%">';
+	print '<table class="nobordernopadding" width="100%">';
 	print "<tr class=\"liste_titre\">";
 	print '<td colspan="3">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
 	print "<tr ".$bc[false]."><td>".$langs->trans("Ref").':</td><td><input type="text" name="search_ref" class="flat" size="18"></td>';
@@ -171,14 +248,14 @@ if (eregi('search',$action))
 	print "<tr ".$bc[false]."><td>".$langs->trans("Keyword").':</td><td><input type="text" name="search_keyword" class="flat" size="18"></td></tr>';
 	print "</table></form>";
 	//print $langs->trans("ECMManualOrgDesc");
-		
+
 	//print_fiche_titre($langs->trans("ECMAutoOrg"));
-	
+
 	print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
 	print '<table class="noborder" width="100%">';
 	print "<tr class=\"liste_titre\">";
 	print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
-	
+
 	$buthtml='<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
 	$butshown=0;
 	foreach($sectionauto as $section)
@@ -195,44 +272,47 @@ if (eregi('search',$action))
 		$butshown++;
 	}
 	if ($butshown % 2 == 1) print '<td>&nbsp;</td><td>&nbsp;</td></tr>';
-	
+
 	print '<tr '. $bc[false].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
 	print "</table></form>";
 	//print $langs->trans("ECMAutoOrgDesc");
 }
 
 
-if (empty($action) || $action == 'file_manager' || eregi('refresh',$action))
+if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $action == 'delete')
 {
+	$userstatic = new User($db);
+	$ecmdirstatic = new ECMDirectory($db);
+
 	// Confirmation de la suppression d'une ligne categorie
 	if ($_GET['action'] == 'delete_section')
 	{
 		$form->form_confirm($_SERVER["PHP_SELF"].'?section='.urldecode($_GET["section"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection');
 		print '<br>';
 	}
-	
-	if ($mesg) { print $mesg."<br>"; }
-	
-	
+
 	// Construit liste des r�pertoires
 	print '<table width="100%" class="nobordernopadding">';
-	
+
 	print '<tr class="liste_titre">';
-	print '<td class="liste_titre" colspan="5" align="right">';
+	print '<td class="liste_titre" align="left">'.$langs->trans("ECMSections").'</td>';
+	print '<td class="liste_titre" colspan="4" align="right">';
 	print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual">'.$langs->trans("Refresh").' '.img_picto($langs->trans("Refresh"),'refresh').'</a>';
 	print '</td>';
 	print '</tr>';
-	
+
 	if (sizeof($sectionauto))
 	{
 		// Automatic sections title line
-		print '<tr '.$bc[false].'><td>';
+		print '<tr>';
+		print '<td>';
 		print '<table class="nobordernopadding"><tr class="nobordernopadding">';
 		print '<td align="left" width="24px">';
 		print img_picto_common('','treemenu/base.gif');
 		print '</td><td align="left">'.$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionAuto").')';
 		print '</td>';
-		print '</tr></table></td>';
+		print '</tr></table>';
+		print '</td>';
 		print '<td align="right">&nbsp;</td>';
 		print '<td align="right">&nbsp;</td>';
 		print '<td align="right">&nbsp;</td>';
@@ -242,9 +322,9 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action))
 		print '</td>';
 		//print '<td align="right">'.$langs->trans("ECMNbOfDocsSmall").' <a href="'.$_SERVER["PHP_SELF"].'?action=refreshauto">'.img_picto($langs->trans("Refresh"),'refresh').'</a></td>';
 		print '</tr>';
-		
-		$sectionauto=dol_sort_array($sectionauto,'label',$sortorder,true,false);
-		
+
+		$sectionauto=dol_sort_array($sectionauto,'label','ASC',true,false);
+
 		$nbofentries=0;
 		$oldvallevel=0;
 		foreach ($sectionauto as $key => $val)
@@ -252,8 +332,8 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action))
 			if ($val['test'])
 			{
 				$var=false;
-	
-				print '<tr '.$bc[$var].'>';
+
+				print '<tr>';
 					
 				// Section
 				print '<td align="left">';
@@ -261,8 +341,8 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action))
 				print tree_showpad($sectionauto,$key);
 				print '</td><td valign="top">';
 				print img_picto('','object_dir');
-				print '</td><td>';
-				print '&nbsp; <a href="'.DOL_URL_ROOT.'/ecm/docother.php">';
+				print '</td><td valign="middle">&nbsp;';
+				print '<a href="'.DOL_URL_ROOT.'/ecm/docother.php">';
 				print $val['label'];
 				print '</a></td></tr></table>';
 				print "</td>\n";
@@ -272,10 +352,10 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action))
 
 				// Edit link
 				print '<td align="right">&nbsp;</td>';
-				
+
 				// Add link
 				print '<td align="right">&nbsp;</td>';
-				
+
 				// Info
 				print '<td align="center">';
 				$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
@@ -284,17 +364,17 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action))
 				$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['desc'];
 				print $form->textwithhelp('',$htmltooltip,1,0);
 				print '</td>';
-				
+
 				print "</tr>\n";
-				
+
 				$oldvallevel=$val['level'];
-				$nbofentries++;				
+				$nbofentries++;
 			}
 		}
 	}
-	
+
 	// Manual sections title line
-	print '<tr '.$bc[false].'><td>';
+	print '<tr><td>';
 	print '<table class="nobordernopadding"><tr class="nobordernopadding">';
 	print '<td align="left" width="24px">';
 	print img_picto_common('','treemenu/base.gif');
@@ -304,113 +384,172 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action))
 	print '<td align="right">';
 	print '</td>';
 	print '<td align="right">&nbsp;</td>';
-	print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create">'.img_edit_add().'</a></td>';
+	//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create">'.img_edit_add().'</a></td>';
+	print '<td align="right">&nbsp;</td>';
 	print '<td align="center">';
 	$htmltooltip=$langs->trans("ECMAreaDesc2");
 	print $form->textwithhelp('',$htmltooltip,1,0);
 	print '</td>';
 	print '</tr>';
-	
-	$ecmdirstatic = new ECMDirectory($db);
-	$rub=$ecmdirstatic->get_full_arbo();
-	
-	$userstatic = new User($db);
-	
+
+	$fulltree=$ecmdirstatic->get_full_arbo();
+
+	// Define fullpathselected ( _x_y_z )
+	$fullpathselected='';
+	foreach($fulltree as $key => $val)
+	{
+		//print $val['id']."-".$section."<br>";
+		if ($val['id'] == $section)
+		{
+			$fullpathselected=$val['fullpath'];
+			break;
+		}
+	}
+	//print "fullpathselected=".$fullpathselected."<br>";
+
 	$nbofentries=0;
 	$oldvallevel=0;
 	$var=true;
-	foreach($rub as $key => $val)
+	foreach($fulltree as $key => $val)
 	{
 		$var=false;
 			
 		$ecmdirstatic->id=$val['id'];
 		$ecmdirstatic->ref=$val['label'];
-	
+
 		// Refresh cache
 		if (eregi('refresh',$_GET['action']))
 		{
 			$result=$ecmdirstatic->fetch($val['id']);
 			$ecmdirstatic->ref=$ecmdirstatic->label;
-	
+
 			$result=$ecmdirstatic->refreshcachenboffile();
 			$val['cachenbofdoc']=$result;
 		}
-		
-	
-		print '<tr '.$bc[$var].'>';
-			
-		// Section
-		print '<td align="left">';
-		print '<table class="nobordernopadding"><tr class="nobordernopadding"><td>';
-		print tree_showpad($rub,$key);
-		print '</td><td valign="top">';
-		print $ecmdirstatic->getNomUrl(1,'index');
-		print '</td><td>';
-		print '&nbsp;</td></tr></table>';
-		print "</td>\n";
-	
-		// Nb of docs
-		print '<td align="right">'.$val['cachenbofdoc'].'</td>';
-		
-		// Edit link
-		print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$val['id'].'">'.img_edit().'</a></td>';
-		
-		// Add link
-		print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
-		
-		// Info
-		print '<td align="center">';
-		$userstatic->id=$val['fk_user_c'];
-		$userstatic->nom=$val['login_c'];
-		$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
-		$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMManualOrg").'<br>';
-		$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1).'<br>';
-		$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dolibarr_print_date($val['date_c'],"dayhour").'<br>';
-		$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'];
-		print $form->textwithhelp('',$htmltooltip,1,0);
-		print "</td>";
-		
-		print "</tr>\n";
-		
+
+		// Show line if level 1 or level selected
+		$showline=0;
+		$fullpathparent=eregi_replace('_[^_]+$','',$val['fullpath']);
+		// If directory is son of selected directory, we show line
+		if ($val['id_mere'] == $section) $showline=5;
+		// If directory is brother of selected directory, we show line
+		elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=4;
+		// If directory is parent of selected directory or is selected directory, we show line
+		elseif (eregi($val['fullpath'].'_',$fullpathselected.'_')) $showline=3;
+		// If parent directory is in a same path than selected directory
+		elseif (eregi($fullpathparent.'_',$fullpathselected.'_')) $showline=2;
+		// If we are level one we show line
+		elseif ($val['level'] < 2) $showline=1;
+
+		if ($showline)
+		{
+			print '<tr>';
+
+			// Show tree graph pictos
+			print '<td align="left">';
+			print '<table class="nobordernopadding"><tr class="nobordernopadding"><td>';
+			print tree_showpad($fulltree,$key);
+			print '</td>';
+			// Show picto
+			print '<td valign="top">';
+			//print $fullpathparent.'-'.$val['fullpath']."(".$showline.")";
+			if ($showline == 5) print img_picto('','/theme/common/treemenu/plustop2.gif','',1).img_picto('','/theme/common/treemenu/folder.gif','',1);
+			elseif ($showline == 4) print img_picto('','/theme/common/treemenu/plustop2.gif','',1).img_picto('','/theme/common/treemenu/folder.gif','',1);
+			elseif ($showline == 3) print img_picto('','/theme/common/treemenu/minustop2.gif','',1).img_picto('','/theme/common/treemenu/folder-expanded.gif','',1);
+			elseif ($showline == 2) print img_picto('','/theme/common/treemenu/plustop2.gif','',1).img_picto('','/theme/common/treemenu/folder.gif','',1);
+			elseif ($showline == 1) print img_picto('','/theme/common/treemenu/plustop2.gif','',1).img_picto('','/theme/common/treemenu/folder.gif','',1);
+			print '</td>';
+			// Show link
+			print '<td valign="middle">';
+			if ($section == $val['id']) print ' <u>';
+			print $ecmdirstatic->getNomUrl(0,'index');
+			if ($section == $val['id']) print '</u>';
+			print '</td>';
+			print '<td>&nbsp;</td>';
+			print '</tr></table>';
+			print "</td>\n";
+
+			// Nb of docs
+			print '<td align="right">'.$val['cachenbofdoc'].'</td>';
+				
+			// Edit link
+			print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$val['id'].'">'.img_edit().'</a></td>';
+				
+			// Add link
+			//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
+			print '<td align="right">&nbsp;</td>';
+				
+			// Info
+			print '<td align="center">';
+			$userstatic->id=$val['fk_user_c'];
+			$userstatic->nom=$val['login_c'];
+			$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
+			$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMManualOrg").'<br>';
+			$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1).'<br>';
+			$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dolibarr_print_date($val['date_c'],"dayhour").'<br>';
+			$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'];
+			print $form->textwithhelp('',$htmltooltip,1,0);
+			print "</td>";
+				
+			print "</tr>\n";
+		}
+
 		$oldvallevel=$val['level'];
 		$nbofentries++;
 	}
-	
-	// If nothing to show	
+
+	// If nothing to show
 	if ($nbofentries == 0)
 	{
 		print '<tr '.$bc[false].'><td colspan="6">'.$langs->trans("ECMNoDirecotyYet").'</td></tr>';
 	}
-	
+
 	print "</table>";
 	// Fin de zone Ajax
 
-// Actions buttons
-print '<div class="tabsAction">';
-if ($user->rights->ecm->setup)
-{
-	print '<a class="butAction" href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create">'.$langs->trans('ECMAddSection').'</a>';
-}
-else
-{
-	print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('ECMAddSection').'</a>';
-}
-print '</div>';
-	
-
 }
 
 print '</td></tr></table>';
 
-print '</td><td>';
+print '</td><td valign="top">';
 
 // Right area
+$relativepath=$ecmdir->getRelativePath();
+$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
+$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
 
+$formfile=new FormFile($db);
+$param='&amp;section='.$section;
+$formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->create,1);
 
+//	print '<table width="100%" class="border">';
 
+//	print '<tr><td> </td></tr></table>';
 
 
-print '</td></tr></table>';
+
+print '</td></tr>';
+
+
+// Actions buttons
+print '<tr height="22"><td align="center">';
+if ($user->rights->ecm->setup)
+{
+	print '<a class="butAction" href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create">'.$langs->trans('ECMAddSection').'</a>';
+}
+else
+{
+	print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('ECMAddSection').'</a>';
+}
+print '</td><td>';
+if ($user->rights->ecm->create && ! empty($section))
+{
+	$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/index.php','',0,$section,1);
+}
+else print '&nbsp;';
+print '</td></tr>';
+
+print '</table>';
 
 
 print '<br>';
diff --git a/htdocs/html.formfile.class.php b/htdocs/html.formfile.class.php
index 7272684a185fec2155f5087cc1904c544ba92e65..a73f5f1892c0b0a6de919a518a8fa92ab26aac94 100644
--- a/htdocs/html.formfile.class.php
+++ b/htdocs/html.formfile.class.php
@@ -46,12 +46,12 @@ class FormFile
 
 
 	/**
-	 *    	\brief      Affiche formulaire ajout fichier
+	 *    	\brief      Show file add form
 	 *    	\param      url				Url
 	 *    	\param      titre			Titre zone
 	 *    	\param      addcancel		1=Ajoute un bouton 'Annuler'
 	 *		\param		sectionid		If upload must be done inside a particular ECM section
-	 *		\return		int				<0 si ko, >0 si ok
+	 * 		\return		int				<0 si ko, >0 si ok
 	 */
 	function form_attach_new_file($url,$titre='',$addcancel=0, $sectionid=0)
 	{
@@ -98,7 +98,7 @@ class FormFile
 			print "</table>";
 
 			print '</form>';
-			print '<br>';
+			if (empty($sectionid)) print '<br>';
 				
 			print "\n<!-- End form attach new file -->\n\n";
 		}
@@ -384,17 +384,18 @@ class FormFile
 	 * 		\param		forcedownload		Mime type is forced to 'application/binary' to have a download
 	 * 		\param		relativepath		Relative path of docs (autodefined if not provided)
 	 * 		\param		permtodelete		Permission to delete
-	 *		\return		int					<0 if KO, nb of files shown if OK
+	 * 		\param		useinecm			Change output for use in ecm module
+	 * 		\return		int					<0 if KO, nb of files shown if OK
 	 */
-	function list_of_documents($filearray,$object,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1)
+	function list_of_documents($filearray,$object,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0)
 	{
 		global $user, $conf, $langs;
 		global $bc;
 		global $sortfield, $sortorder;
 		 
 		// Affiche liste des documents existant
-		print_titre($langs->trans("AttachedFiles"));
-
+		if (empty($useinecm)) print_titre($langs->trans("AttachedFiles"));
+		else { $bc[true]=''; $bc[false]=''; };
 		$url=$_SERVER["PHP_SELF"];
 		print '<table width="100%" class="noborder">';
 		print '<tr class="liste_titre">';
diff --git a/htdocs/lib/treeview.lib.php b/htdocs/lib/treeview.lib.php
index b113ce1ee14353125c4c8ff3da1ba054829f28c4..7d95e71db8834d731773c68ccc860398951ac0c2 100644
--- a/htdocs/lib/treeview.lib.php
+++ b/htdocs/lib/treeview.lib.php
@@ -24,13 +24,14 @@
  *  \version    $Id$
  */
 
+
 /**
  * Show picto of a tree view
  *
  * @param unknown_type $tab		Array of entries in correct order
- * @param unknown_type $key		Key of value	
+ * @param unknown_type $key		Key of value to show picto
  */
-function tree_showpad(&$tab,$key)
+function tree_showpad(&$tab,$key,$selected=0)
 {
 	$pos=1;
 	while ($pos <= $tab[$key]['level'] && $tab[$key]['level'] > 0)
@@ -54,8 +55,6 @@ function tree_showpad(&$tab,$key)
 
 
 
-
-
 // ------------------------------- Used by enu editor -----------------
 
 /**
diff --git a/htdocs/theme/common/treemenu/branch.gif b/htdocs/theme/common/treemenu/branch.gif
index 32e0f683d809fbb8b5d424825d3943e8573ff133..7c568e46f8725c69e9e941895ef430ef2a1a9bb4 100644
Binary files a/htdocs/theme/common/treemenu/branch.gif and b/htdocs/theme/common/treemenu/branch.gif differ
diff --git a/htdocs/theme/common/treemenu/branchbottom.gif b/htdocs/theme/common/treemenu/branchbottom.gif
index 55ceb453fbaf8693dab2d5ea36c00c555681e471..8fd24836533e657630a1af43f301d144ba64478c 100644
Binary files a/htdocs/theme/common/treemenu/branchbottom.gif and b/htdocs/theme/common/treemenu/branchbottom.gif differ
diff --git a/htdocs/theme/common/treemenu/branchtop.gif b/htdocs/theme/common/treemenu/branchtop.gif
index f6bd127b420b37b02d802f070ce04a5653ca395f..e1dfbcfa1b45da4d185780210bdb796825c6371d 100644
Binary files a/htdocs/theme/common/treemenu/branchtop.gif and b/htdocs/theme/common/treemenu/branchtop.gif differ
diff --git a/htdocs/theme/common/treemenu/line.gif b/htdocs/theme/common/treemenu/line.gif
index a567ef9e53e0c2945efa03c306efc814953308f9..46c38e04c216fc2d90ee5863071351c41ec8fe6f 100644
Binary files a/htdocs/theme/common/treemenu/line.gif and b/htdocs/theme/common/treemenu/line.gif differ
diff --git a/htdocs/theme/common/treemenu/minus.gif b/htdocs/theme/common/treemenu/minus.gif
index a2bff1276c75493d56f8c6b1c4f1c952a45b8c10..010ab770969c3ba76cab5da54203c1dce422fb7b 100644
Binary files a/htdocs/theme/common/treemenu/minus.gif and b/htdocs/theme/common/treemenu/minus.gif differ
diff --git a/htdocs/theme/common/treemenu/minustop2.gif b/htdocs/theme/common/treemenu/minustop2.gif
new file mode 100644
index 0000000000000000000000000000000000000000..0675a8fc0233e9fa052651dead48077cdeed2f6e
Binary files /dev/null and b/htdocs/theme/common/treemenu/minustop2.gif differ
diff --git a/htdocs/theme/common/treemenu/plus.gif b/htdocs/theme/common/treemenu/plus.gif
index 5bc24cfb74666c2d612ff98e12e3fe67e91747ab..ae746fb1cfde027c6af388b1a44e02936ee0c71c 100644
Binary files a/htdocs/theme/common/treemenu/plus.gif and b/htdocs/theme/common/treemenu/plus.gif differ
diff --git a/htdocs/theme/common/treemenu/plusbottom.gif b/htdocs/theme/common/treemenu/plusbottom.gif
index 4aa0bde92f5899e6a463638b792b9855916f6b07..ab5bccc456b81d52ccef4e2a0adbda51b5c4eea9 100644
Binary files a/htdocs/theme/common/treemenu/plusbottom.gif and b/htdocs/theme/common/treemenu/plusbottom.gif differ
diff --git a/htdocs/theme/common/treemenu/plustop2.gif b/htdocs/theme/common/treemenu/plustop2.gif
new file mode 100644
index 0000000000000000000000000000000000000000..5abc420e4cf2c43f64b23d1869669308ced7ac9f
Binary files /dev/null and b/htdocs/theme/common/treemenu/plustop2.gif differ