Index: /trunk/plugins/language_switch/default.css
===================================================================
--- /trunk/plugins/language_switch/default.css	(revision 15923)
+++ /trunk/plugins/language_switch/default.css	(revision 15923)
@@ -0,0 +1,14 @@
+#languageSwitchBox {
+	padding: 0.5em 5px;
+	border-radius: 4px;
+	z-index: 100;
+	text-align:left;
+	display: none;
+	position: absolute;
+	left: 0; top: 0; /*left, right set through js*/
+}
+
+#languageSwitchBox .switchBoxTitle {
+  padding-bottom:5px;
+  margin-bottom:5px;
+}
Index: /trunk/plugins/language_switch/flags.tpl
===================================================================
--- /trunk/plugins/language_switch/flags.tpl	(revision 15922)
+++ /trunk/plugins/language_switch/flags.tpl	(revision 15923)
@@ -1,50 +1,36 @@
-</ul>
-<ul class="categoryActions">
-<li class="menuf">
-  <div>
-    <ul>
-      <li>
-        <a rel="nofollow" href="#" class="activeFlag">
-          <img class="flags" src="{$lang_switch.Active.img}" alt="{$lang_switch.Active.alt}" title="{$lang_switch.Active.alt}"/>
-        </a>
-<!--[if lte IE 6]>
-        <a rel="nofollow" href="#">
-          <img class="flags" src="{$lang_switch.Active.img}" alt="{$lang_switch.Active.alt}" title="{$lang_switch.Active.alt}"/>
-          <table>
-            <tr>
-              <td>
-<![endif]-->
-        <ul class="flag-pan">
-         <li class="languageSwitchBoxTitle">{'Language'|@translate}</li>
+<li>{strip}<a id="languageSwitchLink" title="{'Language'|@translate}" class="pwg-state-default pwg-button" rel="nofollow">
+  <span class="pwg-icon" style="background:url('{$lang_switch.Active.img}') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">{'Language'|@translate}</span>
+</a>
+<div id="languageSwitchBox" class="switchBox">
+  <div class="switchBoxTitle">{'Language'|@translate}</div> 
+  {foreach from=$lang_switch.flags item=flag name=f}
+  <a rel="nofollow" href="{$flag.url}"><img class="flags" src="{$flag.img}" alt="{$flag.alt}"> {$flag.title}</a>
+  {if ($smarty.foreach.f.index+1)%3 == 0}<br>{/if}
+  {/foreach}
+</div>
+{/strip}</li>
 
