Index: /extensions/SmiliesSupport/admin.php
===================================================================
--- /extensions/SmiliesSupport/admin.php	(revision 26074)
+++ /extensions/SmiliesSupport/admin.php	(revision 26075)
@@ -1,4 +1,4 @@
 <?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('SMILIES_ID') or die('Hacking attempt!');
 
 include_once(SMILIES_PATH.'include/functions.inc.php');
@@ -9,15 +9,15 @@
 $sets = array();
 $handle = opendir(SMILIES_DIR);
-while (false !== ($folder = readdir($handle)))
+while ($folder = readdir($handle))
 { 
-  if ( $folder != '.' && $folder != '..' && is_dir(SMILIES_DIR.$folder) )
+  if ($folder != '.' && $folder != '..' && is_dir(SMILIES_DIR.$folder))
   {
-    if (file_exists(SMILIES_DIR.$folder.'/representant.txt'))
+    if (file_exists(SMILIES_DIR . $folder . '/representant.txt'))
     {
-      $sets[$folder] = file_get_contents(SMILIES_DIR.$folder.'/representant.txt');
+      $sets[$folder] = file_get_contents(SMILIES_DIR . $folder . '/representant.txt');
     }
     else
     {
-      $sets[$folder] = get_first_file(SMILIES_DIR.$folder, $conf['smiliessupport']['ext']);
+      $sets[$folder] = get_first_file(SMILIES_DIR . $folder, $conf['smiliessupport_ext']);
     }
   }
@@ -37,5 +37,5 @@
   
   conf_update_param('smiliessupport', serialize($conf['smiliessupport']));
-  array_push($page['infos'], l10n('Information data registered in database'));
+  $page['infos'][] = l10n('Information data registered in database');
   
   // shortcuts file
@@ -52,10 +52,10 @@
       if (array_key_exists($short, $used))
       {
-        $page['errors'][] = sprintf(
-                              l10n('<i>%s</i>, shortcut &laquo; %s &raquo; already used for <i>%s</i>'),
-                              get_filename_wo_extension($file),
-                              $short,
-                              get_filename_wo_extension($used[ $short ])
-                              );
+        $page['errors'][] = l10n(
+          '<i>%s</i>, shortcut &laquo; %s &raquo; already used for <i>%s</i>',
+          get_filename_wo_extension($file),
+          $short,
+          get_filename_wo_extension($used[ $short ])
+          );
       }
       else
@@ -80,9 +80,7 @@
   'SETS' =>         $sets,
   'SMILIES_PATH' => SMILIES_PATH,
-));
+  ));
 
 
-$template->set_filename('smiliessupport_conf', dirname(__FILE__).'/template/smiliessupport_admin.tpl');
+$template->set_filename('smiliessupport_conf', realpath(SMILIES_PATH . 'template/smiliessupport_admin.tpl'));
 $template->assign_var_from_handle('ADMIN_CONTENT', 'smiliessupport_conf');
