diff --git a/ChangeLog b/ChangeLog
index 969b7ec5ccd4c554ae4005b6623599686da00b1c..f40003bdb3298ab0d852dcb75b3b6e582b581a43 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ $Id$
 
 ***** ChangeLog for 3.1 compared to 3.0 *****
 For users:
+- New: A specialized menu is now used when using smartphones.
 - New: Can add information on current user on odt generation
 - New: Prefix on third party is not used by default. Hidden option
        SOCIETE_USEPREFIX can restore old feature.
diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php
index bc7a429b165436012c9754150401163a736f12ae..30cc01bb3567fd908b4552e5c5b6063848b65458 100644
--- a/htdocs/admin/menus.php
+++ b/htdocs/admin/menus.php
@@ -164,18 +164,15 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit')
 	print '</tr>';
 
 	// Menu smartphone
-	if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
-	{
-    	$var=!$var;
-    	print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
-    	print '<td>';
-    	print $htmladmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'main_menu_smartphone', $dirsmartphone, empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled="disabled"');
-    	print '</td>';
-    	print '<td>';
-    	print $htmladmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'main_menufront_smartphone', $dirsmartphone, empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?'':' disabled="disabled"');
-    	print '</td>';
-    	print '</tr>';
-	}
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
+	print '<td>';
+	print $htmladmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'main_menu_smartphone', array($dirtop,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled="disabled"');
+	print '</td>';
+	print '<td>';
+	print $htmladmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'main_menufront_smartphone', array($dirtop,$dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?'':' disabled="disabled"');
+	print '</td>';
+	print '</tr>';
 
 	print '</table>';
 
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index f7035f785ca028586d672ff3c6bba73bfdf18ba6..7ab11687460d5b68aa1bb1e93b0780e75d8333cc 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -31,7 +31,7 @@
 
 /**
  *  \class      Conf
- *  \brief      Classe de stockage de la config courante
+ *  \brief      Class to stock current configuration
  */
 class Conf
 {
@@ -207,8 +207,8 @@ class Conf
 		// Clean some variables
 		if (empty($this->global->MAIN_MENU_STANDARD)) $this->global->MAIN_MENU_STANDARD="eldy_backoffice.php";
 		if (empty($this->global->MAIN_MENUFRONT_STANDARD)) $this->global->MAIN_MENUFRONT_STANDARD="eldy_frontoffice.php";
-		if (empty($this->global->MAIN_MENU_SMARTPHONE)) $this->global->MAIN_MENU_SMARTPHONE="iphone_backoffice.php";
-		if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) $this->global->MAIN_MENUFRONT_SMARTPHONE="iphone_frontoffice.php";
+		if (empty($this->global->MAIN_MENU_SMARTPHONE)) $this->global->MAIN_MENU_SMARTPHONE="smartphone_backoffice.php";
+		if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) $this->global->MAIN_MENUFRONT_SMARTPHONE="smartphone_frontoffice.php";
 
 		// Variable globales LDAP
 		if (empty($this->global->LDAP_FIELD_FULLNAME)) $this->global->LDAP_FIELD_FULLNAME='';
@@ -426,8 +426,26 @@ class Conf
 
 		// For backward compatibility
 		$this->produit=$this->product;
-	}
 
+
+        // Define menu manager in setup
+        if (empty($user->societe_id))    // If internal user or not defined
+        {
+            $this->top_menu=(empty($this->global->MAIN_MENU_STANDARD_FORCED)?$this->global->MAIN_MENU_STANDARD:$this->global->MAIN_MENU_STANDARD_FORCED);
+            $this->smart_menu=(empty($this->global->MAIN_MENU_SMARTPHONE_FORCED)?$this->global->MAIN_MENU_SMARTPHONE:$this->global->MAIN_MENU_SMARTPHONE_FORCED);
+            // For backward compatibility
+            if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php';
+            if ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php';
+        }
+        else                        // If external user
+        {
+            $this->top_menu=(empty($this->global->MAIN_MENUFRONT_STANDARD_FORCED)?$this->global->MAIN_MENUFRONT_STANDARD:$this->global->MAIN_MENUFRONT_STANDARD_FORCED);
+            $this->smart_menu=(empty($this->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$this->global->MAIN_MENUFRONT_SMARTPHONE:$this->global->MAIN_MENUFRONT_SMARTPHONE_FORCED);
+            // For backward compatibility
+            if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_frontoffice.php';
+            if ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_frontoffice.php';
+        }
+	}
 }
 
 ?>
diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php
index 4d43cf32ccd2c2febdc4ffbe5ef7965f3e84db32..dd215a8f0cd88d8f7ecd5d1735b73cd425592d4c 100644
--- a/htdocs/core/class/html.formadmin.class.php
+++ b/htdocs/core/class/html.formadmin.class.php
@@ -126,7 +126,7 @@ class FormAdmin
      *    Return list of available menus (eldy_backoffice, ...)
      *    @param      selected        Preselected menu value
      *    @param      htmlname        Name of html select
-     *    @param      dirmenu         Directory to scan
+     *    @param      dirmenu         Directory to scan or array of directories to scan
      *    @param      moreattrib      More attributes on html select tag
      */
     function select_menu($selected='', $htmlname, $dirmenu, $moreattrib='')
