<?php include "components/preheader.php"; ?>
<?php
  if(array_key_exists('PassFail', $_GET))
    setcookie('LastHockeyPassFail', $_GET['PassFail'], time() + (86400 * 30), "/");
?>

<!DOCTYPE HTML>
<head>
<?php include "components/header.php"; ?>

<title>What Game Should I Watch - Hockey</title>
<meta name="description" content="We analyze sporting events to determine an objective rating of how enjoyable it is to watch">
<meta name="keywords" content="football baseball NFL MLB television TV DVR PVR VCR record rating">
<meta http-equiv="refresh" content="180">

<script>
var tiles=[];

function tileclick(elmnt) 
{
  highlightShadow = "none";
  originalShadow = "0px 0px 5px #000000";
  if(elmnt.getElementsByClassName("ranking")[0].style.visibility != "visible")
  {
    //elmnt.style.boxShadow = highlightShadow;
    elmnt.getElementsByClassName("ranking")[0].style.visibility = "visible";
    tiles.push(elmnt);
  }
  else
  {
    //elmnt.style.boxShadow = originalShadow;
    elmnt.getElementsByClassName("ranking")[0].style.visibility = "hidden";
    
    index = tiles.indexOf(elmnt);
    if(index >= 0)
      tiles.splice(index, 1);
  }
  
  tiles.sort(function(a, b) {return parseInt(b.getAttribute("data-value")) - parseInt(a.getAttribute("data-value"))});
  for (index = 0; index < tiles.length; ++index) 
  {
    tiles[index].getElementsByClassName("ranking")[0].innerHTML = "#" + (index+1).toString();
  }
}
</script>

<style>
  div.ranking
  {
    position: relative;
    left: 158px;
    top: -85px;
    font-size: 18px;
    font-family: Impact, Charcoal, sans-serif;
    color: blue;
    background-color: white;
    height: 24px;
    width: 35px;
    background-color: white;
    border-width: 1px;
    border: solid;
    border-radius: 8px;
    visibility: hidden;
    cursor: default;
  }
</style>

<!--[if lt IE 9]>
<script>
document.createElement('header');
document.createElement('nav');
document.createElement('section');
document.createElement('article');
document.createElement('aside');
document.createElement('footer');
document.createElement('hgroup');
</script>
<![endif]-->

</head>

<body>
<?php include_once("components/analyticstracking.php") ?>

  <?php include "components/banner.php"; ?>

  <div class="Everything">
    <?php include "components/nav.php"; ?>

    <div class ="Content" style="height: auto;">

    <?php include "components/hockey_submenu.php"; ?>

<?php

define("QTY", 24);

/*
SET @x = 0;
SET @cnt = (SELECT COUNT(*) FROM hockey WHERE Status >= 99);
SELECT Rating FROM (SELECT *, @x := @x+1 AS idx, mod((@x-1) * 21, @cnt) > mod(@x * 21, @cnt) AS take 
FROM hockey WHERE Status >= 99 ORDER BY Rating) t WHERE take
*/

define("R00", 43);
define("R02", 71); //
define("R05", 115);
define("R07", 172); //
define("R10", 247);
define("R12", 326); //
define("R15", 392);
define("R17", 434); //
define("R20", 477);
define("R22", 524); //
define("R25", 571);
define("R27", 628); //
define("R30", 679);
define("R32", 729); //
define("R35", 778);
define("R37", 826); //
define("R40", 888);
define("R42", 963); //
define("R45", 1043);
define("R47", 1142); //


$con=mysqli_connect("localhost","scosen_wgsiw","password","scosen_wgsiw");
// Check connection
if (mysqli_connect_errno())
{
  exit("Failed to connect to MySQL: " . mysqli_connect_error());
}

