function jewel_check($character){
require("config.php");
$inventory_result_sql = $db->Execute("SELECT Inventory FROM Character WHERE (Character.[Name] = '$character')");
$inventory_result = $inventory_result_sql->fetchrow();
$inventory = $inventory_result[0];
$inventory = bin2hex($inventory);
$inventory = strtoupper($inventory);
//echo($inventory);
$chaos = 0;
$joc = 0;
$blue = 0;
for($x=0; $x<108; ++$x)
{
$item = substr($inventory,$x*32,32);
$chaos = $chaos + substr_count($item, '0F00');
$joc = $joc + substr_count($item, 'D600');
$blue = $blue + substr_count($item, '0E00');
}
$j = array( 'chaos' => $chaos,
'joc' => $joc,
'blue' => $blue);
return $j;
}