Index: /extensions/header_manager/admin.php
===================================================================
--- /extensions/header_manager/admin.php	(revision 17643)
+++ /extensions/header_manager/admin.php	(revision 17644)
@@ -5,27 +5,16 @@
 load_language('plugin.lang', HEADER_MANAGER_PATH);
 
-if (!file_exists(HEADER_MANAGER_DIR)) 
-{
-  mkdir(HEADER_MANAGER_DIR, 0755);
-}
-
 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : 'config';
 
-if ($page['tab'] == 'album')
-{
-  include(HEADER_MANAGER_PATH . 'admin/album.php');
-}
-else
+if ($page['tab'] != 'album')
 {
   // tabsheet
   include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');    
   $tabsheet = new tabsheet();
+  $tabsheet->set_id('header_manager');
   $tabsheet->add('config', l10n('Configuration'), HEADER_MANAGER_ADMIN . '-config');
   $tabsheet->add('add', l10n('Add a banner'), HEADER_MANAGER_ADMIN . '-add');
   $tabsheet->select($page['tab']);
   $tabsheet->assign();
-
-  // include page
-  include(HEADER_MANAGER_PATH . 'admin/' . $page['tab'] . '.php');
 
   // template
@@ -36,4 +25,7 @@
 }
 
+// include page
+include(HEADER_MANAGER_PATH . 'admin/' . $page['tab'] . '.php');
+
 $template->assign('HEADER_MANAGER_PATH', HEADER_MANAGER_PATH);
 
Index: /extensions/header_manager/admin/template/config.tpl
===================================================================
--- /extensions/header_manager/admin/template/config.tpl	(revision 17643)
+++ /extensions/header_manager/admin/template/config.tpl	(revision 17644)
@@ -36,5 +36,5 @@
   {if $banners}
     <div class="banner-radio" style="display:block;">
-      <input type="radio" name="image" value="random" id="banner-random"{if $BANNER_IMAGE=='random'}checked="checked"{/if}>
+      <input type="radio" name="image" value="random" id="banner-random" {if $BANNER_IMAGE=='random'}checked="checked"{/if}>
       <label for="banner-random"><b>{'Random'|@translate}</b></label>
     </div>
@@ -43,7 +43,9 @@
       <span class="actions">
         <input type="radio" name="image" value="{$image.NAME}" id="banner-{$image.NAME}" {if $BANNER_IMAGE==$image.NAME}checked="checked"{/if}><br>
-        <a href="{$CONFIG_URL}&amp;delete_banner={$image.NAME}" class="removeFilter" title="{'Delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><span>[x]</span></a>
       </span>
-      <label for="banner-{$image.NAME}"><img src="{$image.THUMB}" alt="{$image.NAME}"></label> 
+      <span class="banner-wrapper">
+        <a href="{$CONFIG_URL}&amp;delete_banner={$image.NAME}" title="{'Delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');" class="delete-banner">&times;</a>
+        <label for="banner-{$image.NAME}"><img src="{$image.THUMB}" alt="{$image.NAME}"></label>
+      </span>
     </div>
     {/foreach}
Index: /extensions/header_manager/admin/template/style.css
===================================================================
--- /extensions/header_manager/admin/template/style.css	(revision 17643)
+++ /extensions/header_manager/admin/template/style.css	(revision 17644)
@@ -3,9 +3,38 @@
   margin:5px 0 0 20px;
 }