-
-?>
Index: /extensions/SmiliesSupport/include/events.inc.php
===================================================================
--- /extensions/SmiliesSupport/include/events.inc.php	(revision 26075)
+++ /extensions/SmiliesSupport/include/events.inc.php	(revision 26075)
@@ -0,0 +1,164 @@
+<?php
+defined('SMILIES_ID') or die('Hacking attempt!');
+
+function smiliessupport_admin_menu($menu) 
+{
+  $menu[] = array(
+    'NAME' => 'Smilies Support',
+    'URL' => SMILIES_ADMIN,
+    );
+  return $menu;
+}
+
+function add_smiliessupport() 
+{
+  global $page, $pwg_loaded_plugins, $template, $conf;
+  
+  if (script_basename() == 'picture') 
+  {
+    $prefilter = 'picture';
+    $textarea_id = 'contentid';
+  }
+  else if (isset($page['section']))
+  {
+    if (
+      script_basename() == 'index' and isset($pwg_loaded_plugins['Comments_on_Albums'])
+      and $page['section'] == 'categories' and isset($page['category'])
+      )
+    {
+      $prefilter = 'comments_on_albums';
+      $textarea_id = 'contentid';
+    }
+    else if ($page['section'] == 'guestbook') 
+    {
+      $prefilter = 'guestbook';
+      $textarea_id = 'contentid';
+    }
+    else if ($page['section'] == 'contact') 
+    {
+      $prefilter = 'contactform';
+      $textarea_id = 'cf_content';
+    }
+  }
+  
+  if (!isset($prefilter))
+  {
+    return;
+  }
+
+  $template->assign(array(
+    'SMILIES_PATH' => SMILIES_PATH,
+    'SMILIES' => array(
+      'textarea_id' => $textarea_id,
+      'representant' => SMILIES_DIR . $conf['smiliessupport']['folder'] . '/' . $conf['smiliessupport']['representant'],
+      'files' => get_smilies(),
+      ),
+    ));
+    
+  $template->set_filename('smiliessupport', realpath(SMILIES_PATH . 'template/smiliessupport_page.tpl'));
+  $template->parse('smiliessupport');
+}
+
+// parse smilies
+function SmiliesParse($str)
+{
+  global $conf;
+  
+  $root_path = get_absolute_root_url();
+  $folder = SMILIES_DIR.$conf['smiliessupport']['folder'].'/';
+  $str = ' '.$str;
+  
+  if ($handle = opendir($folder))
+  {
+    while (false !== ($file = readdir($handle)))
+    { 
+      if ($file != "." && $file != ".." && in_array(get_extension($file), $conf['smiliessupport_ext'])) 
+      {
+        $filename = get_filename_wo_extension($file);
+        $v = ':'.$filename.':'; 
+        $s = '<img src="'.$root_path.$folder.$file.'" alt=":'.$filename.':"/>';
+        $str = str_replace($v, $s, $str);
+      }
+    }
+    
+    closedir($handle);
+  }
+  
+  if (file_exists($folder.'smilies-custom.txt'))
+  {
+    $file = file($folder.'smilies-custom.txt', FILE_IGNORE_NEW_LINES);
+  }
+  else if (file_exists($folder.'smilies.txt'))
+  {
+    $file = file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES);
+  }
+  if (!empty($file))
+  {
+    foreach ($file as $v)
+    {
+      $v = trim($v);
+      if (preg_match('#^([^\s]+)[\s]+(.+)$#', $v, $matches)) 
+      {  
+        $filename = get_filename_wo_extension($matches[2]);
+        $v = '#([^"])'.preg_quote($matches[1],'/').'#';          
+        $t = '$1<img src="'.$root_path.$folder.$matches[2].'" alt=":'.$filename.':"/>';
+        $str = preg_replace($v, $t, $str);
+      }
+    }
+  } 
+  
+  return trim($str);
+}
+
+function smiliessupport_action()
+{
+  if (!isset($_GET['action'])) return;
+  if (strpos($_GET['action'], 'ss_') !== 0) return;
+  
+  global $conf;
+  
+  $folder = SMILIES_DIR . ltrim($_GET['folder'], '/') . '/';
+  
+  if ($_GET['action'] == 'ss_reset')
+  {
+    @unlink($folder.'smilies-custom.txt');
+    $_GET['action'] = 'ss_list';
+  }
+  else if ($_GET['action'] == 'ss_list')
+  {
+    $short = array();
+    if (file_exists($folder.'smilies-custom.txt'))
+    {
+      $file = file($folder.'smilies-custom.txt', FILE_IGNORE_NEW_LINES);
+    }
+    else if (file_exists($folder.'smilies.txt'))
+    {
+      $file = file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES);
+    }
+    if (!empty($file))
+    {
+      foreach ($file as $v)
+      {
+        if (preg_match('#^([^\s]+)[\s]+(.+)$#', trim($v), $matches)) 
+        {
+          $short[ $matches[2] ][] = $matches[1];
+        }
+      }
+    }
+
+    $smilies = array();
+    $handle = opendir($folder);
+    while (false !== ($file = readdir($handle)))
+    {
+      if ( $file != '.' && $file != '..' && in_array(get_extension($file), $conf['smiliessupport_ext']) )
+      {
+        $smilies[$file] = array('title'=>':'.get_filename_wo_extension($file).':', 'file'=>$file, 'short'=>@$short[$file]);
+      }
+    }
+    closedir($handle);
+    
+    echo json_encode(array('path'=>$folder, 'smilies'=>$smilies));
+  }
+  
+  exit;
+}
Index: /extensions/SmiliesSupport/include/functions.inc.php
===================================================================
--- /extensions/SmiliesSupport/include/functions.inc.php	(revision 26074)
+++ /extensions/SmiliesSupport/include/functions.inc.php	(revision 26075)
@@ -1,4 +1,36 @@
 <?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('SMILIES_ID') or die('Hacking attempt!');
