<?
	require_once('control/include/user.php');
	require_once('control/include/mysql.php');
	require_once('control/include/functions.php');
	require_once('control/include/fb.php');
	
	ob_start();
	session_start();
	
	// SETUP MYSQL HANDLERS
	$mysqldb1 = new mysql($host, $user, $pswd, $db); $mysqldb1->connect(); $mysqldb1->select();
?>
<?
	$query = "SELECT * FROM listing WHERE link_name='".$_GET['link_name']."'";
	fb($query);
	$mysqldb1->query($query);
	$listing = $mysqldb1->fetchArray();
	
	$query = "
	SELECT 
		t1.*, 
		(SELECT name FROM file WHERE source='agent' AND record_id=t1.id AND type='image' AND status='enabled' ORDER BY sequence ASC LIMIT 1) AS image 
	FROM 
		agent AS t1 
	WHERE 
		t1.id=".$listing['agent_id'];
	
	fb($query);
	$mysqldb1->query($query);
	$agent = $mysqldb1->fetchArray();
	
?>
	<? if ($mysqldb1->affectedRows() > 0) { ?>
    <div class="column_module">
    <div class="column_module_heading">Agent Info</div>
    <div class="column_module_body" style="text-align:center;">
	<? if ($agent['image'] != '') { ?>
	<p><a href="<? print '/'.$largeDIR.$agent['image']; ?>" class="popup" rel="" target="_self" title="<? print $agent['name']; ?>"><img src="/<? print $smallDIR.$agent['image']; ?>" alt="<? print $agent['name']; ?>" border="0" /></a></p>
	<? } ?>
    <? if ($agent['name'] != '') { ?><p><strong><? print $agent['name']; ?></strong></p><? } ?>
	<? if ($agent['phone'] != '') { ?><p><strong><? print $agent['phone']; ?></strong></p><? } ?>
    <? if ($agent['email'] != '') { ?><p><a href="mailto:<? print $agent['email']; ?>"><strong>Email the Agent</strong></a></p><? } ?>
    </div>
    </div>
	<? } ?>
<?
	$mysqldb1->close();
?>