$where = "TRUE";
$from = "hockey";
$order = "STime DESC";
$limit = $_GET['IDX'] . ", " . strval(QTY+1);
switch($_GET['Sort'])
{
  case 'Recent':
    //$where .= " AND STime <= DATE(DATE_ADD(NOW(), INTERVAL 20 HOUR)) AND (Status >= 99 OR Status < 75)";	//DST
    $where .= " AND STime <= DATE(DATE_ADD(NOW(), INTERVAL 19 HOUR)) AND (Status >= 99 OR Status < 75)";	//STD   
    break;
  case 'TopRated':
    $order = "Rating DESC";
    $where .= " AND Status >= 99 ";
    break;
}

if($_GET['Season'] != 'All')
{
  $where .= " AND Season = " . $_GET['Season'];
}

if($_GET['Team'] != 'All')
{
  $where .= " AND (FALSE ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Atlantic' || $_GET['Team'] == 'BOS')
    $where .= " OR Home = 'BOS' OR Away = 'BOS' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Atlantic' || $_GET['Team'] == 'BUF')
    $where .= " OR Home = 'BUF' OR Away = 'BUF' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Atlantic' || $_GET['Team'] == 'DET')
    $where .= " OR Home = 'DET' OR Away = 'DET' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Atlantic' || $_GET['Team'] == 'FLA')
    $where .= " OR Home = 'FLA' OR Away = 'FLA' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Atlantic' || $_GET['Team'] == 'MTL')
    $where .= " OR Home = 'MTL' OR Away = 'MTL' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Atlantic' || $_GET['Team'] == 'OTT')
    $where .= " OR Home = 'OTT' OR Away = 'OTT' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Atlantic' || $_GET['Team'] == 'TBL')
    $where .= " OR Home = 'TBL' OR Away = 'TBL' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Atlantic' || $_GET['Team'] == 'TOR')
    $where .= " OR Home = 'TOR' OR Away = 'TOR' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Metropolitan' || $_GET['Team'] == 'CAR')
    $where .= " OR Home = 'CAR' OR Away = 'CAR' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Metropolitan' || $_GET['Team'] == 'CBJ')
    $where .= " OR Home = 'CBJ' OR Away = 'CBJ' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Metropolitan' || $_GET['Team'] == 'NJD')
    $where .= " OR Home = 'NJD' OR Away = 'NJD' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Metropolitan' || $_GET['Team'] == 'NYI')
    $where .= " OR Home = 'NYI' OR Away = 'NYI' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Metropolitan' || $_GET['Team'] == 'NYR')
    $where .= " OR Home = 'NYR' OR Away = 'NYR' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Metropolitan' || $_GET['Team'] == 'PHI')
    $where .= " OR Home = 'PHI' OR Away = 'PHI' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Metropolitan' || $_GET['Team'] == 'PIT')
    $where .= " OR Home = 'PIT' OR Away = 'PIT' ";
  if($_GET['Team'] == 'Eastern' || $_GET['Team'] == 'Metropolitan' || $_GET['Team'] == 'WSH')
    $where .= " OR Home = 'WSH' OR Away = 'WSH' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Central' || $_GET['Team'] == 'CHI')
    $where .= " OR Home = 'CHI' OR Away = 'CHI' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Central' || $_GET['Team'] == 'COL')
    $where .= " OR Home = 'COL' OR Away = 'COL' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Central' || $_GET['Team'] == 'DAL')
    $where .= " OR Home = 'DAL' OR Away = 'DAL' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Central' || $_GET['Team'] == 'MIN')
    $where .= " OR Home = 'MIN' OR Away = 'MIN' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Central' || $_GET['Team'] == 'NSH')
    $where .= " OR Home = 'NSH' OR Away = 'NSH' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Central' || $_GET['Team'] == 'STL')
    $where .= " OR Home = 'STL' OR Away = 'STL' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Central' || $_GET['Team'] == 'WPG')
    $where .= " OR Home = 'WPG' OR Away = 'WPG' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Pacific' || $_GET['Team'] == 'ANA')
    $where .= " OR Home = 'ANA' OR Away = 'ANA' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Pacific' || $_GET['Team'] == 'ARI')
    $where .= " OR Home = 'ARI' OR Away = 'ARI' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Pacific' || $_GET['Team'] == 'CGY')
    $where .= " OR Home = 'CGY' OR Away = 'CGY' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Pacific' || $_GET['Team'] == 'EDM')
    $where .= " OR Home = 'EDM' OR Away = 'EDM' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Pacific' || $_GET['Team'] == 'LAK')
    $where .= " OR Home = 'LAK' OR Away = 'LAK' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Pacific' || $_GET['Team'] == 'SJS')
    $where .= " OR Home = 'SJS' OR Away = 'SJS' ";
  if($_GET['Team'] == 'Western' || $_GET['Team'] == 'Pacific' || $_GET['Team'] == 'VAN')
    $where .= " OR Home = 'VAN' OR Away = 'VAN' ";

  $where .= ") ";
}

