<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php include_once("_globalViewers.php") ?>
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

  // load record from 'pages'
  list($pagesRecords, $pagesMetaData) = getRecords(array(
    'tableName'   => 'pages',
    'where'       => "`num` = '1'",
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $pagesRecord = @$pagesRecords[0]; // get first record
  if (!$pagesRecord) { dieWith404("Record not found!"); } // show error message if no record found
  
  
  
//This function gets the last number from the URL. If there is no number it will return 0;  
  $number = getLastNumberInUrl();  
//This if statement will set the $number variable to the number 3 if it is currently less than 1. Change the number 3 to whatever record you want to load.  
$nothingSelected = ($number < 1)? true : false; 
//The $_REQUEST area variable should contain the table that needs to be searched.
$area 		= @$_REQUEST['area'];
// And the num field should contain the num value. 
$number 	= @intval($_REQUEST['num']);
//Set the number value here if it's less than 1. Note: this needs to be a value that appears in both tables.
$number     = ($number < 1)? '3' : $number; 
//Set the table. Automatically sets to practice_areas if it's not industries to stop people trying to other tables
$area 	    = ($area == 'industries')? 'industries' : 'practice_areas'; 


  // load detail record from 'practice_areas'
  list($practice_areasRecords, $practice_areasMetaData) = getRecords(array(
    'tableName'   => $area,
    'where'       => whereRecordNumberInUrl(1), // If no record # is specified then latest record is shown
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $detailRecord = @$practice_areasRecords[0]; // get first record
  if (!$detailRecord) { dieWith404("Record not found!"); } // show error message if no record found

  // load list records from 'practice_areas'
  list($practice_areasRecords, $practice_areasMetaData) = getRecords(array(
    'tableName'   => 'practice_areas',
    'loadUploads' => false,
    'allowSearch' => false,
  ));

  // load list records from 'industries'
  list($industriesRecords, $industriesMetaData) = getRecords(array(
    'tableName'   => 'industries',
    'loadUploads' => false,
    'allowSearch' => false,
  ));
  
?><!DOCTYPE html>
<html>
<head>	
	<title>Title</title>

	<?php include_once("_globalHeadCode.php") ?>

</head>
<body>
<?php include_once("_google.php") ?>
<div id="page">
	<?php include_once("_header.php") ?>
	<?php include_once("_navigation.php") ?>
	<div id="wrapper" class="clearfix">
		<section id="pageImage" class="row">
			<div class="image">
			<?php foreach ($pagesRecord['image'] as $index => $upload): ?><img src="<?php echo $upload['urlPath'] ?>" alt="<?php echo htmlencode($pagesRecord['title']) ?>"><?php endforeach ?>
			</div>
		</section>
		<section class="row">
			<div class="fifth sideNav">
				<h2>Overview</h2>
					<div class="accordion">
						<div>
							<h3><a href="#">Practice Areas</a></h3>
							<ul>
								<?php foreach ($practice_areasRecords as $listRecord): ?>
							      <li
							      <?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
							      <?php if ($isSelected) { print " class='selectedNavLink'"; } ?>
							      ><a href="what_we_do.php?area=practice_areas&num=<?php echo htmlencode($listRecord['num']) ?>"<?php if ($isSelected) { print " class='selectedNavLink'"; } ?>><?php echo htmlencode($listRecord['title']) ?></a>
							      </li>
								<?php endforeach ?>
							</ul>
							<h3><a href="#">Industries</a></h3>
							<ul>
								<?php foreach ($industriesRecords as $listRecord): ?>
							      <li
							      <?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
							      <?php if ($isSelected) { print " class='current'"; } ?>
							      ><a href="what_we_do.php?area=industries&num=<?php echo htmlencode($listRecord['num']) ?>"><?php echo htmlencode($listRecord['title']) ?></a>
							      </li>
								<?php endforeach ?>
							</ul>
						</div>
					</div>
			</div>
			<div class="threefifth" id="mainContent">
				<?php if($nothingSelected): ?> 
				<?php echo $pagesRecord['content']; ?> 
				<?php else: ?> 
				<?php echo $detailRecord['content']; ?> 
				<?php endif ?>
				
				<div class="accordion">
					<h3>Practice Areas</h3>
						<div class="clearfix">
						<?php foreach ($practice_areasRecords as $listRecord): ?>
					      <div class="twoColumns">
						      <a href="what_we_do.php?area=practice_areas&num=<?php echo htmlencode($listRecord['num']) ?>"><?php echo htmlencode($listRecord['title']) ?></a>
					      </div>
						<?php endforeach ?>
						</div>
					<h3>Industries</h3>
						<div>
						<?php foreach ($industriesRecords as $listRecord): ?>
					      <a href="what_we_do.php?area=industries&num=<?php echo htmlencode($listRecord['num']) ?>"><?php echo htmlencode($listRecord['title']) ?></a><br />
						<?php endforeach ?>
						</div>
				</div>				
			</div>
			<div class="fifth sample">
				<a href="#">
				<div class="sideSnippet">
					<p>a brief sentence or something goes here</p>
					link here >
				</div>
				</a>
				<a href="#">
				<div class="sideSnippet">
					<p>a brief sentence or something goes here</p>
					link here >
				</div>
				</a>
				<a href="#">
				<div class="sideSnippet">
					<p>a brief sentence or something goes here</p>
					link here >
				</div>
				</a>
			</div>
		</section>
		
		<section class="row links">
			<div class="fifth"></div>
			<div class="fifth"><img src="images/sampleHeadShot.png" alt="sampleHeadShot" class="full"></div>
			<div class="fifth"><img src="images/sampleHeadShot.png" alt="sampleHeadShot" class="full"></div>
			<div class="fifth"><img src="images/sampleHeadShot.png" alt="sampleHeadShot" class="full"></div>
			<div class="fifth"></div>
		</section>


	</div>
	<?php include_once("_footer.php") ?>
</div>	
		
</body>
</html>