<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/var/www/westelsystems.com/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load records
  list($wttv_channel_lineup_textRecords, $wttv_channel_lineup_textMetaData) = getRecords(array(
    'tableName'   => 'wttv_channel_lineup_text',
    'allowSearch' => '0',
    'limit'       => '1',
  ));
  $wttv_channel_lineup_textRecord = @$wttv_channel_lineup_textRecords[0]; // get first record

  // show error message if no matching record is found
  if (!$wttv_channel_lineup_textRecord) { dieWith404("Record not found!"); }
  
    // load records 
  list($wttv_channelsRecords, $wttv_channelsMetaData) = getRecords(array(
    'tableName'   => 'wttv_channels',
	'where' => ' location LIKE "%\tAlton\t%"  ',
	'orderBy'   => 'category ASC, dragSortOrder DESC',
  ));
  
  //group arrays into headings
$headingsToRecords = array();

foreach ($wttv_channelsRecords as $record) {
$heading = ($record['category:label']);

if (!array_key_exists($heading, $headingsToRecords)) {
$headingsToRecords[$heading] = array();
}

$headingsToRecords[$heading][] = $record;
}

?>
<!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"><!-- InstanceBegin template="/Templates/alton.dwt" codeOutsideHTMLIsLocked="false" -->
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <!-- InstanceBeginEditable name="doctitle" -->
  <title>WesTel Systems / Alton, Iowa / TV / Channel Line Up</title>
  <!-- InstanceEndEditable -->
  <script type="text/javascript" src="http://fast.fonts.com/jsapi/ff7c6232-2967-4f6f-8793-7eedf1331322.js"></script>
  <link href="/_css/subpage.css" rel="stylesheet" type="text/css" />

  <link href="/p7tmm/p7TMM01.css" rel="stylesheet" type="text/css" media="all" />
  <script type="text/javascript" src="/p7tmm/p7TMMscripts.js"></script>
<link href="/p7apm/p7APM04.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="/p7apm/p7APMscripts.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>

<script type="text/javascript" src="/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" href="/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
	<script type="text/javascript">
		$(document).ready(function() {
			/*
			*   Examples - images
			*/

			
			$(".westelvideo").click(function() {
	$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'overlayColor'  : '#000',
			'title'			: this.title,
			'width'		: 320,
			'height'		: 240,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;

		});
		});
	</script>
      <link href="/p7pmm/p7PMMh10.css" rel="stylesheet" type="text/css" media="all" />
  <script type="text/javascript" src="/p7pmm/p7PMMscripts.js"></script>
    <!-- InstanceBeginEditable name="head" -->
    <!-- InstanceEndEditable -->
    <script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-27855434-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
  </head>
    
  <body>
  
    <div id="topBarWrapper">
  <?php include("/var/www/westelsystems.com/alton/_includes/header.php"); ?>
    </div>
      <div id="navWrapper">
  <?php include("/var/www/westelsystems.com/alton/_includes/top_navigation.php"); ?>
      </div><div id="contentWrapper"><div id="contentWrapper2"><div id="topContentShadow"></div>
<?php include("/var/www/westelsystems.com/alton/_includes/side_navigation.php"); ?>
<!-- InstanceBeginEditable name="contentarea" -->
<div id="pageContent">
  <h1>Channel Line up</h1>
  <?php echo $wttv_channel_lineup_textRecord['content'] ?>
  
  <?php
$half = intval(count($headingsToRecords) / 2);
$count = 0;
?>  <div id="channelColLeft">
<table width="290" border="0" cellspacing="0" cellpadding="2">
<?php $heading = ""; ?>
<?php foreach ($headingsToRecords as $heading => $channels): ?><tr>
      <th align="center" colspan="2" class="tableWhiteCell" scope="col">
      <h4 style="padding-top:10px;">
<?php echo $heading; ?></h4></th></tr>

    <tr>
      <th align="center" width="50" class="tableChannelBlue" scope="col">CHNL</th>
      <th width="232" align="center" valign="middle" class="tableChannelGrey" scope="col">STATION</th>
      </tr>
      
 <?php foreach ($channels as $record): ?>      
    <?php if($record['hd'] == 1): ?>
      <tr>
      <td width="50" align="center" class="tableChannelBlue"><strong><?php echo $record['channel'] ?></strong></td>
      <td width="232" align="left" valign="middle" class="tableChannelWhite">&nbsp;&nbsp;&nbsp;<strong><?php echo $record['station'] ?></strong></td>
      </tr>  <?php else:?>
    <tr>
      <td width="50" align="center" class="tableChannelBlue"><?php echo $record['channel'] ?></td>
      <td width="232" align="left" valign="middle" class="tableChannelWhite">&nbsp;&nbsp;&nbsp;<?php echo $record['station'] ?></td>
      </tr><?php endif; ?> <?php endforeach ?>
<?php if (++$count == $half): ?></table>  
            </div>
    
    
  <div id="channelColRight">  <table width="290" border="0" cellspacing="0" cellpadding="2"><?php endif ?> 
	   
      <?php endforeach ?>  </table></div>
</div>
<!-- InstanceEndEditable --></div><div class="clearboth"></div></div>
  <div id="footerWrapper">
<?php include("/var/www/westelsystems.com/_includes_global/footer.php"); ?>
  </div>
  </body>
  <!-- InstanceEnd --></html>
