<?php

$keyFound	=	"/".$_GET['keyWord']."/";

$keyWord	=	$_GET['keyWord'];

include('XMLParser.php');

$xml = file_get_contents('../data/search.xml');

//Set up the parser object

$parser = new XMLParser($xml);

$flag=0;

$parser->Parse();

$arrResults	=	$parser->document->tagChildren;

$return		=	"<table cellspacing='0px' cellpadding='0px' style='border: 1px solid rgb(168, 168, 168); width: 400px;'><tr><td>&nbsp;</td></tr>";

for($i=0; $i<COUNT($arrResults); $i++)
{

	$results		=	$arrResults[$i]->tagAttrs;

	$resultChild	=	$arrResults[$i]->paragraph[0]->tagData;

	$pageNum		=   $results['pagenumber'];

	if($keyWord != '')
	{
		if(preg_match($keyFound,$resultChild))
		{
			$flag=1;
			$return		.=	 "<tr><td>&nbsp;&nbsp;</td><td> ".$keyWord." <a nohref style='cursor:pointer;color:#000;font-size:12px;font-weight:normal;' title='page $pageNum'onClick='goTo($pageNum)'>[Page ".$pageNum."]</a><td></tr>";
		}
	}
	else
	{
		$flag=0;
	}
}

$return		.=	"<tr><td>&nbsp;</td></tr></table><br/>";

if($flag	==	1)
{
	echo $return	.=	"_".$flag."_".$keyWord;
}
else
{

}
?>