switch($_GET['MinRating'])
{
  case '05':
    $where .= " AND Rating >= " . strval(R02) . " AND Status >= 99 ";
    break;
  case '10':
    $where .= " AND Rating >= " . strval(R07) . " AND Status >= 99 ";
    break;
  case '15':
    $where .= " AND Rating >= " . strval(R12) . " AND Status >= 99 ";
    break;
  case '20':
    $where .= " AND Rating >= " . strval(R17) . " AND Status >= 99 ";
    break;
  case '25':
    $where .= " AND Rating >= " . strval(R22) . " AND Status >= 99 ";
    break;
  case '30':
    $where .= " AND Rating >= " . strval(R27) . " AND Status >= 99 ";
    break;
  case '35':
    $where .= " AND Rating >= " . strval(R32) . " AND Status >= 99 ";
    break;
  case '40':
    $where .= " AND Rating >= " . strval(R37) . " AND Status >= 99 ";
    break;
  case '45':
    $where .= " AND Rating >= " . strval(R42) . " AND Status >= 99 ";
    break;
  case '50':
    $where .= " AND Rating >= " . strval(R47) . " AND Status >= 99 ";
    break;
}


$query = "SELECT * FROM " . $from ." WHERE " . $where . " ORDER BY " . $order . " LIMIT " . $limit;

//print $query . "<br/>";

$result = mysqli_query($con, $query);

$now = new DateTime("now", new DateTimeZone("America/New_York"));
$newdate = clone $now;
$newdate->modify('-36 hours');
$today = new DateTime($now->format('n/j/Y') . " 0:00", new DateTimeZone("America/New_York"));
$yesterday = clone $today;
$yesterday->modify('-24 hours');
$tomorrow = clone $today;
$tomorrow->modify('+24 hours');
$oneweek = clone $today;
$oneweek->modify('-1 week');
$sixmonths = clone $today;
$sixmonths->modify('-6 months');

define("ASE", "<img src=\"images/AltSmallEmpty.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("ASF", "<img src=\"images/AltSmallFull.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("ALE", "<img src=\"images/AltLargeEmpty.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("AL2", "<img src=\"images/AltLarge25.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("AL5", "<img src=\"images/AltLarge50.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("AL7", "<img src=\"images/AltLarge75.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("ALF", "<img src=\"images/AltLargeFull.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("SE", "<img src=\"images/SmallEmpty.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("SF", "<img src=\"images/SmallFull.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("LE", "<img src=\"images/LargeEmpty.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("L2", "<img src=\"images/Large25.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("L5", "<img src=\"images/Large50.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("L7", "<img src=\"images/Large75.png\" alt=\"\" style=\"vertical-align: middle;\">");
define("LF", "<img src=\"images/LargeFull.png\" alt=\"\" style=\"vertical-align: middle;\">");

$pfCutoff = 0;
switch($_GET['PassFail'])
{
  case '10':
    $pfCutoff = R07;
    break;
  case '15':
    $pfCutoff = R12;
    break;
  case '20':
    $pfCutoff = R17;
    break;
  case '25':
    $pfCutoff = R22;
    break;
  case '30':
    $pfCutoff = R27;
    break;
  case '35':
    $pfCutoff = R32;
    break;
  case '40':
    $pfCutoff = R37;
    break;
}