-{foreach from=$lang_switch.flags key=code item=flag name=f}
-          <li>
-            <a rel="nofollow" href="{$flag.url}">
-              <img class="flags" src="{$flag.img}" alt="{$flag.alt}" title="{$flag.alt}"/> {$flag.title}
-            </a>
-          </li>
-{/foreach}
+{footer_script require='jquery'}{literal}
+jQuery("#languageSwitchLink").click(function() {
+	var elt = jQuery("#languageSwitchBox");
+	elt.css("left", Math.min(jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
+		.css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
+		.toggle();
+});
+jQuery("#languageSwitchBox").on("mouseleave", function() {
+	jQuery(this).hide();
+});
+{/literal}{/footer_script}
 
-        </ul>
-<!--[if lte IE 6]>
-              </td>
-            </tr>
-          </table>
-        </a>
-<![endif]-->
-      </li>
-    </ul>
-  </div>
-</li>
-
-{combine_css path="plugins/language_switch/language_switch-default.css"}
-
-{if $themeconf.name eq 'Sylvia'}
-{combine_css path="plugins/language_switch/language_switch-Sylvia.css"}
+{* <!-- switchBox structure for theme which don't include default style --> *}
+{if $themeconf.parent != 'default' or (isset($themeconf.load_parent_local_head) and $themeconf.load_parent_local_head == false) }
+{combine_css path=$LANGUAGE_SWITCH_PATH|@cat:"default.css"}
 {/if}
 
-{html_head}
-<!--[if lte IE 6]>
-<link rel="stylesheet" type="text/css" href="{$ROOT_URL}plugins/language_switch/language_switch-ie6.css">
-<![endif]-->
-{/html_head}
+{* <!-- stylish for non core themes (should be removed when all themes are updated) --> *}
+{if $themeconf.name != 'clear' and $themeconf.name != 'dark' and $themeconf.name != 'elegant' and $themeconf.name != 'Sylvia'}
+{combine_css path=$LANGUAGE_SWITCH_PATH|@cat:"style.css"}
+{/if}
+
+{* <!-- common style specific for LanguageSwitch --> *}
+{combine_css path=$LANGUAGE_SWITCH_PATH|@cat:"language_switch.css"}
Index: unk/plugins/language_switch/language_switch-Sylvia.css
===================================================================
--- /trunk/plugins/language_switch/language_switch-Sylvia.css	(revision 15922)
+++ 	(revision )
@@ -1,7 +1,0 @@
-.flag-pan { border:1px solid; background-color: #111; }
-.content ul.categoryActions .flag-pan a:hover {color:#ddd}
-.menuf .flags {border-color: #000 !important; }
-
-.flag-pan { 	border-radius: 8px; } /* round corners with CSS3 compliant browsers */
-.flag-pan { -moz-border-radius:8px; } 
-.flag-pan { -webkit-border-radius: 8px; }
Index: unk/plugins/language_switch/language_switch-default.css
===================================================================
--- /trunk/plugins/language_switch/language_switch-default.css	(revision 15922)
+++ 	(revision )
@@ -1,19 +1,0 @@
-.flag-pan { width:380px; z-index:100; border:2px solid #CDCDCD; background-color: #f0f0f0; padding: 2px 5px 10px 5px; }
-.languageSwitchBoxTitle {display:block;width:370px;text-align:center;margin:5px auto;font-weight:bold;color:#464646;}
-.content ul.categoryActions .flag-pan a img.flags { margin-bottom: -2px; }
-.content ul.categoryActions .flag-pan a { margin: 0; border:none; color:#464646;}
-.content ul.categoryActions .flag-pan a:hover {color:black}
-.menuf { width:30px; height:24px; display: inline; } 
-.menuf ul li a, .menuf ul li a:visited {display:block; text-decoration:none; width:120px; height:27px; text-align:left; line-height:27px; overflow:hidden; border:none}
-.menuf ul {padding:0; margin:0; list-style: none;}
-.menuf ul li {float:left; position:relative; right:0; top:0; margin-left:5px}
-.menuf ul li ul {display: none;}/* specific to non IE browsers */
-.menuf li a:hover { border:1px dotted #464646}
-.menuf .flags {border:1px solid #ddd !important; margin-top:5px; }
-.menuf ul li:hover ul {display:block; position:absolute; top:0px; right:0px; }
-.menuf ul li:hover ul li ul {display: none;}
-.menuf ul li:hover ul li {display: block;}
-.menuf ul li:hover ul li a {display:block;}
-.menuf ul li:hover ul li:hover ul {display:block; position:absolute; left:0px; top:0;}
-
-.menuf ul li a.activeFlag, .menuf ul li a.activeFlag:visited {width:30px;}
Index: unk/plugins/language_switch/language_switch-ie6.css
===================================================================
--- /trunk/plugins/language_switch/language_switch-ie6.css	(revision 15922)
+++ 	(revision )
@@ -1,6 +1,0 @@
-.menuf ul li a.hide, .menuf ul li a:visited.hide {display:none;}
-.menuf ul li a:hover ul li a.hide {display:none;}
-.menuf ul li a:hover ul { display:block; position:absolute; top:-15%; left:-85%; }
-.menuf ul li a:hover ul li a {display:block; }
-.menuf ul li a:hover ul li a ul {visibility:hidden;}
-.menuf ul li a:hover ul li a:hover ul {visibility:visible; position:absolute; left:105px; top:0;}
Index: /trunk/plugins/language_switch/language_switch.css
===================================================================
--- /trunk/plugins/language_switch/language_switch.css	(revision 15923)
+++ /trunk/plugins/language_switch/language_switch.css	(revision 15923)
@@ -0,0 +1,7 @@
+#languageSwitchBox a {
+  display:inline-block;
+  width:130px;
+  text-decoration:none;
+  border:none;
+  text-transform:none;
+}
Index: /trunk/plugins/language_switch/language_switch.inc.php
===================================================================
--- /trunk/plugins/language_switch/language_switch.inc.php	(revision 15922)
+++ /trunk/plugins/language_switch/language_switch.inc.php	(revision 15923)
@@ -22,133 +22,109 @@
 // +-----------------------------------------------------------------------+
 
-if (!defined('LANGUAGE_SWITCH_PATH'))
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+function language_controler_switch()
 {
-  define('LANGUAGE_SWITCH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
-}
+  global $user;
+    
+  $same = $user['language'];
+  
+  if (isset($_GET['lang']))
+  {
+    include_once(PHPWG_ROOT_PATH . 'admin/include/languages.class.php');
+    $languages = new languages();
+    if ( !in_array($_GET['lang'], array_keys($languages->fs_languages)) )
+    {
+      $_GET['lang'] = PHPWG_DEFAULT_LANGUAGE;
+    }
 
-class language_controler
-{
-  static public function _switch()
-  {
-    global $user;
-    
-    if (!defined('PHPWG_ROOT_PATH'))
+    if ( !empty($_GET['lang']) and file_exists(PHPWG_ROOT_PATH.'language/'.$_GET['lang'].'/common.lang.php') )
     {
-      die('Hacking attempt!');
-    }
-    
-    $same = $user['language'];
-    
-    if (isset($_GET['lang']))
-    {
-      include_once(PHPWG_ROOT_PATH . 'admin/include/languages.class.php');
-      $languages = new languages();
-      if (!in_array($_GET['lang'], array_keys($languages->fs_languages)))
+      if ( is_a_guest() or is_generic() )
       {
-        $_GET['lang'] = PHPWG_DEFAULT_LANGUAGE;
+        pwg_set_session_var('lang_switch', $_GET['lang']);
       }
-
-      if (!empty($_GET['lang']) and file_exists(PHPWG_ROOT_PATH.'language/'.$_GET['lang'].'/common.lang.php'))
+      else
       {
-        if (is_a_guest() or is_generic())
-        {
-          pwg_set_session_var('lang_switch', $_GET['lang']);
-        }
-        else
-        {
-          $query = '
+        $query = '
 UPDATE '.USER_INFOS_TABLE.'
   SET language = \''.$_GET['lang'].'\'
   WHERE user_id = '.$user['id'].'
 ;';
-          pwg_query($query);
-        }
-        
-        $user['language'] = $_GET['lang'];
+        pwg_query($query);
       }
+      
+      $user['language'] = $_GET['lang'];
     }
-    elseif ((is_a_guest() or is_generic()))
+  }
+  elseif ( (is_a_guest() or is_generic()) )
+  {
+    $user['language'] = pwg_get_session_var('lang_switch', $user['language']);
+  }
+  
+  // Reload language only if it isn't the same one
+  if ( $same !== $user['language'] )
+  {
+    load_language('common.lang', '', array('language'=>$user['language']));
+    
+    load_language(
+      'lang',
+      PHPWG_ROOT_PATH.PWG_LOCAL_DIR,
+      array(
+        'language' => $user['language'],
+        'no_fallback' => true,
+        'local' => true
+        )
+      );
+    
+    if ( defined('IN_ADMIN') and IN_ADMIN )
     {
-      $user['language'] = pwg_get_session_var('lang_switch', $user['language']);
+      // Never currently
+      load_language('admin.lang', '', array('language'=>$user['language']));
     }
+  }
+}
+
+function language_controler_flags()
+{
+  global $user, $template, $conf;
+  
+  $available_lang = get_languages();
+  
+  if (isset($conf['no_flag_languages']))
+  {
+    $available_lang = array_diff_key($available_lang, array_flip($conf['no_flag_languages']));
+  }
+  
+  $url_starting = get_query_string_diff(array('lang'));
+
+  foreach ($available_lang as $code => $displayname)
+  {
+    $qlc = array (
+      'url' => add_url_params(duplicate_index_url(), array('lang'=> $code)),
+      'alt' => ucwords($displayname),
+      'title' => substr($displayname, 0, -4), // remove [FR] or [RU]
+      'img' => get_root_url().'language/'.$code.'/'.$code.'.jpg',
+      );
     
-    // Reload language only if it isn't the same one
-    if ( $same !== $user['language'])
+    $lsw['flags'][$code] = $qlc;
+    
+    if ($code == $user['language'])
     {
-      load_language('common.lang', '', array('language'=>$user['language']));
-      
-      load_language(
-        'lang',
-        PHPWG_ROOT_PATH.PWG_LOCAL_DIR,
-        array(
-          'language' => $user['language'],
-          'no_fallback' => true,
-          'local' => true
-          )
-        );
-      
-      if (defined('IN_ADMIN') and IN_ADMIN)
-      {
-        // Never currently
-        load_language('admin.lang', '', array('language'=>$user['language']));
-      }
+      $lsw['Active'] = $qlc;
     }
   }
   
-  static public function _flags()
-  {
-    global $user, $template, $conf;
-    
-    $available_lang = get_languages();
-    
-    if (isset($conf['no_flag_languages']))
-    {
-      $available_lang = array_diff_key($available_lang, array_flip($conf['no_flag_languages']));
-    }
-    
-    $url_starting = get_query_string_diff(array('lang'));
-
-    foreach ($available_lang as $code => $displayname)
-    {
-      $qlc = array (
-        'url' => add_url_params(duplicate_index_url(), array('lang'=> $code)),
-        'alt' => ucwords($displayname),
-        'title' => substr($displayname, 0, -4), // remove [FR] or [RU]
-        'img' => get_root_url().'language/'.$code.'/'.$code.'.jpg',
-        );
-      
-      $lsw['flags'][$code] = $qlc ;
-      
-      if ($code == $user['language'])
-      {
-        $lsw['Active'] = $qlc;
-      }
-    }
-    
-    $template->set_filename('language_flags', dirname(__FILE__) . '/flags.tpl');
-    
-    $lsw['side'] = ceil(sqrt(count($available_lang)));
-    
-    $template->assign(
-      array(
-        'lang_switch'=> $lsw,
-        'LANGUAGE_SWITCH_PATH' => LANGUAGE_SWITCH_PATH,
-        )
-      );
-    
-    $flags = $template->parse('language_flags',true);
-    $template->clear_assign('lang_switch');
-    $template->concat( 'PLUGIN_INDEX_ACTIONS', $flags);
-  }
-}
-
-  /* {html_head} usage function */
-  /* See flags.tpl for example (due no catenation available) */
-if (!function_exists('Componant_exists'))
-{
-  function Componant_exists($path, $file)
-  {
-    return file_exists( $path . $file);
-  }
+  $template->set_filename('language_flags', dirname(__FILE__) . '/flags.tpl');
+  
+  $template->assign(
+    array(
+      'lang_switch'=> $lsw,
+      'LANGUAGE_SWITCH_PATH' => LANGUAGE_SWITCH_PATH,
+      )
+    );
+  
+  $template->concat('PLUGIN_INDEX_ACTIONS', $template->parse('language_flags', true) );
+  $template->clear_assign('lang_switch');
 }
 
Index: /trunk/plugins/language_switch/main.inc.php
===================================================================
--- /trunk/plugins/language_switch/main.inc.php	(revision 15922)
+++ /trunk/plugins/language_switch/main.inc.php	(revision 15923)
@@ -24,5 +24,5 @@
 /*
 Plugin Name: Language Switch
-Version: 2.3.0
+Version: 2.4.0
 Description: Switch to another language from flags on your gallery home page.
 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=123
@@ -31,7 +31,12 @@
 */
 
-include_once(PHPWG_PLUGINS_PATH.'language_switch/language_switch.inc.php');
-$language_controler = new language_controler();
-add_event_handler('loading_lang', array(&$language_controler, '_switch'), 5 );
-add_event_handler('loc_end_index', array(&$language_controler, '_flags'), 95 );
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+define('LANGUAGE_SWITCH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+
+include_once(LANGUAGE_SWITCH_PATH.'language_switch.inc.php');
+
+add_event_handler('loading_lang', 'language_controler_switch', 5 );
+add_event_handler('loc_end_index', 'language_controler_flags', 95 );
+
 ?>
Index: /trunk/plugins/language_switch/style.css
===================================================================
--- /trunk/plugins/language_switch/style.css	(revision 15923)
+++ /trunk/plugins/language_switch/style.css	(revision 15923)
@@ -0,0 +1,14 @@
+#languageSwitchBox {
+  background-color: #555;
+  border: 1px solid #000;
+}
+
+#languageSwitchBox .switchBoxTitle {
+  border-bottom: 1px solid #444;
+}
+#languageSwitchBox a {
+  color:#aaa;
+}
+#languageSwitchBox a:hover {
+  color:#ddd;
+}
