<?
function browse_ads()
{
global $ads_count, $html_header, $html_footer, $ct, $mds, $schopt,
$categories, $ad_ind_width, $text_userinfo, $cat_fields, $ratedads, $ind_leftcol,
$tbclr_1, $tbclr_2, $tbclr_3, $tbclr_4, $fntclr_1, $tpadsindd, $fntclr_3,$bc2adsfrm,$HTTP_GET_VARS,
$adbnrcll, $width_2tpf, $schresinfo, $msg, $idadcol, $_REQUEST, $javastl, $pltopratedln, 
$pltopcontln, $pltopvisitln, $use_gl_map; 
$idadcol='0';

if ($mds=="search") 
{$count_info="<font color='#aa0000'>$ads_count ".$msg['ads_match_your_query']."</font>";}
else {$count_info="$ads_count ".$msg['entries'];}  

if(($mds=='search') and ($_REQUEST['adsordtp']=='')){$dislpval='block';} else {$dislpval='none';}

$citygetval="";
if(($mds!='search') and ($HTTP_GET_VARS[$schopt]!="")){$citygetval="?".$schopt."=".$HTTP_GET_VARS[$schopt];}

 
get_tm_tags($categories[$ct][0],"");
echo $html_header;

echo "
<body  onload='self.focus()'>
";

if ($use_gl_map=='yes') {echo getmapjsp();}
 
echo "
$javastl
".print_layerjavas()." 
<table width='$ad_ind_width' border=0 cellspacing='1' cellpadding='0'><tr>
$ind_leftcol
<td valign='top' bgcolor='$tbclr_4'>
<table width='100%'  bgcolor='$tbclr_2' border=0 cellspacing='0' cellpadding='0'>
<tr>
<td> 
<TABLE  WIDTH='100%'   border='0' cellspacing='1' cellpadding='0' >
<tr><td bgcolor='$tbclr_4'> 
 <TABLE  WIDTH='100%'   border='0' cellspacing='0' cellpadding='0' >
<tr><td> 
<font FACE='ARIAL, HELVETICA' COLOR='BLACK'  size=-1>
<a href='index.php".$citygetval."'>".$msg['top'].":</a>&nbsp; </font>
<font FACE='ARIAL, HELVETICA' COLOR='$fntclr_1' size=-1><b>
".category_name()." </b>  </font>  ".subcat_options()."    $text_userinfo 
 
</td><td align='right'>
".print_fav_ads_ind()." ".nb_best_ads()." 
</td></tr></table> 
<TABLE BORDER=0 COLS=1 WIDTH='100%'  bgcolor='$tbclr_3' 
border=0 cellspacing=0 cellpadding=0>

<tr><TD colspan=3 bgcolor='$tbclr_4'>
<DIV id=schf style='DISPLAY: $dislpval'>
<table width='80%'><tr><td>
".get_search_form()."
</td></tr></table></div>
</td></tr>
<TR> 
<TD width='33%' height='16'>
<FONT FACE='Verdana,Geneva,Arial' SIZE=1>
".pages_next_prev()."&nbsp;

</font>
</td><td align='center' width='33%'>
<FONT FACE='Verdana,Geneva,Arial' SIZE=1>
$count_info 
</td><td align='right' width='33%'>
&nbsp;
";
if (($ct!="") and ($ratedads=="") and ($categories[$ct][2]!='h') and ($categories[$ct][2]!='p') )
{
echo "
<FONT FACE='Verdana,Geneva,Arial' SIZE=1><b>
[<a href='index.php?ct=$ct&md=add_form' >".$msg['post_new_ad']."</a>]
[<a href='index.php?ct=$ct&md=editlogin' >".$msg['edit_ad']."</a>]&nbsp;
</b></font>
";
}
echo "
</td></tr>

<tr><td colspan=3 bgcolor='$tbclr_1'   style='BORDER-BOTTOM: $tbclr_3 2px solid;'>

";

if ( ($HTTP_GET_VARS['idemail']=="") and ($HTTP_GET_VARS['mblogin'] == ""))
{
echo "
&nbsp;   <font FACE='Verdana, ARIAL, HELVETICA' size=-2 style='color:#0000aa; TEXT-DECORATION: underline; cursor: pointer;' 
 OnClick=\"displ('schf');\"><b>[".$msg['Search']."]</b></font>
";
}

echo "
 &nbsp; ".getlink_topads()."  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $schresinfo</td></tr>
</table>
";
$width_2tpc=$width_2tpf+15;
if ($tpadsindd=="2")
{
echo "
<table width='100%'  bgcolor='$bc2adsfrm' border=0 cellspacing=0 cellpadding=0>
<tr><td width=$width_2tpc valign='top'>
 <center>".get_ads()."</center>
</td><td valign=top bgcolor='$tbclr_1'>  $adbnrcll </td></tr>
</table> 
";
}
else {
echo "
<table width='100%'  bgcolor='$tbclr_4' border=0 cellspacing=0 cellpadding=0>
<tr><td>
<table width='100%'  border=0 cellspacing=1 cellpadding=1>
".get_ads_captions().get_ads()."
</table>
</table> 
";
}
echo " 
<table width='100%' bgcolor='$tbclr_3' border=0 cellspacing=0 cellpadding=0>
<tr><td>
<FONT FACE='Verdana,Geneva,Arial' SIZE=1>
".ads_pages_list()."
 </font></td>
</td></tr></table>
 
</td></tr></table> 
</center>

</td></tr>
</table>
</td></tr>
</table>
";

echo $html_footer;
exit;
}