-.banner-radio .actions {
-  display:inline-block;
-  vertical-align:80%;
-  text-align:center;
-}
+  .banner-radio .actions {
+    display:inline-block;
+    padding-top:30px;
+    vertical-align:top;
+  }
+  .banner-wrapper {
+    display:inline-block;
+    position:relative;
+    width:230px;
+    height:70px;
+  }
+    .delete-banner {
+      position:absolute;
+      display:block;
+      top:0;
+      right:0;
+      margin:0;
+      width:16px;
+      height:16px;
+      background:rgba(20,20,20,0.5);
+      color:#eee;
+      border:1px solid #999;
+      border-top:none;
+      border-right:none;
+      border-radius:0 0 0 4px;
+      font-weight:bold;
+      text-align:center;
+    }
+      .delete-banner:hover {
+        color:#e00 !important;
+        border-color:#e00;
+        background:rgba(20,20,20,1);
+      }
+
 .showInfo {
   position:static;
Index: /extensions/header_manager/include/header_manager.inc.php
===================================================================
--- /extensions/header_manager/include/header_manager.inc.php	(revision 17643)
+++ /extensions/header_manager/include/header_manager.inc.php	(revision 17644)
@@ -8,6 +8,4 @@
 {
   global $conf, $user, $template, $page;
-  
-  if (defined('IN_ADMIN')) return $page_banner;
   
   // search banner for a specific category
@@ -28,11 +26,5 @@
     if (count($cat_banners))
     {
-      function uppercats_sort($a, $b)
-      {
-        global $page;
-        $ids = explode(',', $page['category']['uppercats']);
-        return array_search($a['category_id'], $ids) < array_search($b['category_id'], $ids);
-      }
-      usort($cat_banners, 'uppercats_sort');
+      usort($cat_banners, 'hm_uppercats_sort');
       
       foreach ($cat_banners as $cat_banner)
@@ -106,32 +98,9 @@
 }
 
-/**
- * Header Manager admin link
- */
-function header_manager_admin_menu($menu) 
+function hm_uppercats_sort($a, $b)
 {
-  array_push($menu, array(
-    'NAME' => 'Header Manager',
-    'URL' => HEADER_MANAGER_ADMIN,
-  ));
-  return $menu;
-}
-
-/**
- * tab on album edition page
- */
-function header_manager_tab($sheets, $id)
-{
-  if ($id == 'album')
-  {
-    load_language('plugin.lang', HEADER_MANAGER_PATH);
-    
-    $sheets['headermanager'] = array(
-      'caption' => l10n('Banner'),
-      'url' => HEADER_MANAGER_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'],
-      );
-  }
-  
-  return $sheets;
+  global $page;
+  $ids = explode(',', $page['category']['uppercats']);
+  return array_search($a['category_id'], $ids) < array_search($b['category_id'], $ids);
 }
 
Index: /extensions/header_manager/include/install.inc.php
===================================================================
--- /extensions/header_manager/include/install.inc.php	(revision 17644)
+++ /extensions/header_manager/include/install.inc.php	(revision 17644)
@@ -0,0 +1,39 @@
+<?php
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+function header_manager_install()
+{
+  global $conf, $prefixeTable;
+
+  // configuration
+  if (empty($conf['header_manager']))
+  {
+    $header_manager_default_config = serialize(array(
+      'width' => 1000,
+      'height' => 150,
+      'image' => 'random',
+      'display' => 'image_only'
+      ));
+    
+    conf_update_param('header_manager', $header_manager_default_config);
+  }
+
+  // banners directory
+  if (!file_exists(PWG_LOCAL_DIR . 'banners/')) 
+  {
+    mkdir(PWG_LOCAL_DIR . 'banners/', 0755);
+  }
+
+  // banners table
+  $query = '
+CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` (
+  `category_id` smallint(5) unsigned NOT NULL,
+  `image` varchar(255) NOT NULL,
+  `deep` tinyint(1) DEFAULT 1,
+  PRIMARY KEY (`category_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+;';
+  pwg_query($query);
+}
+
+?>
Index: /extensions/header_manager/main.inc.php
===================================================================
--- /extensions/header_manager/main.inc.php	(revision 17643)
+++ /extensions/header_manager/main.inc.php	(revision 17644)
@@ -12,8 +12,9 @@
 
 global $prefixeTable;
-define('HEADER_MANAGER_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
-define('HEADER_MANAGER_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__)));
-define('HEADER_MANAGER_DIR', PWG_LOCAL_DIR . 'banners/');
-define('HEADER_MANAGER_TABLE', $prefixeTable . 'category_banner');
+define('HEADER_MANAGER_PATH',    PHPWG_PLUGINS_PATH . 'header_manager/');
+define('HEADER_MANAGER_ADMIN',   get_root_url() . 'admin.php?page=plugin-header_manager');
+define('HEADER_MANAGER_DIR',     PWG_LOCAL_DIR . 'banners/');
+define('HEADER_MANAGER_TABLE',   $prefixeTable . 'category_banner');
+define('HEADER_MANAGER_VERSION', '1.0.3');
 
 add_event_handler('init', 'header_manager_init');
@@ -26,16 +27,82 @@
   $conf['header_manager'] = unserialize($conf['header_manager']);
     
-  include(HEADER_MANAGER_PATH . 'include/functions.inc.php');
-  include(HEADER_MANAGER_PATH . 'include/header_manager.inc.php');
+  include_once(HEADER_MANAGER_PATH . 'include/functions.inc.php');
+  include_once(HEADER_MANAGER_PATH . 'include/header_manager.inc.php');
   
-  add_event_handler('render_page_banner', 'header_manager_render');
-
-  if (defined('IN_ADMIN'))
+  if (!defined('IN_ADMIN'))
   {
+    add_event_handler('render_page_banner', 'header_manager_render');
+  }
+  else
+  {
+    add_event_handler('loc_begin_admin_page', 'header_manager_check_version');
+    add_event_handler('get_admin_plugin_menu_links', 'header_manager_admin_menu');
     add_event_handler('tabsheet_before_select', 'header_manager_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
-    add_event_handler('get_admin_plugin_menu_links', 'header_manager_admin_menu');
     add_event_handler('delete_categories', 'header_manager_delete_categories');
   }
 }
 
+/**
+ * Header Manager admin link
+ */
+function header_manager_admin_menu($menu) 
+{
+  array_push($menu, array(
+    'NAME' => 'Header Manager',
+    'URL' => HEADER_MANAGER_ADMIN,
+  ));
+  return $menu;
+}
+
+/**
+ * tab on album edition page
+ */
+function header_manager_tab($sheets, $id)
+{
+  if ($id == 'album')
+  {
+    load_language('plugin.lang', HEADER_MANAGER_PATH);
+    
+    $sheets['headermanager'] = array(
+      'caption' => l10n('Banner'),
+      'url' => HEADER_MANAGER_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'],
+      );
+  }
+  
+  return $sheets;
+}
+
+/**
+ * updating the plugin
+ */
+function header_manager_check_version()
+{
+  global $pwg_loaded_plugins, $page;
+  
+  if (
+    ( 
+      @$page['page'] == 'intro' or 
+      @$_GET['section'] == 'header_manager/admin.php' 
+    )
+    and 
+    (
+      $pwg_loaded_plugins['header_manager']['version'] == 'auto' or
+      version_compare($pwg_loaded_plugins['header_manager']['version'], HEADER_MANAGER_VERSION, '<')
+    ) 
+  )
+  {
+    include_once(HEADER_MANAGER_PATH . 'include/install.inc.php');
+    header_manager_install();
+    
+    if ($pwg_loaded_plugins['header_manager']['version'] != 'auto')
+    {
+      $query = '
+UPDATE '. PLUGINS_TABLE .'
+SET version = "'. HEADER_MANAGER_VERSION .'"
+WHERE id = "header_manager"';
+      pwg_query($query);
+    }
+  }
+}
+
 ?>
Index: /extensions/header_manager/maintain.inc.php
===================================================================
--- /extensions/header_manager/maintain.inc.php	(revision 17643)
+++ /extensions/header_manager/maintain.inc.php	(revision 17644)
@@ -1,56 +1,19 @@
 <?php
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-
-define('header_dir', PWG_LOCAL_DIR . 'banners/');
-
-define(
-  'header_manager_default_config', 
-  serialize(array(
-    'width' => 1000,
-    'height' => 150,
-    'image' => 'random',
-    'display' => 'image_only'
-    ))
-  );
   
+include_once(PHPWG_PLUGINS_PATH . 'header_manager/include/install.inc.php');
 
 function plugin_install() 
 {
-  global $prefixeTable;
-  
-	pwg_query(
-'CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` (
-  `category_id` smallint(5) unsigned NOT NULL,
-  `image` varchar(255) NOT NULL,
-  `deep` tinyint(1) DEFAULT 1,
-  PRIMARY KEY (`category_id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8
-;');
-
-  conf_update_param('header_manager', header_manager_default_config);
-  mkdir(header_dir, 0755);
+  header_manager_install();
+  define('header_manager_installed', true);
 }
 
 function plugin_activate()
 {
-  global $conf, $prefixeTable;
-
-  if (empty($conf['header_manager']))
+  if (!defined('header_manager_installed'))
   {
-    conf_update_param('header_manager', header_manager_default_config);
+    header_manager_install()
   }
-  if (!file_exists(header_dir)) 
-  {
-    mkdir(header_dir, 0755);
-  }
-  
-  pwg_query(
-'CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` (
-  `category_id` smallint(5) unsigned NOT NULL,
-  `image` varchar(255) NOT NULL,
-  `deep` tinyint(1) DEFAULT 1,
-  PRIMARY KEY (`category_id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8
-;');
 }
 
