<?php include ("_website_init.php"); ?>
<?php // 11/7/16 added !$record['notAdmin'] == '1' to lines 382 and 446 to eliminate all admins from searches ?>
<?php // 3/31/17 commented out the "are you a therapist" questiond (line 173-177). Uncomment this question and move the "description (client) field in the Provider Profiles database from "no longer used" status to reinstate the two categories. ?>
<?php // load records from 'accounts'
  list($accountsRecords, $accountsMetaData) = getRecords(array(
    'tableName'   => 'accounts',
    'loadUploads' => true,
    'allowSearch' => true,

  ));
  
   list($faqRecords, $faqMetaData) = getRecords(array(
    'tableName'   => 'faq',
    'loadUploads' => true,
    'allowSearch' => false,

  ));
  
   // load records from 'navigation_menu'
  list($navigation_menuRecords, $navigation_menuMetaData) = getRecords(array(
    'tableName'   => 'navigation_menu',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

 // error checking
  if (!@$GLOBALS['GEOCODER_PLUGIN']) { die("You must activate the Geocoder plugin before you can access this page."); }

  // set default values (not required)
//  if (!array_key_exists('fromAddress', $_REQUEST)){ $_REQUEST['fromAddress'] = 'Please Enter A Zip/Postal Code';}      // this is the default address/postalcode if none entered

  // get geocoding data
  list($myLat, $myLng) = geocodeAddress( @$_REQUEST['fromAddress'] );
  $kmOrMiles           = 'miles'; // can be 'miles' or 'km'
  $geoOptions          = geocoder_getOptions($myLat, $myLng, @$_REQUEST['maxDistance'], $kmOrMiles);

  // get records
  list($addressRecords, $addressMetaData) = getRecords(array(
    'tableName'     => $GLOBALS['GEOCODER_SAMPLE_TABLENAME'],
  ) + $geoOptions);  // geoOptions WILL NOT override the above options
 
  // error checking
   $errorsAndAlerts = '';
   if (@$_REQUEST['save']) 
  { 
  @$count = '';
   $action = '' ;
     @$count = mb_strlen($_REQUEST['fromAddress']  );
	// echo $count ;

    if     (!@$_REQUEST['fromAddress']) { $errorsAndAlerts .= "No zip/postal code entered<br/>\n"; }
	  elseif (@$count < 5 )                                  { $errorsAndAlerts .= "Your zip/postal code must be at least 5 digits long.<br/>\n"; }
	 elseif (!$myLat || !$myLng)         { $errorsAndAlerts .= "Please enter a valid zip/postal code<br/>\n"; }
    
  }
  



?>

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>THE DBT PROVIDER DIRECTORY</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/ico" href="/favicon.ico" />
<link href="css/dbt.css.php" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/fonts.css.php" />
<?php include ("_preload.php"); ?>
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=<?php 
    $output = ''; 
    foreach ($google_font_namesRecords as $record) { $record['name'] = preg_replace("/[, ]/", "+", $record['name']);
      $output .= $record['name'] . "|"; 
    } 
    $output = rtrim($output,"|"); // remove trailing pipe 
    print $output; 
?>">
<?php function formatPhone($phone = '', $convert = false, $trim = true)
{
	// If we have not entered a phone number just return empty
	if (empty($phone)) {
		return '';
	}
 
	// Strip out any extra characters that we do not need only keep letters and numbers
	$phone = preg_replace("/[^0-9A-Za-z]/", "", $phone);
 
	// Do we want to convert phone numbers with letters to their number equivalent?
	// Samples are: 1-800-TERMINIX, 1-800-FLOWERS, 1-800-Petmeds
	if ($convert == true) {
		$replace = array('2'=>array('a','b','c'),
				 '3'=>array('d','e','f'),
			         '4'=>array('g','h','i'),
				 '5'=>array('j','k','l'),
                                 '6'=>array('m','n','o'),
				 '7'=>array('p','q','r','s'),
				 '8'=>array('t','u','v'),								 '9'=>array('w','x','y','z'));
 
		// Replace each letter with a number
		// Notice this is case insensitive with the str_ireplace instead of str_replace 
		foreach($replace as $digit=>$letters) {
			$phone = str_ireplace($letters, $digit, $phone);
		}
	}
 
	// If we have a number longer than 11 digits cut the string down to only 11
	// This is also only ran if we want to limit only to 11 characters
	if ($trim == true && strlen($phone)>11) {
		$phone = substr($phone, 0, 11);
	}						 
 
	// Perform phone number formatting here
	if (strlen($phone) == 7) {
		return preg_replace("/([0-9a-zA-Z]{3})([0-9a-zA-Z]{4})/", "$1-$2", $phone);
	} elseif (strlen($phone) == 10) {
		return preg_replace("/([0-9a-zA-Z]{3})([0-9a-zA-Z]{3})([0-9a-zA-Z]{4})/", "($1) $2-$3", $phone);
	} elseif (strlen($phone) == 11) {
		return preg_replace("/([0-9a-zA-Z]{1})([0-9a-zA-Z]{3})([0-9a-zA-Z]{3})([0-9a-zA-Z]{4})/", "$1($2) $3-$4", $phone);
	}
 
	// Return original phone if not 7, 10 or 11 digits long
	return $phone;
}
?>
<script type="text/javascript">
jQuery("#zip").click(function() {
  alert( "Handler for .click() called." );
});</script>
<style>
input[type=submit] {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 18px;
	color: #ffffff;
	padding: 10px 20px;
	background: -moz-linear-gradient(  top,  #dedede 0%,  #1b3768);
	background: -webkit-gradient(  linear, left top, left bottom,  from(#dedede),  to(#203e73));
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;
	border: 1px solid #134201;
	-moz-box-shadow: 0px 1px 3px rgba(000,000,000,0.5),  inset 0px 0px 2px rgba(255,255,255,1);
	-webkit-box-shadow: 0px 1px 3px rgba(000,000,000,0.5),  inset 0px 0px 2px rgba(255,255,255,1);
	box-shadow: 0px 1px 3px rgba(000,000,000,0.5),  inset 0px 0px 2px rgba(255,255,255,1);
	text-shadow: 0px -1px 0px rgba(000,000,000,0.4),  0px 1px 0px rgba(255,255,255,0.3);
}
</style>

</head>
<body >
<p>&nbsp;</p>
<table class="shadow3" bgcolor="#<?php echo $dbt_colorsRecord['main_box_background_color'] ?>" width="55%" border="0" align="center" cellpadding="0">
  <tr>
    <td  colspan="2" bgcolor="#<?php echo $dbt_colorsRecord['masthead_background_color'] ?>"><div class="under round-corner" align="left">
        <?php foreach ($common_informationRecord['masthead'] as $index => $upload): ?>
        <a href="index.php"><img src="<?php echo $upload['thumbUrlPath3'] ?>"   alt="DBT Masthead" /></a>
        <?php endforeach ?>
      </div></td>
  </tr>
  <tr>
    <td class="shadow3"  width="20%" rowspan="4" align="right" valign="top" bgcolor="#<?php echo $dbt_colorsRecord['menu_background_color'] ?>" ><?php include ("_mainnavmenu.php"); ?></td>
    <td width="82%"></td>
  </tr>
  <tr>
    <td align="center" ><br />
      <br />
      <div align="center" style="width:80%; text-align:left">
      
      <!-- Insert Active Code Here --> 
      <br />
      <div align="center" style="width:80%; " class="heading_font"><?php echo $common_informationRecord['home_page_head'] ?></div>
      <br />
      <div align="center" class="text_font" style="width:80%; text-align:left"><?php echo str_replace($placeHolders, $replaceWith, $common_informationRecord['home_page_text']);?></div>
      <br />
      <hr  align="left" style="height:2px; background-color:#<?php echo $dbt_colorsRecord['menu_background_color'] ?>;" width="90%" color="#<?php echo $dbt_colorsRecord['menu_background_color'] ?>"/>
      <br />
      <?php if(@$errorsAndAlerts):?>
      <table align="left" width="90%" border="0" cellspacing="0" cellpadding="2">
        <tr>
        <tr>
          <td align="left"  colspan="2"><span class="heading_font" style="color: #C00;"><?php echo @$errorsAndAlerts ?></span></td>
        </tr>
      </table>
      <?php endif ?>
      <table align="left" width="90%" border="0" cellspacing="0" cellpadding="2">
        <!-- <tr>
            <td align="right" class="text_font"><b>Are You A Therapist?: </b></td>
            <td align="left" valign="bottom" colspan="2"><select name = "therapist" width="300" class="text_font" style="width: 300px; background-color:#<?php echo $dbt_colorsRecord['main_box_background_color'] ?>;">
                <option value="">Optional</option>
                <option value="1">Yes</option>
              </select></td>
          </tr> -->
        <?php if  (!@$_REQUEST['save'] == 1 || @$errorsAndAlerts):
		    ?>
        <tr>
          <td colspan="2"><span class="heading_font"><b>SEARCH FOR A PROVIDER</b><br />
            </span></td>
        </tr>
        <tr>
          <td align="left"  colspan="2"><span class=" sub_heading_font">Use The pull down fields below to narrow your search.</span> <br />
            <span class="text_font">&bull; You can always change your search criteria and re-submit. <br />
            <br />
            <b>Hint:</b> to select more than one option for any of the fields below, hold the CTRL (CMD) key and Click to highlight each of the options.<br />
            </span><br />
            <font color="#FF0000">*</font> = Required Field <br />
            <br /></td>
        </tr>
        <form method="post"  action= "?">
          <input type="hidden" name="save" value="1" />
          <input type="hidden" name="km_miles" value="<?php echo $kmOrMiles ?>" />
          <tr>
            <td colspan="2">&nbsp;</td>
          </tr>
          <tr>
            <td valign="top"  align="right" class="text_font"><b><font color="#FF0000">*</font> Enter A Zip/Postal Code<br />
              And A Country To Search: <font color="#FF0000">*</font><br />
              </b></td>
            <td align="left" valign="top" colspan="2"><input type="text" name="fromAddress" value="<?php echo htmlspecialchars(@$_REQUEST['fromAddress']); ?>" size="38" class="text_font" style="background-color:#<?php echo $dbt_colorsRecord['main_box_background_color'] ?>;" placeholder="Please Enter A Zip/Postal Code And A Country To Search" id="zip">
              <br />
              
              <!--<span class="text_font">Add The Country Name After The Postal Code<br />If Searching Outside Your Current Location<br /><br /></span>--></td>
          </tr>
          <tr>
            <td  align="right" class="text_font"><b>How Far Away From This Zip/Postal Code?:<br />
              </b></td>
            <td align="left" valign="top" colspan="2"><select name="maxDistance" width="300" class="text_font" style="width: 300px; max-height: 50px; background-color:#<?php echo $dbt_colorsRecord['main_box_background_color'] ?>;">
                <option value="">At Any Distance</option>
                <option value="100" <?php selectedIf(100, @$_REQUEST['maxDistance']) ?> >within 100
                <?php if ( $kmOrMiles == 'miles'):?>
                miles
                <?php elseif ( $kmOrMiles == 'km'):?>
                km
                <?php endif ?>
                </option>
                <option value="50"  <?php selectedIf( 50, @$_REQUEST['maxDistance']) ?> >within 50
                <?php if ( $kmOrMiles == 'miles'):?>
                miles
                <?php elseif ( $kmOrMiles == 'km'):?>
                km
                <?php endif ?>
                </option>
                <option value="25"  <?php selectedIf( 25, @$_REQUEST['maxDistance']) ?> >within 25
                <?php if ( $kmOrMiles == 'miles'):?>
                miles
                <?php elseif ( $kmOrMiles == 'km'):?>
                km
                <?php endif ?>
                </option>
                <option value="10"  <?php selectedIf( 10, @$_REQUEST['maxDistance']) ?> >within 10
                <?php if ( $kmOrMiles == 'miles'):?>
                miles
                <?php elseif ( $kmOrMiles == 'km'):?>
                km
                <?php endif ?>
                </option>
                <option value="5"   <?php selectedIf( 5,  @$_REQUEST['maxDistance']) ?> >within 5
                <?php if ( $kmOrMiles == 'miles'):?>
                miles
                <?php elseif ( $kmOrMiles == 'km'):?>
                km
                <?php endif ?>
                </option>
              </select></td>
          </tr>
          <tr>
            <td  align="right" class="text_font"><b>Languages Spoken:</b><br /></td>
            <td align="left" valign="bottom" colspan="2"><select name = "languages_spoken_keyword[]"  width="300" class="text_font" style="width: 300px; max-height: 50px; background-color:#<?php echo $dbt_colorsRecord['main_box_background_color'] ?>;"  multiple>
                <?php foreach (getListOptions('accounts', 'languages_spoken') as $value => $label7): ?>
                <option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['languages_spoken']);?>> <?php echo $label7; ?></option>
                <?php endforeach ?>
              </select></td>
          </tr>
          <tr>
            <td  align="right" class="text_font"><b>Insurance Networks Accepted:</b><br /></td>
            <td align="left" valign="bottom" colspan="2"><select name = "insurance_classes_accepted_keyword[]"  width="300" class="text_font" style="width: 300px; max-height: 50px; background-color:#<?php echo $dbt_colorsRecord['main_box_background_color'] ?>;"  multiple>
                <?php foreach (getListOptions('accounts', 'insurance_classes_accepted') as $value => $label6): ?>
                <option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['insurance_classes_accepted']);?>> <?php echo $label6; ?></option>
                <?php endforeach ?>
              </select></td>
          </tr>
          <tr>
            <td  align="right" class="text_font"><b>Level of Care Required:</b><br /></td>
            <td align="left" valign="bottom" colspan="2"><select name = "levels_of_care_keyword[]"  width="300" class="text_font" style="width: 300px; max-height: 50px; background-color:#<?php echo $dbt_colorsRecord['main_box_background_color'] ?>;"  multiple>
                <?php foreach (getListOptions('accounts', 'levels_of_care') as $value => $label2): ?>
                <option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['levels_of_care']);?>> <?php echo $label2; ?></option>
                <?php endforeach ?>
              </select></td>
          </tr>
          <tr>
            <td align="right" class="text_font"><b>Services Offered:</b><br /></td>
            <td align="left" valign="bottom" colspan="2"><select name = "services_offered_keyword[]"  width="300" class="text_font" style="width: 300px; max-height: 50px; background-color:#<?php echo $dbt_colorsRecord['main_box_background_color'] ?>;"  multiple>
                <?php foreach (getListOptions('accounts', 'services_offered') as $value => $label4): ?>
                <option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['services_offered']);?>> <?php echo $label4; ?></option>
                <?php endforeach ?>
              </select></td>
          </tr>
          <tr>
            <td align="right" class="text_font"><b>Age Group:</b><br /></td>
            <td align="left" valign="bottom" colspan="2"><select name = "general_target_population_keyword[]" width="300" class="text_font" style="width: 300px; max-height: 50px; background-color:#<?php echo $dbt_colorsRecord['main_box_background_color'] ?>;" multiple>
                <?php foreach (getListOptions('accounts', 'general_target_population') as $value => $label5): ?>
                <option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['general_target_population']);?>> <?php echo $label5; ?></option>
                <?php endforeach ?>
              </select></td>
          </tr>
          <tr>
            <td align="right" class="text_font"><b>Public Transportation Near By: </b></td>
            <td align="left" valign="bottom" colspan="2"><select name = "public_transportation_nearby" width="300" class="text_font" style="width: 300px; background-color:#<?php echo $dbt_colorsRecord['main_box_background_color'] ?>;">
                <option value="">Optional</option>
                <option value="1">Yes</option>
              </select></td>
          </tr>
          <tr>
            <td align="right" class="text_font"><b>Wheelchair Accessible: </b></td>
            <td align="left" valign="bottom" colspan="2"><select name = "wheelchair_accessible" width="300" class="text_font" style="width: 300px; background-color:#<?php echo $dbt_colorsRecord['main_box_background_color'] ?>;">
                <option value="">Optional</option>
                <option value="1">Yes</option>
              </select></td>
          </tr>
          <tr>
            <td align="right" class="text_font"><b>&nbsp;</b></td>
            <td align="left" valign="bottom" colspan="2"><br />
              <input type="submit" value="Submit Your Search" ></td>
          </tr>
          
        </form>
        <?php  endif ?>
        <tr>
          <td>&nbsp;</td>
          <td colspan="2"><form method="post" action="" >
            <input type="hidden" name="save" value="0" />
               <INPUT TYPE="submit" VALUE="Cancel Search Filters - Start Another Search">
            </form></td>
        </tr>
        <!-- BEGIN RESULTS DISPLAY-->
        
        <tr>
          <td colspan="2">
		  <?php
	// Start Languages Spoken
		  @$languagesSpokensearchCriteria = "";  // set default value
		  if  (@$_REQUEST['save'] == 1 && @$_REQUEST['languages_spoken_keyword']) {
		   @$languagesSpokensearchCriteria = "<b>Languages Spoken: </b>";  // set default value 
		   // cycle through each language selected
		   foreach ($_REQUEST['languages_spoken_keyword'] as $languagesSpoken) {
			 
			 // lookup languages spoken number in database
			 $languages_listRecord = mysql_get("languages_list", $languagesSpoken);
			 
			 if ($languages_listRecord) {
			   // add "language spoken" value to output
			   @$languagesSpokensearchCriteria .= $languages_listRecord['language'] .", ";
			 }
			 
		   }
		   
		  }
		  //End Languages Spoken 
		 	
		  // Start Insurance networks Accepted 
		  @$insuranceNetworksAcceptedsearchCriteria = "";  // set default value
		  if  ((@$_REQUEST['save'] == 1) && @$_REQUEST['insurance_classes_accepted_keyword']) {
		   @$insuranceNetworksAcceptedsearchCriteria = "<b>Insurance Networks Accepted: </b>";  // set default value 
		   // cycle through each Insurance Networks Accepted selected
		   foreach ($_REQUEST['insurance_classes_accepted_keyword'] as $insuranceNetworksAccepted) {
			 
			 // lookup Insurance Networks Acceptedn number in database
			 $insurance_classes_accepted_categoriesRecord = mysql_get("insurance_classes_accepted_categories", $insuranceNetworksAccepted);
			 
			 if ($insurance_classes_accepted_categoriesRecord) {
			   // add "Insurance Networks Accepted" value to output
			   @$insuranceNetworksAcceptedsearchCriteria .= $insurance_classes_accepted_categoriesRecord['category'] .", ";
			 }
			 
		   }
		   
		  }
		  //End Insurance network Accepted
		
		// Start Levels Of Care
		  @$levelsOfCaresearchCriteria = "";  // set default value
		  if  ((@$_REQUEST['save'] == 1) && @$_REQUEST['levels_of_care_keyword']) {
		   @$levelsOfCaresearchCriteria = "<b>Levels of Care: </b>";  // set default value 
		   // cycle through each level of care selected
		   foreach ($_REQUEST['levels_of_care_keyword'] as $levelOfCare) {
			 
			 // lookup level of care number in database
			 $levelOfCareRecord = mysql_get("levels_of_care_categories", $levelOfCare);
			 
			 if ($levelOfCareRecord) {
			   // add "level of care" value to output
			   @$levelsOfCaresearchCriteria .= $levelOfCareRecord['category'] .", ";
			 }
			 
		   }
		   
		  }
		  //End Levels Of Care
		 
		  //Start Age Group
		  @$generalTargetPopulationsearchCriteria = "";  // set default value
		  if  ((@$_REQUEST['save'] == 1) && @$_REQUEST['general_target_population_keyword']) {
		   @$generalTargetPopulationsearchCriteria = "<b>Age Group: </b>";  // set default value 
		   // cycle through each general target population selected
		   foreach ($_REQUEST['general_target_population_keyword'] as $generalTargetPopulation) {
			 
			 // lookup general target population number in database
			 $general_target_populationRecord = mysql_get("general_target_population_categories", $generalTargetPopulation);
			 
			 if ($general_target_populationRecord) {
			   // add "general target population" value to output
			   @$generalTargetPopulationsearchCriteria .= $general_target_populationRecord['category'] .", ";
			 }
		   }
		  }
		  //End Age Group
		  
		 // Start Services Offered
		    @$servicesOfferedsearchCriteria = "";  // set default value
		  if  ((@$_REQUEST['save'] == 1) && @$_REQUEST['services_offered_keyword']) {
		   @$servicesOfferedsearchCriteria = "<b>Services Offered: </b>";  // set default value 
		   // cycle through each services offered selected
		   foreach ($_REQUEST['services_offered_keyword'] as $servicesOffered) {
			 
			 // lookup services offered number in database
			 $servicesOfferedRecord = mysql_get("services_offered_categories", $servicesOffered);
			 
			 if ($servicesOfferedRecord) {
			   // add "services offered" value to output
			   @$servicesOfferedsearchCriteria .= $servicesOfferedRecord['category'] .", ";
			 }
		   }
		  } 
		  // End Services Offered	
		 	  
		  if ((@$_REQUEST['save'] == 1) && @$_REQUEST['public_transportation_nearby'] && @$_REQUEST['public_transportation_nearby'] == 1) { @$publicTransportationNearbysearchCriteria .= "<b>Public Transportation Nearby:</b> Yes"; }