+
+// return an array with available smilies (name and path)
+function get_smilies()
+{
+  global $conf;
+  
+  if ($handle = opendir(SMILIES_DIR.$conf['smiliessupport']['folder']))
+  {
+    $i = 1;
+    while (false !== ($file = readdir($handle)))
+    {
+      if ($file != '.' and $file != '..' and
+          in_array(get_extension($file), $conf['smiliessupport_ext'])
+        )
+      {
+        $smilies[] = array(
+          'PATH' => SMILIES_DIR.$conf['smiliessupport']['folder'].'/'.$file,
+          'TITLE' => ':'.get_filename_wo_extension($file).':',
+          'TR' => ($i>0 and $i%$conf['smiliessupport']['cols'] == 0) ? '</tr><tr>' : null,
+        );
+        $i++;
+      }
+    }
+    
+    closedir($handle);
+    return $smilies;
+  } 
+  else 
+  {
+    return false;
+  }
+}
 
 function get_first_file($path, $ext=null)
@@ -7,7 +39,9 @@
   $handle = opendir($path);
   
-  while ( false !== ($file=readdir($handle)) )
+  while (false !== ($file=readdir($handle)))
   {
-    if ( $file!='.' && $file!='..' && is_file($path.$file) && (!is_array($ext) || in_array(get_extension($file), $ext)) )
+    if ($file!='.' and $file!='..' and is_file($path.$file) and
+        (!is_array($ext) or in_array(get_extension($file), $ext))
+      )
     {
       closedir($handle);
@@ -19,58 +53,2 @@
   return null;
 }
-
-function smiliessupport_action()
-{
-  if (!isset($_GET['action'])) return;
-  if (strpos($_GET['action'], 'ss_') !== 0) return;
-  
-  global $conf;
-  
-  $folder = SMILIES_DIR . ltrim($_GET['folder'], '/') . '/';
-  
-  if ($_GET['action'] == 'ss_reset')
-  {
-    @unlink($folder.'smilies-custom.txt');
-    $_GET['action'] = 'ss_list';
-  }
-  
-  if ($_GET['action'] == 'ss_list')
-  {
-    $short = array();
-    if (file_exists($folder.'smilies-custom.txt'))
-    {
-      $file = file($folder.'smilies-custom.txt', FILE_IGNORE_NEW_LINES);
-    }
-    else if (file_exists($folder.'smilies.txt'))
-    {
-      $file = file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES);
-    }
-    if (!empty($file))
-    {
-      foreach ($file as $v)
-      {
-        if (preg_match('#^([^\s]+)[\s]+(.+)$#', trim($v), $matches)) 
-        {
-          $short[ $matches[2] ][] = $matches[1];
-        }
-      }
-    }
-
-    $smilies = array();
-    $handle = opendir($folder);
-    while (false !== ($file = readdir($handle)))
-    {
-      if ( $file != '.' && $file != '..' && in_array(get_extension($file), $conf['smiliessupport']['ext']) )
-      {
-        $smilies[$file] = array('title'=>':'.get_filename_wo_extension($file).':', 'file'=>$file, 'short'=>@$short[$file]);
-      }
-    }
-    closedir($handle);
-    
-    echo json_encode(array('path'=>$folder, 'smilies'=>$smilies));
-  }
-  
-  exit;
-}
-
-?>
Index: tensions/SmiliesSupport/include/smiliessupport.inc.php
===================================================================
--- /extensions/SmiliesSupport/include/smiliessupport.inc.php	(revision 26074)
+++ 	(revision )
@@ -1,107 +1,0 @@
-<?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-
-// add smilies button to the comment field
-function set_smiliessupport($prefilter='picture', $textarea_id='contentid')
-{
-  global $conf, $template;
-
-  $template->assign(array(
-    'SMILIES_PATH' => SMILIES_PATH,
-    'SMILIES_ID' =>   $textarea_id,
-    'REPRESENTANT' => SMILIES_DIR.$conf['smiliessupport']['folder'].'/'.$conf['smiliessupport']['representant'],
-    'smiliesfiles' => get_smilies(),
-  ));
-  
-  $template->set_prefilter($prefilter, 'set_smiliessupport_prefilter');  
-}
-
-function set_smiliessupport_prefilter($content, &$smarty)
-{
-  $search = '#(<div id="guestbookAdd">|<div id="commentAdd">|<div class="contact">)#';
-  $replace = file_get_contents(SMILIES_PATH.'/template/smiliessupport_page.tpl').'$1';
-  return preg_replace($search, $replace, $content);
-}
-
-// return an array with available smilies (name and path)
-function get_smilies()
-{
-  global $conf;
-  
-  if ($handle = opendir(SMILIES_DIR.$conf['smiliessupport']['folder']))
-  {
-    $i = 1;
-    while (false !== ($file = readdir($handle)))
-    {
-      if ($file != '.' and $file != '..' and in_array(get_extension($file), $conf['smiliessupport']['ext']))
-      {
-        $smilies[] = array(
-          'PATH' => SMILIES_DIR.$conf['smiliessupport']['folder'].'/'.$file,
-          'TITLE' => ':'.get_filename_wo_extension($file).':',
-          'TR' => ($i>0 and $i%$conf['smiliessupport']['cols'] == 0) ? '</tr><tr>' : null,
-        );
-        $i++;
-      }
-    }
-    
-    closedir($handle);
-    return $smilies;
-  } 
-  else 
-  {
-    return false;
-  }
-}
-
-// parse smilies
-function SmiliesParse($str)
-{
-  global $conf;
-  
-  $root_path = get_absolute_root_url();
-  $folder = SMILIES_DIR.$conf['smiliessupport']['folder'].'/';
-  $str = ' '.$str;
-  
-  if ($handle = opendir($folder))
-  {
-    while (false !== ($file = readdir($handle)))
-    { 
-      if ($file != "." && $file != ".." && in_array(get_extension($file), $conf['smiliessupport']['ext'])) 
-      {
-        $filename = get_filename_wo_extension($file);
-        $v = ':'.$filename.':'; 
-        $s = '<img src="'.$root_path.$folder.$file.'" alt=":'.$filename.':"/>';
-        $str = str_replace($v, $s, $str);
-      }
-    }
-    
-    closedir($handle);
-  }
-  
-  if (file_exists($folder.'smilies-custom.txt'))
-  {
-    $file = file($folder.'smilies-custom.txt', FILE_IGNORE_NEW_LINES);
-  }
-  else if (file_exists($folder.'smilies.txt'))
-  {
-    $file = file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES);
-  }
-  if (!empty($file))
-  {
-    foreach ($file as $v)
-    {
-      $v = trim($v);
-      if (preg_match('#^([^\s]+)[\s]+(.+)$#', $v, $matches)) 
-      {  
-        $filename = get_filename_wo_extension($matches[2]);
-        $v = '#([^"])'.preg_quote($matches[1],'/').'#';          
-        $t = '$1<img src="'.$root_path.$folder.$matches[2].'" alt=":'.$filename.':"/>';
-        $str = preg_replace($v, $t, $str);
-      }
-    }
-  } 
-  
-  return trim($str);
-}
-
-?>
Index: /extensions/SmiliesSupport/main.inc.php
===================================================================
--- /extensions/SmiliesSupport/main.inc.php	(revision 26074)
+++ /extensions/SmiliesSupport/main.inc.php	(revision 26075)
@@ -8,17 +8,31 @@
 */
 
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
-define('SMILIES_ID',   basename(dirname(__FILE__)));
-define('SMILIES_PATH', PHPWG_PLUGINS_PATH . SMILIES_ID . '/');
-define('SMILIES_DIR',  SMILIES_PATH . 'smilies/');
+define('SMILIES_ID',      basename(dirname(__FILE__)));
+define('SMILIES_PATH',    PHPWG_PLUGINS_PATH . SMILIES_ID . '/');
+define('SMILIES_DIR',     SMILIES_PATH . 'smilies/');
+define('SMILIES_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . SMILIES_ID);
+define('SMILIES_VERSION', 'auto');
+
 
 include_once(SMILIES_PATH.'include/functions.inc.php');
-include_once(SMILIES_PATH.'include/smiliessupport.inc.php');
+include_once(SMILIES_PATH.'include/events.inc.php');
+
 
 add_event_handler('init', 'init_smiliessupport');
-add_event_handler('render_comment_content', 'SmiliesParse', 60);
+
+if (defined('IN_ADMIN'))
+{
+  add_event_handler('init', 'smiliessupport_action');
+  add_event_handler('get_admin_plugin_menu_links', 'smiliessupport_admin_menu');
+}
+else
+{
+  add_event_handler('loc_after_page_header', 'add_smiliessupport', EVENT_HANDLER_PRIORITY_NEUTRAL+2);
+}
+
+add_event_handler('render_comment_content', 'SmiliesParse', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
 add_event_handler('render_contact_content', 'SmiliesParse');
-add_event_handler('loc_after_page_header', 'add_smiliessupport');
 
 
@@ -27,61 +41,11 @@
   global $conf;
   
+  include_once(SMILIES_PATH . 'maintain.inc.php');
+  $maintain = new SmiliesSupport_maintain(SMILIES_ID);
+  $maintain->autoUpdate(SMILIES_VERSION, 'install');
+  
   $conf['smiliessupport'] = unserialize($conf['smiliessupport']);
-  $conf['smiliessupport']['ext'] = array('gif', 'jpg', 'png', 'GIF', 'JPG', 'PNG');
+  $conf['smiliessupport_ext'] = array('gif', 'jpg', 'png', 'GIF', 'JPG', 'PNG');
   
   load_language('plugin.lang', SMILIES_PATH);
 }
-
-function add_smiliessupport() 
-{
-  global $page, $pwg_loaded_plugins;
-  
-  // if BBCodeBar is installed let him manage smilies
-  if (isset($pwg_loaded_plugins['bbcode_bar'])) return;
-  
-  if (isset($page['body_id']) AND $page['body_id'] == 'thePicturePage') 
-  {
-    $prefilter = 'picture';
-    $textarea_id = 'contentid';
-  }
-  else if (
-    script_basename() == 'index' and isset($pwg_loaded_plugins['Comments_on_Albums'])
-    and isset($page['section']) and $page['section'] == 'categories' and isset($page['category'])
-    ) 
-  {
-    $prefilter = 'comments_on_albums';
-    $textarea_id = 'contentid';
-  }
-  else if (isset($page['section']) and $page['section'] == 'guestbook') 
-  {
-    $prefilter = 'index';
-    $textarea_id = 'contentid';
-  }
-  else if (isset($page['section']) and $page['section'] == 'contact') 
-  {
-    $prefilter = 'index';
-    $textarea_id = 'cf_content';
-  }
-  
-  if (isset($prefilter))
-  {
-    set_smiliessupport($prefilter, $textarea_id);
-  }
-}
-
-if (script_basename() == 'admin')
-{
-  add_event_handler('get_admin_plugin_menu_links', 'smiliessupport_admin_menu');
-  add_event_handler('init', 'smiliessupport_action');
-  
-  function smiliessupport_admin_menu($menu) 
-  {
-    array_push($menu, array(
-      'NAME' => 'Smilies Support',
-      'URL' => get_root_url().'admin.php?page=plugin-' . SMILIES_ID
-    ));
-    return $menu;
-  }
-}
-
-?>
Index: /extensions/SmiliesSupport/maintain.inc.php
===================================================================
--- /extensions/SmiliesSupport/maintain.inc.php	(revision 26074)
+++ /extensions/SmiliesSupport/maintain.inc.php	(revision 26075)
@@ -1,45 +1,44 @@
 <?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
-function plugin_install()
+class SmiliesSupport_maintain extends PluginMaintain
 {
-  $new_smiliessupport =  array(
+  private $installed = false;
+  
+  private $default_conf = array(
     'folder'       => 'crystal',
     'cols'         => '6',
     'representant' => 'smile.png',
-  );
-  
-  conf_update_param('smiliessupport', serialize($new_smiliessupport));
-}
+    );
 
-function plugin_activate()
-{
-  global $conf;
-  
-  if (strpos($conf['smiliessupport'],',') !== false)
+  function install($plugin_version, &$errors=array())
   {
-    $conf_smiliessupport = explode(',', $conf['smiliessupport']);
+    global $conf;
     
-    switch ($conf_smiliessupport[0])
+    if (isset($conf['smiliessupport']))
     {
-      case 'plugins/SmiliesSupport/smilies': $conf_smiliessupport[0] = 'ipb'; break;
-      case 'plugins/SmiliesSupport/smilies_2': $conf_smiliessupport[0] = 'sylvia'; break;
-      default: $conf_smiliessupport[0] = 'crystal'; break;
+      $conf['smiliessupport'] = serialize($this->default_conf);
+
+      conf_update_param('smiliessupport', $conf['smiliessupport']);
     }
     
-    $new_smiliessupport =  array(
-      'folder'       => $conf_smiliessupport[0],
-      'cols'         => $conf_smiliessupport[1],
-      'representant' => $conf_smiliessupport[2],
-    );
-    
-    conf_update_param('smiliessupport', serialize($new_smiliessupport));
+    $this->installed = true;
+  }
+
+  function activate($plugin_version, &$errors=array())
+  {
+    if (!$this->installed)
+    {
+      $this->install($plugin_version, $errors);
+    }
+  }
+
+  function deactivate()
+  {
+  }
+
+  function uninstall()
+  {
+    conf_delete_param('smiliessupport');
   }
 }
-
-function plugin_uninstall()
-{
-  pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE param="smiliessupport" LIMIT 1;');
-}
-
-?>
Index: /extensions/SmiliesSupport/template/smiliessupport_admin.tpl
===================================================================
--- /extensions/SmiliesSupport/template/smiliessupport_admin.tpl	(revision 26074)
+++ /extensions/SmiliesSupport/template/smiliessupport_admin.tpl	(revision 26075)
@@ -1,24 +1,27 @@
+{combine_css path='themes/default/js/plugins/jquery.tokeninput.css'}
 {combine_script id='jquery.tokeninput' load='footer' path='themes/default/js/plugins/jquery.tokeninput.js'}
+
 {combine_css path=$SMILIES_PATH|cat:'template/style.css'}
 
 
-{footer_script}{literal}
-var data = {};
-var edit = false;
-var edited = false;
+{footer_script}
+(function(){
+var data = {ldelim}},
+    edit = false,
+    edited = false;
 
 // set changed
-jQuery("select[name='folder']").change(function() {
+jQuery('select[name="folder"]').change(function() {
     if (edited) {
-        var ok = confirm("{/literal}{'If you change current set you will lost every shortcuts changes.'|@translate}{literal}");
+        var ok = confirm('{'If you change current set you will lost every shortcuts changes.'|translate|escape:javascript}');
         if (!ok) {
-            jQuery(this).val(jQuery(this).data("selected"));
+            jQuery(this).val(jQuery(this).data('selected'));
             return false;
         }
     }
     
-    var image = jQuery(this).find(":selected").css("background-image");
-    jQuery(this).css("background-image", image);
-    jQuery(this).data("selected", jQuery(this).val());
+    var image = jQuery(this).find(':selected').css('background-image');
+    jQuery(this).css('background-image', image);
+    jQuery(this).data('selected', jQuery(this).val());
     
     fetch();
@@ -26,15 +29,15 @@
 
 // size changed
-jQuery("input[name='cols']").change(function() {
+jQuery('input[name="cols"]').change(function() {
     update();
 });
 
 // switch preview/edit
-jQuery(".edit").click(function() {
+jQuery('.edit').click(function() {
     if (edit) {
-        $(this).html("{/literal}{'Edit shorcuts'|@translate}{literal}");
+        $(this).html('{'Edit shorcuts'|translate|escape:javascript}');
     }
     else {
-        $(this).html("{/literal}{'Preview'|@translate}{literal}");
+        $(this).html('{'Preview'|translate|escape:javascript}');
     }
     
@@ -45,7 +48,8 @@
 
 // reset defaults
-jQuery(".reset").click(function() {
-    var ok = confirm("{/literal}{'Are you sure?'|@translate}{literal}");
-    if (!ok) return false;
+jQuery('.reset').click(function() {
+    if (!confirm('{'Are you sure?'|translate|escape:javascript}')) {
+        return false;
+    }
     
     jQuery.ajax({
@@ -55,5 +59,5 @@
         data: {
             action: 'ss_reset',
-            folder: jQuery("select[name='folder']").val(),
+            folder: jQuery('select[name="folder"]').val(),
         },
         success: function(result) {
@@ -68,6 +72,8 @@
 
 // display edit form before submit
-jQuery("#smiliesupport").submit(function() {
-    if (!edit) jQuery(".edit").click();
+jQuery('#smiliesupport').submit(function() {
+    if (!edit) {
+        jQuery('.edit').click();
+    }
     return true;
 });
@@ -81,5 +87,5 @@
         data: {
             action: 'ss_list',
-            folder: jQuery("select[name='folder']").val(),
+            folder: jQuery('select[name="folder"]').val(),
         },
         success: function(result) {
@@ -93,11 +99,10 @@
 /* update preview/edit table */
 function update() {
-    var html = '';
+    var html = '', i=0;
     
     if (!edit) {
         html+= '<tr>';
         
-        var cols = parseInt(jQuery("input[name='cols']").val());
-        var i=0;
+        var cols = parseInt(jQuery('input[name="cols"]').val());
         
         for (var file in data.smilies) {
@@ -110,22 +115,18 @@
         html+= '</tr>';
         
-        jQuery(".reset").hide();
+        jQuery('.reset').hide();
     }
     else {
-    {/literal}
         html+= '<tr>'
             +'<th></th>'
-            +'<th>{'Name'|@translate}</th>'
-            +'<th>{'Shortcuts'|@translate}</th>'
+            +'<th>{'Name'|translate}</th>'
+            +'<th>{'Shortcuts'|translate}</th>'
             +'<th class="spacer"></th>'
             +'<th></th>'
-            +'<th>{'Name'|@translate}</th>'
-            +'<th>{'Shortcuts'|@translate}</th>'
+            +'<th>{'Name'|translate}</th>'
+            +'<th>{'Shortcuts'|translate}</th>'
           +'</tr>'
           
           +'<tr>';
-     {literal}
-     
-        var i=0;
      
         for (var file in data.smilies) {
@@ -152,17 +153,16 @@
         html+= '</tr>';
         
-        jQuery(".reset").show();
-    }
-    
-    jQuery("#preview").html(html);
+        jQuery('.reset').show();
+    }
+    
+    jQuery('#preview').html(html);
     
     // init tokeninput
-    jQuery(".shortcuts").tokenInput([], {
-        hintText: '{/literal}{'Type in a new shortcut'|@translate}{literal}',
+    jQuery('.shortcuts').tokenInput([], {
+        hintText: '{'Type in a new shortcut'|translate|escape:javascript}',
         newText: '',
         animateDropdown: false,
         preventDuplicates: true,
-        caseSensitive: true,
-        allowCreation: true,
+        allowFreeTagging: true,
         minChars: 2,
         searchDelay: 10,
@@ -170,5 +170,5 @@
         onAdd: function(item) {
             edited = true;
-            var file = $(this).parent("td").data("file");
+            var file = $(this).parent('td').data("file");
             
             if (data.smilies[file].short == null) {
@@ -181,5 +181,5 @@
         onDelete: function(item) {
           edited = true;
-          var file = $(this).parent("td").data("file");
+          var file = $(this).parent('td').data("file");
           
           for (var i in data.smilies[file].short) {
@@ -192,5 +192,5 @@
     
     // prevent spaces
-    jQuery(".token-input-input-token input").keydown(function(e) {
+    jQuery('.token-input-input-token input').keydown(function(e) {
         if (e.keyCode == 32) {
             return false;
@@ -201,5 +201,5 @@
 // init
 fetch();
-{/literal}{/footer_script}
+}());{/footer_script}
 
 
@@ -211,9 +211,9 @@
 
 <fieldset>
-  <legend>{'Configuration'|@translate}</legend>  
+  <legend>{'Configuration'|translate}</legend>  
   
   <ul>      
     <li>
-      <b>{'Smilies set'|@translate}</b>
+      <b>{'Smilies set'|translate}</b>
       <select name="folder" style="background-image:url('{$SMILIES_PATH}smilies/{$FOLDER}/{$SETS[$FOLDER]}');" data-selected="{$FOLDER}">
       {foreach from=$SETS item=rep key=set}
@@ -223,5 +223,5 @@
     </li>
     <li>
-      <b>{'Columns'|@translate}</b>
+      <b>{'Columns'|translate}</b>
       <input type="text" size="2" name="cols" value="{$COLS}">
     </li>
@@ -230,11 +230,11 @@
 
 <fieldset>
-  <legend>{'Preview'|@translate}</legend>  
-  <a href="#" class="edit buttonLike">{'Edit shortcuts'|@translate}</a>
+  <legend>{'Preview'|translate}</legend>  
+  <a href="#" class="edit buttonLike">{'Edit shortcuts'|translate}</a>
   <table id="preview"></table>
-  <a href="#" class="reset buttonLike" style="display:none;">{'Reset defaults'|@translate}</a>
+  <a href="#" class="reset buttonLike" style="display:none;">{'Reset defaults'|translate}</a>
 </fieldset>
   
-<p class="formButtons"><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p>
+<p class="formButtons"><input class="submit" type="submit" value="{'Submit'|translate}" name="submit" /></p>
 
 </form>
Index: /extensions/SmiliesSupport/template/smiliessupport_page.tpl
===================================================================
--- /extensions/SmiliesSupport/template/smiliessupport_page.tpl	(revision 26074)
+++ /extensions/SmiliesSupport/template/smiliessupport_page.tpl	(revision 26075)
@@ -1,10 +1,10 @@
-{if not isset($BBCODE_PATH)}
-{combine_script id="markitup" require='jquery' path=$SMILIES_PATH|@cat:"template/markitup/jquery.markitup.js"}
-{combine_css path=$SMILIES_PATH|@cat:"template/markitup/style.markitup.css"}
-{/if}
+{combine_script id='markitup' require='jquery' load='footer' path=$SMILIES_PATH|cat:'template/markitup/jquery.markitup.js'}
+{combine_css id='markitup' order=10 path=$SMILIES_PATH|cat:'template/markitup/style.markitup.css'}
 
-{footer_script require='jquery'}{literal}
+{footer_script require='markitup'}
 if (jQuery('.markItUp').length == 0) {
-  jQuery('#{/literal}{$SMILIES_ID}{literal}').markItUp({markupSet: []});
+  jQuery('#{$SMILIES.textarea_id}').markItUp({
+    markupSet: []
+  });
   jQuery('.markItUpHeader>ul').css('width', '22');
 }
@@ -16,17 +16,19 @@
 
 jQuery('#allsmilies').hover(function(){ 
-  jQuery('#{/literal}{$SMILIES_ID}{literal}').focus();
-  jQuery('#smiliesdiv').css('display',''); 
+  jQuery('#{$SMILIES.textarea_id}').focus();
+  jQuery('#smiliesdiv').css('display', ''); 
 });
 
 jQuery('#smiliesdiv img').click(function() {
-  emoticon = jQuery(this).attr("title");
-  jQuery.markItUp({ replaceWith:emoticon });
-  jQuery('#smiliesdiv').css('display','none');
+  var emoticon = jQuery(this).attr('title');
+  jQuery.markItUp({
+    replaceWith: emoticon
+  });
+  jQuery('#smiliesdiv').css('display', 'none');
   return false;
 });
-{/literal}{/footer_script}
+{/footer_script}
 
-{html_style}{literal}
+{html_style}
 #SmiliesSupport table img:hover {
   border:1px solid #08e;
@@ -35,21 +37,22 @@
   cursor:pointer;
 }
-#allsmilies { background-size:contain;
-{/literal}
-background-image:url('{$ROOT_URL}{$REPRESENTANT}'); }
+#allsmilies {
+  background-size:contain;
+  background-image:url('{$ROOT_URL}{$SMILIES.representant}');
+}
 {/html_style}
 
 <ul style="display:none;">
 <li id="SmiliesSupport" class="markItUpButton markItUpDropMenu">
-  <a id="allsmilies" title="{'Smilies'|@translate}"></a>
+  <a id="allsmilies" title="{'Smilies'|translate}"></a>
 
-  <ul id="smiliesdiv">
-    <li><table><tr>{strip}
-    {foreach from=$smiliesfiles item=smileyfile} 
+  <ul id="smiliesdiv"><li>
+    <table><tr>{strip}
+    {foreach from=$SMILIES.files item=smileyfile} 
       <td><img src="{$ROOT_URL}{$smileyfile.PATH}" title="{$smileyfile.TITLE}"/></td>
       {$smileyfile.TR}
     {/foreach}
-    {/strip}</tr></table></li>
-  </ul>
+    {/strip}</tr></table>
+  </li></ul>
 </li>
 </ul>
