<div id="contact-page-wrapper">
<h1>Contact &frasl; Location</h1>
<div class="table-responsive">
            <table cellpadding=0 cellspacing=6 class="table-wrapper">
            
<?php
	$query = "Select fax, email, address1, address2, city, state, zip, phone, directions from storePrefs";
	$rt=mysql_query($query);         		
	if (mysql_num_rows($rt) == 0) {
		//not found, do nothing
	} else {
		while($nt=mysql_fetch_array($rt)){
			$faxnum=$nt[fax];
			$storeemail = $nt[email];
			$address1= $nt[address1];
			$address2= $nt[address2];
			$city= $nt[city];
			$state= $nt[state];
			$zip= $nt[zip];
			$phone= $nt[phone];
			$directions= $nt[directions];
		}
	}
	if(!empty($address1)){
		echo"<tr><td valign='top'><p><strong>Address:</strong></p>
		<td><p><a href='";
		include("address_link.php");
		echo "' target='blank'>$address1";
		if(!empty($address2)){
			echo "<br>".$address2;
		}
		
	}			

	if((!empty($city))||(!empty($state))||(!empty($zip))){
		if((!empty($city))&&(!empty($state))){$sep=", ";} else {$sep="";}
		echo"<br>$city$sep$state $zip";
	}
	if(!empty($address1)){
		echo"</a>";
	}
	if(!empty($phone)){
		echo"<tr><td><p><strong>Phone:</strong></p> <td><p><a href='tel:$phone'>$phone</a></p>";
	}
	if(!empty($faxnum)){
		echo"<tr><td><p><strong>Fax:</strong></p> <td><p>$faxnum</p>";
	}
	if(!empty($storeemail)){
		echo "<tr><td><p><strong>Email:</strong><td> <p><a href=\"mailto:$storeemail\"> $storeemail</a></p>";
	}
	if(!empty($directions)){
		echo "<tr><td valign='top'><p><strong>Directions:</strong></p><td><p>$directions</p>";
	}
			?>
<?php include('./hours.php'); ?>

            <!--<tr><td valign="top"><p><strong>Hours:</strong></td><td><p><?php  echo $hours; ?></p></td></tr>-->
	
    
	</table>
            
             <?php include('mapurl.php'); ?>
	<div style"clear:both;"><hr /></div> 
	</div>
			 

 
<?php
//now insert any locations
$qry = "select * from additional_locations";
$rt2=mysql_query($qry);
if (mysql_num_rows($rt2) == 0) {
		//not found, do nothing
	} else {
		while($nt=mysql_fetch_array($rt2)){
			//for each address record found:
			echo '<div class="table-responsive">
            <table cellpadding=0 cellspacing=6 class="table-wrapper">';	
            
			$faxnum=$nt[fax];
			$address1= $nt[address1];
			$address2= $nt[address2];
			$city= $nt[city];
			$state= $nt[state];
			$zip= $nt[zip];
			$phone= $nt[phone];
			$hours= $nt[hours1];
			$mapURL= $nt[mapURL];
			
						//show entered map url or create from address

			if(!empty($address1)){
				echo"<tr><td valign='top'><p><strong>Address:</strong></p>
				<td><p><a href='";
				echo'http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=';
				echo $address1;
				echo '+';
				echo $city . ", " . $state . "&nbsp;" . $zip;

				echo "' target='blank'>$address1";
				if(!empty($address2)){
					echo "<br>".$address2;
				}
				
			}			

			if((!empty($city))||(!empty($state))||(!empty($zip))){
				if((!empty($city))&&(!empty($state))){$sep=", ";} else {$sep="";}
				echo"<br>$city$sep$state $zip";
			}
			if(!empty($address1)){
				echo"</a>";
			}
			if(!empty($phone)){
				echo"<tr><td><p><strong>Phone:</strong></p> <td><p><a href='tel:$phone'>$phone</a></p>";
			}
			if(!empty($faxnum)){
				echo"<tr><td><p><strong>Fax:</strong></p> <td><p>$faxnum</p>";
			}
			
			if(!empty($hours)){			
				echo"<tr><td valign='top'><p><strong>Hours:</strong></td><td><p><?php  echo $hours; ?></p></td></tr>";
			}

			 echo '</table></div>';
			 			
			if ($mapURL !==""){	
			//admin entered a custom URL, use it here
			echo $mapURL;
			} else {
				//no custom map entered, use google default
				if ($nt[address1] !==""){	//make sure address is found, otherwise display no map	

					 echo'<div id="google-map"><div id="google-map-mobile">
					<iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=';
					echo $address1;
					echo '+';
					echo $city . ", " . $state . "&nbsp;" . $zip;
					echo '&amp;ie=UTF8&amp;hq=&amp;hnear=';
					echo $address1;
					echo '+';
					echo $city . ", " . $state . "&nbsp;" . $zip;
					echo '&amp;iwloc=near&amp;output=embed&amp;z=15"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=';
					echo $address1;
					echo '+';
					
					echo '" style=color:#0000FF;text-align:left;" target="blank">View Larger Map</a></small> </div></div>';
					echo '<div style"clear:both;"><hr /></div>';
				}
			}
			
			

			
		}
	}
?>

</div><!--end contact page wrapper div -->

