diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 0ef1a7417d174fae9a6ca65586fa9f1502bd807b..1f505734d4d921ae55b33d80d6389b97d802974f 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -35,6 +35,8 @@ require_once(DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php");
 class FormMail
 {
 	var $db;
+	
+	var $withform;
 
 	var $fromname;
 	var $frommail;
@@ -72,6 +74,8 @@ class FormMail
 	function FormMail($DB)
 	{
 		$this->db = $DB;
+		
+		$this->withform=1;
 
 		$this->withfrom=1;
 		$this->withto=1;
@@ -178,7 +182,7 @@ class FormMail
 		if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]);
 		return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes);
 	}
-
+	
 	/**
 	 *	Show the form to input an email
      *  this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
@@ -186,11 +190,24 @@ class FormMail
 	 *	@param			removefileaction	Name of action when removing file attachments
 	 */
 	function show_form($addfileaction='addfile',$removefileaction='removefile')
+	{
+		print $this->get_form($addfileaction,$removefileaction);
+	}
+
+	/**
+	 *	Get the form to input an email
+     *  this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
+	 *	@param			addfileaction		Name of action when posting file attachments
+	 *	@param			removefileaction	Name of action when removing file attachments
+	 */
+	function get_form($addfileaction='addfile',$removefileaction='removefile')
 	{
 		global $conf, $langs, $user;
 
 		$langs->load("other");
 		$langs->load("mails");
+		
+		$out='';
 
 		// Define list of attached files
 		$listofpaths=array();
@@ -203,26 +220,29 @@ class FormMail
 
 		$form=new Form($DB);
 
-		print "\n<!-- Debut form mail -->\n";
-		print "<form method=\"POST\" name=\"mailform\" enctype=\"multipart/form-data\" action=\"".$this->param["returnurl"]."\">\n";
-		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+		$out.= "\n<!-- Debut form mail -->\n";
+		if ($this->withform)
+		{
+			$out.= '<form method="POST" name="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">'."\n";
+			$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
+		}
 		foreach ($this->param as $key=>$value)
 		{
-			print "<input type=\"hidden\" name=\"$key\" value=\"$value\">\n";
+			$out.= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n";
 		}
-		print "<table class=\"border\" width=\"100%\">\n";
+		$out.= '<table class="border" width="100%">'."\n";
 
 		// Substitution array
 		if ($this->withsubstit)
 		{
-			print "<tr><td colspan=\"2\">";
+			$out.= '<tr><td colspan="2">';
 			$help="";
 			foreach($this->substit as $key => $val)
 			{
 				$help.=$key.' -> '.$langs->trans($val).'<br>';
 			}
-			print $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help);
-			print "</td></tr>\n";
+			$out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help);
+			$out.= "</td></tr>\n";
 		}
 
 		// From
@@ -230,42 +250,42 @@ class FormMail
 		{
 			if ($this->withfromreadonly)
 			{
-				print '<input type="hidden" name="fromname" value="'.$this->fromname.'">';
-				print '<input type="hidden" name="frommail" value="'.$this->frommail.'">';
-				print "<tr><td width=\"180\">".$langs->trans("MailFrom")."</td><td>";
+				$out.= '<input type="hidden" id="fromname" name="fromname" value="'.$this->fromname.'" />';
+				$out.= '<input type="hidden" id="frommail" name="frommail" value="'.$this->frommail.'" />';
+				$out.= '<tr><td width="180">'.$langs->trans("MailFrom").'</td><td>';
 				if ($this->fromtype == 'user')
 				{
 					$langs->load("users");
 					$fuser=new User($this->db);
 					$fuser->fetch($this->fromid);
-					print $fuser->getNomUrl(1);
+					$out.= $fuser->getNomUrl(1);
 				}
 				else
 				{
-					print $this->fromname;
+					$out.= $this->fromname;
 				}
 				if ($this->frommail)
 				{
-					print " &lt;".$this->frommail."&gt;";
+					$out.= " &lt;".$this->frommail."&gt;";
 				}
 				else
 				{
 					if ($this->fromtype)
 					{
 						$langs->load("errors");
-						print '<font class="warning"> &lt;'.$langs->trans("ErrorNoMailDefinedForThisUser").'&gt; </font>';
+						$out.= '<font class="warning"> &lt;'.$langs->trans("ErrorNoMailDefinedForThisUser").'&gt; </font>';
 					}
 				}
-				print "</td></tr>\n";
-				print "</td></tr>\n";
+				$out.= "</td></tr>\n";
+				$out.= "</td></tr>\n";
 			}
 			else
 			{
-				print "<tr><td>".$langs->trans("MailFrom")."</td><td>";
-				print $langs->trans("Name").':<input type="text" name="fromname" size="32" value="'.$this->fromname.'">';
-				print '&nbsp; &nbsp; ';
-				print $langs->trans("EMail").':&lt;<input type="text" name="frommail" size="32" value="'.$this->frommail.'">&gt;';
-				print "</td></tr>\n";
+				$out.= "<tr><td>".$langs->trans("MailFrom")."</td><td>";
+				$out.= $langs->trans("Name").':<input type="text" id="fromname" name="fromname" size="32" value="'.$this->fromname.'" />';
+				$out.= '&nbsp; &nbsp; ';
+				$out.= $langs->trans("EMail").':&lt;<input type="text" id="frommail" name="frommail" size="32" value="'.$this->frommail.'" />&gt;';
+				$out.= "</td></tr>\n";
 			}
 		}
 
