<?php
	function indent($num)
	{
		$indent = "";
		for ($i = 0; $i < $num; $i++) {
			$indent .= "\t";
		}
		return $indent;
	}
/*
	$randomFactArray = array(
		"Lemurs can only be found in Madagascar, an island off the coast of Africa. <a href=\"http://www.amazon.com/Lemurs-Location-Tara-Darling/dp/0688125395/ref=sr_1_1?ie=UTF8&s=books&qid=1266520048&sr=1-1\" target=\"_blank\">(src)</a>",
		"The largest cat in the world is the Siberian tiger. <a href=\"http://www.amazon.com/Tiger-Habitats-Cycles-Threats-Natural/dp/0750224436/ref=sr_1_1?ie=UTF8&s=books&qid=1266519727&sr=8-1\" target=\"_blank\">(src)</a>",
		"Peregrine falcons can dive at speeds up to 200 mph. <a href=\"http://www.amazon.com/Eagles-Hawks-Other-Birds-First/dp/0531105709/ref=sr_1_1?ie=UTF8&s=books&qid=1266519954&sr=1-1\" target=\"blank\">(src)</a>",
		"Boa constrictors live in all sorts of habitats, in all kinds of climates, such as deserts and rainforests. <a href=\"http://www.amazon.com/Rainforest-Creatures-Wild-Benita-Sen/dp/140423893X/ref=sr_1_1?ie=UTF8&s=books&qid=1266447069&sr=8-1\" target=\"_blank\">(src)</a>");

	$quoteArray = array(
		"\"I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals.\"</p><p>- Winston Churchill</p>",
		"\"For instance, on the planet Earth, man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars, and so on - whilst all the dolphins had ever done was much about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.\"</p><p>- Douglas Adams in <i>The Hitchhiker's Guide to the Galaxy</i></p>",
		"\"Curiously enough, the dolphins had long known of the impending destruction of the planet Earth and had made many attempts to alert mankind of the danger; but most of their commications were misinterpreted as amusing attempts to punch footballs or whistle for tidbits, so they eventually gave up and left the Earth by their own means shortly before the Vogons arrived.\"</p><p>- Douglas Adams in <i>The Hitchhiker's Guide to the Galaxy</i></p>");
*/

	$scriptName = $_SERVER["SCRIPT_NAME"];
	// Divide the name into directories
	$scriptNameArray = preg_split("[/]", $scriptName);

	// Number of directories to get to main directory
	$directoriesUp = count($scriptNameArray) - 3;// - 2 for live website
	// What to add to go so many directories up
	$filePrefix = "";
	if ($directoriesUp > 0) {
		$filePrefix = str_repeat("../", $directoriesUp);
	}

	// Read the fact file and load it into an array
	$randomFactArray = array();
	$lines = file($filePrefix."textfiles/facts.txt");
	foreach ($lines as $line) {
		$randomFactArray[count($randomFactArray)] = $line;
	}

	// Read the quote file and load it into an array
	$quoteArray = array();
	$lines = file($filePrefix."textfiles/quotes.txt");
	foreach ($lines as $line) {
		// Divide the line at the spot where the quote end (" -)
		$lineArray = preg_split("[\" -]", $line);
		// Smash together a few strings: quote + </p><p> + quoter + </p>
		// (we also add in what we took out by dividing it (the " -)
		$quoteArray[count($quoteArray)] = $lineArray[0]."\"</p><p>-".$lineArray[1];
	}

	// Declare navigation arrays
	$mainNavigationArray = array(
		"Home" => $filePrefix."index.php",
		"About" => $filePrefix."about.php",
//		"Notices" => $filePrefix."notices.php",
//		"Contact" => $filePrefix."contact.php",
		"Featured" => $filePrefix."featured.php",
		"General Information" => $filePrefix."general_info.php",
		"Fun Stuff" => $filePrefix."fun_stuff.php");

	$featuredArray = array(//"Discussion" => $filePrefix."featured/discussion.php",
							"Featured Animal" => $filePrefix."featured/featured_animal.php");
	$generalInfoArray = array("Era Timeline" => $filePrefix."general-info/era_timeline.php",
							"Classification" => $filePrefix."general-info/classification.php",
							"Unit Conversions" => $filePrefix."general-info/unit_conversions.php");
	$funStuffArray = array("Videos" => $filePrefix."fun-stuff/videos.php",
							"Flash Cards" => $filePrefix."fun-stuff/flash_cards.php");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
	<head>
<?php
	echo "\t\t<title>";
	if ($pageTitle != "")
		echo $pageTitle." - ";
?>
Something About Animals</title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?php
	echo "\t\t<link rel=\"icon\" type=\"image/png\" href=\"".$filePrefix."images/icon.png\" />\n";
	echo "\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$filePrefix."styles/header_style.css\" />\n";
	echo "\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$filePrefix."styles/style.css\" />\n";
	echo "\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$filePrefix."styles/footer_style.css\" />\n";
	echo "\t\t<script type=\"text/javascript\" src=\"".$filePrefix."jquery/js/jquery-1.5.1.min.js\"></script>\n";
	echo "\t\t<script type=\"text/javascript\" src=\"".$filePrefix."jquery/js/jquery-ui-1.8.11.custom.min.js\"></script>";

	//echo "<link type=\"text/css\" href=\"".$filePrefix."jquery/css/ui-lightness/jquery-ui-1.8.11.custom.css\" rel=\"stylesheet\" />";
?>

		<script type="text/javascript">
			$(function()
			{
				$(".accordion").accordion({ header: "h3" });
			});
			</script>
	</head>

	<body>
		<div id="container">
			<div id="header">
				<a href="/"><h1>Something About Animals</h1></a>
				<ul class="nav-menu">
<?php
	// Get the name of the current page (ie "index.php")
	$currentPage = substr($scriptName, strrpos($scriptName, "/") + 1);
	// Write the navigation menu
	// If we are on the page, give it the selected id
	foreach ($mainNavigationArray as $page => $url) {
		$id = "";
		if ($currentPage == $url)
			$id = " id=\"selected\"";
		echo "\t\t\t\t\t<li".$id."><a href=\"".$url."\">".$page."</a></li>\n";
	}
?>
				</ul>

			</div> <!-- closes header -->
			<div id="main-container">
				<div id="main"><table>
					<td rowspan="2" width="75%" style="vertical-align: top; border-right: 1px solid #999999;">