<?
require_once("conn.php");
require_once("includes.php");

$q1 = "select * from yellow_agents, yellow_categories,yellow_posts where yellow_posts.PostID = '$_GET[id]' and yellow_categories.CategoryID = yellow_posts.CategoryID and yellow_posts.AgentID=yellow_agents.AgentID ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
if ($a1[City]=="")
{
$aset[SiteTitle] =$a1[city]. ": " .$a1[CompanyName];
}
else
{
$aset[SiteTitle] =$a1[City]. ": " .$a1[CompanyName];
}
//////////////////////////////////////////////////////
//////////////////	Home View Counter Start
//////////////////////////////////////////////////////

if($a1[AgentID] != $_SESSION[AgentID])
{
	if(!empty($_COOKIE[RealEstates]))
	{
		$CookieArray = explode("|", $_COOKIE[cars]);
		array_unique($CookieArray);

		$rev = count($CookieArray);

		if(!in_array($_GET[id], $CookieArray))
		{
			$NewValue = $_COOKIE[cars]."|".$_GET[id];
			setcookie ("yellow", $NewValue);

			$ch = '1';
		}
	}
	else
	{
		setcookie ("yellow", $_GET[id]);
	}




	if($rev == '0' || empty($rev))
	{
		$HomeCount = 1;
	}
	else
	{
		if(isset($ch))
		{
			$HomeCount = $rev + 1;
		}
		else
		{
			$HomeCount = $rev;
		}
	}

	$HomeViews = $HomeCount." listings viewed this visit.";
}

//////////////////////////////////////////////////////
//////////////////	Home View Counter End
//////////////////////////////////////////////////////

if(empty($i) || $i == '1')
{
	$Image1 = "bg_info2.gif";

	$desc = nl2br($a1[resume]);

	$MyPrice = number_format($a1[Price], 2, ".", "'");

	$ShowInfo = "<table border=0 align=center width=\"100%\">\n\t<tr>\n\t<td width=\"100%\" valign=top colspan=2><font size=3 face=verdana color=black><b>$a1[CompanyName]</b><br>$a1[address], $a1[city], $a1[state], $a1[country]<br></font>";
	
	if(!empty($a1[phone]))
	{
		$contacts[] = "Phone: $a1[phone]";
	}

	if(!empty($a1[cellular]))
	{
		$contacts[] = "Cellular: $a1[cellular]";
	}

	if(!empty($a1[pager]))
	{
		$contacts[] = "Pager: $a1[pager]";
	}

	if(!empty($a1[website]))
	{
		$contacts[] = "<br><a class=BlackLink href=\"$a1[website]\" target=_blank>$a1[website]</a>";
	}

	if(!empty($contacts))
	{
		$ShowContacts = implode(", ", $contacts);
	}

	$ShowInfo .= "$ShowContacts</td>\n</tr>\n\n<tr>\n\t<td valign=top width=\"60%\"><br><br>$desc<br>";

	if(!empty($a1[logo]))
	{
		//$logo = "<a href=\"info.php?id=$a1[PostID]&i=2\"><img src=\"phpThumb.php?src=yellow_images/$a1[logo]&w=100\" style=\"border-color:black; border-width:1px\"></a>";
	$logo = "<img src=\"phpThumb.php?src=yellow_images/$a1[logo]&w=100\" style=\"border-color:black; border-width:1px\">";
	}

	$ShowInfo .= "</td>\n\t<td align=center valign=top width=\"40%\">$logo<br><br>For more information call<br><b> $a1[FirstName] $a1[LastName]<br>$a1[phone]</b><br>or click <a class=RedLink href=\"email.php?AgentID=$a1[PostID]&ListingID=$a1[ListingID]\">here</a> to email.<center>";
	
	$ShowInfo .= "</center></td>\n</tr>";
	
	$ShowInfo .= "\n</table>";

}
else
{
	$Image1 = "bg_info.gif";
}
if($i == '2')
{
	$Image2 = "bg_photos2.gif";

	if(!empty($a1[ResumeImages]))
	{
		$MyImages = explode("|", $a1[ResumeImages]);

		$ShowInfo .= "<table valign=top align=center  height=50>\n<tr>\n\t<td align=center valign=top  height=50>";
		
		while(list(,$v) = each($MyImages))
		{
			$ShowInfo .= "<a href=\"info.php?id=$_GET[id]&i=$_GET[i]&f=$v\"><img src=\"phpThumb.php?src=yellow_images/$v&w=50\"  border=0></a>&nbsp;&nbsp;&nbsp;\n\n\t";
		}

		$ShowInfo .= "</table><hr size=1  color=#336699><br>";


		if(!empty($f))
		{
			$ShowInfo .= "<center><img src=\"phpThumb.php?src=yellow_images/$f&w=150\"></center><br>";
		}
		else
		{
			$ShowInfo .= "<center><img src=\"phpThumb.php?src=yellow_images/$MyImages[0]&w=150\"></center><br>";
		}

	}
	else
	{
		$ShowInfo .= "<br><center><img src=\"no_image.gif\"></center>";
	}

}
else
{
	$Image2 = "bg_photos.gif";
}


$MyAddress = str_replace(" ", "+", $a1[address]);
$MyAddress = str_replace(",", "", $MyAddress);

$Image3 = "<a target=_blank  href=\"http://www.mapquest.com/maps/map.adp?city=$a1[city]&state=$a1[state]&address=$MyAddress&country=$a1[country]&zoom=5\"><img src=\"myimages/bg_directions.gif\" width=198 height=20 border=0></a>";

//$Image3 = "<img src=\"myimages/no_directions.gif\">";

$ListingID = $a1[PostID];


require_once("templates/HeaderTemplate.php");
require_once("templates/InfoTemplate.php");	
require_once("templates/FooterTemplate.php");

//update the stats
$q1 = "update yellow_posts set visits = visits + '1' where PostID = '$_GET[id]' ";
mysql_query($q1) or die(mysql_error());

?>