@@ -138,39 +138,44 @@ class FormAdmin
 		$menuarray=array();
         foreach ($conf->file->dol_document_root as $dirroot)
         {
-            $dir=$dirroot.$dirmenu;
-            if (is_dir($dir))
+            if (is_array($dirmenu)) $dirmenus=$dirmenu;
+            else $dirmenus=array($dirmenu);
+            foreach($dirmenus as $dirtoscan)
             {
-	            $handle=opendir($dir);
-	            if (is_resource($handle))
-	            {
-	                while (($file = readdir($handle))!==false)
-	                {
-	                    if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
-	                    {
-	                        if (preg_match('/lib\.php$/i',$file)) continue;	// We exclude library files
-	                    	$filelib=preg_replace('/\.php$/i','',$file);
-	        				$prefix='';
-	        				if (preg_match('/^eldy|^iphone/i',$file)) $prefix='0';	// 0=Recommanded, 1=Experimental, 2=Other
-	        				else $prefix='2';
-
-	                        if ($file == $selected)
-	                        {
-	        					$menuarray[$prefix.'_'.$file]='<option value="'.$file.'" selected="selected">'.$filelib.'</option>';
-	                        }
-	                        else
-	                        {
-	                            $menuarray[$prefix.'_'.$file]='<option value="'.$file.'">'.$filelib.'</option>';
-	                        }
-	                    }
-	                }
-	                closedir($handle);
-	            }
+                $dir=$dirroot.$dirtoscan;
+                if (is_dir($dir))
+                {
+    	            $handle=opendir($dir);
+    	            if (is_resource($handle))
+    	            {
+    	                while (($file = readdir($handle))!==false)
+    	                {
+    	                    if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
+    	                    {
+    	                        if (preg_match('/lib\.php$/i',$file)) continue;	// We exclude library files
+    	                    	$filelib=preg_replace('/\.php$/i','',$file);
+    	        				$prefix='';
+    	        				if (preg_match('/^eldy|^smartphone/i',$file)) $prefix='0';	// 0=Recommanded, 1=Experimental, 2=Other
+    	        				else $prefix='2';
+
+    	                        if ($file == $selected)
+    	                        {
+    	        					$menuarray[$prefix.'_'.$file]='<option value="'.$file.'" selected="selected">'.$filelib.'</option>';
+    	                        }
+    	                        else
+    	                        {
+    	                            $menuarray[$prefix.'_'.$file]='<option value="'.$file.'">'.$filelib.'</option>';
+    	                        }
+    	                    }
+    	                }
+    	                closedir($handle);
+    	            }
+                }
             }
         }
 		ksort($menuarray);
 
-		// Affichage liste deroulante des menus
+		// Output combo list of menus
         print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>';
         $oldprefix='';
 		foreach ($menuarray as $key => $val)
@@ -202,7 +207,8 @@ class FormAdmin
     {
 		global $langs,$conf;
 
-        $expdevmenu=array('iphone_backoffice.php','iphone_frontoffice.php');  // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set
+        //$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php');  // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set
+		$expdevmenu=array();
 
 		$menuarray=array();
 
diff --git a/htdocs/core/class/smartphone.class.php b/htdocs/core/class/smartphone.class.php
index 14e391f7e3ea0966ed534696086b9876a9980287..af0535e69fb4024dd36648482a297608ed30bd6e 100644
--- a/htdocs/core/class/smartphone.class.php
+++ b/htdocs/core/class/smartphone.class.php
@@ -26,7 +26,7 @@
 
 /**
  *  \class      Smartphone
- *	\brief      Classe de gestion des smartphones
+ *	\brief      Class to manage Smartphones
  */
 class Smartphone {
 
@@ -41,52 +41,25 @@ class Smartphone {
      *  Constructor for class
      *  @param	DB		Handler acces base de donnees
      */
-    function Smartphone($DB)
+    function Smartphone($DB,$phone)
     {
       	$this->db = $DB;
-    }
 
-    /**
-     * 	Get template directory
-     */
-    function getTemplateDir()
-    {
-    	// iWebKit template
-		if (preg_match('/android|blackberry|iphone|maemo/i',$this->phone))
-		{
-			$this->theme = 'default';
-			$this->template_dir=DOL_DOCUMENT_ROOT."/theme/phones/smartphone/tpl/";
-		}
-		// Special template
-		elseif (file_exists(DOL_DOCUMENT_ROOT."/theme/phones/".$this->phone))
-		{
-			$this->theme = 'default';
-			$this->template_dir=DOL_DOCUMENT_ROOT."/theme/phones/".$this->phone."/tpl/";
-		}
-		// Default template
-		else
-		{
-			$this->template_dir=DOL_DOCUMENT_ROOT."/theme/phones/others/tpl/";
-		}
-    }
+        $dirt='others';     // default
 
-    /**
-     *  Show HTML header
-     *  @param      title   	Web page title
-     */
-    function smartheader($type='default')
-    {
-    	global $conf;
-
-    	if ($type == 'default') include_once($this->template_dir.'header.tpl.php');
-    }
+        if (preg_match('/android|blackberry|iphone|maemo/i',$phone))    // iWebKit template
+        {
+            $this->theme = 'default';
+            $dirt='smartphone';
+        }
+        elseif (file_exists(DOL_DOCUMENT_ROOT."/theme/phones/".$phone)) // Special template
+        {
+            $this->theme = 'default';
+            $dirt=$phone;
+        }
 
-	/**
-     *  Show HTML footer
-     */
-    function smartfooter()
-    {
-    	include_once($this->template_dir.'footer.tpl.php');
+        $this->phone=$phone;
+        $this->template_dir=DOL_DOCUMENT_ROOT.'/theme/phones/'.$dirt.'/tpl/';
     }
 
 	/**
@@ -96,7 +69,7 @@ class Smartphone {
     {
     	global $conf, $langs;
 
-    	if (! $conf->smart_menu)  $conf->smart_menu ='iphone_backoffice.php';
+    	if (! $conf->smart_menu)  $conf->smart_menu ='smartphone_backoffice.php';
     	$smart_menu=$conf->smart_menu;
     	if (GETPOST('top_menu')) $smart_menu=GETPOST('top_menu');
 
@@ -104,7 +77,7 @@ class Smartphone {
     	$result=@include_once(DOL_DOCUMENT_ROOT ."/includes/menus/smartphone/".$smart_menu);
     	if (! $result)	// If failed to include, we try with standard
     	{
-    		$conf->smart_menu='iphone_backoffice.php';
+    		$conf->smart_menu='smartphone_backoffice.php';
     		include_once(DOL_DOCUMENT_ROOT ."/includes/menus/smartphone/".$smart_menu);
     	}
     	$menusmart = new MenuSmart($this->db);
diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php
index 3e81c765cac2a28d5562df9c785c3a004d87449f..9fc34c51571c6e86a604b9dff39083fd894b676d 100644
--- a/htdocs/core/tpl/passwordforgotten.tpl.php
+++ b/htdocs/core/tpl/passwordforgotten.tpl.php
@@ -92,7 +92,7 @@ function donnefocus() {
 
 <?php if ($captcha) { ?>
 	<tr><td valign="middle" nowrap="nowrap"> &nbsp; <b><?php echo $langs->trans('SecurityCode'); ?></b></td>
-	<td valign="top" nowrap="nowrap" align="left" class="none">
+	<td valign="middle" nowrap="nowrap" align="left" class="none">
 
 	<table style="width: 100px;"><tr>
 	<td><input id="securitycode" class="flat" type="text" size="6" maxlength="5" name="code" tabindex="3"></td>
diff --git a/htdocs/includes/menus/init_menu_iphone.sql b/htdocs/includes/menus/init_menu_smartphone.sql
old mode 100644
new mode 100755
similarity index 100%
rename from htdocs/includes/menus/init_menu_iphone.sql
rename to htdocs/includes/menus/init_menu_smartphone.sql
diff --git a/htdocs/includes/menus/smartphone/iphone.lib.php b/htdocs/includes/menus/smartphone/smartphone.lib.php
old mode 100644
new mode 100755
similarity index 90%
rename from htdocs/includes/menus/smartphone/iphone.lib.php
rename to htdocs/includes/menus/smartphone/smartphone.lib.php
index 1fb1688cbc12e788177a2368b4542ab98a3f8aca..d9a64f4bd65e729320d39e794f5cb0cd244dce88
--- a/htdocs/includes/menus/smartphone/iphone.lib.php
+++ b/htdocs/includes/menus/smartphone/smartphone.lib.php
@@ -19,30 +19,30 @@
  */
 
 /**
- *  \file		htdocs/includes/menus/smartphone/iphone.lib.php
- *  \brief		Library for file iphone menus
+ *  \file		htdocs/includes/menus/smartphone/smartphone.lib.php
+ *  \brief		Library for file smartphone menus
  *  \version	$Id$
  */
 
 
 /**
- * Core function to output top menu iphone
+ * Core function to output top menu smartphone
  *
  * @param $db
  * @param $atarget
  * @param $type_user     0=Internal,1=External,2=All
  */
-function print_iphone_menu($db,$atarget,$type_user)
+function print_smartphone_menu($db,$atarget,$type_user)
 {
 	require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php");
 
 	global $user,$conf,$langs,$dolibarr_main_db_name;
-	
+
 	$submenus='';
 
-	$menutop = new Menubase($db,'iphone','top');
-	$menuleft = new Menubase($db,'iphone','left');
-	$tabMenu = $menutop->menuTopCharger($type_user, '', 'iphone');
+	$menutop = new Menubase($db,'smartphone','top');
+	$menuleft = new Menubase($db,'smartphone','left');
+	$tabMenu = $menutop->menuTopCharger($type_user, '', 'smartphone');
 	$numTabMenu = count($tabMenu);
 
 	print_start_menu_array();
@@ -64,12 +64,12 @@ function print_iphone_menu($db,$atarget,$type_user)
 					$title=$tabMenu[$i]['titre'];
 					// To remove & and special chars: $title=dol_string_unaccent(dol_string_nospecial(dol_html_entity_decode($tabMenu[$i]['titre'],ENT_QUOTES,'UTF-8'),'',array('&')));
 					print_text_menu_entry($title);
-					
+
 					$newmenu = new Menu();
-					$leftmenu = $menuleft->menuLeftCharger($newmenu,$tabMenu[$i]['mainmenu'],'',($user->societe_id?1:0),'iphone');
+					$leftmenu = $menuleft->menuLeftCharger($newmenu,$tabMenu[$i]['mainmenu'],'',($user->societe_id?1:0),'smartphone');
 					$menus = $leftmenu->liste;
 					//var_dump($menus);
-					
+
 					print '<ul>';
 					if (is_array($menus) && !empty($menus))
 					{
@@ -89,11 +89,11 @@ function print_iphone_menu($db,$atarget,$type_user)
 								print_text_menu_entry($title);
 								if (empty($menus[$j+1]['level'])) print '</a>';
 							}
-							
+
 							if ($menus[$j]['level'] > 0)
 							{
 								if ($menus[$j-1]['level'] == 0) print_start_submenu_array();
-								
+
 								$url=dol_buildpath($menus[$j]['url'],1);
 								$url=preg_replace('/&amp.*/i','',$url);
 								print_start_menu_entry();
@@ -103,10 +103,10 @@ function print_iphone_menu($db,$atarget,$type_user)
 								print_text_menu_entry($title);
 								print '</a>';
 								print_end_menu_entry();
-								
+
 								if (empty($menus[$j+1]['level'])) print_end_menu();
 							}
-							
+
 							if (empty($menus[$j+1]['level'])) print_end_menu_entry();
 						}
 					}
@@ -115,7 +115,7 @@ function print_iphone_menu($db,$atarget,$type_user)
 			}
 		}
 	}
