<?php header('Content-type: text/html; charset=utf-8'); ?> 
<?php 
 
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php'; 
  $dirsToCheck = array('/home/xxxx/public_html/','','../','../../','../../../'); 
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }} ?> 
<?php if (!@$GLOBALS['GEOCODER_PLUGIN']) { die("You must activate the Geocoder plugin before you can access this page."); } ?> 
<?php 
 
  // get records 
  list($myRecords, $myMetaData) = getRecords(array( 
    'tableName' => 'locations', 
  )); 
  list($locationsRecords, $locationsMetaData) = getRecords(array( 
    'tableName'   => 'locations', 
  )); 
?> 
 
 
 
<?php 
 
  $kmOrMiles = 'miles'; // can be 'miles' or 'km' 
 
  // set default values 
  if (!array_key_exists('fromAddress', $_REQUEST)) { $_REQUEST['fromAddress'] = ''; }      // this is the default address/postalcode if none entered 
  if (!@$_REQUEST['maxDistance'])                  { $_REQUEST['maxDistance'] = '50000'; } // this will include all results 
 
  // get coordinates 
  list($myLat, $myLng) = geocodeAddress( @$_REQUEST['fromAddress'] ); 
 
  // error checking 
  $errorsAndAlerts = ''; 
  if (@$_REQUEST['search']) { 
    if     (!@$_REQUEST['fromAddress']) { $errorsAndAlerts .= "No address entered!<br/>\n"; } 
    elseif (!$myLat || !$myLng)         { $errorsAndAlerts .= "We couldn't determine your location, please try again!<br/>\n"; } 
  } 
 
  // get records 
  $addressRecords = array(); 
  if ($myLat && $myLng) { 
    $maxDist = floatval(@$_REQUEST['maxDistance']); 
    list($addressRecords, $addressMetaData) = getRecords(array( 
    'tableName'   => 'locations', 
      'addSelectExpr' => geocoder_getSelectExprForDistance($myLat, $myLng, '_distance', $kmOrMiles), // adds '_distance' field to output records 
      'where'         => geocoder_getWhereForDistanceWithin($myLat, $myLng, $maxDist, $kmOrMiles),   // optimization: remove results outside of minimum bounding rectangle 
      'having'        => "_distance <= " . $maxDist, // only show results within max distance 
      'orderBy'       => 'ISNULL(_distance), _distance', // sort nearest records first -and- unknown or undefined distances last 
    )); 
  } 
  list($stateRecords, $stateMetaData) = getRecords(array( 
    'tableName'   => 'state', 
  )); 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<link href="css/locations.css" rel="stylesheet" type="text/css" /> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>xxxx</title> 
 
<link rel="stylesheet" href="css/reset.css" type="text/css" media="screen" /><!-- Reset --> 
<link href="css/default.css" rel="stylesheet" type="text/css" media="all" /> 
<style type="text/css"> 
@import "css/layout.css"; 
</style> 
 
<link rel="stylesheet" href="css/.css" type="text/css" media="screen" /> 
<link href="css/960.css" rel="stylesheet" type="text/css" /> 
<link rel="stylesheet" href="css/nav.css" type="text/css" media="screen" /> 
<!--Map with multiple addresses --> 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript"> 
function initialize() { 
  var mapCanvasId = 'map_canvas'; 
  var mapOptions  = { mapTypeId: google.maps.MapTypeId.ROADMAP }; 
  var map         = new google.maps.Map(document.getElementById(mapCanvasId), mapOptions); 
  var bounds      = new google.maps.LatLngBounds(); 
  var infowindow  = new google.maps.InfoWindow(); 
<?php 
foreach ($myRecords as $record) { 
  if (!$record['latitude'] || !$record['longitude']) { continue; } 
  $jsFunctionArgs = "{$record['latitude']}, {$record['longitude']}, {$record['num']}, '" .escapeJs($record['_link']). "'"; 
  print "  _geocoder_addMarker($jsFunctionArgs);\n"; 
} 
?> 
 
  // 
  function _geocoder_addMarker(latitude, longitude, recordNum, detailLink) { 
    var latLng       = new google.maps.LatLng(latitude, longitude); 
    var infowindowEl = document.getElementById('marker_infowindow_' + recordNum); 
    var marker       = new google.maps.Marker({ map: map, position: latLng }); 
    google.maps.event.addListener(marker, 'click', function() { 
      if (infowindowEl) { 
        infowindow.setContent(infowindowEl.innerHTML); 
        infowindow.open(map, marker); 
      } 
      else { 
        window.location = detailLink; 
      } 
    }); 
    bounds.extend(latLng); 
  } 
 
  // 
  map.fitBounds(bounds); 
} 
 
