<?php include ("_website_init.php"); ?>
<?php // load records from 'accounts'
  list($accountsRecords, $accountsMetaData) = getRecords(array(
    'tableName'   => 'accounts',
    'loadUploads' => true,
    'allowSearch' => true,
//	showme( $_REQUEST['levels_of_care_keyword'] ),
  ));
?>
<?php $errorsAndAlerts = ""; ?>
<?php if (@$_REQUEST['save'] == 1) {
// if     (!@$_REQUEST['practice_state'] )                     { $errorsAndAlerts .= "You'll need to choose at least a State and re-submit your search to continue<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>DBT NETWORK SERVICE PROVIDER DIRECTORY LISTINGS</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<meta name="viewport" content="width=device-width, target-densitydpi=device-dpi, 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;
}
?>
</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 -->
  

  <span class="heading_font"><b>SERVICE PROVIDER DIRECTORY LISTINGS
  </b><br />
  <br />
   <a href="directory_search.php"><span class="sub_heading_font"><br />
                &lt;&lt; <u>Change Your Directory Search Criteria</u></span></a>
  <br /><br />
  </span><span class="text_font">

 <table align="left" width="90%" border="0" cellspacing="0" cellpadding="2">
    
    <tr>
      <td colspan="2"><?php
  $searchCriteria = '';
   if  (($_REQUEST['save'] == 1) && @$_REQUEST['levels_of_care_keyword']) {
	// $_REQUEST['levels_of_care_keyword'] = array();
    $levels_of_care =  implode(',', @$_REQUEST['levels_of_care_keyword']);
    $searchCriteria .= "<b>Levels of Care:</b> $levels_of_care - ";
 }
 
 /* if (@$_REQUEST['practice_state_keyword']) { $searchCriteria .= "<b>Practices Located In:</b> {$_REQUEST['practice_state_keyword']} - "; }
  if (@$_REQUEST['nearby_major_cities_keyword']) { $searchCriteria .= "<b>Nearest Major Cities:</b> {$_REQUEST['nearby_major_cities_keyword']} - "; }
  
  
  // if (@$_REQUEST['levels_of_care_keyword']) { $searchCriteria .= "<b>Levels of Care:</b> {$_REQUEST['levels_of_care_keyword']} - "; }
 if (@$_REQUEST['dbt_training_support_keyword']) { $searchCriteria .= "<b>DBT Training and Support:</b> {$_REQUEST['dbt_training_support_keyword']} - "; } 
 if (@$_REQUEST['services_offered_keyword']) { $searchCriteria .= "<b>Services Offered:</b> {$_REQUEST['services_offered_keyword']} - "; }
  if (@$_REQUEST['public_transportation_nearby'] && @$_REQUEST['public_transportation_nearby'] == 1) { $searchCriteria .= "<b>Public Transportation Nearby:</b> Yes - "; }
   if (@$_REQUEST['public_transportation_nearby'] && (@$_REQUEST['public_transportation_nearby'] == 0 || @$_REQUEST['public_transportation_nearby'] == "")) { $searchCriteria .= "<b>Public Transportation Nearby:</b> No - "; }
   
    if (@$_REQUEST['wheelchair_accessible'] && @$_REQUEST['wheelchair_accessible'] == 1) { $searchCriteria .= "<b>Wheelchair Accessible:</b> Yes - "; }
   if (@$_REQUEST['wheelchair_accessible'] && (@$_REQUEST['wheelchair_accessible'] == 0 || @$_REQUEST['wheelchair_accessible'] == "")) { $searchCriteria .= "<b>Wheelchair Accessible:</b> No - "; }
  if (@$_REQUEST['general_target_population_keyword']) { $searchCriteria .= "<b>General Target Population:</b> {$_REQUEST['general_target_population_keyword']} - "; }
  if (@$_REQUEST['specific_target_populations_keyword']) { $searchCriteria .= "<b>Specific Target Population:</b> {$_REQUEST['specific_target_populations_keyword']} - "; }
  if (@$_REQUEST['other_specialized_bpd_training_keyword']) { $searchCriteria .= "<b>Other Specialized BPD Training: </b>{$_REQUEST['other_specialized_bpd_training_keyword']} - "; }
*/
  $searchCriteria = chop($searchCriteria, ', '); // remove trailing , or spaces
    $searchCriteria = chop($searchCriteria, '- '); // 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 foreach ($accountsRecords as $record): ?>
      <?php if(!$record['isAdmin']):?>
      <?php $count++; ?>
      <?php endif ?>
      <?php endforeach ?>
      <?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 ( @!$searchCriteria ):?>
      All Listings
      <?php else :?>
      <br />
      <?php echo $searchCriteria ?>
      <?php endif ?>
      </span><br />
    </div>
      </td>
    
      </tr>
    
  
    <tr>
      <td colspan="2"><hr />
        <?php foreach ($accountsRecords as $record): ?>
        <?php if(!$record['isAdmin']):?>
        <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:label'] ?> <?php echo htmlencode($record['practice_zip']) ?>">click for a map</a><br />
       
        <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:label'] ?> <?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> <?php echo htmlencode($record['practice_web_site']) ?><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>General Target Population:</b> <?php echo join(', ', $record['general_target_population:labels']); ?><br/>
        <?php endif ?>
        <?php if($record['specific_target_populations']):?>
        <b>Specific Target Populations:</b> <?php echo join(', ', $record['specific_target_populations:labels']); ?><br/>
        <?php endif ?>
        <?php if($record['exclusion_criteria']):?>
        <b>Exclusion Criteria:</b> <?php echo join(', ', $record['exclusion_criteria:labels']); ?><br/>
        <?php endif ?>
        <?php if($record['insurance_classes_accepted']):?>
        <b>Insurance Classes Accepted:</b> <?php echo join(', ', $record['insurance_classes_accepted:labels']); ?><br/>
        <?php endif ?>
        <?php if($record['list_of_insurance_companies_accepted']):?>
        <b>List Of Insurance Companies Accepted:</b> <?php echo htmlencode($record['list_of_insurance_companies_accepted']) ?><br/>
        <?php endif ?>
        <br />
        <?php if ($record['prescribe_medication'] && @$record['prescribe_medication:text'] == 'Yes'):?>
        <b>Prescribe Medication:</b> Yes<br />
        <?php elseif ($record['prescribe_medication'] && @$record['prescribe_medication:text'] == 'No'):?>
        <b>Prescribe Medication:</b> No<br />
        <?php endif ?>
        <?php if($record['languages_spoken']):?>
        <b>Languages Spoken:</b> <?php echo htmlencode($record['languages_spoken']) ?><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']):?>
        <b>Practice Description:</b> <?php echo htmlencode($record['practice_description']) ?><br/>
        <?php endif ?><br />
        <?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 ?><br />
        <?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/>
        <?php endif ?>
        <?php endforeach ?>
        <?php if (!$accountsRecords): ?>
        Sorry, no providers were found that matched your criteria, please try again.<br/>
        <br/>
        <?php endif ?>
		<?php endif?>
        <br />
     
      </td>
      </tr>
  </table>
  </span><br />
    </td>
  
    </tr>
  
  <tr>
    <td colspan="2"><p>&nbsp;</p>
      <br />
      <br />
      <?php include ("_footer.php"); ?></td>
  </tr>
</table>
</body>
</html>