-	
+
 	print_end_menu();
 	print "\n";
 }
diff --git a/htdocs/includes/menus/smartphone/iphone_backoffice.php b/htdocs/includes/menus/smartphone/smartphone_backoffice.php
old mode 100644
new mode 100755
similarity index 72%
rename from htdocs/includes/menus/smartphone/iphone_backoffice.php
rename to htdocs/includes/menus/smartphone/smartphone_backoffice.php
index b976eb44c6f822a7ec5d548f4a86f823f95afade..153437a7dcf53dbac853dee01da4749042b6a7f0
--- a/htdocs/includes/menus/smartphone/iphone_backoffice.php
+++ b/htdocs/includes/menus/smartphone/smartphone_backoffice.php
@@ -18,19 +18,19 @@
  */
 
 /**
- *		\file       htdocs/includes/menus/smartphone/iphone_backoffice.php
- *		\brief      Gestionnaire nomme iphone du menu smartphone
+ *		\file       htdocs/includes/menus/smartphone/smartphone_backoffice.php
+ *		\brief      Gestionnaire nomme smartphone du menu smartphone
  *		\version    $Id$
  */
 
 
 /**
  *      \class      MenuSmart
- *	    \brief      Class to manage smartphone menu Iphone (for internal users)
+ *	    \brief      Class to manage smartphone menu smartphone (for internal users)
  */
 class MenuSmart {
 
-	var $require_left=array("iphone_backoffice");     // Si doit etre en phase avec un gestionnaire de menu particulier
+	var $require_left=array("smartphone_backoffice");     // Si doit etre en phase avec un gestionnaire de menu particulier
 	var $hideifnotallowed=0;						// Put 0 for back office menu, 1 for front office menu
 	var $atarget="";                                // Valeur du target a utiliser dans les liens
 
@@ -50,9 +50,9 @@ class MenuSmart {
 	 */
 	function showmenu()
 	{
-		require_once(DOL_DOCUMENT_ROOT.'/includes/menus/smartphone/iphone.lib.php');
+		require_once(DOL_DOCUMENT_ROOT.'/includes/menus/smartphone/smartphone.lib.php');
 
-		print_iphone_menu($this->db,$this->atarget,$this->hideifnotallowed);
+		print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed);
 	}
 
 }
