function Joom_ShowCommentsArea_HTML($allowcomment)
    {
        $config = Joom_getConfig();
        $database =& JFactory::getDBO();
        $user =& JFactory::getUser();
        $linecolor = 0;
        ?>
      <a name="joomcomments"></a>
<?php 
        if ($user->get('username') || !$user->get('username') && $config->jg_showcommentsunreg == 0) {
            if ($config->jg_showcommentsarea == 1) {
                $order = 'DESC';
            } else {
                $order = 'ASC';
            }
            $database->setQuery(" SELECT\n                              cm.*\n                            FROM\n                              #__joomgallery_comments AS cm\n                            WHERE\n                                  cm.cmtpic    = " . $this->id . "\n                              AND cm.published = '1'\n                              AND cm.approved  = '1'\n                            ORDER BY\n                              cmtid {$order}\n                          ");
            $result1 = $database->LoadObjectList();
            $count = count($result1);
            if ($count > 0) {
                ?>
      <tr class="sectiontableheader">
        <td class="jg_cmtl">
          <?php 
                echo JText::_('JGS_AUTHOR');
                ?>
&nbsp;
        </td>
        <td class="jg_cmtr">
          <?php 
                echo JText::_('JGS_COMMENT');
                ?>
&nbsp;
        </td>
      </tr>
<?php 
                foreach ($result1 as $row1) {
                    $linecolor = $linecolor % 2 + 1;
                    ?>
      <tr class="<?php 
                    echo "sectiontableentry" . $linecolor;
                    ?>
">
        <td class="jg_cmtl">
<?php 
                    if ($row1->userid > 0) {
                        ?>
          <?php 
                        echo Joom_GetDisplayName($row1->userid, false);
                        ?>
&nbsp;
<?php 
                    } elseif ($row1->cmtname == JText::_('JGS_GUEST')) {
                        ?>
          <?php 
                        echo $row1->cmtname;
                        ?>
&nbsp;
<?php 
                    } else {
                        ?>
      <?php 
                        echo $row1->cmtname . ' (' . JText::_('JGS_GUEST') . ') ';
                        ?>
&nbsp;
<?php 
                    }
                    // Editor logged?
                    if ($user->get('gid') == 20 || $user->get('gid') == 24 || $user->get('gid') == 25) {
                        ?>
          <div class="jg_cmticons">
            <a href="http://www.db.ripe.net/whois?form_type=simple&full_query_string=&searchtext=<?php 
                        echo $row1->cmtip;
                        ?>
&do_search=Search" target="_blank">
              <img src="<?php 
                        echo _JOOM_LIVE_SITE . $this->joom_assetspath;
                        ?>
images/ip.gif" alt="<?php 
                        echo $row1->cmtip;
                        ?>
" title="<?php 
                        echo $row1->cmtip;
                        ?>
" hspace="3" border="0" /></a>
            <a href="<?php 
                        echo JRoute::_($this->joom_componenturl . '&func=deletecomment&cmtid=' . $row1->cmtid . _JOOM_ITEMID);
                        ?>
">
              <img src="<?php 
                        echo _JOOM_LIVE_SITE . $this->joom_assetspath;
                        ?>
images/del.gif" alt="<?php 
                        echo JText::_('JGS_DELETE_COMMENT');
                        ?>
" hspace="3" border="0" /></a>
          </div>
<?php 
                    }
                    ?>
        </td>
<?php 
                    $signtime = strftime($config->jg_dateformat, $row1->cmtdate);
                    $origtext = $row1->cmttext;
                    $origtext = Joom_ProcessText($origtext);
                    if ($config->jg_bbcodesupport) {
                        $origtext = Joom_BBDecode($origtext);
                    }
                    if ($config->jg_smiliesupport) {
                        $smileys = Joom_GetSmileys();
                        foreach ($smileys as $i => $sm) {
                            $origtext = str_replace($i, '<img src="' . $sm . '" border="0" alt="' . $i . '" title="' . $i . '" />', $origtext);
                        }
                    }
                    ?>
        <td class="jg_cmtr">
          <span class="small">
            <?php 
                    echo JText::_('JGS_COMMENT_ADDED');
                    ?>
: <?php 
                    echo $signtime;
                    ?>
&nbsp;
            <hr />
          </span>
          <?php 
                    echo stripslashes($origtext);
                    ?>
&nbsp;
        </td>
      </tr>
<?php 
                }
            } else {
                ?>
      <tr class="<?php 
                echo "sectiontableentry" . $linecolor;
                ?>
">
        <td colspan="2" class="jg_cmtf">
          <p>
          <?php 
                echo JText::_('JGS_NO_EXISTING_COMMENTS');
                ?>
&nbsp;
<?php 
                if ($allowcomment == 1) {
                    ?>
          <?php 
                    echo ' ' . JText::_('JGS_WRITE_FIRST_COMMENT');
                    ?>
&nbsp;
<?php 
                }
                ?>
          </p>
        </td>
      </tr>
<?php 
            }
        } else {
            ?>
      <tr class="<?php 
            echo "sectiontableentry" . $linecolor;
            ?>
">
        <td colspan="2" class="jg_cmtf">
          <p>
          <?php 
            echo JText::_('JGS_NO_COMMENTS_FOR_UNREG');
            ?>
&nbsp;
          </p>
        </td>
      </tr>
<?php 
        }
    }
    /**
     * Comments manager
     *
     * @param string $rows
     * @param string $search
     * @param object $pageNav
     */
    function Joom_ShowComments_HTML(&$rows, &$search, &$pageNav)
    {
        $config = Joom_getConfig();
        $database =& JFactory::getDBO();
        jimport('joomla.filesystem.file');
        ?>
<script  type="text/javascript" src="<?php 
        echo _JOOM_LIVE_SITE;
        ?>
includes/js/overlib_mini.js"></script>
<form action="index.php" method="post" name="adminForm">
<table cellpadding="4" cellspacing="0" border="0" width="100%">
  <tr>
    <td width="100%"></td>
    <td>
      <?php 
        echo JText::_('JGA_SEARCH');
        ?>
    </td>
    <td>
      <input type="text" name="search" value="<?php 
        echo $search;
        ?>
" class="inputbox" onChange="document.adminForm.submit();" />
    </td>
  </tr>
</table>
<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
  <tr>
    <th width="20">
      <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php 
        echo count($rows);
        ?>
);" />
    </th>
    <th class="title" width="15%">
      <div align="left">
        <?php 
        echo JText::_('JGA_AUTHOR');
        ?>
      </div>
    </th>
    <th width="35%">
      <div align="left">
        <?php 
        echo JText::_('JGA_TEXT');
        ?>
      </div>
    </th>
    <th width="10%">
      <div align="center">
      <?php 
        echo JText::_('JGA_IP');
        ?>
      </div>
    </th>
    <th width="10%">
      <?php 
        echo JText::_('JGA_PUBLISHED');
        ?>
    </th>
    <th width="10%">
      <?php 
        echo JText::_('JGA_APPROVED');
        ?>
    </th>
    <th width="10%">
      <?php 
        echo JText::_('JGA_PICTURE');
        ?>
    </th>
    <th width="24"></th>
    <th width="15%">
      <?php 
        echo JText::_('JGA_DATE');
        ?>
    </th>
  </tr>