function subcat_options()
{
global $ads_fields,  $HTTP_GET_VARS, $fntclr_3, $fntclr_1;

 
$vhtml="&nbsp; &nbsp;<font FACE='ARIAL, HELVETICA' color='$fntclr_1' size=-1>";

$k1='';
foreach ($ads_fields as $key => $value )
{
if ($HTTP_GET_VARS[$key] != "") {$k1='1';
$vhtml=$vhtml." &nbsp; <nobr><font color='$fntclr_3'>
".$ads_fields[$key][0].":".$HTTP_GET_VARS[$key].";</font></nobr> ";
}
 
}
global $rmmbrloc, $msg;

if ($HTTP_GET_VARS['city']!=""){
$vhtml=$vhtml." &nbsp;&nbsp;<font size='-2'><b>( <a href='index.php?ct=".$HTTP_GET_VARS['ct']."&allc=1'>".$msg['all_cities']."</a> $rmmbrloc )</b></font></font>";
}


return $vhtml;
}

 

function get_ads_captions()
{

global $cat_fields, $ads_count, $ct, $photos_count, $incl_prevphoto, $prwph_layer,
$tbclr_1, $tbclr_2, $tbclr_3, $tbclr_4, $fntclr_1, $fntclr_2,$tbclr_5,$colspn,
$lnkttlfl, $msg, $prphscr, $use_gl_map,  $clmnmap, $nmcolmap;

$bgcol21="$tbclr_5";
$bgcol22="$fntclr_2";
$colspn=0;
$captions="<tr>";

if ($ct == '')
{$colspn=$colspn+1;
$captions=$captions." 
<td align='center' bgcolor='$bgcol21'>
<font FACE='ARIAL, HELVETICA'  COLOR='$bgcol22' size=-2>
<b>".$msg['category']."</b>
</font>
</td>
" ;
}
if ((($incl_prevphoto == 'yes') and ($prwph_layer!='yes')) or ($prphscr =='yes'))
{$colspn=$colspn+1;
$captions=$captions." 
<td align='center' bgcolor='$bgcol21'>
<font FACE='ARIAL, HELVETICA'  COLOR='$bgcol22' size=-2>
<b>".$msg['preview_photo']."</b>
</font>
</td>
";
}
foreach ($cat_fields as $key => $value)
{
$ik++;
if ( ($cat_fields[$key][1]=='1') or ($cat_fields[$key][1] == '12'))
{$colspn=$colspn+1;
$captions=$captions." 
<td align='center' bgcolor='$bgcol21'>
<font FACE='ARIAL, HELVETICA'  COLOR='$bgcol22' size=-2>
<b> ".$cat_fields[$key][0]."</b>
 </font>
 </td>
";
}
}
if ($photos_count > 0)
{$colspn=$colspn+1;
$captions=$captions."
<td align='center' bgcolor='$bgcol21'>
<font FACE='ARIAL, HELVETICA'  COLOR='$bgcol22' size=-2>
".$msg['photoind']."
</font>
</td>
";
}
$colspn=$colspn+1;
$captions=$captions."
<td align='center' bgcolor='$bgcol21' width='5%'>
<font FACE='ARIAL, HELVETICA'  COLOR='$bgcol22' size=-2>
<b>".$msg['posted']."</b>
</font>
</td>
";

if ($use_gl_map=='yes' and  $clmnmap=='yes'){
$colspn=$colspn+1;
$captions=$captions."
<td align='center' bgcolor='$bgcol21' width='5%'>
<font FACE='ARIAL, HELVETICA'  COLOR='$bgcol22' size=-2>
<b>$nmcolmap</b>
</font>
</td>
";
}

$captions=$captions."</tr>";
if($ads_count == 0) $captions="";
return $captions;
}

