<?php
$nowDate=strtotime("now");
$hostName="localhost";
$databaseName="ors";
$dbUsername="ors";
$dbPassword="henry";

function clean($input,$maxlength)
{
	$input=substr($input,0,$maxlength);
	//$input=EscapeShellCmd($input);
	return($input);
}

function echoReplace($input)
{
	$divider="<p align=\"center\"><img src=\"images/dkblue.gif\" hspace=\"0\" vspace=\"0\" border=\"0\" height=\"1\" width=\"380\"></p>";
	$img="<img border=\"0\" hspace=\"0\" vspace=\"5\" src=\"uploads/";
	$output=str_replace("<img src=\"", $img, $input);
	$output=str_replace("<ln>", $divider, $output);

	echo nl2br($output);
}
function eventsTable($result)
{

	if(mysql_fetch_row($result)==FALSE)
	{
		echo "<span class=\"head2\">There are currently no events</span>";



	}else{
	mysql_data_seek($result,0);
	$nowDate=$GLOBALS["nowDate"];
	echo "\n<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
	echo "\n<tr><td><img src=\"images/spacer.gif\" hspace=\"0\" vspace=\"0\" border=\"0\" height=\"1\" width=\"110\"></td><td><img src=\"images/spacer.gif\" hspace=\"0\" vspace=\"0\" border=\"0\" height=\"1\" width=\"260\"></td><td><img src=\"images/spacer.gif\" hspace=\"0\" vspace=\"0\" border=\"0\" height=\"1\" width=\"40\"></td></tr>";
	/*
	*/echo "\n<tr><td align=\"center\" colspan=\"3\"><img src=\"images/dkblue.gif\" hspace=\"0\" vspace=\"5\" border=\"0\" height=\"1\" width=\"410\"></td></tr>";
	
	$prevClass="greyed";
	$nowClass="whited";

	$marker=0;
	

	while($row=mysql_fetch_array($result))
	{
	$isoDate=strtotime($row["ISODATE"]);
		if((float)$isoDate < (float)$nowDate)
		{
			echo"\n<tr class=\"padded\">";
			echo"\n<td align=\"left\"><span class=\"".$prevClass."\">".$row["NICEDATE"]."</span></td>";
			echo"\n<td align=\"left\"><span class=\"".$prevClass."\">".$row["events_header"]."</span></td>";
			echo"\n<td align=\"right\" valign=\"bottom\">";//<a href=\"events_view.php?eventID=".$row["events_id"]."\">more</a></td>";
			echo"\n</tr>";
			echo "\n<tr><td align=\"center\" colspan=\"3\"><img src=\"images/dkblue.gif\" hspace=\"0\" vspace=\"5\" border=\"0\" height=\"1\" width=\"410\"></td></tr>";

		}else{
			if($marker==0)
			{

				echo"\n<tr><td colspan=\"3\"><img src=\"images/bluedkblue.gif\" hspace=\"0\" vspace=\"0\" border=\"0\" height=\"10\" width=\"412\"></td></tr>";
				echo"\n<tr class=\"dkblue\">";
				echo"\n<td align=\"left\"><span class=\"".$nowClass."\">".$row["NICEDATE"]."</span></td>";
				echo"\n<td align=\"left\"><span class=\"".$nowClass."\">".$row["events_header"]."</span></td>";
				echo"\n<td align=\"right\" valign=\"bottom\"><a href=\"events_view.php?eventID=".$row["events_id"]."\"><span class=\"".$nowClass."link\">more</span></a></td>";
				echo"\n</tr>";
				echo"\n<tr><td colspan=\"3\"><img src=\"images/dkblueblue.gif\" hspace=\"0\" vspace=\"0\" border=\"0\" height=\"10\" width=\"412\"></td></tr>";
				echo "\n<tr><td align=\"center\" colspan=\"3\"><img src=\"images/dkblue.gif\" hspace=\"0\" vspace=\"5\" border=\"0\" height=\"1\" width=\"410\"></td></tr>";
				$marker=1;
			}else{
				echo"\n<tr class=\"padded\">";
				echo"\n<td align=\"left\">".$row["NICEDATE"]."</td>";
				echo"\n<td align=\"left\">".$row["events_header"]."</td>";
				echo"\n<td align=\"right\" valign=\"bottom\"><a href=\"events_view.php?eventID=".$row["events_id"]."\">more</a></td>";
				echo"\n</tr>";
				echo "\n<tr><td align=\"center\" colspan=\"3\"><img src=\"images/dkblue.gif\" hspace=\"0\" vspace=\"5\" border=\"0\" height=\"1\" width=\"410\"></td></tr>";
			}
		}
	}
	
	echo "\n</table>";
	}
}
?>