Index: /extensions/reply_to/index.php
===================================================================
--- /extensions/reply_to/index.php	(revision 15107)
+++ /extensions/reply_to/index.php	(revision 15108)
@@ -3,5 +3,5 @@
 // | Piwigo - a PHP based photo gallery                                    |
 // +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
Index: /extensions/reply_to/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/reply_to/language/en_UK/plugin.lang.php	(revision 15107)
+++ /extensions/reply_to/language/en_UK/plugin.lang.php	(revision 15108)
@@ -1,5 +1,5 @@
 <?php
 
-$lang['reply to this comment'] = 'reply to this comment';
+$lang['Reply'] = 'Reply';
 
 ?>
Index: /extensions/reply_to/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/reply_to/language/fr_FR/plugin.lang.php	(revision 15107)
+++ /extensions/reply_to/language/fr_FR/plugin.lang.php	(revision 15108)
@@ -1,5 +1,5 @@
 <?php
 
-$lang['reply to this comment'] = 'répondre à ce commentaire';
+$lang['Reply'] = 'Répondre';
 
 ?>
Index: /extensions/reply_to/language/it_IT/plugin.lang.php
===================================================================
--- /extensions/reply_to/language/it_IT/plugin.lang.php	(revision 15107)
+++ /extensions/reply_to/language/it_IT/plugin.lang.php	(revision 15108)
@@ -1,5 +1,5 @@
 <?php
 
-$lang['reply to this comment'] = 'Rispondere a questo commento';
+$lang['Reply'] = 'Rispondere';
 
 ?>
Index: /extensions/reply_to/language/lv_LV/plugin.lang.php
===================================================================
--- /extensions/reply_to/language/lv_LV/plugin.lang.php	(revision 15107)
+++ /extensions/reply_to/language/lv_LV/plugin.lang.php	(revision 15108)
@@ -1,5 +1,5 @@
 <?php
 
-$lang['reply to this comment'] = 'atbildēt uz šo komentāru';
+$lang['Reply'] = 'Atbildēt';
 
 ?>
Index: /extensions/reply_to/main.inc.php
===================================================================
--- /extensions/reply_to/main.inc.php	(revision 15107)
+++ /extensions/reply_to/main.inc.php	(revision 15108)
@@ -20,6 +20,6 @@
 
 add_event_handler('render_comment_content', 'replyto_parse', 60, 2);
-if (script_basename() == 'comments') add_event_handler('init', 'replyto_add_link'); // for comments page (section_init.inc is not called on this page)
-else add_event_handler('loc_end_section_init', 'replyto_add_link'); // for all other pages (we need section infos)
+if (script_basename() == 'comments') add_event_handler('loc_after_page_header', 'replyto_add_link');
+else add_event_handler('loc_end_section_init', 'replyto_add_link');
     
 ?>
Index: /extensions/reply_to/reply_to.inc.php
===================================================================
--- /extensions/reply_to/reply_to.inc.php	(revision 15107)
+++ /extensions/reply_to/reply_to.inc.php	(revision 15108)
@@ -11,4 +11,5 @@
   global $pwg_loaded_plugins, $template, $page, $conf, $lang;
   $template->assign('REPLYTO_PATH', REPLYTO_PATH);
+  $location = null;
   
   // comment form has different id
@@ -25,14 +26,26 @@
   }
   
-  // must check our location
-  if (script_basename() == 'comments') /* COMMENTS page */
+  /* COMMENTS page */
+  if (script_basename() == 'comments') 
   {
     if ( !is_a_guest() OR $conf['comments_forall'] )
     {
+      $comments = &$template->get_template_vars('comments');
+      if (!count($comments)) return;
+      
+      // generates urls to picture or albums with necessary url params
+      foreach ($comments as $tpl_var)
+      {
+        $replyto_links[ $tpl_var['ID'] ] = get_absolute_root_url().$tpl_var['U_PICTURE'].'&amp;rt='.$tpl_var['ID'].'&amp;rta='.$tpl_var['AUTHOR'].'#commentform';
+      }
+      
+      $template->assign('replyto_links', $replyto_links);
       $template->set_prefilter('comments', 'replyto_add_link_comments_prefilter');
     }
   }
