Index: smf/SSI.php
===================================================================
--- smf/SSI.php	(revision 1003)
+++ smf/SSI.php	(working copy)
@@ -240,7 +240,7 @@
 }
 
 // Display an entire SMF topic as a comment thread.
-function ssi_commentThread($topicID, $display, $begin_comm, $output_method = 'echo')
+function ssi_commentThread($topicID, $display, $begin_comm, $max_comm = 10, $output_method = 'echo')
 {
     global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
     global $user_info, $modSettings, $func;
@@ -253,7 +253,6 @@
 
     // Get $max_comm posts, starting with $begin_comm. Newer ones will have higher IDs.
     // Do this only if there is a 'show' request.
-    $max_comm = 10;
     $posts = array();
 
     if($display == 'show') {
@@ -364,28 +363,27 @@
                         ', $post['preview'], '
                     </div>
                 </div>';
+    }
 
-        $new_post_url = $scripturl.'?action=post;topic='.$topicID;
-        if (0 == $count_comm) {
-            $new_post_caption = 'Fii primul care comenteaza!';
-        }
-        else {
-            echo '
-                <h3>Comenteaza si tu!</h3>';
-            $new_post_caption = 'Lasa un comentariu!';
-        }
-
+    $new_post_url = $scripturl.'?action=post;topic='.$topicID;
+    if (0 == $count_comm) {
+        $new_post_caption = 'Fii primul care comenteaza!';
+    }
+    else {
         echo '
-                <div class="toolbar">
-                    <a href="', htmlentities($new_post_url), '">',
-                        htmlentities($new_post_caption),
-                    '</a> Vrem sa aflam ce crezi!
-                </div>';
+            <h3>Comenteaza si tu!</h3>';
+        $new_post_caption = 'Lasa un comentariu!';
+    }
 
-        echo '
+    echo '
+            <div class="toolbar">
+                <a href="', htmlentities($new_post_url), '">',
+                    htmlentities($new_post_caption),
+                '</a> Vrem sa aflam ce crezi!
             </div>';
 
-    }
+    echo '
+        </div>';
 }
 
 //////
Index: smf/ia_comments.php
===================================================================
--- smf/ia_comments.php	(revision 1003)
+++ smf/ia_comments.php	(working copy)
@@ -7,6 +7,7 @@
 $topic_id = getattr($_GET, 'topic_id');
 $display = getattr($_GET, 'display', 'hide');
 $begin_comm = (int)getattr($_GET, 'begin_comm', '0');
+$max_comm = getattr($_GET, 'max_comm');
 
 if (!$topic_id) {
     echo 'Expecting topic_id';
@@ -14,7 +15,11 @@
 }
 
 echo '<div class="smf comment-thread">';
-ssi_commentThread($topic_id, $display, $begin_comm);
+if (is_null($max_comm)) {
+    ssi_commentThread($topic_id, $display, $begin_comm);
+} else {
+    ssi_commentThread($topic_id, $display, $begin_comm, (int)$max_comm);
+}
 echo '</div>';
 
 ?>
Index: www/macros/macro_remotebox.php
===================================================================
--- www/macros/macro_remotebox.php	(revision 1003)
+++ www/macros/macro_remotebox.php	(working copy)
@@ -23,8 +23,12 @@
     $buffer .= '<div id="remotebox">remote content</div>';
     $buffer .= '<script type="text/javascript">RemoteBox_Url="';
     $buffer .= html_escape($args['url']);
-    if(array_key_exists('display', $args))
-        $buffer .= '";RemoteBox_Display="' . $args['display'];
+    if (array_key_exists('display', $args)) {
+        $buffer .= '";RemoteBox_Display="' . html_escape($args['display']);
+    }
+    if (array_key_exists('max_comm', $args)) {
+        $buffer .= '";RemoteBox_MaxComm="' . html_escape((int)$args['max_comm']);
+    }
     $buffer .= '";</script>';
 
     return $buffer;