diff --git a/htdocs/includes/menus/smartphone/iphone_frontoffice.php b/htdocs/includes/menus/smartphone/smartphone_frontoffice.php
old mode 100644
new mode 100755
similarity index 73%
rename from htdocs/includes/menus/smartphone/iphone_frontoffice.php
rename to htdocs/includes/menus/smartphone/smartphone_frontoffice.php
index 125f1b3fddb9bc283298a2bb2fdec3fac7426023..ce1e39d64aab90c3ab29dd0eb839f16de22aba28
--- a/htdocs/includes/menus/smartphone/iphone_frontoffice.php
+++ b/htdocs/includes/menus/smartphone/smartphone_frontoffice.php
@@ -18,19 +18,19 @@
  */
 
 /**
- *	\file       htdocs/includes/menus/smartphone/iphone_frontoffice.php
- *	\brief      Gestionnaire nomme iphone du menu smartphone
+ *	\file       htdocs/includes/menus/smartphone/smartphone_frontoffice.php
+ *	\brief      Gestionnaire nomme smartphone du menu smartphone
  *	\version    $Id$
  */
 
 
 /**
  *      \class      MenuSmart
- *	    \brief      Class to manage smartphone menu Iphone (for external users)
+ *	    \brief      Class to manage smartphone menu smartphone (for external users)
  */
 class MenuSmart {
 
-	var $require_left=array("iphone_frontoffice");    // Si doit etre en phase avec un gestionnaire de menu particulier
+	var $require_left=array("smartphone_frontoffice");    // Si doit etre en phase avec un gestionnaire de menu particulier
 	var $hideifnotallowed=1;						// Put 0 for back office menu, 1 for front office menu
 	var $atarget="";                                // Valeur du target a utiliser dans les liens
 
@@ -50,9 +50,9 @@ class MenuSmart {
 	 */
 	function showmenu()
 	{
-		require_once(DOL_DOCUMENT_ROOT.'/includes/menus/smartphone/iphone.lib.php');
+		require_once(DOL_DOCUMENT_ROOT.'/includes/menus/smartphone/smartphone.lib.php');
 
-		print_iphone_menu($this->db,$this->atarget,$this->hideifnotallowed);
+		print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed);
 	}
 
 }
diff --git a/htdocs/index.php b/htdocs/index.php
index 48ed24812439891e8d964dc12446d4ba1c4c09f8..297836d9b5aa9d9dd63ca92bfdb9657aabd842d5 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -46,16 +46,6 @@ if (! isset($_GET["mainmenu"])) $_GET["mainmenu"]="home";
  * View
  */
 
-// Smartphone
-if (class_exists('Smartphone'))
-{
-	// Template directory
-	$smartphone->getTemplateDir();
-	$smartphone->title = $langs->trans("Home");
-	$smartphone->smartmenu();
-	exit;
-}
-
 // Check if company name is defined (first install)
 if (!isset($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_NOM))
 {
@@ -63,6 +53,18 @@ if (!isset($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_IN
 	exit;
 }
 
+
+// If smartphone mode, we do no show main page, we show only menu
+if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone))
+{
+    include_once(DOL_DOCUMENT_ROOT.'/core/class/smartphone.class.php');
+    $smartphone = new Smartphone($db,$conf->browser->phone);  // This class is only to know template dir according to phone type
+    $smartphone->title = $langs->trans("Home");
+    $smartphone->smartmenu();
+    exit;
+}
+
+
 llxHeader();
 
 print_fiche_titre($langs->trans("HomeArea"));
diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql
index 626788975b44bdd404a121f7d176ecb72d1bb620..acfd83d1396e7fb495a9fd9090f3f08cbe30f4df 100644
--- a/htdocs/install/mysql/data/llx_const.sql
+++ b/htdocs/install/mysql/data/llx_const.sql
@@ -62,8 +62,8 @@ insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_S
 
 insert into llx_const (name, value, type, note, visible) values ('MAIN_MENU_STANDARD','eldy_backoffice.php','chaine','Module de gestion de la barre de menu pour utilisateurs internes',0);
 insert into llx_const (name, value, type, note, visible) values ('MAIN_MENUFRONT_STANDARD','eldy_frontoffice.php','chaine','Module de gestion de la barre de menu pour utilisateurs externes',0);
-insert into llx_const (name, value, type, note, visible) values ('MAIN_MENU_SMARTPHONE','iphone_backoffice.php','chaine','Module de gestion de la barre de menu smartphone pour utilisateurs internes',0);
-insert into llx_const (name, value, type, note, visible) values ('MAIN_MENUFRONT_SMARTPHONE','iphone_frontoffice.php','chaine','Module de gestion de la barre de menu smartphone pour utilisateurs externes',0);
+insert into llx_const (name, value, type, note, visible) values ('MAIN_MENU_SMARTPHONE','eldy_backoffice.php','chaine','Module de gestion de la barre de menu smartphone pour utilisateurs internes',0);
+insert into llx_const (name, value, type, note, visible) values ('MAIN_MENUFRONT_SMARTPHONE','eldy_frontoffice.php','chaine','Module de gestion de la barre de menu smartphone pour utilisateurs externes',0);
 
 insert into llx_const (name, value, type, note, visible) values ('MAIN_THEME','eldy','chaine','Default theme',0);
 
diff --git a/htdocs/lib/security.lib.php b/htdocs/lib/security.lib.php
index d297804754d7ce052e76fb9af03e4169414c4e46..a1f178cfc6dbc0520865f76aeb68630f9bbafd71 100644
--- a/htdocs/lib/security.lib.php
+++ b/htdocs/lib/security.lib.php
@@ -57,10 +57,11 @@ function dol_loginfunction($langs,$conf,$mysoc)
 	if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
 
 	// Select templates
