Index: smf/SSI.php
===================================================================
--- smf/SSI.php	(revision 1010)
+++ smf/SSI.php	(working copy)
@@ -239,6 +239,21 @@
 	echo '<a href="', $scripturl, '?action=logout;sesc=', $sc, '">', $txt[108], '</a>';
 }
 
+function ssi_displayPaging($count_comm, $begin_comm, $max_comm, $display)
+{
+    if($count_comm > $max_comm) {
+        echo '<b>Mergi la pagina:</b> ';
+        for ($i = 1; $i <= $count_comm; $i += $max_comm) {
+            if ($i != $begin_comm) {
+                echo '<a href="javascript:stay()" onclick="RemoteBox_BlogPost('. $i .', '. $max_comm .', true, \''. $display .'\');">
+                    ['. (int)(($i + $max_comm - 1) / $max_comm) . ']</a> ';
+            } else {
+                echo '<b>[' . (int)(($i + $max_comm - 1)/ $max_comm) . ']</b> ';
+            }
+        }
+    }
+}
+
 // Display an entire SMF topic as a comment thread.
 function ssi_commentThread($topicID, $display, $begin_comm, $max_comm = 10, $output_method = 'echo')
 {
@@ -320,8 +335,9 @@
     echo '
         <div class="comments">';
 
+    $remotebox_display = ($display == 'show' ? 'hide' : 'show');
     echo '
-        <a href="javascript:stay()" onclick="RemoteBox_Display = (RemoteBox_Display == \'show\' ? \'hide\' : \'show\'); RemoteBox_Load();"><h3>&#187; ';
+        <a href="javascript:stay()" onclick="RemoteBox_BlogPost('. $begin_comm .', '. $max_comm .', false, \''. $remotebox_display .'\');"><h3>&#187; ';
 
     if (0 == $count_comm){
         echo 'Niciun comentariu inca...';
@@ -337,17 +353,8 @@
 
     if($display == 'show') {
 
-        // Pagination
-        if($count_comm > $max_comm) {
-            echo '<b>Mergi la pagina:</b> ';
-            for ($i = 1; $i <= $count_comm; $i += $max_comm) {
-                if ($i != $begin_comm) {
-                    echo '<a href="javascript:stay()" onclick="RemoteBox_BeginComm=' . $i . ';RemoteBox_Load();">[' . (int)(($i + $max_comm - 1) / $max_comm) . ']</a> ';
-                } else {
-                    echo '<b>[' . (int)(($i + $max_comm - 1)/ $max_comm) . ']</b> ';
-                }
-            }
-        }
+        // Front paging display
+        ssi_displayPaging($count_comm, $begin_comm, $max_comm, $display);
 
         foreach ($posts as $post)
             echo '
@@ -363,6 +370,10 @@
                         ', $post['preview'], '
                     </div>
                 </div>';
+
+        // Back paging display
+        echo '<br>';
+        ssi_displayPaging($count_comm, $begin_comm, $max_comm, $display);
     }
 
     $new_post_url = $scripturl.'?action=post;topic='.$topicID;
Index: smf/ia_comments.php
===================================================================
--- smf/ia_comments.php	(revision 1010)
+++ smf/ia_comments.php	(working copy)
@@ -5,8 +5,8 @@
 require("./SSI.php");
 
 $topic_id = getattr($_GET, 'topic_id');
-$display = getattr($_GET, 'display', 'hide');
-$begin_comm = (int)getattr($_GET, 'begin_comm', '0');
+$display = getattr($_GET, 'display', 'show');
+$begin_comm = (int)getattr($_GET, 'begin_comm', '1');
 $max_comm = getattr($_GET, 'max_comm');
 
 if (!$topic_id) {
Index: www/static/js/remotebox.js
===================================================================
--- www/static/js/remotebox.js	(revision 1010)
+++ www/static/js/remotebox.js	(working copy)
@@ -4,11 +4,8 @@
  */
 
 var RemoteBox_Url = '';
-var RemoteBox_Display = 'hide';
-var RemoteBox_BeginComm = 1;
-var RemoteBox_MaxComm = 10;
 
-function RemoteBox_Load() {
+function RemoteBox_Load(remotebox_function) {
     var container = $('remotebox');
     if (!container || !RemoteBox_Url) {
         // no remotebox in this page
@@ -18,9 +15,7 @@
     // visual clue to indicate that remotebox is loading
     container.innerHTML = '<div class="loading"> <img src="/static/images/indicator.gif" />Se incarca ...</div>';
 
-    var d = doSimpleXMLHttpRequest(RemoteBox_Url + "&display=" + RemoteBox_Display +
-            "&begin_comm=" + RemoteBox_BeginComm +
-            "&max_comm=" + RemoteBox_MaxComm);
+    var d = doSimpleXMLHttpRequest(RemoteBox_Url);
 
     var ready = function(data) {
         if (data) {
@@ -33,7 +28,27 @@
     }
 
     d.addCallbacks(ready, error);
+    d.addCallbacks(remotebox_function, null);
 }
 
+function RemoteBox_BlogPost(begin_comm, max_comm, focus_on_comments, display) {
+    var RemoteBox_Base_Url = RemoteBox_Url;
+
+    RemoteBox_Url = RemoteBox_Url + "&display=" + display +
+            "&begin_comm=" + begin_comm +
+            "&max_comm=" + max_comm;
+    if (focus_on_comments == true) {
+        var remotebox_function = function() {
+            // set the anchor to the "comentarii" element
+            window.location.hash = "comentarii";
+        }
+        RemoteBox_Load(remotebox_function);
+    } else {
+        RemoteBox_Load(null);
+    }
+
+    RemoteBox_Url = RemoteBox_Base_Url;
+}
+
 connect(window, 'onload', RemoteBox_Load);
 
