<?php
	global $fileisphp;
	
	$ua=$_SERVER['HTTP_USER_AGENT'];
	if ( stristr($ua, "Windows CE") or
		 stristr($ua, "Mobile")) {
		 header ('Location: '. "index-touch.php");
		 exit;
	}

	if ( isset($_GET["page"]) && $_GET["page"] ) {
	   $basefile=basename($_GET["page"]);
	   $htmlfile = "$basefile";
	}else{
	   $htmlfile = "main.html";
	}

	if (basename("$htmlfile",'.php') != "$htmlfile") {
		$fileisphp=1;
	}
?>
<HEAD>
<TITLE>Edsel Adap</TITLE>
<BASE href="http://www.adap.org/~edsel/index.php">
</HEAD>
<BODY bgcolor=white link="#404040" vlink="#7c7c7c" alink="#bb0000">
<FONT FACE="Arial,Helvetica">
<TABLE width="100%" border=0>
<tr>
<td width="20%">&nbsp;</td>
<td align=center valign=middle><img src="images/title.gif"></td>
<td width="20%">&nbsp;</td>
</tr>
<tr>
<td width="20%">&nbsp;</td>
<TD width="60%">
<CENTER>
<?php
include("php/navigation.php")
?>
<HR>
</TD>
<td width="20%">&nbsp </TD>
</tr>
<tr>
<TD width="20%">&nbsp;</TD>
<TD width="60%">
<?php
	if ($fileisphp == 1) {
		include("php/$htmlfile");
	}else{
		if(file_exists("html/$htmlfile")) {
			$fh=fopen("html/$htmlfile","r");
			$contents = fread($fh, filesize("html/$htmlfile"));
			fclose($fh);
			echo $contents;
		}else{
			print("Requested page does not exist");
		}
	}
?>
</TD>
<TD width="20%">&nbsp;</TD>
</TR>
<tr>
<TD width="20%">&nbsp;</td>
<TD width="60%">
<?php
include('html/footer.html');
?>
</TD>
<TD width="20%">&nbsp;</TD>
</tr>
</TABLE>
</FONT>
</BODY>
</HTML>
