
<?php
require_once("aidb.inc");
require_once("nn-util.php");

// This first section checks for possible keyword lookups.  Any URL of
// the form:
//
//   http://nn.cs.utexas.edu?X
//
// ...will be treated as a lookup for keyword X.

// get the first thing after the ? in the url
$keys = array_keys($_GET);
if( sizeof($keys) > 0 ) {
  $lookupText = sanitize_mysqli($keys[0]);
  // see if there are any matches on that word in the keywords table
  $result = new Result("select * from keywords where keyword = '$lookupText'");

  // check if our query worked or not
  if( $result->getSize() == 0 ) {
    echo "Invalid keyword: " . htmlentities($lookupText);
    exit;
  } else {
    $data = $result->getData(0);
    $tableName = $data['tableName'];
    $id = $data['id'];

    switch( $tableName ) {
    case "areas":
      $_REQUEST['AreaID'] = $id;
      echo get_include_contents("area-view.php");
      exit;
    case "people":
      $_REQUEST['PID'] = $id;
      echo get_include_contents("people-view.php");
      exit;
    case "projects":
      $_REQUEST['ProjID'] = $id;
      echo get_include_contents("project-view.php");
      exit;
    case "pubs":
      $_REQUEST['PubID'] = $id;
      echo get_include_contents("pub-view.php");
      exit;
    case "software":
      $_REQUEST['SoftID'] = $id;
      echo get_include_contents("soft-view.php");
      exit;
    case "demos":
      $_REQUEST['DemoID'] = $id;
      echo get_include_contents("demo-view.php");
      exit;
    default:
      echo "Error: internal database error, no association for table<br>\n";
      exit;
    }

  }
} 


//foreach( $_REQUEST as $key => $val ) {
//  echo "$key: $val<br>\n";
//}
?>

<html>
<head>
  <title>Neural Network Research Group</title>
  <link rel="stylesheet" type="text/css" href="nn-styles.css" />
</head>

<body onLoad="document.search.q.focus();">

<div id="main">

<?php
echo getHeader( "Welcome" );
echo <<<EOF
<div class='top-content'>
<div class="logo-box">
  <a href="about.php">
    <img class="logo-pic" src='nnlogo.png' />
  </a>
</div>
<div class='side-content'>
EOF;

$bio = <<<EOF
<p>
Welcome to the <a href="http://nn.cs.utexas.edu/about.php">Neural Networks Research Group</a> web site.  
</p>
<p>
The group is directed by 
<a href="http://www.cs.utexas.edu/~risto">Prof. Risto Miikkulainen</a>
and is located at the 
<a href="http://www.cs.utexas.edu">Department of Computer Sciences</a>
at the 
<a href="http://www.utexas.edu">University of Texas at Austin.</a>
</p>
EOF;
echo getInBox( $bio );
?>

</div>
</div>
<div class='bottom-content'>

<div class="inline-header">Spotlight</div>

<div class="box-content">
  <?php include( "spotlight.html" ); ?>

  <p>
  <a href="spotlight.php">Previous Spotlights</a>
  </p>
</div>

</div>

<?php echo getFooter(); ?>

</div>

</body>
</html>