-  else if (script_basename() == 'picture') /* PICTURE page */
-  {
+  /* PICTURE page */
+  else if (script_basename() == 'picture') 
+  {
+    $location = 'picture';
     add_event_handler('user_comment_insertion', 'replyto_parse_picture_mail');
     
@@ -42,5 +55,6 @@
     }
   } 
-  else if /* ALBUM page */
+  /* ALBUM page */
+  else if 
     (
       script_basename() == 'index' AND isset($page['section']) AND
@@ -49,4 +63,5 @@
     )
   {
+    $location = 'album';
     add_event_handler('user_comment_insertion', 'replyto_parse_album_mail');
     
@@ -57,35 +72,36 @@
   }
   
+
   /* we come from comments.php page */
-  if ( !empty($_GET['reply_to']) and !empty($_GET['reply_to_a']) )
-  {
-    $lang['Comment'].= '
-    <script type="text/javascript">
-      $(document).ready(function(){
-        jQuery("#'.$template->get_template_vars('replyto_form_name').' textarea").insertAtCaret("[reply='.$_GET['reply_to'].']'.$_GET['reply_to_a'].'[/reply] ");
-      });
-    </script>';
-  }
-}
-
-/**
- * links to commentform on comments.php page
+  if ( !empty($_GET['rt']) and !empty($_GET['rta']) )
+  {
+    if ($location == 'picture')
+    {
+      $template->set_prefilter('picture', 'replyto_fillform_prefilter');
+    }
+    else
+    {
+      $template->set_prefilter('comments_on_albums', 'replyto_fillform_prefilter');
+    }    
+  }
+}
+
+/**
+ * add reply tag from values given in url
+ */
+function replyto_fillform_prefilter($content, &$smarty)
+{
+  $search = '<ul class="commentsList">';
+  $replace = '{footer_script require=\'insertAtCaret\'}replyTo("'.$_GET['rt'].'", "'.$_GET['rta'].'");{/footer_script}'.$search;
+  return str_replace($search, $replace, $content);
+}
+
+/**
+ * reply buttons on comments.php page
  */
 function replyto_add_link_comments_prefilter($content, &$smarty)
-{
-  global $template;
-  $comments = $template->get_template_vars('comments');
-  
-  if (!count($comments)) return $content;
-  
-  foreach ($comments as $tpl_var)
-  {
-    $replyto_links[ $tpl_var['ID'] ] = get_absolute_root_url().$tpl_var['U_PICTURE'].'&reply_to='.$tpl_var['ID'].'&reply_to_a='.$tpl_var['AUTHOR'].'#commentform';
-  }
-  
-  $template->assign('replyto_links', $replyto_links);
-  
-    // style
-  $search[0] = '<ul class="thumbnailCategories">';
+{ 
+  // style
+  $search[0] = '<ul class="commentsList">';
   $replace[0] = '
 {html_head}
@@ -93,10 +109,11 @@
   .replyTo {ldelim}
     display:inline-block;
-    width:16px;
+    background:url({$REPLYTO_PATH}reply.png) left top no-repeat;
     height:16px;
-    background:url({$REPLYTO_PATH}reply.png) center top no-repeat;
+    margin-left:20px;
+    padding-left:20px;
   }
   .replyTo:hover {ldelim}
-    background-position:center -16px;
+    background-position:left -16px;
   }
 </style>
@@ -105,12 +122,6 @@
 
   // button
-  $search[1] = '<span class="author">';
-  $replace[1] = '
-{if not isset($comment.IN_EDIT)}
-<div class="actions" style="float:right;">
-  <a href="{$replyto_links[$comment.ID]}" title="{\'reply to this comment\'|@translate}" class="replyTo">&nbsp;</a>
-</div>
-{/if}'
-.$search[1];
+  $search[1] = '<span class="commentDate">{$comment.DATE}</span>';
+  $replace[1] = $search[1].'<a href="{$replyto_links[$comment.ID]}" class="replyTo">{\'Reply\'|@translate}</a>';
   
   return str_replace($search, $replace, $content);
