<?php
require_once("xajax/xajax.inc.php");
$xajax = new xajax();
$xajax->registerFunction("myFunction");

function myFunction($arg)
{
	if (empty($arg))
	{
		$arg = " ";
	}
	
	$names[] = "filip";
	$names[] = "fillemon";
	$names[] = "jeff";
	$names[] = "jeffrey";
	$names[] = "bram";
	$names[] = "bramster";
	$names[] = "koen";
	$names[] = "koenraad";
	$names[] = "houdini";
	
	$newContent = "";
	$eerste = "";
	foreach ($names as $i)
	{
		if (eregi("^".$arg, $i))
		{
			if ( "" == $eerste ) {
				$eerste = $i;
			}
		}
	}
	
	// Instantiate the xajaxResponse object
    $objResponse = new xajaxResponse();
    
    // add a command to the response to assign the innerHTML attribute of
    // the element with id="SomeElementId" to whatever the new content is
	if ( "" != $eerste ) {
    $objResponse->addAssign("veld", "value", $eerste );
   }
    $objResponse->addAssign("z", "value", $eerste );
    //return the  xajaxResponse object
    return $objResponse;
}

$xajax->processRequest();
?>