<?php 
        $k = 0;
        for ($i = 0, $n = count($rows); $i < $n; $i++) {
            $row =& $rows[$i];
            $task = $row->published ? 'unpublishcmt' : 'publishcmt';
            $img = $row->published ? 'tick.png' : 'publish_x.png';
            $taska = $row->approved ? 'rejectcmt' : 'approvecmt';
            $imga = $row->approved ? 'tick.png' : 'publish_x.png';
            ?>
  <tr class="<?php 
            echo "row{$k}";
            ?>
">
    <td>
      <input type="checkbox" id="cb<?php 
            echo $i;
            ?>
" name="id[]" value="<?php 
            echo $row->cmtid;
            ?>
" onclick="isChecked(this.checked);" />
    </td>
    <td>
      <div align="left">
<?php 
            if ($row->userid > 0) {
                echo Joom_GetDisplayName($row->userid, false);
            } else {
                echo $row->cmtname;
            }
            ?>
      </div>
    </td>
    <td>
      <div align="left">
<?php 
            $cmttext = Joom_ProcessText($row->cmttext);
            ?>
        <?php 
            echo $cmttext;
            ?>
      </div>
    </td>
    <td>
      <div align="center">
        <?php 
            echo $row->cmtip;
            ?>
      </div>
    </td>
    <td align='center'>
      <a href="javascript: void(0);" onClick="return listItemTask('cb<?php 
            echo $i;
            ?>
','<?php 
            echo $task;
            ?>
')">
        <img src="images/<?php 
            echo $img;
            ?>
" border="0" alt="" /><?php 
            /* portierung: width und height entfernt */
            ?>
      </a>
    </td>
    <td align='center'>
      <a href="javascript: void(0);" onClick="return listItemTask('cb<?php 
            echo $i;
            ?>
','<?php 
            echo $taska;
            ?>
')">
        <img src="images/<?php 
            echo $imga;
            ?>
" border="0" alt="" /><?php 
            /* portierung: width und height entfernt */
            ?>
      </a>
    </td>
    <td width="10%" align="center">
      <?php 
            echo $row->cmtpic;
            ?>
    </td>
    <td>
<?php 
            $database->setQuery("SELECT imgthumbname\n            FROM #__joomgallery\n            WHERE id = '{$row->cmtpic}'");
            $is_imgthumbname = $database->loadResult();
            $database->setQuery("SELECT catid\n            FROM #__joomgallery\n            WHERE id = '{$row->cmtpic}'");
            $is_catid = $database->loadResult();
            $catpath = Joom_GetCatPath($is_catid);
            if (JFile::exists(JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $is_imgthumbname)) {
                $imginfo = getimagesize(JPath::clean(JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $is_imgthumbname));
                $imgsource = _JOOM_LIVE_SITE . $config->jg_paththumbs . $catpath . $is_imgthumbname;
                $srcWidth = $imginfo[0];
                $srcHeight = $imginfo[1];
                $thumbexists = 1;
            } else {
                $thumbexists = 0;
            }
            if ($thumbexists) {
                ?>
      <a href="<?php 
                echo _JOOM_LIVE_SITE;
                ?>
index.php?option=<?php 
                echo _JOOM_OPTION;
                ?>
&amp;func=detail&amp;id=<?php 
                echo $row->cmtpic;
                ?>
" onmouseover="return overlib('<img src=\'<?php 
                echo $imgsource;
                ?>
\' />',WIDTH,<?php 
                echo $srcWidth;
                ?>
, HEIGHT,<?php 
                echo $srcHeight;
                ?>
)"  onmouseout="return nd()";target="_blank">
        <img src="<?php 
                echo $imgsource;
                ?>
" border="0" width="24" height="24" alt="" />
      </a>
<?php 
            } else {
                ?>
      &nbsp;
<?php 
            }
            ?>

    </td>
    <td width="10%" align="center">
      <?php 
            echo strftime($config->jg_dateformat, $row->cmtdate);
            ?>
    </td>
<?php 
            $k = 1 - $k;
            ?>
  </tr>
<?php 
        }
        ?>
  <tr>
    <td colspan="9">
      <?php 
        echo $pageNav->getListFooter();
        ?>
    </td>
  </tr>