</script> 
<!-- end Map with multiple addresses --> 
</head> 
 
<!-- multiple addresses initialize() --> 
<body onLoad="initialize()"> 
<!-- multiple addresses initialize()--> 
 
<div id="header-wrapper"> 
 
	<div id="header-bg"> 
		<div id="header" class="container"> 
<div id="logo"> 
 
 
</div> 
<!-- end logo --> 
	<div class="clear"></div>   
<!-- nav  --> 
        <?php include("nav.php"); ?>	   
 <!-- end  --> 
 
 
	<div class="clear"></div> 
 
 
        </div> 
         
	</div> 
</div> 
<div id="page-wrapper"> 
	<div id="page-wrapper-bgtop"> 
		<div id="page-wrapper-bgbtm"> 
			<div id="box1">  
<img src="images/images/header-btm.jpg" width="960" height="20" />                        
<!-- content --> 
 
 
 
 
 
 
 
 
</div> 
 
    	<!-- end content --> 
 
 
          </div> 
    	<!-- box-sub --> 
<div id="content-wrapper">             
  <div id="content-bgtop-sub"> 
			<div id="content-bgbtm"> 
                       
<div id="sub2"class="container_16"> 
	<div class="grid_8"> 
<!-- content --> 
 
  <!--  Map with multiple addresses --> 
  <?php $hasAddresses = array_filter(array_pluck($myRecords, 'latitude')); ?> 
  <?php if ($hasAddresses): ?> 
    <div id="map_canvas" style="width: 460px; height: 230px;"></div> 
  <?php endif ?> 
 
  <?php if (!$hasAddresses): ?> 
    <div style="width: 460px; height: 230px;"> 
      <div style="text-align: center;"> 
        Site maintenance, please check back. 
      </div> 
    </div> 
  <?php endif ?> 
 
 
  <!-- popup window --> 
  <div id="marker_details" style="display: none;"> 
    <?php foreach ($myRecords as $record): ?> 
      <div id="marker_infowindow_<?php echo $record['num']; ?>"> 
<?php if($record['coming_soon']):?><strong>Coming Soon!</strong><br /><?php endif?>       
        <?php echo htmlspecialchars( @$record['address']); ?><br /> 
        <?php if($record['city']):?><?php echo htmlspecialchars($record['city']); ?><?php endif?><?php if($record['state']):?>,&nbsp;<?php echo $record['state:label']; ?><?php endif?><?php if($record['zipcode']):?>&nbsp;<?php echo htmlspecialchars($record['zipcode']); ?><?php endif?><br/><?php if($record['phone']):?><strong>Phone&nbsp;</strong><?php echo htmlspecialchars($record['phone']); ?><?php endif?> 
 
 
      </div> 
 
    <?php endforeach ?> 
  </div> 
  <!-- END Map with multiple addresses --> 
</div>    <!-- end grid 8 --> 
 
	<div class="grid_8"> 
  <!-- proximity search --> 
  <h2>Find a Location</h2> 
  Enter your address or postal code to see nearby results: 