if ((@$_REQUEST['save'] == 1) && @$_REQUEST['public_transportation_nearby'] && (@$_REQUEST['public_transportation_nearby'] == 0 || @$_REQUEST['public_transportation_nearby'] == "")) { @$publicTransportationNearbysearchCriteria .= "<b>Public Transportation Nearby:</b> No"; }
   
    if ((@$_REQUEST['save'] == 1) && @$_REQUEST['wheelchair_accessible'] && @$_REQUEST['wheelchair_accessible'] == 1) { @$wheelchairAccessiblesearchCriteria .= "<b>Wheelchair Accessible:</b> Yes"; }
 
  if (( @$_REQUEST['save'] == 1) && @$_REQUEST['wheelchair_accessible'] && (@$_REQUEST['wheelchair_accessible'] == 0 || @$_REQUEST['wheelchair_accessible'] == "")) { @$wheelchairAccessiblesearchCriteria .= "<b>Wheelchair Accessible:</b> No"; }

		 // else {
		//	$searchCriteria = "All Listings";
		//  }
		  
		  @$insuranceNetworksAcceptedsearchCriteria = chop(@$insuranceNetworksAcceptedsearchCriteria, ', '); // remove trailing , or spaces
		 @$insuranceNetworksAcceptedsearchCriteria = chop(@$insuranceNetworksAcceptedsearchCriteria, '- '); // remove trailing - or spaces
		 
		 @$languagesSpokensearchCriteria = chop(@$languagesSpokensearchCriteria, ', '); // remove trailing , or spaces
		 @$languagesSpokensearchCriteria = chop(@$languagesSpokensearchCriteria, '- '); // remove trailing - or spaces
		 
		   @$levelsOfCaresearchCriteria = chop(@$levelsOfCaresearchCriteria, ', '); // remove trailing , or spaces
		 @$levelsOfCaresearchCriteria = chop(@$levelsOfCaresearchCriteria, '- '); // remove trailing - or spaces
		 
		  @$generalTargetPopulationsearchCriteria = chop(@$generalTargetPopulationsearchCriteria, ', '); // remove trailing , or spaces
		 @$generalTargetPopulationsearchCriteria = chop(@$generalTargetPopulationsearchCriteria, '- '); // remove trailing - or spaces
		
		  @$servicesOfferedsearchCriteria = chop(@$servicesOfferedsearchCriteria, ', '); // remove trailing , or spaces
		 @$servicesOfferedsearchCriteria = chop(@$servicesOfferedsearchCriteria, '- '); // remove trailing - or spaces
		 
		  @$generalTargetPopulationsearchCriteria = chop(@$generalTargetPopulationsearchCriteria, ', '); // remove trailing , or spaces
		 @$generalTargetPopulationsearchCriteria = chop(@$generalTargetPopulationsearchCriteria, '- '); // remove trailing - or spaces
		 
		
		 
		 
		?></td>
        </tr>
        <tr>
          <td colspan="2"><!-- <?php // if ($errorsAndAlerts) :?>
            <span class="new_sub_heading_font"><?php // echo $errorsAndAlerts ?></span>
            <?php // endif?>-->
            
            <div align="left"> <span class="text_font">
              <?php if (!$errorsAndAlerts) :?>
              <?php $count = '' ?>
              <?php if(@$_REQUEST['save']):?>
              <?php foreach ($addressRecords as $record): ?>
              <?php 