</table>
<input type="hidden" name="option" value="<?php 
        echo _JOOM_OPTION;
        ?>
" />
<input type="hidden" name="task" value="comments" />
<input type="hidden" name="boxchecked" value="0" />
</form>
<?php 
    }
    function Joom_ShowSpecials_HTML($tl_title, $rows, $sorting)
    {
        $config = Joom_getConfig();
        $database =& JFactory::getDBO();
        $user =& JFactory::getUser();
        $num_rows = ceil(count($rows) / $config->jg_toplistcols);
        $index = 0;
        $line = 1;
        ?>
  <div class="jg_topview">
    <div class="sectiontableheader">
      <?php 
        echo $tl_title;
        ?>
&nbsp;
    </div>
<?php 
        $count_rows = count($rows);
        if ($count_rows) {
            for ($row_count = 0; $row_count < $num_rows; $row_count++) {
                $line++;
                $linecolor = $line % 2 + 1;
                ?>
    <div class="jg_row <?php 
                if ($linecolor == 1) {
                    echo "sectiontableentry1";
                } else {
                    echo "sectiontableentry2";
                }
                ?>
">
<?php 
                for ($col_count = 0; $col_count < $config->jg_toplistcols && $index < $count_rows; $col_count++) {
                    $row1 = $rows[$index];
                    ?>
      <div class="jg_topelement">
<?php 
                    $catpath = Joom_GetCatPath($row1->catid);
                    if ($config->jg_showdetailpage == 0 && $user->get('aid') != 0 || $config->jg_showdetailpage == 1) {
                        $link = Joom_OpenImage($config->jg_detailpic_open, $row1->id, $catpath, $row1->catid, $row1->imgfilename, $row1->imgtitle, $row1->imgtext);
                    } else {
                        $link = "javascript:alert('" . JText::_('JGS_ALERT_NO_DETAILVIEW_FOR_GUESTS', true) . "')";
                    }
                    ?>
        <div  class="jg_topelem_photo">
          <a href="<?php 
                    echo $link;
                    ?>
">
            <img src="<?php 
                    echo _JOOM_LIVE_SITE . $config->jg_paththumbs . $catpath . $row1->imgthumbname;
                    ?>
" class="jg_photo" alt="<?php 
                    echo $row1->imgtitle;
                    ?>
" />
          </a>
        </div>
        <div class="jg_topelem_txt">
          <ul>
            <li>
              <b><?php 
                    echo $row1->imgtitle;
                    ?>
</b>
            </li>
            <li>
              <?php 
                    echo JText::_('JGS_CATEGORY') . ':';
                    ?>
              <a href="<?php 
                    echo JRoute::_('index.php?option=com_joomgallery&func=viewcategory&catid=' . $row1->catid . _JOOM_ITEMID);
                    ?>
">
                <?php 
                    echo $row1->name;
                    ?>
              </a>
            </li>
<?php 
                    if ($config->jg_showauthor) {
                        if ($row1->imgauthor) {
                            $authorowner = $row1->imgauthor;
                        } elseif ($config->jg_showowner) {
                            $authorowner = Joom_GetDisplayName($row1->owner);
                        } else {
                            $authorowner = JText::_('JGS_NO_DATA');
                        }
                        ?>
            <li>
              <?php 
                        echo JText::_('JGS_AUTHOR') . ': ' . $authorowner;
                        ?>
&nbsp;
            </li>
<?php 
                    }
                    if ($config->jg_showhits) {
                        ?>
            <li>
              <?php 
                        echo JText::_('JGS_HITS') . ': ' . $row1->imgcounter;
                        ?>
&nbsp;
            </li>
<?php 
                    }
                    if ($config->jg_showcatrate) {
                        ?>
            <li>
<?php 
                        if ($row1->imgvotes > 0) {
                            $fimgvotesum = number_format($row1->imgvotesum / $row1->imgvotes, 2, ',', '');
                            if ($row1->imgvotes == 1) {
                                $frating = $fimgvotesum . ' (' . $row1->imgvotes . ' ' . JText::_('JGS_ONE_VOTE') . ')';
                            } else {
                                $frating = $fimgvotesum . ' (' . $row1->imgvotes . ' ' . JText::_('JGS_VOTES') . ')';
                            }
                        } else {
                            $frating = '(' . JText::_('JGS_NO_RATINGS') . ')';
                        }
                        ?>
              <?php 
                        echo JText::_('JGS_RATING') . ': ' . $frating;
                        ?>
            </li>
<?php 
                    }
                    if ($config->jg_showcatcom) {
                        # Check how many comments exist
                        $database->setQuery(" SELECT \n                                    COUNT(*)\n                                  FROM \n                                    #__joomgallery_comments\n                                  WHERE \n                                           cmtpic = '{$row1->id}' \n                                    AND approved  = '1' \n                                    AND published = '1'\n                                ");
                        $comments = $database->LoadResult();
                        ?>
            <li>
<?php 
                        switch ($comments) {
                            case 0:
                                ?>
              <?php 
                                echo JText::_('JGS_NO_COMMENTS');
                                ?>
&nbsp;
<?php 
                                break;
                            case 1:
                                ?>
              <?php 
                                echo $comments . ' ' . JText::_('JGS_COMMENT');
                                ?>
&nbsp;
<?php 
                                break;
                            default:
                                ?>
              <?php 
                                echo $comments . ' ' . JText::_('JGS_COMMENTS');
                                ?>
&nbsp;
<?php 
                                break;
                        }
                        ?>
            </li>
<?php 
                        if ($sorting == 'lastcomment' && $config->jg_showthiscomment) {
                            for ($ii = 0; $ii < $comments; $ii++) {
                                $userid = $row1->userid;
                                $cmtname = $row1->cmtname;
                                if ($userid > 0) {
                                    $cmtname = $row1->username;
                                }
                                $cmttext = $row1->cmttext;
                                $cmtdate = $row1->cmtdate;
                                #$cmtdate = strftime( "%d-%m-%Y %H:%M:%S", $cmtdate );
                                $cmtdate = strftime($config->jg_dateformat, $cmtdate);
                            }
                            ?>
            <li>
<?php 
                            if ($userid > 0) {
                                ?>
			        <?php 
                                echo Joom_GetDisplayName($userid, false);
                            } else {
                                echo $cmtname;
                            }
                            echo ' ' . JText::_('JGS_WROTE') . ' (' . JText::_('JGS_AT') . ' ' . $cmtdate . '):';
                            $cmttext = Joom_ProcessText($cmttext);
                            if ($config->jg_smiliesupport) {
                                $smileys = Joom_GetSmileys();
                                foreach ($smileys as $i => $sm) {
                                    $cmttext = str_replace($i, '<img src="' . $sm . '" border="0" alt="' . $i . '" title="' . $i . '" />', $cmttext);
                                }
                            }
                            ?>
              <?php 
                            echo stripslashes($cmttext);
                            ?>
&nbsp;
            </li>
<?php 
                        }
                    }
                    ?>
          </ul>
        </div>
      </div>
<?php 
                    $index++;
                }
                ?>
      <div class="jg_clearboth"></div>
    </div>
<?php 
            }
        }
        ?>
  </div>
<?php 
    }