<?PHP include("config.php");

if (!isset($_GET['state']) || !in_array($_GET['state'], $state_tag_list)) {
	header('Location: '.$site_url.'/?error=no_state');
}

$results = mysql_query("SELECT statelong FROM ".$prefix."ResourceStates WHERE statetag = '".mysql_escape_string($_GET['state'])."' LIMIT 1") OR die(mysql_error());

if (mysql_num_rows($results) == 0) {
  header('Location: '.$site_url.'?mysql_error');
}

$row = mysql_fetch_array($results);
$statename = $row['statelong'];

$results = mysql_query("SELECT * FROM ".$prefix.$main_table." WHERE ".$field_lead."state_tag='".mysql_escape_string($_GET['state'])."' AND ".$field_lead."valid=1 ORDER BY ".$field_lead."name ASC");

$none = FALSE;
if (mysql_num_rows($results) == 0) {
  $none = TRUE;
}

// set the page title
$pagetitle = $statename;

// set meta tags
$meta_keywords = $local_name_lc." in ".$statename;
$meta_description = "Trying to find ".$local_name_lc." in ".$statename."? Here is a listing of all ".$statename." ".$local_name_lc.". Users can even rate and comment on these ".$local_name_lc.".";

?>

<? include("include_common_head.php"); ?>
<? include("include_common_content.php"); ?>

<!-- Start outer -->
<div id="outer">

<!-- BODY -->
<div class="content">
<!-- LEFT COLUMN -->

<!-- End left column -->
<!-- Content col -->

<h1 class="content-title"><strong><? echo ($statename." ".$local_name); ?></strong></h1>
<div class="indent">
<?
if($none == TRUE){
echo ("No ".$local_name_lc." have been entered yet for ".$statename.".");
}
?>
<table border="0" cellspacing="0" cellpadding="1" width="580">
<? 
$x = 0;
while($row = mysql_fetch_array($results)){
$x++;
if($x % 2 == 0){ $bg = '#dddddd'; }else{ $bg = '#eeeeee'; }
?>
<tr bgcolor="<? echo "$bg"; ?>"><td><br><a class="sub-hdr" style="margin-left: 5px;" href="<? echo ("individual.php?".$field_lead."id=".$row[''.$field_lead.'id'].""); ?>"><? echo $row[''.$field_lead.'name']; ?></a></td></tr>

<tr bgcolor="<? echo "$bg"; ?>">
	<td><strong class="indent">Address:</strong> <? 
		echo ($row[''.$field_lead.'address']); 
		if($row[''.$field_lead.'address_two']) { 
			echo ("<br /><span class='indent'>".$row[''.$field_lead.'address_two']."</span>"); 
		} 
		echo("<br /><span class='indent'>".$row[''.$field_lead.'city'].", ".$row[''.$field_lead.'state']." ".$row[''.$field_lead.'zip']."</span>"); 
	?>
	</td>
</tr>
<tr bgcolor="<? echo "$bg"; ?>">
	<td><strong class="indent"><? 
		echo ("Phone: </strong>".$row[''.$field_lead.'phone']."<br /><strong class='indent'>Fax/Alt Phone: </strong>". $row[''.$field_lead.'fax']."");
	?>
	</td>
</tr>

<tr bgcolor="<? echo "$bg"; ?>">
	<td>
		<div class="indent">
			<strong>Email:</strong> <? echo "<a href='mailto:".$row[''.$field_lead.'email']."'>".$row[''.$field_lead.'email']."</a>"; ?><br />
			<strong>Website:</strong> <? echo "<a href='".$row[''.$field_lead.'website']."' target='_blank'>".$row[''.$field_lead.'website']."</a>"; ?>
			<br />
			<? echo ("<a class='nav' href='individual.php?".$field_lead."id=".$row[''.$field_lead.'id']."'>More information</a>"); ?>
			<br /><br />
		</div>
	</td>
</tr>

<? } ?>
</table>
</div>
<!-- End content col -->

</div>
<!-- End BODY -->
</div>
<!-- End Outer -->

<? include("include_common_footer.php"); ?>