<?php if (@$errorsAndAlerts): ?> 
<div style="color: #C00; font-weight: bold; font-size: 12px; font-family: arial;"> <?php echo $errorsAndAlerts; ?><br/> 
</div><?php endif ?> 
 
<form method="post" action=""> 
  <input type="hidden" name="search" value="1" /> 
  <input type="text" name="fromAddress" value="<?php echo htmlspecialchars(@$_REQUEST['fromAddress']); ?>" size="30" /> 
  <select name="maxDistance"> 
    <option value="">at any distance</option> 
    <option value="100" <?php selectedIf(100, @$_REQUEST['maxDistance']) ?> >within 100 miles</option> 
    <option value="25"  <?php selectedIf( 25, @$_REQUEST['maxDistance']) ?> >within 25 miles</option> 
    <option value="10"  <?php selectedIf( 10, @$_REQUEST['maxDistance']) ?> >within 10 miles</option> 
    <option value="5"   <?php selectedIf( 5,  @$_REQUEST['maxDistance']) ?> >within 5 miles</option> 
  </select> 
  <input type="submit" value="Search" /> 
</form> 
<?php if (@$_REQUEST['search'] && !$errorsAndAlerts): ?> 
<?php foreach ($addressRecords as $record): ?> 
<ul class="list_location"> 
  <?php if($record['coming_soon']):?> 
  <li><div class="soon">Coming Soon!</div></li> 
    <?php endif?> 
  <?php if($record['address']):?>   
  <li><h3><?php echo htmlspecialchars($record['address']); ?></h3></li> 
  <?php endif?> 
 
  <li><strong>Distance</strong>&nbsp;<?php echo floor($record['_distance'] * 10) / 10; ?> <?php echo $kmOrMiles ?><?php if($record['site']):?>&nbsp;[<?php echo htmlspecialchars($record['site']); ?>]<?php endif?></li><br/> 
  <?php if($record['address']):?>   
  <li><?php echo htmlspecialchars($record['address']); ?></li> 
  <?php endif?> 
<li><?php if($record['city']):?><?php echo htmlspecialchars($record['city']); ?><?php endif?>   
<?php if($record['state']):?>,&nbsp;<?php echo $record['state:label']; ?><?php endif?>   
<?php if($record['zipcode']):?>&nbsp;<?php echo htmlspecialchars($record['zipcode']); ?><?php endif?> 
</li> <br/>  
  <?php if($record['phone']):?> 
  <li><strong>Phone&nbsp;</strong><?php echo htmlspecialchars($record['phone']); ?><?php if($record['fax']):?><div style="padding-left: 10px; padding-right: 10px; display: inline;">|</div><strong>Fax</strong> 
<?php echo htmlspecialchars($record['fax']); ?><?php endif?></li> 
  <?php endif?> 
  <?php if($record['e_mail']):?> 
  <li><strong>E-mail&nbsp;</strong><?php echo htmlspecialchars($record['e_mail']); ?></li> 
  <?php endif?> 
  <?php if($record['hours']):?> 
  <li><strong>Hours&nbsp;</strong><?php echo htmlspecialchars($record['hours']); ?></li> 
  <?php endif?> 
 
</ul> 
<?php endforeach ?> 
<?php if (!$addressRecords): ?> 
<ul style="line-height: 1.5"> 
  <li>No results found. Please read our search tips or try increasing the distance in the drop menu.</li> 
</ul> 
<?php endif ?> 
 
<?php endif ?> 
 
  <!-- end proximity search --> 
 
 
 
    	<!-- end content --> 
</div>   
	<!-- end .grid_16 --> 
	<div class="clear"></div>     
 
           
 
            </div><!--end content-bgbtm --> 
	    </div><!--end content-bgtop --> 
	</div> 
	<!-- end content-wrapper -->  
 
		</div> 
      	<!-- page-wrapper-bgtop -->    
	</div> 
 
<div id="footer"> 
	<p></p> 
</div> 
 
 
</body> 
</html>