$num = 0;
$more = false;

$rows = array();
while($row = mysqli_fetch_array($result))
{
  array_push($rows, $row);

  $num++;  
  if($num >= QTY)
  {
    $more = true;
    break;
  }
}

$id = 0;
foreach($rows as $row)
{
  $id++;
  $kickoff = new DateTime($row['STime'], new DateTimeZone("America/New_York"));
  
  $gameover = clone $kickoff;
  $gameover->modify('+7 hours');

  $time = $kickoff->format('g:i D n/j');

  if($kickoff >= $tomorrow)
  {
    $time = $kickoff->format('g:i D n/j');
  }
  elseif($kickoff >= $today)
  {
    $time = $kickoff->format('g:i') . ' Today';
  }
  elseif($kickoff >= $yesterday)
  {
    $time = $kickoff->format('g:i') . ' Yesterday';
  }
  elseif($kickoff >= $oneweek)
  {
    $time = $kickoff->format('g:i l');
  }
  elseif($kickoff < $sixmonths)
  {
    $time = $kickoff->format('g:i D n/j/Y');
  }

  //print $row['Away'] . ' at ' . $row['Home'] . ' ' . $time . ' ' . $row['Rating'] . '<br/>';
  
  $status = '';
  if($newdate < $kickoff && $row['Status'] == 99)
  {
    $status = '&emsp;&emsp;<span style="color:red;font-weight:bold;">NEW</span>';
  }
  elseif($row['Status'] < 99 && $now > $gameover)
  {
    $status = '&emsp;&emsp;<span style="color:red;font-weight:bold;">Error</span>';
  }
  elseif($row['Status'] == 0)
  {
    if($kickoff > $now)
      $status = '&emsp;&emsp;<span style="color:gray;font-style:italic;">Future</span>';
    else
      $status = '&emsp;&emsp;<span style="color:gray;font-style:italic;">Calculating...</span>';
  }
  elseif($row['Status'] == 1)
  {
    $status = '&emsp;&emsp;<span style="color:gray;font-style:italic;">Calculating...</span>';
  }
  elseif($row['Status'] == 2)
  {
    $status = '&emsp;&emsp;<span style="color:gray;font-style:italic;">Q1 Projection</span>';
  }
  elseif($row['Status'] == 3)
  {
    $status = '&emsp;&emsp;<span style="color:gray;font-style:italic;">Q2 Projection</span>';
  }
  elseif($row['Status'] >= 4 && $row['Status'] < 99)
  {
    $status = '&emsp;&emsp;<span style="color:gray;font-style:italic;">Q3 Projection</span>';
  }
  elseif($row['Type'] == 'PRE')
  {
    $status = '&emsp;&emsp;<span style="color:gray;font-style:italic;">Preseason</span>';
  }
  elseif($row['Type'] == 'POST')
  {
    $status = '&emsp;&emsp;<span style="color:gray;font-style:italic;">Postseason</span>';
  }
  	
  if($row['Type'] == 'PRE')
    print "<div class=\"pretile\"";
  else if($row['Type'] == 'POST')
    print "<div class=\"posttile\"";
  else
    print "<div class=\"tile\"";
  
  if(intval($row['Status']) >= 99)
    print " id=\"tile" . strval($id) . "\" onclick=\"tileclick(this)\" data-value=\"" . $row['Rating'] . "\"";

  print ">";
    


  print "<p class=\"tile_title\">" . "<span style=\"float: left;\">". $time . "</span><span style=\"float: right;\">" . $status . "</span>" . "</p><hr>";
  print "<p class=\"tile_content\">" . $row['Away'] . " at " . $row['Home'] . "</p>";


if($row['Status'] < 1)
  {
  echo ASF . ASF . ALF . ASF . ASF;
  }
elseif($row['Status'] < 99)
  {
  if($pfCutoff > 0)
    {
    if($row['Rating'] < $pfCutoff)
      {
      echo ASE . ASE . ALE . ASE . ASE;		//Fail
      }
    else
      {
      echo ASF . ASF . ALF . ASF . ASF;		//Pass
      }
    }
  elseif($row['Rating'] < R00)
    {
    echo ALE . ASE . ASE . ASE . ASE;  // 0 Stars
    }
  elseif($row['Rating'] < R02)
    {
    echo AL2 . ASE . ASE . ASE . ASE;  // 1/4 Stars
    }
  elseif($row['Rating'] < R05)
    {
    echo AL5 . ASE . ASE . ASE . ASE;  // 1/2 Stars
    }
  elseif($row['Rating'] < R07)
    {
    echo AL7 . ASE . ASE . ASE . ASE;  // 3/4 Stars
    }
  elseif($row['Rating'] < R10)
    {
    echo ALF . ASE . ASE . ASE . ASE;  // 1 Stars
    }
  elseif($row['Rating'] < R12)
    {
    echo ASF . AL2 . ASE . ASE . ASE;  // 1 1/4 Stars
    }
  elseif($row['Rating'] < R15)
    {
    echo ASF . AL5 . ASE . ASE . ASE;  // 1 1/2 Stars
    }
  elseif($row['Rating'] < R17)
    {
    echo ASF . AL7 . ASE . ASE . ASE;  // 1 /3/4 Stars
    }
  elseif($row['Rating'] < R20)
    {
    echo ASF . ALF . ASE . ASE . ASE;  // 2 Stars
    }
  elseif($row['Rating'] < R22)
    {
    echo ASF . ASF . AL2 . ASE . ASE;  // 2 1/4 Stars
    }
  elseif($row['Rating'] < R25)
    {
    echo ASF . ASF . AL5 . ASE . ASE;  // 2 1/2 Stars
    }
  elseif($row['Rating'] < R27)
    {
    echo ASF . ASF . AL7 . ASE . ASE;  // 2 3/4 Stars
    }
  elseif($row['Rating'] < R30)
    {
    echo ASF . ASF . ALF . ASE . ASE;  // 3 Stars
    }
  elseif($row['Rating'] < R32)
    {
    echo ASF . ASF . ASF . AL2 . ASE;  // 3 1/4 Stars
    }
  elseif($row['Rating'] < R35)
    {
    echo ASF . ASF . ASF . AL5 . ASE;  // 3 1/2 Stars
    }
  elseif($row['Rating'] < R37)
    {
    echo ASF . ASF . ASF . AL7 . ASE;  // 3 3/4 Stars
    }
  elseif($row['Rating'] < R40)
    {
    echo ASF . ASF . ASF . ALF . ASE;  // 4 Stars
    }
  elseif($row['Rating'] < R42)
    {
    echo ASF . ASF . ASF . ASF . AL2;  // 4 1/4 Stars
    }
  elseif($row['Rating'] < R45)
    {
    echo ASF . ASF . ASF . ASF . AL5;  // 4 1/2 Stars
    }
  elseif($row['Rating'] < R47)
    {
    echo ASF . ASF . ASF . ASF . AL7;  // 4 3/4 Stars
    }
  else
    {
    echo ASF . ASF . ASF . ASF . ALF;  // 5 Stars
    }
  }
else
  {
  if($pfCutoff > 0)
    {
    if($row['Rating'] < $pfCutoff)
      {
      echo SE . SE . LE . SE . SE;		//Fail
      }
    else
      {
      echo SF . SF . LF . SF . SF;		//Pass
      }
    }
  elseif($row['Rating'] < R00)
    {
    echo LE . SE . SE . SE . SE;  // 0 Stars
    }
  elseif($row['Rating'] < R02)
    {
    echo L2 . SE . SE . SE . SE;  // 1/4 Stars
    }
  elseif($row['Rating'] < R05)
    {
    echo L5 . SE . SE . SE . SE;  // 1/2 Stars
    }
  elseif($row['Rating'] < R07)
    {
    echo L7 . SE . SE . SE . SE;  // 3/4 Stars
    }
  elseif($row['Rating'] < R10)
    {
    echo LF . SE . SE . SE . SE;  // 1 Stars
    }
  elseif($row['Rating'] < R12)
    {
    echo SF . L2 . SE . SE . SE;  // 1 1/4 Stars
    }
  elseif($row['Rating'] < R15)
    {
    echo SF . L5 . SE . SE . SE;  // 1 1/2 Stars
    }
  elseif($row['Rating'] < R17)
    {
    echo SF . L7 . SE . SE . SE;  // 1 3/4 Stars
    }
  elseif($row['Rating'] < R20)
    {
    echo SF . LF . SE . SE . SE;  // 2 Stars
    }
  elseif($row['Rating'] < R22)
    {
    echo SF . SF . L2 . SE . SE;  // 2 1/4 Stars
    }
  elseif($row['Rating'] < R25)
    {
    echo SF . SF . L5 . SE . SE;  // 2 1/2 Stars
    }
  elseif($row['Rating'] < R27)
    {
    echo SF . SF . L7 . SE . SE;  // 2 3/4 Stars
    }
  elseif($row['Rating'] < R30)
    {
    echo SF . SF . LF . SE . SE;  // 3 Stars
    }
  elseif($row['Rating'] < R32)
    {
    echo SF . SF . SF . L2 . SE;  // 3 1/4 Stars
    }
  elseif($row['Rating'] < R35)
    {
    echo SF . SF . SF . L5 . SE;  // 3 1/2 Stars
    }
  elseif($row['Rating'] < R37)
    {
    echo SF . SF . SF . L7 . SE;  // 3 3/4 Stars
    }
  elseif($row['Rating'] < R40)
    {
    echo SF . SF . SF . LF . SE;  // 4 Stars
    }
  elseif($row['Rating'] < R42)
    {
    echo SF . SF . SF . SF . L2;  // 4 1/4 Stars
    }
  elseif($row['Rating'] < R45)
    {
    echo SF . SF . SF . SF . L5;  // 4 1/2 Stars
    }
  elseif($row['Rating'] < R47)
    {
    echo SF . SF . SF . SF . L7;  // 4 3/4 Stars
    }
  else
    {
    echo SF . SF . SF . SF . LF;  // 5 Stars
    }
  }




print "<div class=\"ranking\">";
print "</div>";



  print "</div>";
}
mysqli_free_result($result);

