Nice one :) another thing u could do to it to get a better template system is to add smarty template and it would be really simple since most of the code is in $HTMLOUT
for example in index.php at start...
Code:
require_once ROOT_DIR.'/smarty/smarty.class.php';
$index = new Smarty;
//$index->debugging = true; //optional
//$index->caching = true; //optional
//$index->cache_lifetime = 120;//optional
Then at the end...
Code:
$index->assign("content",stdhead('Home') . $HTMLOUT . stdfoot($stdfoot),true);
$index->display('index.tpl');
and define your template path in the smarty class just a thought :)