function print_ad($row)
{
global $tpadsindd;
if ($tpadsindd=="2"){$rtn_ads=print_ad2($row);}
else {$rtn_ads=print_ad1($row);}  
return $rtn_ads;
}

function print_ad1 ($row)
{
global $cat_fields, $photos_count, $ct, $categories, $incl_prevphoto, $urlphtn1,
$previewphoto_url, $previewphoto_path, $prphotolimits, $pr_lim_height, $pr_lim_width,
$prwph_layer, $colr_hltads, $capt_hltads, $prphscr,$prphscrwdth,$prwdly, $photo_path,
$tbclr_1, $tbclr_2, $tbclr_3, $tbclr_4, $fntclr_1, $lnkttlfl, $msg, $idadcol, $colspn, 
$tbclhlads, $coltblayer, $use_gl_map,  $clmnmap;

if ($idadcol=="0"){$adtbcol=$tbclr_4; $idadcol="1";} else {$adtbcol=$tbclr_1; $idadcol="0";}
$row=check_row($row);
$colr1_hltads="color='$fntclr_1'";
 
$capt1_hltads="";
$coltblayer=$tbclr_2;
if($row['adrate']>0)
{
$colr1_hltads=$colr_hltads;
$capt1_hltads=$capt_hltads;
$coltblayer=$tbclhlads;
}

$html_ad="<tr>";
$time1=$row['time'];
$ad_date=get_short_date($time1);
$idnum=$row['idnum'];

$ctval=$ct;
if ($ct =='')
{
 
$key_ctn=$row['catname'];
$ctval=$key_ctn;
$html_ad=$html_ad."
<td bgcolor='$adtbcol' align='center' width='10%'>
<font FACE='ARIAL, HELVETICA' size='-2' $colr1_hltads>
<b>
 <a href='index.php?md=browse&ct=$ctval'>
<nobr>".$categories[$key_ctn][0]."</nobr>
</b></a>
&nbsp;
</td>
";
}

if (($incl_prevphoto=='yes') and ($prwph_layer!='yes'))
{
get_jpg_path($idnum);
$phlimitinfo="";
if ($prphotolimits=='yes'){
if ($pr_lim_height==""){
$phlimitinfo="width='$pr_lim_width'";
}
else{
$phlimitinfo="width='$pr_lim_width' height='$pr_lim_height'";
}
}
$html_ad=$html_ad."
<td bgcolor='$adtbcol'  align='center' width='5%' >
";
if (file_exists($previewphoto_path)){
$html_ad=$html_ad."
<img src='$previewphoto_url' $phlimitinfo> 
";
}
else {
 $html_ad=$html_ad."
 
<font FACE='ARIAL, HELVETICA' size='-1'  $colr1_hltads>
-</font>  
";
}

$html_ad=$html_ad."</td>";
}

if ($prphscr=='yes') 
{ 
get_jpg_path($idnum);
if(file_exists($photo_path[1])){
     $html_ad=$html_ad."
      <td bgcolor='#ffffff'  align='center' width='5%' ".print_layerlink($idnum).">
<a href='index.php?ct=$ctval&md=details&id=$idnum' 
   title='#$idnum'>
     <img src='".$urlphtn1."sph.php?id=$idnum&wd=$prphscrwdth&np=1' $phlimitinfo border=0> 
</a> 
      </td>
     ";}
else {
$html_ad=$html_ad."
<td bgcolor='$adtbcol'  align='center' width='5%'  >
<font FACE='ARIAL, HELVETICA' size='-1' $colr1_hltads >
--</font>  
</td>
";
}
} 

$titlfldind=$row['title'];

if ($lnkttlfl =="yes"){
$titlfldind="&nbsp;
<a href='index.php?ct=$ctval&md=details&id=$idnum' 
  title='#$idnum' ".print_layerlink($idnum).">
".$row['title']." 
</a>  ".print_layerads($row)."
";
}
foreach ($cat_fields as $key => $value) 
{
if ( ($cat_fields[$key][1]=='1') or ($cat_fields[$key][1] == '12'))
{
if ($key == 'title'){
if ($row['adcommkey']==1){
$ttlbrf="
&nbsp;&nbsp;<a href='index.php?md=details&id=".$row['replyid']."'  >
<font size='-2'><b>  ".$msg['View_initia_ad']."(#".$row['replyid'].")</b></font></a>
";
}

if ($row['comment']!=""){$ttlbrf=$ttlbrf."<br> &nbsp;&nbsp;".$row['comment'];}

$html_ad=$html_ad."
<td bgcolor='$adtbcol' valign='center' width='40%' height='30' >
$capt1_hltads 
<font FACE='ARIAL, HELVETICA' size='-1' $colr1_hltads>
<b>$titlfldind</b>  $ttlbrf </font></td>";}
else {
$html_ad=$html_ad."
<td bgcolor='$adtbcol' align='center'>
<font FACE='ARIAL, HELVETICA' size='-1' $colr1_hltads>
<nobr>$row[$key]</nobr> </font></td>";}
}

}

if ($photos_count > 0)
{
if ($row['adphotos']=="yes"){$adphtovl=$msg['pictvl'];}
else {$adphtovl="-";}
$html_ad=$html_ad."
<td bgcolor='$adtbcol' align='center' width='2%'> 
<font FACE='ARIAL, HELVETICA' size='-2' $colr1_hltads>
<b>$adphtovl</b></a>
</font>
</td>
";
}
$html_ad=$html_ad."
<td bgcolor='$adtbcol'  align='center' width='5%'> 
<font FACE='ARIAL, HELVETICA' size='-2' $colr1_hltads>
<b>$ad_date </b>
</font> 
</td>
";

if ($use_gl_map=='yes' and  $clmnmap=='yes'){

$html_ad=$html_ad."
<td bgcolor='$adtbcol'  align='center' width='5%'> 
<font FACE='ARIAL, HELVETICA' size='-2' $colr1_hltads>
".adsjsp($row['addrmap'],$idnum)."
</font> 
</td>
";

}

$html_ad=$html_ad."</tr>";

return $html_ad;
}

function print_layerjavas()
{
global $use_adslayer, $md;
if (($use_adslayer=="yes") and (($md=="") or ($md=="browse")))
{
$html_layerjs= " <script language='JavaScript'>
<!--
function showlayer(nlayer)
{
 
if (document.layers)
document.layers[nlayer].visibility='show';
else 
document.all[nlayer].style.visibility='visible';
} 

function hidelayer(nlayer)
{
if (document.layers)
document.layers[nlayer].visibility='hide';
else 
document.all[nlayer].style.visibility='hidden';
} 
-->
</script>
";
}

return $html_layerjs;
}

function print_layerads($row)
{
global $cat_fields, $photos_count, $ct, $categories, $incl_prevphoto, $urlphtn1,
$previewphoto_url, $previewphoto_path, $prphotolimits, $pr_lim_height, $pr_lim_width,
$use_adslayer, $layertopval, $fields_layer, $prphscr, $prwdly, $photo_path, $fntclr_1,
$tbclr_1, $tbclr_2, $tbclr_3, $tbclr_4, $fntclr_1,$fntclr_3, $msg, $coltblayer;
 
if ($use_adslayer=="yes")
{
$ads_id=$row['idnum'];
get_jpg_path($ads_id);
 if ((file_exists($previewphoto_path)) and ($incl_prevphoto=='yes')){
$html_prvpht="<font size='-2' color='#000099'><b>".$msg['preview_photo'].":</b></font><br>  
<img src='$previewphoto_url' $phlimitinfo>
";
}

if ($prphscr=='yes') 
get_jpg_path($ads_id);
{ if(file_exists($photo_path[1])){
     $html_prvpht="
     <img src='".$urlphtn1."sph.php?id=$ads_id&wd=$prwdly&np=1' $phlimitinfo> 
     ";}
}


if ($ct =='')
{
$key_ctn=$row['catname'];
$categ_nm="  &nbsp; 
 <nobr>".$msg['category'].":  
".$categories[$key_ctn][0]."</nobr>
 
&nbsp;
";
}

$html_layerads = "
<DIV ID=\"dd".$row['idnum']."\"  ALIGN='CENTER' STYLE=\" position:absolute;
LEFT:200; VISIBILITY:hidden;\">
&nbsp;
<table   bgcolor='$coltblayer' border=0 cellspacing=0 cellpadding=0>
<tr><td> <font FACE='ARIAL, HELVETICA' COLOR='$tbclr_4' size=-1>
&nbsp;<b>".$row['title']."</b><font>
<table  width='400' border=0 cellspacing=1 cellpadding=6 >
<tr><td bgcolor='$tbclr_4'> 
<table  width='100%' border=0 cellspacing=1 cellpadding=1><tr>
<td valign=top>$html_prvpht</td>
<td valign=top>
<font FACE='ARIAL, HELVETICA' size=-1>
<font color='#008800' size='-2'>
 <b> ".$msg['adsid'].": ".$row['idnum'].";    $categ_nm  </font></b><br>
";
foreach ($cat_fields as $key => $value) 
{
if ($fields_layer[$key] == 'yes'){
$html_layerads=$html_layerads."
<font color='$fntclr_3'>".$cat_fields[$key][0].":</font>
<font color='$fntclr_1'>".$row[$key].";</font> <br>
";
}
}
$html_layerads=$html_layerads."
</td></tr></table>
</td></tr></table>
</td></tr></table>
</DIV>
";
}
return $html_layerads;
}

function print_layerlink($ads_id)
{
global $use_adslayer;

if ($use_adslayer=="yes")
{
$adsidq1="dd".$ads_id;
$html_layerlink="
OnMouseOver=\"showlayer('$adsidq1');\"
OnMouseOut=\"hidelayer('$adsidq1');\"
"; 
}
return $html_layerlink;
}

function print_ad2 ($row)
{
global $cat_fields, $photos_count, $ct, $categories, $incl_prevphoto,$bc2adsfrm,$urlphtn1,
$previewphoto_url, $previewphoto_path, $prphotolimits, $pr_lim_height, $pr_lim_width,
$prwph_layer, $colr_hltads, $capt_hltads, $prphscr, $prphscrwdth, $prwdly, $photo_path,
$tbclr_1, $tbclr_2, $tbclr_3, $tbclr_4, $fntclr_1, $fntclr_3, $lnkttlfl, $width_2tpf, $msg;

$row=check_row($row);
$colr1_hltads="color='$fntclr_1'";
 
$capt1_hltads="";
if($row['adrate']>0)
{
$colr1_hltads=$colr_hltads;
$capt1_hltads=$capt_hltads;
}

 
$time1=$row['time'];
$ad_date=get_short_date($time1);
$idnum=$row['idnum'];

$phts11="";
if ($row['adphotos'] == "yes"){$phts11="& ".$msg['photos2'];}

$ctval=$ct;
if ($ct =='')
{
 
$key_ctn=$row['catname'];
$ctval=$key_ctn;
$html_adct="
<font FACE='ARIAL, HELVETICA' size='-2' $colr1_hltads>
<b>
".$msg['category'].": <a href='index.php?md=browse&ct=$ctval'>
".$categories[$key_ctn][0]."
</b></a> 
&nbsp;
";
}

if ($incl_prevphoto=='yes')  
{
get_jpg_path($idnum);
$phlimitinfo="";
if ($prphotolimits=='yes'){
if ($pr_lim_height==""){
$phlimitinfo="width='$pr_lim_width'";
}
else{
$phlimitinfo="width='$pr_lim_width' height='$pr_lim_height'";
}
}

$html_adph="";
if (file_exists($previewphoto_path))
{
$html_adph="
<img src='$previewphoto_url' $phlimitinfo>
</td><td valign='top' width='90%'> 
";
}
}

if ($prphscr=='yes') 
{ 
get_jpg_path($idnum);
if(file_exists($photo_path[1])){
     $html_adph="
      <img src='".$urlphtn1."sph.php?id=$idnum&wd=$prphscrwdth&np=1' $phlimitinfo> 
      </td><td valign='top' width='90%'>
     ";}
} 
 
$html_ad="
<div align='left'>&nbsp; $capt1_hltads &nbsp; $html_adct</div> 
<table width=$width_2tpf bgcolor='$tbclr_4' cellspacing=3 cellpadding=3>
<tr><td bgcolor=$tbclr_1 colspan='2'>  
<font FACE='ARIAL, HELVETICA' size='-1' $colr1_hltads>
<b>
".$row['title']."
</b></font>
</td></tr><tr><td valign='top'> $html_adph   
<font FACE='ARIAL, HELVETICA' size='-2'  $colr1_hltads>
<b><font color='$fntclr_3'>  ".$msg['adsid'].":</font>$idnum;  
&nbsp;&nbsp;&nbsp; <font color='$fntclr_3'>  ".$msg['posted'].": </font> $ad_date; </b></font> &nbsp;   <br>
<font FACE='ARIAL, HELVETICA' size='-1' $colr1_hltads>
";

foreach ($cat_fields as $key => $value) 
{
if ( ($cat_fields[$key][1]=='1') or ($cat_fields[$key][1] == '12'))
{
if (($key != 'title') and ($key !='brief')){
$html_ad=$html_ad."
<font  color='$fntclr_3'>
".$cat_fields[$key][0].":  &nbsp;</font>
".$row[$key]."   <br>
";
}
}
}

$html_ad=$html_ad."
&nbsp;&nbsp;
".$row['brief']."
<br>
<font FACE='ARIAL, HELVETICA' size='-2' $colr1_hltads>
<a href='index.php?ct=$ctval&md=details&id=$idnum'>
<b>".$msg['Details']." $phts11</b></a>
</font></font>   
</td></tr></table> 
";
 
return $html_ad;
}
?>