@@ -118,10 +129,10 @@
 
 /**
- * links to commentform on picture.php (and index.php) page(s)
+ * reply buttons on picture.php and index.php pages
  */
 function replyto_add_link_prefilter($content, &$smarty)
 {
   // script & style
-  $search[0] = '<ul class="thumbnailCategories">';
+  $search[0] = '<ul class="commentsList">';
   $replace[0] = '
 {combine_script id=\'insertAtCaret\' require=\'jquery\' path=$REPLYTO_PATH|@cat:\'insertAtCaret.js\'}
@@ -137,10 +148,11 @@
   .replyTo {ldelim}
     display:inline-block;
-    width:16px;
+    background:url({$REPLYTO_PATH}reply.png) left top no-repeat;
     height:16px;
-    background:url({$REPLYTO_PATH}reply.png) center top no-repeat;
+    margin-left:20px;
+    padding-left:20px;
   }
   .replyTo:hover {ldelim}
-    background-position:center -16px;
+    background-position:left -16px;
   }
 </style>
@@ -149,22 +161,13 @@
 
   // button
-  $search[1] = '<span class="author">';
-  $replace[1] = '
-{if not isset($comment.IN_EDIT)}
-<div class="actions" style="float:right;">
-  <a href="#commentform" title="{\'reply to this comment\'|@translate}" class="replyTo" onclick="replyTo(\'{$comment.ID}\', \'{$comment.AUTHOR}\');">&nbsp;</a>
-</div>
-{/if}'
-.$search[1];
-  
-  // anchor
-  $search[2] = '<div class="thumbnailCategory';
-  $replace[2] = '
-<a name="comment-{$comment.ID}"></a>'
-.$search[2];
-
-  $search[3] = '<legend>{\'Add a comment\'|@translate}</legend>';
-  $replace[3] = $search[3].'
-<a name="commentform"></a>';
+  $search[1] = '<span class="commentDate">{$comment.DATE}</span>';
+  $replace[1] = $search[1].'<a href="#commentform" class="replyTo" onclick="replyTo(\'{$comment.ID}\', \'{$comment.AUTHOR}\');">{\'Reply\'|@translate}</a>';
+  
+  // anchors
+  $search[2] = '<li class="commentElement';
+  $replace[2] = '<a name="comment-{$comment.ID}"></a>'.$search[2];
+
+  $search[3] = '<div id="commentAdd">';
+  $replace[3] = $search[3].'<a name="commentform"></a>';
 
   return str_replace($search, $replace, $content);
@@ -185,13 +188,13 @@
       $query = '
 SELECT
-  img.id,
-  img.file,
-  cat.category_id
-FROM ' . IMAGES_TABLE . ' AS img
-INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS cat
-  ON cat.image_id = img.id
-INNER JOIN ' . COMMENTS_TABLE . ' AS com
-  ON com.image_id = img.id
-WHERE com.id = ' . $matches[1] . '
+    img.id,
+    img.file,
+    cat.category_id
+  FROM ' . IMAGES_TABLE . ' AS img
+    INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS cat
+      ON cat.image_id = img.id
+    INNER JOIN ' . COMMENTS_TABLE . ' AS com
+      ON com.image_id = img.id
+  WHERE com.id = ' . $matches[1] . '
 ;';
       $result = pwg_query($query);
@@ -205,10 +208,10 @@
         $query = '
 SELECT 
-  id, 
-  name, 
-  permalink, 
-  uppercats
-FROM ' . CATEGORIES_TABLE . '
-WHERE id = ' . $image['category_id'] . '
+    id, 
+    name, 
+    permalink, 
+    uppercats
+  FROM ' . CATEGORIES_TABLE . '
+  WHERE id = ' . $image['category_id'] . '
 ;';
         $image['cat'] = pwg_db_fetch_assoc(pwg_query($query));
@@ -234,12 +237,12 @@
       $query = '
 SELECT
-  cat.id, 
-  cat.name, 
-  cat.permalink, 
-  cat.uppercats
-FROM ' . COA_TABLE . ' AS com
-INNER JOIN ' . CATEGORIES_TABLE . ' AS cat
-  ON cat.id = com.category_id
-WHERE com.id = ' . $matches[1] . '
+    cat.id, 
+    cat.name, 
+    cat.permalink, 
+    cat.uppercats
+  FROM ' . COA_TABLE . ' AS com
+    INNER JOIN ' . CATEGORIES_TABLE . ' AS cat
+      ON cat.id = com.category_id
+  WHERE com.id = ' . $matches[1] . '
 ;';
       $result = pwg_query($query);