Index: www/macros/macro_smfcomments.php
===================================================================
--- www/macros/macro_smfcomments.php	(revision 1003)
+++ www/macros/macro_smfcomments.php	(working copy)
@@ -6,21 +6,42 @@
 // wrapper for the more generic macro RemoteBox()
 //
 // Arguments:
-//      topic_id (required) SMF numeric topic id
+//      topic_id (required) - SMF numeric topic id
+//      display (required)  - parameter for visibility
+//      max_comm (optional) - number of comments showed
 //
 // Examples:
-//      SmfComments( topic_id="400" )
+//      SmfComments( topic_id="400" display="show" )
+//      SmfComments( topic_id="400" display="hide" max_comm="5")
 function macro_smfcomments($args) {
     $topic_id = getattr($args, 'topic_id');
+    $display = getattr($args, 'display');
+    $max_comm = getattr($args, 'max_comm');
 
     if (is_null($topic_id)) {
         return macro_error('Expecting argument `topic_id`');
     }
 
+    if (is_null($display)) {
+        return macro_error('Expecting argument `display`');
+    }
+
+    if ($display != 'show' && $display != 'hide') {
+        return macro_error('Wrong value for argument `display`');
+    }
+
     $args = array(
         'url' => IA_SMF_URL.'/ia_comments.php?topic_id='.$topic_id,
-        'display' => 'show'
+        'display' => $display
     );
+    if(!is_null($max_comm)) {
+        if(is_whole_number($max_comm)) {
+            $args['max_comm'] = $max_comm;
+        } else {
+            return macro_error('Wrong value for argument `max_comm`');
+        }
+    }
+
     return macro_remotebox($args, true);
 }
 
Index: www/static/js/remotebox.js
===================================================================
--- www/static/js/remotebox.js	(revision 1003)
+++ www/static/js/remotebox.js	(working copy)
@@ -6,6 +6,7 @@
 var RemoteBox_Url = '';
 var RemoteBox_Display = 'hide';
 var RemoteBox_BeginComm = 1;
+var RemoteBox_MaxComm = 10;
 
 function RemoteBox_Load() {
     var container = $('remotebox');
@@ -17,7 +18,9 @@
     // 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);
+    var d = doSimpleXMLHttpRequest(RemoteBox_Url + "&display=" + RemoteBox_Display +
+            "&begin_comm=" + RemoteBox_BeginComm +
+            "&max_comm=" + RemoteBox_MaxComm);
 
     var ready = function(data) {
         if (data) {
Index: www/views/blog_view.php
===================================================================
--- www/views/blog_view.php	(revision 1003)
+++ www/views/blog_view.php	(working copy)
@@ -1,7 +1,7 @@
 <?php
 
 require_once(IA_ROOT_DIR.'www/wiki/wiki.php');
-require_once(IA_ROOT_DIR.'www/macros/macro_remotebox.php');
+require_once(IA_ROOT_DIR.'www/macros/macro_smfcomments.php');
 
 // site header
 include('header.php');
@@ -36,7 +36,7 @@
 // blog comments
 echo '<div id="comentarii">';
 if (getattr($view, 'forum_topic')) {
-    echo macro_remotebox(array('url' => IA_SMF_URL.'/ia_comments.php?topic_id='.$view['forum_topic'], 'display' => 'show'), true);
+    echo macro_smfcomments(array('topic_id' => $view['forum_topic'], 'display' => 'show'));
 }
 echo '</div></div>';
 echo '</div>';
Index: www/views/textblock_view.php
===================================================================
--- www/views/textblock_view.php	(revision 1003)
+++ www/views/textblock_view.php	(working copy)
@@ -21,8 +21,8 @@
 // page comments
 echo '<div id="comentarii">';
 if (getattr($view, 'forum_topic')) {
-    require_once(IA_ROOT_DIR.'www/macros/macro_remotebox.php');
-    echo macro_remotebox(array('url' => IA_SMF_URL.'/ia_comments.php?topic_id='.$view['forum_topic']), true);
+    require_once(IA_ROOT_DIR.'www/macros/macro_smfcomments.php');
+    echo macro_smfcomments(array('topic_id' => $view['forum_topic'], 'display' => 'hide'));
 }
 echo '</div>';
 