$updateUnixTime     = strtotime( $record['updatedDate'] ); // seconds since 1970 
$sixMonths = time() - (180*60*60*24) ; //(changed from + to -)
$sixMonthsGone = $updateUnixTime > $sixMonths;

?>
              <?php if(!$record['isAdmin'] && !$record['notAdmin'] == '1' && ( $sixMonthsGone) ):?>
              <?php $count++; ?>
              <?php endif ?>
              <?php endforeach ?>
              <hr  align="left" style="height:2px; background-color:#<?php echo $dbt_colorsRecord['menu_background_color'] ?>;" width="90%" color="#<?php echo $dbt_colorsRecord['menu_background_color'] ?>"/>
              <?php if($count >= 2 || $count == 0 ):?>
              There are
              <?php elseif($count == 1):?>
              There is
              <?php endif ?>
              <?php if ($count == 0):?>
              no
              <?php elseif (!$count == 0):?>
              <?php echo $count ?>
              <?php endif?>
              <?php if($count >= 2 || $count == 0 ):?>
              listings
              <?php elseif($count == 1):?>
              listing
              <?php endif ?>
              that
              <?php if ($count == 1):?>
              matches
              <?php else:?>
              match
              <?php endif ?>
              your search for:
              <?php if ( @$levelsOfCaresearchCriteria || @$generalTargetPopulationsearchCriteria || @$wheelchairAccessiblesearchCriteria || @$publicTransportationNearbysearchCriteria || @$servicesOfferedsearchCriteria || @$practiceStatesearchCriteria || @$languagesSpokensearchCriteria || $insuranceNetworksAcceptedsearchCriteria):?>
              <br />
              <?php echo @$languagesSpokensearchCriteria ?>
              <?php if ( @$languagesSpokensearchCriteria):?>
              <br />
              <?php endif ?>
              <?php echo @$insuranceNetworksAcceptedsearchCriteria ?>
              <?php if ( @$insuranceNetworksAcceptedsearchCriteria):?>
              <br />
              <?php endif ?>
              <?php echo @$levelsOfCaresearchCriteria ?>
              <?php if ( @$levelsOfCaresearchCriteria):?>
              <br />
              <?php endif ?>
              <?php echo @$servicesOfferedsearchCriteria ?>
              <?php if ( @$servicesOfferedsearchCriteria):?>
              <br />
              <?php endif ?>
              <?php echo @$generalTargetPopulationsearchCriteria ?>
              <?php if ( @$generalTargetPopulationsearchCriteria):?>
              <br />
              <?php endif ?>
              <?php echo @$publicTransportationNearbysearchCriteria ?>
              <?php if ( @$publicTransportationNearbysearchCriteria):?>
              <br />
              <?php endif ?>
              <?php echo @$wheelchairAccessiblesearchCriteria ?>
              <?php if ( @$wheelchairAccessiblesearchCriteria):?>
              <br />
              <?php endif ?>
              <?php else :?>
              All Listings<br />
              <?php  endif ?>
              <?php if ($myLat):?>
              <b>Distance from <?php echo htmlspecialchars(@$_REQUEST['fromAddress']); ?>:</b> Within
              <?php if (@$_REQUEST['maxDistance']):?>
              <?php echo htmlspecialchars(@$_REQUEST['maxDistance']); ?>
              <?php else:?>
              unlimited
              <?php endif ?>
              <?php if ( @$_REQUEST['km_miles'] == 'miles'):?>
              miles
              <?php elseif (  @$_REQUEST['km_miles'] == 'km'):?>
              km
              <?php endif ?>
              <?php endif?>
              </span><br />
            </div>
            <?php endif ?>
            <?php foreach ($navigation_menuRecords as $record): ?>
            <?php  if (strpos($record['url'], 'faq')!== FALSE): ?>
            <?php if(@$_REQUEST['therapist'] == 0 || @$_REQUEST['therapist'] == "") :?>
            <?php foreach ($faqRecords as $record): ?>
            <br />
            If you're not sure what a term means, you'll find more information on our <a target="_blank" href="faq.php">FAQ</a> pages. <br />
            <?php break ?>
            <?php endforeach ?>
            <?php  endif ?>
            <?php endif ?>
            <?php  endforeach ?></td>
        </tr>
        <tr>
          <td colspan="2"><hr  align="left" style="height:2px; background-color:#<?php echo $dbt_colorsRecord['menu_background_color'] ?>;" width="90%" color="#<?php echo $dbt_colorsRecord['menu_background_color'] ?>"/>
            <span class="text_font">
            <?php foreach ($addressRecords as $record): ?>
            <?php 
