<?PHP
  if (!isset($$phcollapse)) {
    $$phcollapse=0;
  }

  // Modif GC :
  $m_author = $ClsMembre->GetPrenom($guserid)." ".$ClsMembre->GetNom($guserid) ;
  //-------------------------------------
?>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="<?PHP echo $color2 ?>" >
<TR><TD>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
    <td height="21" <?PHP echo bgcolor($color1); ?> width="100%"><FONT class="HEADER2" >&nbsp;<b><?PHP echo $lTopics;?></b></font></td>
    <td height="21" <?PHP echo bgcolor($color1); ?> width="150" nowrap><FONT class="HEADER2"><b><?PHP echo $lAuthor;?>&nbsp;</b></font></td>
<?PHP if ( $$phcollapse != 0 && !$read) { ?>
    <td align="center" height="21" <?PHP echo bgcolor($color1); ?> width="80" nowrap><FONT class="HEADER2"><b><?PHP echo $lReplies;?>&nbsp;</b></font></td>
    <td height="21" <?PHP echo bgcolor($color1); ?> width="115" nowrap><FONT class="HEADER2"><b><?PHP echo $lLatest;?></b></font></td>
<?PHP }else{ ?>
    <td height="21" <?PHP echo bgcolor($color1); ?> width="115" nowrap><FONT class="HEADER2"><b><?PHP echo $lDate;?></b></font></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";//$ForumTableBodyColor1;
			$fcolor=$ForumTableBodyFontColor1;
		}
		else{
			$bgcolor=$color1;//$ForumTableBodyColor2;
			$fcolor=$ForumTableBodyFontColor2;
		}
		$t_id=$message["id"];
		$t_thread=$message["thread"];
		$t_subject=chop($message["subject"]);
		$t_author=chop($message["author"]);
		$t_datestamp = date_format($message["datestamp"]);

		if( ($$phcollapse != 0) && (!$read) ){
		  $t_latest=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="student" href="'.HTTP_FORUM.$read_page.$ext.'?f='.$num.'&i='.$t_id.'&t='.$t_thread.$myconnexion.'" '.Status().'>'.$t_subject.'</a>';
		}

    $color=bgcolor($bgcolor);
		echo "<tr>\n";
		echo '  <td height="20" '.$color.'><FONT color="'.$fcolor.'">'.$img.'&nbsp;'.$t_subject."&nbsp;</font>";

    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 "<font face=\"MS Sans Serif,Geneva\" size=\"-2\" color=\"#FF0000\">".$lNew."</font>";
      }
    }

		echo "</td>\n";
		if (   $m_author != $t_author ) 
			echo '  <td width="150" height="20" '.$color.' nowrap><FONT color="'.$fcolor.'"><b>'.$t_author.'</b>&nbsp;</font></td>'."\n";
		else
			echo '  <td width="150" height="20" '.$color.' nowrap><FONT color="'.$fcolor.'">'.$t_author.'&nbsp;</font></td>'."\n";
		if( $$phcollapse != 0 && !$read ){
  		$t_count=$trec["tcount"]-1;
    	$trec=next($threads);
		  echo '  <td align="center" width="80" height="20" '.$color.' nowrap><FONT color="'.$fcolor.'" size=-1>'.$t_count."&nbsp;</font></td>\n";
		  echo '  <td width="115" height="20" '.$color.' nowrap><FONT color="'.$fcolor.'" size=-1>'.$t_latest."&nbsp;</font></td>\n";
		}
    else{
  		echo '  <td width="115" height="20" '.$color.' nowrap><FONT color="'.$fcolor.'" size=-1>'.$t_datestamp.'&nbsp;</font></td>'."\n";
    }
		echo "</tr>\n";
		$x++;
		$loc++;
	} // end while
?>
</table>
</TR></TD></TABLE>