@@ -274,10 +294,10 @@ class FormMail
 		{
 			if ($this->withreplytoreadonly)
 			{
-				print '<input type="hidden" name="replyname" value="'.$this->replytoname.'">';
-				print '<input type="hidden" name="replymail" value="'.$this->replytomail.'">';
-				print "<tr><td>".$langs->trans("MailReply")."</td><td>".$this->replytoname.($this->replytomail?(" &lt;".$this->replytomail."&gt;"):"");
-				print "</td></tr>\n";
+				$out.= '<input type="hidden" id="replyname" name="replyname" value="'.$this->replytoname.'" />';
+				$out.= '<input type="hidden" id="replymail" name="replymail" value="'.$this->replytomail.'" />';
+				$out.= "<tr><td>".$langs->trans("MailReply")."</td><td>".$this->replytoname.($this->replytomail?(" &lt;".$this->replytomail."&gt;"):"");
+				$out.= "</td></tr>\n";
 			}
 		}
 
@@ -287,32 +307,32 @@ class FormMail
 			//if (! $this->errorstomail) $this->errorstomail=$this->frommail;
 			if ($this->witherrorstoreadonly)
 			{
-				print '<input type="hidden" name="errorstomail" value="'.$this->errorstomail.'">';
-				print "<tr><td>".$langs->trans("MailErrorsTo")."</td><td>";
-				print $this->errorstomail;
-				print "</td></tr>\n";
+				$out.= '<input type="hidden" id="errorstomail" name="errorstomail" value="'.$this->errorstomail.'" />';
+				$out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
+				$out.= $this->errorstomail;
+				$out.= "</td></tr>\n";
 			}
 			else
 			{
-				print "<tr><td>".$langs->trans("MailErrorsTo")."</td><td>";
-				print "<input size=\"30\" name=\"errorstomail\" value=\"".$this->errorstomail."\">";
-				print "</td></tr>\n";
+				$out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
+				$out.= '<input size="30" id="errorstomail" name="errorstomail" value="'.$this->errorstomail.'" />';
+				$out.= "</td></tr>\n";
 			}
 		}
 
 		// To
 		if ($this->withto || is_array($this->withto))
 		{
-			print '<tr><td width="180">';
-			print $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
-			print '</td><td>';
+			$out.= '<tr><td width="180">';
+			$out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
+			$out.= '</td><td>';
 			if ($this->withtoreadonly)
 			{
-				print (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:"";
+				$out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:"";
 			}
 			else
 			{
-				print "<input size=\"".(is_array($this->withto)?"30":"60")."\" name=\"sendto\" value=\"".(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"")."\">";
+				$out.= '<input size="'.(is_array($this->withto)?"30":"60").'" id="sendto" name="sendto" value="'.(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"").'" />';
 				if ($this->withtosocid > 0)
 				{
 					$liste=array();
@@ -323,27 +343,27 @@ class FormMail
 					{
 						$liste[$key]=$value;
 					}
-					print " ".$langs->trans("or")." ";
+					$out.= " ".$langs->trans("or")." ";
 					//var_dump($_REQUEST);exit;
-					print $form->selectarray("receiver", $liste, isset($_REQUEST["receiver"])?$_REQUEST["receiver"]:0);
+					$out.= $form->selectarray("receiver", $liste, isset($_REQUEST["receiver"])?$_REQUEST["receiver"]:0);
 				}
 			}
-			print "</td></tr>\n";
+			$out.= "</td></tr>\n";
 		}
 
 		// CC
 		if ($this->withtocc || is_array($this->withtocc))
 		{
-			print '<tr><td width="180">';
-			print $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
-			print '</td><td>';
+			$out.= '<tr><td width="180">';
+			$out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
+			$out.= '</td><td>';
 			if ($this->withtoccreadonly)
 			{
-				print (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:"";
+				$out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:"";
 			}
 			else
 			{
-				print "<input size=\"".(is_array($this->withtocc)?"30":"60")."\" name=\"sendtocc\" value=\"".((! is_array($this->withtocc) && ! is_numeric($this->withtocc))? (isset($_POST["sendtocc"])?$_POST["sendtocc"]:$this->withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") )."\">";
+				$out.= '<input size="'.(is_array($this->withtocc)?"30":"60").'" id="sendtocc" name="sendtocc" value="'.((! is_array($this->withtocc) && ! is_numeric($this->withtocc))? (isset($_POST["sendtocc"])?$_POST["sendtocc"]:$this->withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />';
 				if ($this->withtoccsocid > 0)
 				{
 					$liste=array();
@@ -354,26 +374,26 @@ class FormMail
 					{
 						$liste[$key]=$value;
 					}
-					print " ".$langs->trans("or")." ";
-					print $form->selectarray("receivercc", $liste, isset($_REQUEST["receivercc"])?$_REQUEST["receivercc"]:0);
+					$out.= " ".$langs->trans("or")." ";
+					$out.= $form->selectarray("receivercc", $liste, isset($_REQUEST["receivercc"])?$_REQUEST["receivercc"]:0);
 				}
 			}
-			print "</td></tr>\n";
+			$out.= "</td></tr>\n";
 		}
 
 		// CCC
 		if ($this->withtoccc || is_array($this->withtoccc))
 		{
-			print '<tr><td width="180">';
-			print $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
-			print '</td><td>';
+			$out.= '<tr><td width="180">';
+			$out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
+			$out.= '</td><td>';
 			if ($this->withtocccreadonly)
 			{
-				print (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:"";
+				$out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:"";
 			}
 			else
 			{
-				print "<input size=\"".(is_array($this->withtoccc)?"30":"60")."\" name=\"sendtoccc\" value=\"".((! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))? (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:$this->withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") )."\">";
+				$out.= '<input size="'.(is_array($this->withtoccc)?"30":"60").'" id="sendtoccc" name="sendtoccc" value="'.((! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))? (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:$this->withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />';
 				if ($this->withtocccsocid > 0)
 				{
 					$liste=array();
@@ -384,29 +404,29 @@ class FormMail
 					{
 						$liste[$key]=$value;
 					}
-					print " ".$langs->trans("or")." ";
-					print $form->selectarray("receiverccc", $liste, isset($_REQUEST["receiverccc"])?$_REQUEST["receiverccc"]:0);
+					$out.= " ".$langs->trans("or")." ";
+					$out.= $form->selectarray("receiverccc", $liste, isset($_REQUEST["receiverccc"])?$_REQUEST["receiverccc"]:0);
 				}
 			}
 			//if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1);
-			print "</td></tr>\n";
+			$out.= "</td></tr>\n";
 		}
 
 		// Ask delivery receipt
 		if ($this->withdeliveryreceipt)
 		{
-			print '<tr><td width="180">'.$langs->trans("DeliveryReceipt").'</td><td>';
+			$out.= '<tr><td width="180">'.$langs->trans("DeliveryReceipt").'</td><td>';
 
 			if ($this->withdeliveryreceiptreadonly)
 			{
-				print yn($this->withdeliveryreceipt);
+				$out.= yn($this->withdeliveryreceipt);
 			}
 			else
 			{
-				print $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0) ,1);
+				$out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0) ,1);
 			}
 
-			print "</td></tr>\n";
+			$out.= "</td></tr>\n";
 		}
 
 		// Topic
@@ -414,50 +434,50 @@ class FormMail
 		{
 			$this->withtopic=make_substitutions($this->withtopic,$this->substit);
 
-			print "<tr>";
-			print "<td width=\"180\">".$langs->trans("MailTopic")."</td>";
-			print "<td>";
+			$out.= '<tr>';
+			$out.= '<td width="180">'.$langs->trans("MailTopic").'</td>';
+			$out.= '<td>';
 			if ($this->withtopicreadonly)
 			{
-				print $this->withtopic;
-				print "<input type=\"hidden\" size=\"60\" name=\"subject\" value=\"".$this->withtopic."\">";
+				$out.= $this->withtopic;
+				$out.= '<input type="hidden" size="60" id="subject" name="subject" value="'.$this->withtopic.'" />';
 			}
 			else
 			{
-				print "<input type=\"text\" size=\"60\" name=\"subject\" value=\"". (isset($_POST["subject"])?$_POST["subject"]:$this->withtopic) ."\">";
+				$out.= '<input type="text" size="60" id="subject" name="subject" value="'. (isset($_POST["subject"])?$_POST["subject"]:$this->withtopic) .'" />';
 			}
-			print "</td></tr>\n";
+			$out.= "</td></tr>\n";
 		}
 
 		// Attached files
 		if ($this->withfile)
 		{
-			print "<tr>";
-			print '<td width="180">'.$langs->trans("MailFile")."</td>";
-			print "<td>";
+			$out.= '<tr>';
+			$out.= '<td width="180">'.$langs->trans("MailFile").'</td>';
+			$out.= '<td>';
 			//print '<table class="nobordernopadding" width="100%"><tr><td>';
 			if (sizeof($listofpaths))
 			{
 				foreach($listofpaths as $key => $val)
 				{
-					print img_mime($listofnames[$key]).' '.$listofnames[$key];
-					print ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key+1).'" name="removedfile">';
-					print '<br>';
+					$out.= img_mime($listofnames[$key]).' '.$listofnames[$key];
+					$out.= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key+1).'" id="removedfile" name="removedfile" />';
+					$out.= '<br>';
 				}
 			}
 			else
 			{
-				print $langs->trans("NoAttachedFiles").'<br>';
+				$out.= $langs->trans("NoAttachedFiles").'<br>';
 			}
 			if ($this->withfile == 2)	// Can add other files
 			{
 				//print '<td><td align="right">';
-				print '<input type="file" class="flat" name="addedfile" value="'.$langs->trans("Upload").'"/>';
-				print ' ';
-				print '<input type="submit" class="button" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'">';
+				$out.= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
+				$out.= ' ';
+				$out.= '<input type="submit" class="button" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
 				//print '</td></tr></table>';
 			}
-			print "</td></tr>\n";
+			$out.= "</td></tr>\n";
 		}
 
 		// Message
@@ -497,42 +517,48 @@ class FormMail
 			if (isset($_POST["message"])) $defaultmessage=$_POST["message"];
 			$defaultmessage=str_replace('\n',"\n",$defaultmessage);
 
-			print "<tr>";
-			print "<td width=\"180\" valign=\"top\">".$langs->trans("MailText")."</td>";
-			print "<td>";
+			$out.= '<tr>';
+			$out.= '<td width="180" valign="top">'.$langs->trans("MailText").'</td>';
+			$out.= '<td>';
 			if ($this->withbodyreadonly)
 			{
-				print nl2br($defaultmessage);
-				print '<input type="hidden" name="message" value="'.$defaultmessage.'">';
+				$out.= nl2br($defaultmessage);
+				$out.= '<input type="hidden" id="message" name="message" value="'.$defaultmessage.'" />';
 			}
 			else
 			{
 				// Editeur wysiwyg
 				require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
 				$doleditor=new DolEditor('message',$defaultmessage,'',280,'dolibarr_notes','In',true,false,$this->withfckeditor,8,72);
-				$doleditor->Create();
+				$out.= $doleditor->Create(1);
 			}
-			print "</td></tr>\n";
+			$out.= "</td></tr>\n";
 		}
-
-		print "<tr><td align=center colspan=2><center>";
-		print "<input class=\"button\" type=\"submit\" name=\"sendmail\" value=\"".$langs->trans("SendMail")."\"";
-		// Add a javascript test to avoid to forget to submit file before sending email
-		if ($this->withfile == 2 && $conf->use_javascript_ajax)
+		
+		if ($this->withform)
 		{
-			print ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"';
-		}
-		print ">";
-		if ($this->withcancel)
-		{
-			print " &nbsp; &nbsp; ";
-			print "<input class=\"button\" type=\"submit\" name=\"cancel\" value=\"".$langs->trans("Cancel")."\">";
+			$out.= '<tr><td align="center" colspan="2"><center>';
+			$out.= '<input class="button" type="submit" id="sendmail" name="sendmail" value="'.$langs->trans("SendMail").'"';
+			// Add a javascript test to avoid to forget to submit file before sending email
+			if ($this->withfile == 2 && $conf->use_javascript_ajax)
+			{
+				$out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"';
+			}
+			$out.= ' />';
+			if ($this->withcancel)
+			{
+				$out.= ' &nbsp; &nbsp; ';
+				$out.= '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'" />';
+			}
+			$out.= '</center></td></tr>'."\n";
 		}
-		print "</center></td></tr>\n";
-		print "</table>\n";
+		
+		$out.= '</table>'."\n";
 
-		print "</form>\n";
-		print "<!-- Fin form mail -->\n";
+		if ($this->withform) $out.= '</form>'."\n";
+		$out.= "<!-- Fin form mail -->\n";
+		
+		return $out;
 	}
 
 
diff --git a/htdocs/lib/doleditor.class.php b/htdocs/lib/doleditor.class.php
index 5cac53b2bdb307a34b14ab9e338a1797c6f5807e..e8c575dd7cf72c41183f25e936ab314384b6407e 100644
--- a/htdocs/lib/doleditor.class.php
+++ b/htdocs/lib/doleditor.class.php
@@ -134,11 +134,12 @@ class DolEditor
     /**
      *		Output edit area inside the HTML stream
      */
-    function Create()
+    function Create($noprint=0)
     {
     	global $conf;
 
         $found=0;
+        $out='';
 
         if ($this->tool == 'fckeditor')
         {
@@ -148,9 +149,9 @@ class DolEditor
         if (in_array($this->tool,array('textarea','ckeditor')))
         {
             $found=1;
-            print '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'" cols="'.$this->cols.'" class="flat">';
-            print $this->content;
-            print '</textarea>';
+            $out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'" cols="'.$this->cols.'" class="flat">';
+            $out.= $this->content;
+            $out.= '</textarea>';
 
             if ($this->tool == 'ckeditor')
             {
@@ -161,7 +162,7 @@ class DolEditor
             	//$skin='v2';
             	$skin='kama';
 
-            	print '<script type="text/javascript">
+            	$out.= '<script type="text/javascript">
             			jQuery(document).ready(function () {
             				CKEDITOR.replace(\''.$this->htmlname.'\',
             					{
@@ -188,27 +189,27 @@ class DolEditor
                                             }';
             	if ($this->uselocalbrowser)
             	{
-                    print ','."\n";
+                    $out.= ','."\n";
                     // To use filemanager with old fckeditor (GPL)
-                    print '    filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/browser/default/browser.html?Connector='.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/connector.php\',';
-                    //print '    filebrowserUploadUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/upload.php?Type=File\',';
-                    print '    filebrowserImageBrowseUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/browser/default/browser.html?Type=Image&Connector='.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/connector.php\',';
+                    $out.= '    filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/browser/default/browser.html?Connector='.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/connector.php\',';
+                    //$out.= '    filebrowserUploadUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/upload.php?Type=File\',';
+                    $out.= '    filebrowserImageBrowseUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/browser/default/browser.html?Type=Image&Connector='.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/connector.php\',';
                     //print '    filebrowserImageUploadUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/upload.php?Type=Image\',';
-                    print "\n";
+                    $out.= "\n";
                     // To use filemanager with ckfinder (Non free) and ckfinder directory is inside htdocs/includes
-/*                  print '    filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html\',
+/*                  $out.= '    filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html\',
                                filebrowserImageBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Images\',
                                filebrowserFlashBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Flash\',
                                filebrowserUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files\',
                                filebrowserImageUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images\',
                                filebrowserFlashUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash\','."\n";
 */
-                    print '    filebrowserWindowWidth : \'900\',
+                    $out.= '    filebrowserWindowWidth : \'900\',
                                filebrowserWindowHeight : \'500\',
                                filebrowserImageWindowWidth : \'900\',
                                filebrowserImageWindowHeight : \'500\'';
             	}
-            	print '
+            	$out.= '
             					});
 
             			});
@@ -218,8 +219,11 @@ class DolEditor
 
         if (empty($found))
         {
-            print 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.';
+            $out.= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.';
         }
+        
+        if ($noprint) return $out;
+        else print $out;
     }
 
 }