-	if (class_exists('Smartphone'))
+    if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone))
 	{
 		// Template directory
-		$smartphone->getTemplateDir();
+		include_once(DOL_DOCUMENT_ROOT.'/core/class/smartphone.class.php');
+		$smartphone = new Smartphone($db,$conf->browser->phone);  // This class is only to know template dir according to phone type
 		$smartphone->title = $title;
 		$template_dir = $smartphone->template_dir;
 	}
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 007295de3cf75ce166f49889b8394c410240c8fe..98b1c393cc3c04931e3f50f1e63579ae664cb9ca 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -264,14 +264,6 @@ if (sizeof($conf->need_smarty) > 0)
 	}
 }
 
-// Init Smartphone (for dev only)
-if ($conf->global->MAIN_FEATURES_LEVEL == 2 && isset($conf->browser->phone))
-{
-	include_once(DOL_DOCUMENT_ROOT."/core/class/smartphone.class.php");
-
-	$smartphone = new Smartphone($db);
-	$smartphone->phone = $conf->browser->phone;
-}
 
 /*
  * Phase authentication / login
@@ -666,23 +658,6 @@ if (! empty($_GET["theme"]))
 	$conf->css  = "/theme/".$conf->theme."/style.css.php";
 }
 
-// Define menu manager to use
-if (empty($user->societe_id))    // If internal user or not defined
-{
-	$conf->top_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED);
-	$conf->smart_menu=(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED);
-	// For backward compatibility
-    if ($conf->top_menu == 'eldy.php') $conf->top_menu='eldy_backoffice.php';
-	if ($conf->top_menu == 'rodolphe.php') $conf->top_menu='eldy_backoffice.php';
-}
-else                        // If external user
-{
-    $conf->top_menu=(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED);
-    $conf->smart_menu=(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED);
-	// For backward compatibility
-    if ($conf->top_menu == 'eldy.php') $conf->top_menu='eldy_frontoffice.php';
-	if ($conf->top_menu == 'rodolphe.php') $conf->top_menu='eldy_frontoffice.php';
-}
 
 if (! defined('NOLOGIN'))
 {
@@ -704,6 +679,7 @@ if (! defined('NOLOGIN'))
 	$user->getrights();
 }
 
+
 dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]);
 //Another call for easy debugg
 //dol_syslog("Access to ".$_SERVER["PHP_SELF"].' GET='.join(',',array_keys($_GET)).'->'.join(',',$_GET).' POST:'.join(',',array_keys($_POST)).'->'.join(',',$_POST));
@@ -770,8 +746,8 @@ if (! function_exists("llxHeader"))
 	{
 		top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);	// Show html headers
 		top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring);
-		left_menu('', $help_url, '', '', 1);
-		main_area();
+		left_menu('', $help_url, '', '', 1, $title);
+		main_area($title);
 	}
 }
 
@@ -1075,9 +1051,9 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
     // Show menu
     $menutop = new MenuTop($db);
 	$menutop->atarget=$target;
-	$menutop->showmenu();
+	$menutop->showmenu();      // This contains a \n
 
-	print "\n</div>\n";
+	print "</div>\n";
 
 	// Link to login card
 	$loginhtmltext=''; $logintext='';
@@ -1180,6 +1156,8 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
 	print "<!-- End top horizontal menu -->\n";
 
 	if (! $conf->use_javascript_ajax || ! $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print '<table width="100%" class="notopnoleftnoright" summary="leftmenutable" id="undertopmenu"><tr>';
+
+
 }
 
 
@@ -1192,16 +1170,15 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
  *  @param      moresearchform             Search Form Permanent Supplemental
  *  @param      menu_array_after           Table of menu entries to show after entries of menu handler
  *  @param      leftmenuwithoutmainarea    Must be set to 1. 0 by default for backward compatibility with old modules.
+ *  @param      title                      Title of web page
  */
-function left_menu($menu_array_before, $helppagename='', $moresearchform='', $menu_array_after='', $leftmenuwithoutmainarea=0)
+function left_menu($menu_array_before, $helppagename='', $moresearchform='', $menu_array_after='', $leftmenuwithoutmainarea=0, $title='')
 {
 	global $user, $conf, $langs, $db;
 
 	$searchform='';
 	$bookmarks='';
 
-	//    print '<div class="vmenuplusfiche">'."\n";
-
 	if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print "\n".'<div class="ui-layout-west"> <!-- Begin left layout -->'."\n";
 	else print '<td class="vmenu" valign="top">';
 
@@ -1262,7 +1239,7 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
 	}
 
     // Left column
-    print '<!-- Begin left vertical menu '.$left_menu.' -->'."\n";
+    print '<!-- Begin left area - menu '.$left_menu.' -->'."\n";
 
     print '<div class="vmenu">'."\n";
 
@@ -1351,17 +1328,19 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
 	if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print '</div> <!-- End left layout -->'."\n";
 	else print '</td>';
 
-	print "\n".'<!-- End of left column, begin right area -->'."\n\n";
-	//	    print '</div>'."\n";
-	//		print '<div class="vmenuplusfiche">'."\n";
+	print "\n";
+	print '<!-- End of left area -->'."\n";
+	print "\n";
+    print '<!-- Begin right area -->'."\n";
+
 
-	if (empty($leftmenuwithoutmainarea)) main_area();
+	if (empty($leftmenuwithoutmainarea)) main_area($title);
 }
 
 /**
  *  Begin main area
  */
-function main_area()
+function main_area($title='')
 {
 	global $conf, $langs;
 
@@ -1371,12 +1350,26 @@ function main_area()
 		print '<table width="100%" class="notopnoleftnoright" summary="centermenutable" id="undertopmenu"><tr>';
 	}
 
-	print '<td valign="top"><!-- Begin right area --> '."\n";
+	print '<td valign="top">'."\n";
 
 	print "\n";
 
 	print '<div class="fiche"> <!-- begin div class="fiche" -->'."\n";
-
+    if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone))
+    {
+        print '<div data-role="page"> <!-- begin div data-role="page" -->';
+
+        print '<div data-role="header" data-nobackbtn="false" data-theme="b">';
+        print '<div id="dol-homeheader">'."\n";
+        $appli='Dolibarr';
+        if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE;
+        print $appli;
+        print '</div>'."\n";
+        print '</div>'."\n";
+        print "\n";
+
+        print '<div data-role="content"> <!-- begin div data-role="content" -->'."\n";
+    }
 	if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) print info_admin($langs->trans("WarningYouAreInMaintenanceMode",$conf->global->MAIN_ONLY_LOGIN_ALLOWED));
 }
 