while($num < QTY)
{
  $num++;
  print "<div class=\"blanktile\"></div>";
}

echo "<div style=\"clear:both\"/>";













$idx = intval($_GET['IDX']);
echo "<div style=\"text-align:center;\">";

//$query2 = strstr("SELECT COUNT(ID)" . substr($query, 8), " LIMIT", true);
//$result = mysqli_query($con, $query2);
//$row = mysqli_fetch_array($result);
//$count = $row[0];

if($idx > 0)
  echo "<a href=\"" . GenerateURL('IDX', strval(max($idx - QTY, 0))) . "\"  style=\"text-decoration: none;\">
          <img src=\"images/PrevButton.png\" style=\"margin: 20px;\" 
               onmousedown=\"this.src='images/PrevButtonPressed.png'\" 
               onmouseup=\"this.src='images/PrevButton.png'\"></img>
        </a> ";
else
  echo "<img src=\"images/PrevButtonHollow.png\" style=\"margin: 20px;\"></img>";

if($more)
  echo "<a href=\"" . GenerateURL('IDX', strval($idx + QTY)) . "\" style=\"text-decoration: none;\">
          <img src=\"images/NextButton.png\" style=\"margin: 20px;\" 
               onmousedown=\"this.src='images/NextButtonPressed.png'\" 
               onmouseup=\"this.src='images/NextButton.png'\"></img>
        </a>";
else
  echo "<img src=\"images/NextButtonHollow.png\" style=\"margin: 20px;\"></img>";



echo "</div>";















mysqli_free_result($result);
mysqli_close($con);  

?>


    </div>
  </div>
</div>

<?php include "components/footer.php"; ?>
    
</body>