$updateUnixTime     = strtotime( $record['updatedDate'] ); // seconds since 1970 
$sixMonths = time() - (180*60*60*24) ; //(changed from + to -)
$sixMonthsGone = $updateUnixTime > $sixMonths;

?>
            <?php if(@$_REQUEST['save']&& !$record['isAdmin'] && !$record['notAdmin'] == '1' && ( $sixMonthsGone) ):?>
            <br />
            (
            <?php
          if (@$record['_distance']) { print number_format($record['_distance'], 1) . " $kmOrMiles away"; }
          else                       { print "unknown distance"; }
        ?>
            ) - <a target="_blank" href="http://maps.google.com/?q=<?php echo htmlencode($record['practice_street_address']) ?>, <?php echo htmlencode($record['practice_city']) ?>, <?php echo $record['practice_state'] ?> <?php echo htmlencode($record['practice_zip']) ?>">CLICK/TAP FOR A MAP</a><br />
            <b><?php echo htmlencode($record['practice_name']) ?></b> <br/>
            <?php echo htmlencode($record['practice_street_address']) ?>
            <?php if($record['room_or_floor']):?>
            - <?php echo htmlencode($record['room_or_floor']) ?>
            <?php endif?>
            <br/>
            <?php echo htmlencode($record['practice_city']) ?>, <?php echo $record['practice_state'] ?> <?php echo htmlencode($record['practice_zip']) ?>
            <?php if($record['practice_country']):?>
            - <?php echo $record['practice_country:label'] ?>
            <?php endif?>
            <br/>
            
            <!--<?php if($record['nearby_major_cities']):?>
            <b>Nearest Major Cities:</b> <?php echo join(', ', $record['nearby_major_cities:labels']); ?><br/>
            <?php endif ?>
            <br /> -->
            
            <?php if($record['practice_phone']):?>
            <b>Practice Phone:</b> <?php echo  htmlencode(formatPhone($record['practice_phone']))?><br/>
            <?php endif ?>
            <?php if($record['practice_fax']):?>
            <b>Practice FAX:</b> <?php echo  htmlencode(formatPhone($record['practice_fax']))?><br/>
            <?php endif ?>
            <?php if($record['practice_web_site']):?>
            <b>Practice Web Site:</b> <a target="_blank" href="<?php echo htmlencode($record['practice_web_site']) ?>"><?php echo htmlencode($record['practice_web_site']) ?></a><br/>
            <?php endif ?>
            <?php if($record['practice_facebook_page_url']):?>
            Practice Facebook Page URL: <?php echo htmlencode($record['practice_facebook_page_url']) ?><br/>
            <?php endif ?>
            <?php if($record['practice_linkedin_page_url']):?>
            <b>Practice Linkedin Page URL:</b> <?php echo htmlencode($record['practice_linkedin_page_url']) ?><br/>
            <?php endif ?>
            <br />
            
            <!-- <?php // if($record['practice_license_number']):?>
            Practice License Number: <?php // echo htmlencode($record['practice_license_number']) ?><br/>
            <?php // endif ?> -->
            
            <?php if ($record['accepting_new_clients'] && @$record['accepting_new_clients:text'] == 'Yes'):?>
            <b>Accepting New Clients:</b> Yes<br />
            <?php elseif ($record['accepting_new_clients'] && @$record['accepting_new_clients:text'] == 'No'):?>
            <b>Accepting New Clients: No</b><br />
            <?php endif ?>
            <?php if($record['in_practice_since']):?>
            <b>In Practice Since:</b> <?php echo htmlencode($record['in_practice_since']) ?><br/>
            <?php endif ?>
            <br />
            <?php if($record['contact_last_name']):?>
            <b>Contact:</b> <?php echo htmlencode($record['contact_courtesy_title']) ?> <?php echo htmlencode($record['contact_first_name']) ?> <?php echo htmlencode($record['contact_middle_initial']) ?> <?php echo htmlencode($record['contact_last_name']) ?> <?php echo htmlencode($record['contact_title']) ?><br/>
            <?php endif ?>
            <?php if($record['contact_or_practice_email']):?>
            <b>EMAIL:</b> <?php echo htmlencode($record['contact_or_practice_email']) ?><br />
            <?php else:?>
            <b>EMAIL:</b> <?php echo htmlencode($record['email']) ?><br/>
            <?php endif ?>
            <br />
            <?php if($record['levels_of_care']):?>
            <b>Levels of Care:</b> <?php echo join(', ', $record['levels_of_care:labels']); ?><br/>
            <?php endif ?>
            <?php if($record['services_offered']):?>
            <b>Services Offered:</b> <?php echo join(', ', $record['services_offered:labels']); ?><br/>
            <?php endif ?>
            <?php if($record['general_target_population']):?>
            <b>Age Groups:</b> <?php echo join(', ', $record['general_target_population:labels']); ?><br/>
            <?php endif ?>
            <?php if($record['insurance_classes_accepted']):?>
            <b>Insurance Networks Accepted:</b> <?php echo join(', ', $record['insurance_classes_accepted:labels']); ?><br/>
            <?php endif ?>
            <?php if($record['list_of_insurance_companies_accepted']):?>
            <b>Other Insurance Companies Accepted:</b> <?php echo htmlencode($record['list_of_insurance_companies_accepted']) ?><br/>
            <?php endif ?>
            <?php if($record['languages_spoken']):?>
            <b>Languages Spoken:</b> <?php echo join(', ', $record['languages_spoken:labels']); ?><br/>
            <?php endif ?>
            <?php if($record['practitioner_gender']):?>
            <b>Practitioner Gender(s):</b> <?php echo join(', ', $record['practitioner_gender:labels']); ?><br/>
            <?php endif ?>
            <?php if($record['dbt_training_support']):?>
            <b>DBT Training Support:</b> <?php echo $record['dbt_training_support:label'] ?><br/>
            <?php endif ?>
            <br />
            <?php if($record['practice_description_peers'] || $record['practice_description_clients']):?>
            <b>Practice Description:</b>
            <?php if (@$_REQUEST['therapist'] ==1):?>
            <?php if($record['practice_description_peers']):?>
            <?php echo htmlencode($record['practice_description_peers']) ?>
            <?php else: ?>
            <?php echo htmlencode($record['practice_description_clients']) ?><br/>
            <?php endif ?>
            <?php endif ?>
            <?php endif ?>
            <?php if(@$_REQUEST['therapist'] == 0 || @$_REQUEST['therapist'] == "") :?>
            <?php echo htmlencode($record['practice_description_clients']) ?>
            <?php endif ?>
            <?php if($record['practitioner_descriptions_and_license_numbers']):?>
            <b>Practitioner Description(s):</b> <?php echo htmlencode($record['practitioner_descriptions_and_license_numbers']) ?><br/>
            <?php endif ?>
            <?php if ($record['wheelchair_accessible:text'] && @$record['wheelchair_accessible:text'] == 'Yes'):?>
            <b>Wheelchair Accessible:</b> Yes<br />
            <?php elseif ($record['wheelchair_accessible:text'] && @$record['wheelchair_accessible:text'] == 'No'):?>
            <b>Wheelchair Accessible:</b> No<br />
            <?php endif ?>
            <?php if ($record['public_transportation_nearby:text'] && @$record['public_transportation_nearby:text'] == 'Yes'):?>
            <b>Public Transportation Nearby:</b> Yes<br />
            <?php elseif ($record['public_transportation_nearby:text'] && @$record['public_transportation_nearby:text'] == 'No'):?>
            <b>Public Transportation Nearby:</b> No<br />
            <?php endif ?>
            <?php if($record['public_transportation_description']):?>
            <b>Public Transportation Description:</b> <?php echo htmlencode($record['public_transportation_description']) ?><br/>
            <?php endif ?>
            <hr  align="left" style="height:2px; background-color:#<?php echo $dbt_colorsRecord['menu_background_color'] ?>;" width="90%" color="#<?php echo $dbt_colorsRecord['menu_background_color'] ?>"/>
            <?php endif ?>
            <?php endforeach ?>
            <?php endif ?>
            <br /></td>
        </tr>
      </table>
      </span><br /></td>
  </tr>
  <tr>
    <td colspan="2"><p>&nbsp;</p>
      <br />
      <br />
      <?php include ("_footer2.php"); ?></td>
  </tr>
</table>
</body>
</html>