@@ -1420,12 +1413,12 @@ function getHelpParamFor($helppagename,$langs)
 
 
 /**
- *  \brief   Show a search area
- *  \param   urlaction          Url post
- *  \param   urlobject          Url of the link under the search box
- *  \param   title              Title search area
- *  \param   htmlmodesearch     'search'
- *  \param   htmlinputname      Field Name input form
+ *  Show a search area
+ *  @param   urlaction          Url post
+ *  @param   urlobject          Url of the link under the search box
+ *  @param   title              Title search area
+ *  @param   htmlmodesearch     'search'
+ *  @param   htmlinputname      Field Name input form
  */
 function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch='search',$htmlinputname)
 {
@@ -1448,6 +1441,7 @@ function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch='search',$
 /**
  *   Return list of login method of third party module.
  *   @return	array
+ *   TODO Move this into security.lib.php
  */
 function getLoginMethod()
 {
@@ -1500,9 +1494,9 @@ function getLoginMethod()
 }
 
 /**
- *		\brief   	Show HTML footer DIV + BODY + HTML
- *		\remarks	Close 2 div
- * 		\param   	foot    		A text to add in HTML generated page
+ *		Show HTML footer
+ *		Close div /DIV data-role=page + /DIV class=fiche + /DIV /DIV main layout + /BODY + /HTML
+ * 		@param   	foot    		A text to add in HTML generated page
  */
 if (! function_exists("llxFooter"))
 {
@@ -1529,12 +1523,19 @@ if (! function_exists("llxFooter"))
 			define("MAIN_CORE_ERROR",0);
 		}
 
-		print "\n\n".'</div> <!-- end div class="fiche" -->'."\n";
+        print "\n\n";
+        if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone))
+        {
+            print '</div> <!-- end div data-role="content" -->'."\n";
+            print '</div> <!-- end div data-role="page" -->'."\n";
+        }
+		print '</div> <!-- end div class="fiche" -->'."\n";
+
 
-		//    print "\n".'</div> <!-- end div class="vmenuplusfiche" -->'."\n";
 		print "\n".'</td></tr></table> <!-- end right area -->'."\n";
 		if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print '</div></div> <!-- end main layout -->'."\n";
 
+
 		if (! empty($_SERVER['DOL_TUNING']))
 		{
 			$micro_end_time=dol_microtime_float(true);
@@ -1562,6 +1563,7 @@ if (! function_exists("llxFooter"))
 			if (defined('XDEBUGCOVERAGE')) { var_dump(xdebug_get_code_coverage()); }
 		}
 
+
 		// If there is some logs in buffer to show
 		if (sizeof($conf->logbuffer))
 		{
@@ -1581,6 +1583,7 @@ if (! function_exists("llxFooter"))
 
 		if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n";
 
+
 		print "</body>\n";
 		print "</html>\n";
 	}
diff --git a/htdocs/public/error-401.php b/htdocs/public/error-401.php
index 1d98a248acab437b4507e9de87daa99132a74279..9648402e85b32d28f8f754435c8e5f0c583cf067 100644
--- a/htdocs/public/error-401.php
+++ b/htdocs/public/error-401.php
@@ -5,6 +5,16 @@
   </head>
 
   <body>
+
+    <div data-role="page">
+
+    <!-- <div data-role="header" data-theme="b">
+            <h1>Introduction</h1>
+            <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
+        </div>
+    -->
+    <div data-role="content">
+
     <h1>Error</h1>
 
     <br>
@@ -14,5 +24,9 @@
     <?php print isset($_SERVER["HTTP_REFERER"])?'You come from '.$_SERVER["HTTP_REFERER"].'.':''; ?>
 
     <hr>
+
+    </div>
+    </div>
+
   </body>
 </html>
diff --git a/htdocs/public/error-404.php b/htdocs/public/error-404.php
index ed5fafd01b62db9e393d86bb7f018dab3f2701bd..851401f07e8c7d3c2a3d987868d5d0f4d75771c4 100644
--- a/htdocs/public/error-404.php
+++ b/htdocs/public/error-404.php
@@ -5,6 +5,16 @@
   </head>
 
   <body>
+
+    <div data-role="page">
+
+    <!-- <div data-role="header" data-theme="b">
+            <h1>Introduction</h1>
+            <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
+        </div>
+    -->
+    <div data-role="content">
+
     <h2>Error</h2>
 
     <br>
@@ -14,5 +24,9 @@
     <?php print isset($_SERVER["HTTP_REFERER"])?'You come from '.$_SERVER["HTTP_REFERER"].'.':''; ?>
 
     <hr>
+
+    </div>
+    </div>
+
   </body>
 </html>
diff --git a/htdocs/theme/phones/smartphone/theme/default/default.css.php b/htdocs/theme/phones/smartphone/theme/default/default.css.php
index 501eae52c543d600303afb1aa6f2424365fbd799..968254b675e9b0b386560b80dd1ba47e0c7228d4 100644
--- a/htdocs/theme/phones/smartphone/theme/default/default.css.php
+++ b/htdocs/theme/phones/smartphone/theme/default/default.css.php
@@ -43,9 +43,12 @@ else header('Cache-Control: no-cache');
 
 ?>
 
+#dol-homeheader { height: 40px; font-size: 16px; }
+.ui-header { height: 40px; font-size: 16px; }
+
 /*.ui-mobile #dol-home {  background: #e5e5e5 url(<?php echo DOL_URL_ROOT.'/theme/phones/smartphone/theme/default/menu/pinstripes.png'; ?>) top center repeat-x; }*/
 .ui-mobile #dol-home {  background: #e5e5e5 }
-.ui-mobile #dol-homeheader { padding: 5px 5px 0; text-align: center }
+.ui-mobile #dol-homeheader { padding: 10px 5px 0; text-align: center }
 .ui-mobile #dol-homeheader h1 { margin: 0 0 10px; }
 .ui-mobile #dol-homeheader p { margin: 0; }
 
