<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */
  require_once "/home/tcfs/public_html/cmsAdmin/lib/viewer_functions.php";

  list($featured_carsRecords, $featured_carsMetaData) = getRecords(array(
   'tableName'   => 'featured_cars',
    'where'       => 'featured_ad = 1',
    'orderBy'     => 'RAND()',
    'allowSearch' => '0',
  ));

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title></title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  <style type="text/css">
    body          { font-family: arial; }
    .instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
  </style>
 </head>
<body topmargin="0">
		<div align="left">
			<table width="730" border="0" cellspacing="0" cellpadding="5" bgcolor="#ff3232">
				<tr>
					<td><b><font size="4" color="white" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">FEATURED ADS</font></b></td>
				</tr>
				<tr>
					<td bgcolor="white"><marquee height="165" scrolldelay="200" width="720" bgcolor="white">
							<table width="360" border="0">
								<tr><?php $currentDateTime = time(); ?><?php foreach ($featured_carsRecords as $record): ?><?php if (strtotime($record['featuredStartDate']) <= $currentDateTime && strtotime($record['featuredEndDate']) >= $currentDateTime): ?>
									<td width="360">
										<table width="360" border="0" cellspacing="0" cellpadding="0">
											<tr height="120">
												<td valign="top" width="172" height="120"><?php foreach ($record['main_photo'] as $upload): ?><?php if ($upload['hasThumbnail']): ?><a href="<?php echo $record['_link'] ?>" target="_blank"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="160" height="120" border="1" alt="" hspace="5" vspace="15" /></a><?php elseif ($upload['isImage']): ?><img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><?php else: ?><a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><?php endif ?><?php break; ?><?php endforeach ?><br />
												</td>
												<td valign="top" width="188" height="120"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">
														<table border="0" cellspacing="0" cellpadding="0">
															<tr height="15">
																<td align="left" valign="top" width="58" height="15"></td>
																<td align="left" valign="top" width="129" height="15"></td>
															</tr>
															<tr height="20">
																<td colspan="2" align="left" valign="top" width="187" height="20"><font size="3" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><a href="<?php echo $record['_link'] ?>" target="_blank"><?php echo $record['main_id'] ?></a></b></font><?php  
  $secondsOld = time() - strtotime($record['date_added']);  
  $daysOld    = intval($secondsOld/60/60/24);  
?><?php if ($daysOld <= 7): ?> <img src="new.gif" alt="" height="12" width="31" border="0" /><?php endif ?></td>
															</tr>
															<tr height="20">
																<td align="left" valign="top" width="58" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Make:</b></font></td>
																<td align="left" valign="top" width="129" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><?php echo $record['make_of_car'] ?></font></td>
															</tr>
															<tr height="20">
																<td align="left" valign="top" width="58" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Model:</b></font></td>
																<td align="left" valign="top" width="129" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><?php echo $record['model_of_car'] ?></font></td>
															</tr>
															<tr height="20">
																<td align="left" valign="top" width="58" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Series:</b></font></td>
																<td align="left" valign="top" width="129" height="20"><?php echo $record['license_plate_no'] ?></td>
															</tr>
															<tr height="20">
																<td align="left" valign="top" width="58" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Price:</b></font></td>
																<td align="left" valign="top" width="129" height="20"><font size="2" color="red" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>$<?php echo number_format ($record['asking_price'] ,0) ?><?php echo $record['price_details'] ?></b></font></td>
															</tr>
															<tr height="20">
																<td align="left" valign="top" width="58" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Contact:</b></font></td>
																<td align="left" valign="top" width="129" height="20"><?php echo $record['contact_phone_nos'] ?></td>
															</tr>
														</table>
													</font></td>
											</tr>
											<tr height="1">
												<td colspan="2" valign="top" bgcolor="#d9dadc" width="360" height="2"></td>
											</tr>
										</table>
										<?php endif ?></td>
									<?php $maxCols=1000; if (@++$count % $maxCols == 0): ?></tr>
								<tr><?php endif; ?><?php endforeach ?></tr>
							</table>
						</marquee></td>
				</tr>
				<tr>
					<td><b><font size="4" color="white" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">FEATURED ADS</font></b></td>
				</tr>
			</table>
		</div>
	</body>
</html>
