<?PHP
  if (!isset($$phcollapse)) {
    $$phcollapse=0;
  }
?>
<table width="<?PHP echo $ForumTableWidth; ?>" cellspacing="0" cellpadding="2" border="0">
<tr bgcolor="#FFFFFF">
    <td class=boldDarkGreen>&nbsp;<?PHP echo $lTopics;?></td>
    <td class=boldDarkGreen><?PHP echo $lAuthor;?>&nbsp;</td>
<?PHP if ( $$phcollapse != 0 && !$read) { ?>
    <td align="center" class=boldDarkGreen><?PHP echo $lReplies;?>&nbsp;</td>
    <td align="center" class=boldDarkGreen><?PHP echo $lLatest;?></td>
<?PHP }else{ ?>
    <td align="center" class=boldDarkGreen><?PHP echo $lDate;?></td>
<?PHP } ?>
</tr>
<?PHP
  $x=0;
  $loc=0;
  @reset($headers);
	$message = @current($headers);
  if(!$read){
    @reset($threads);
  	$trec=@current($threads);
  }
	while (is_array($message)){
		if(($x%2)==0){
			$bgcolor="#FFFFFF";
      $fcolor="#000000";
		}
		else{
			$bgcolor="#FAFAFA";
      $fcolor="#000000";
		}
		$t_id=$message["id"];
		$t_thread=$message["thread"];
		$t_subject=chop($message["subject"]);
		$t_author=chop($message["author"]);

		$t_author = setAuthor($t_author, "Name");
		/*
		if ($t_author == $WEBMASTER_NAME)
			$t_author = $t_author."&nbsp;<img src=".$WEBMASTER_IMG." border=0>";
		*/
		
		$t_datestamp = old_date_format($message["datestamp"]);

		if( ($$phcollapse != 0) && (!$read) ){
		  $t_latest=old_date_format($trec["latest"]);
		  $t_maxid=$trec["maxid"];
    }
  	$message = next($headers);

		if($t_thread!=$t_id){
			$img = '&nbsp;<img src="images/l.gif" border=0 width=12 height=21 align="top">';
			if(is_array($message)){
				if($t_thread==$message["thread"]){
					$img='&nbsp;<img src="images/t.gif" border=0 width=12 height=21 align="top">';
				}
			}
		}
    		else{
			$img="";
			$loc=0;
		}

		if($id==$t_id && $read=true){
			$t_subject = "<b>$t_subject</b>";
			$t_author = "<b>$t_author</b>";
			$t_datestamp = "<b>$t_datestamp</b>";
		}
		else{
			$t_subject="<a class=smallDarkLink href=\"".$sess->link3($FORUM_URL."$read_page.$ext","f=$num&i=$t_id&t=$t_thread$GetVars")."\">$t_subject</a>";
		}

    $color=bgcolor($bgcolor);
		echo "<tr>\n";
		echo '  <td '.$color.' class=smallDark>'.$img.'&nbsp;'.$t_subject."&nbsp;";

    if($UseCookies){
      $isnew=false;
		  if($$phcollapse != 0 && !$read){
        // collapsed code
        if($use_haveread){
          if ($old_message<$t_maxid) {
            if(!IsSet($haveread[$t_maxid])) {
              $isnew=true;
            }
          }
        }
        elseif($old_message<$t_maxid){
          $isnew=true;
        }
      } else {
        // expanded code
        if ($use_haveread) {
          if ($old_message<$t_id) {
            if(!isset($haveread[$t_id])){
              $isnew=true;
            }
          }
        } elseif ($old_message<$t_id) {
          $isnew=true;
        }
      }
      if($isnew){
        echo "<span class=smallDarkRed>".$lNew."</span>";
      }
    }

		echo "</td>\n";
		echo '  <td '.$color.' class=smallDark>'.$t_author.'&nbsp;</td>'."\n";
		if( $$phcollapse != 0 && !$read ){
  		$t_count=$trec["tcount"]-1;
    	$trec=next($threads);
		  echo '  <td align="center" '.$color.' class=smallDark>'.$t_count."&nbsp;</td>\n";
		  echo '  <td  '.$color.' align=center class=smallDark>'.$t_latest."&nbsp;</td>\n";
		}
    else{
  		echo '  <td '.$color.' nowrap align=center class=smallDark>'.$t_datestamp.'&nbsp;</td>'."\n";
    }
		echo "</tr>\n";
		$x++;
		$loc++;
	} // end while
?>
</table>