diff --git a/htdocs/theme/phones/smartphone/tpl/header.tpl.php b/htdocs/theme/phones/smartphone/tpl/header.tpl.php
index 60187c99d711a550bfd7a3210f8ae8d4e134053d..fa4fa414a086b45ff300be530e84746598695edf 100644
--- a/htdocs/theme/phones/smartphone/tpl/header.tpl.php
+++ b/htdocs/theme/phones/smartphone/tpl/header.tpl.php
@@ -17,21 +17,15 @@
  *
  * $Id$
  */
-header('Cache-Control: Public, must-revalidate');
 header("Content-type: text/html; charset=".$conf->file->character_set_client);
 ?>
-
 <!DOCTYPE html>
-
-<!-- BEGIN HEADER SMARTPHONE TEMPLATE -->
-
 <html>
-
 <head>
-<title><?php echo $this->title; ?></title>
+<title><?php echo $title; ?></title>
 <meta name="robots" content="noindex,nofollow" />
 <meta name="apple-mobile-web-app-capable" content="yes" />
-<link rel="apple-touch-icon" href="<?php echo DOL_URL_ROOT.'/theme/phones/smartphone/theme/'.$this->theme.'/thumbs/homescreen.png'; ?>" />
+<link rel="apple-touch-icon" href="<?php echo DOL_URL_ROOT.'/theme/phones/smartphone/theme/'.$conf->theme.'/img/homescreen.png'; ?>" />
 <link rel="stylesheet" href="<?php echo DOL_URL_ROOT.'/includes/jquery/mobile/jquery.mobile-latest.min.css'; ?>" />
 <link rel="stylesheet" href="<?php echo DOL_URL_ROOT.'/theme/phones/smartphone/theme/default/default.css.php'; ?>" />
 <script type="text/javascript" src="<?php echo DOL_URL_ROOT.'/includes/jquery/js/jquery-latest.min.js'; ?>"></script>
@@ -40,4 +34,4 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
 
 <body>
 
-<!-- END HEADER SMARTPHONE TEMPLATE -->
\ No newline at end of file
+<!-- END HEADER SMARTPHONE TEMPLATE -->
diff --git a/htdocs/theme/phones/smartphone/tpl/login.tpl.php b/htdocs/theme/phones/smartphone/tpl/login.tpl.php
index 9f37956ffbfbe4866ade34b2cfe0deea4b4bc130..23c8f33868bcb581874e91acda0335e1aecc2d24 100644
--- a/htdocs/theme/phones/smartphone/tpl/login.tpl.php
+++ b/htdocs/theme/phones/smartphone/tpl/login.tpl.php
@@ -17,67 +17,71 @@
  *
  * $Id$
  */
-$smartphone->smartheader();
+include('header.tpl.php');
 ?>
 
 <!-- START LOGIN SMARTPHONE TEMPLATE -->
-
 <div data-role="page" id="dol-home" data-theme="b">
 
 	<div data-role="header" data-nobackbtn="true" data-theme="b">
-		<div id="dol-homeheader">
-			<img src="<?php echo $dol_url_root.'/theme/phones/smartphone/theme/'.$smartphone->theme.'/img/dolibarr.png'; ?>">
-		</div>
+        <div id="dol-homeheader">
+        <?php
+        $appli='Dolibarr';
+        if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE;
+        print $appli;
+        ?>
+        </div>
 	</div>
 
 	<div data-role="content">
-	
+
 		<form id="login" name="login" method="post" action="<?php echo $php_self; ?>">
 		<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
 		<input type="hidden" name="loginfunction" value="loginfunction" />
-		
+
 		<div data-role="fieldcontain">
 			<label for="username"><?php echo $langs->trans('Login'); ?></label>
 			<input type="text" name="username" id="username" value="<?php echo $login; ?>"  />
-			
+
 			<br><label for="password"><?php echo $langs->trans('Password'); ?></label>
 			<input type="password" name="password" id="password" value="<?php echo $password; ?>" />
-			
+
 			<?php if ($select_entity) { ?>
 			<br><label for="entity" class="select"><?php echo $langs->trans('Entity'); ?></label>
 			<?php echo $select_entity; ?>
 			<?php } ?>
-			
+
 			<?php if ($captcha) { ?>
 			<label for="securitycode"><?php echo $langs->trans('SecurityCode'); ?></label>
 			<input type="text" id="securitycode" name="securitycode" />
 			<div align="center"><img src="<?php echo $dol_url_root.'/lib/antispamimage.php'; ?>" border="0" width="128" height="36" /></div>
 			<?php } ?>
 		</div>
-		
+
 		<input type="submit" data-theme="b" value="<?php echo $langs->trans('Connection'); ?>" />
-		
+
 		</form><br>
 
 	</div><!-- /content -->
-	
+
 	<?php if ($forgetpasslink || $helpcenterlink) { ?>
 	<div data-role="footer" data-id="foo1" data-theme="b">
 		<div data-role="navbar">
 			<ul>
-
+			<li>
 		<?php if ($forgetpasslink) { ?>
-			<li><a href="<?php echo 'user/passwordforgotten.php'; ?>" data-icon="gear"><?php echo $langs->trans('PasswordForgotten'); ?></a></li>
+			<a href="<?php echo $dol_url_root.'/user/passwordforgotten.php'; ?>" data-icon="gear"><?php echo $langs->trans('PasswordForgotten'); ?></a>
 		<?php } ?>
-		
-		<?php if ($helpcenterlink) { ?>
-			<li><a href="<?php echo 'support/index.php'; ?>" data-icon="info"><?php echo $langs->trans('NeedHelpCenter'); ?></a></li>
-		<?php } ?>
-			</ul>
-		</div><!-- /navbar -->
-	</div><!-- /footer -->
+            </li>
+            <li>
+        <?php if ($helpcenterlink && 1 == 2) { ?>
+            <a href="<?php echo $dol_url_root.'/support/index.php'; ?>" data-icon="info"><?php echo $langs->trans('NeedHelpCenter'); ?></a>
+        <?php } ?>
+            </li>
+        	</ul>
+		</div>
+	</div>
 	<?php } ?>
-
 </div><!-- /page -->
 
 <?php if ($dol_loginmesg) { ?>
@@ -85,7 +89,8 @@ $smartphone->smartheader();
 		alert('<?php echo $dol_loginmesg; ?>');
 	</script>
 <?php } ?>
-
 <!-- END LOGIN SMARTPHONE TEMPLATE -->
 
-<?php $smartphone->smartfooter(); ?>
\ No newline at end of file
+<?php
+include('footer.tpl.php');
+?>
\ No newline at end of file
diff --git a/htdocs/theme/phones/smartphone/tpl/menu.tpl.php b/htdocs/theme/phones/smartphone/tpl/menu.tpl.php
index 2d55bd8e41208789cbb654ea144ff5e39ec4898e..1f96e88b8e1dec09555ff5e3e73064caa135e550 100644
--- a/htdocs/theme/phones/smartphone/tpl/menu.tpl.php
+++ b/htdocs/theme/phones/smartphone/tpl/menu.tpl.php
@@ -17,25 +17,33 @@
  *
  * $Id$
  */
-$this->smartheader();
+require('header.tpl.php');
 ?>
+<div data-role="page" data-theme="b" id="dol-home">
 
-<!-- START MENU SMARTPHONE TEMPLATE -->
-
-<div data-role="page" id="dol-home">
-	
 	<div data-role="header" data-nobackbtn="true" data-theme="b">
 		<div id="dol-homeheader">
-			<img src="<?php echo DOL_URL_ROOT.'/theme/phones/smartphone/theme/'.$this->theme.'/img/dolibarr.png'; ?>">
+            <?php
+            $appli='Dolibarr';
+            if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE;
+            print $appli;
+            ?>
 		</div>
 	</div>
 
-	<div data-role="content">
+    <div data-role="content">
+<!--
+        <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">
+            <li data-role="list-divider">Overview</li>
+            <li><a href="http://jquerymobile.com/test/docs/about/intro.html">Intro to jQuery Mobile</a></li>
+            <li><a href="http://localhost/dolibarrnew/public/error-401.php">Features</a></li>
+        </ul>
+-->
 
 	<?php $menusmart->showmenu(); ?>
-	
+
 	</div><!-- /content -->
-	
+
 	<div data-role="footer" data-theme="b">
 		<div data-role="navbar">
 			<ul>
@@ -44,9 +52,12 @@ $this->smartheader();
 			</ul>
 		</div><!-- /navbar -->
 	</div><!-- /footer -->
-	
+
 </div><!-- /page -->
 
 <!-- END MENU SMARTPHONE TEMPLATE -->
 
-<?php $this->smartfooter(); ?>
\ No newline at end of file
+<?php
+require('footer.tpl.php');
+// $this->smartfooter();
+?>
\ No newline at end of file
diff --git a/htdocs/theme/phones/smartphone/tpl/passwordforgotten.tpl.php b/htdocs/theme/phones/smartphone/tpl/passwordforgotten.tpl.php
index 17ceabdce2c225f3418dc5c43154c36687ac39b0..37c3957293f2b8489376800126945ec245267550 100644
--- a/htdocs/theme/phones/smartphone/tpl/passwordforgotten.tpl.php
+++ b/htdocs/theme/phones/smartphone/tpl/passwordforgotten.tpl.php
@@ -17,7 +17,7 @@
  *
  * $Id$
  */
-$smartphone->smartheader();
+include('header.tpl.php');
 ?>
 
 <!-- BEGIN SMARTPHONE TEMPLATE -->
@@ -25,37 +25,39 @@ $smartphone->smartheader();
 <div data-role="page" id="dol-home" data-theme="b">
 
 	<div data-role="header" data-theme="b" data-position="inline">
-			<h1><?php echo $langs->trans('Identification'); ?></h1>
+			<div id="dol-homeheader">
+			<?php echo $langs->trans('Identification'); ?>
+			</div>
 	</div>
 
 	<div data-role="content">
-	
+
 		<form id="login" name="login" method="post" action="<?php echo $php_self; ?>">
 		<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
 		<input type="hidden" name="loginfunction" value="buildnewpassword" />
-		
+
 		<div data-role="fieldcontain">
 			<label for="username"><?php echo $langs->trans('Login'); ?></label>
 			<input type="text" name="username" id="username" value="<?php echo $login; ?>"  />
-			
+
 			<?php if ($select_entity) { ?>
 			<label for="entity" class="select"><?php echo $langs->trans('Entity'); ?></label>
 			<?php echo $select_entity; ?>
 			<?php } ?>
-			
+
 			<?php if ($captcha) { ?>
 			<label for="securitycode"><?php echo $langs->trans('SecurityCode'); ?></label>
 			<input type="text" id="securitycode" name="securitycode" />
 			<div align="center"><img src="<?php echo $dol_url_root.'/lib/antispamimage.php'; ?>" border="0" width="256" height="48" /></div>
 			<?php } ?>
 		</div>
-		
+
 		<input type="submit" data-theme="b" value="<?php echo $langs->trans('SendByMail'); ?>" />
-		
+
 		</form>
 
 	</div><!-- /content -->
-	
+
 	<div data-role="footer" data-theme="b">
 		<?php if ($mode == 'dolibarr' || ! $disabled) {
 			echo $langs->trans('SendNewPasswordDesc');
@@ -74,4 +76,6 @@ $smartphone->smartheader();
 
 <!-- END SMARTPHONE TEMPLATE -->
 
-<?php $smartphone->smartfooter(); ?>
\ No newline at end of file
+<?php
+include('footer.tpl.php');
+?>
\ No newline at end of file
diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php
index 6b65b1163cd605843f4c0a339954ce1b4bc6f59e..19d62a1141e26128f8e49eba3c5ab27684bf7d5d 100644
--- a/htdocs/user/passwordforgotten.php
+++ b/htdocs/user/passwordforgotten.php
@@ -151,10 +151,10 @@ $title='Dolibarr '.DOL_VERSION;
 if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
 
 // Select templates
-if (class_exists('Smartphone'))
+if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone))
 {
-	// Template directory
-	$smartphone->getTemplateDir();
+    include_once(DOL_DOCUMENT_ROOT.'/core/class/smartphone.class.php');
+    $smartphone = new Smartphone($db,$conf->browser->phone);  // This class is only to know template dir according to phone type
 	$smartphone->title = $title;
 	$template_dir = $smartphone->template_dir;
 }
@@ -215,7 +215,7 @@ if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $rowspan++;
 if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)  && ! $disabled)
 {
 	global $db;
-	
+
 	$res=dol_include_once('/multicompany/class/actions_multicompany.class.php');
 	if ($res)
 	{