function invention_show_details($invention_id, $planet_id, $user_id, $stock_ores)
{
    assert(is_numeric($invention_id));
    assert(is_numeric($planet_id));
    assert(is_numeric($user_id));
    assert(is_string($stock_ores));
    global $_GALAXY;
    $build_option = 1;
    // Check our mode, we can just look at details, or let the user build
    if ($planet_id == 0 and $user_id == 0 and $stock_ores == "") {
        $build_option = 0;
    }
    $invention = item_get_item($invention_id);
    if ($build_option) {
        $cannot_build = false;
        $user = user_get_user($user_id);
        $planet = anomaly_get_anomaly($planet_id);
        $planet_ores = csl($stock_ores);
        $invention_ores = ore_csl_to_list($invention['initial_ores']);
    } else {
        $planet_ores = ore_csl_to_list("");
        $invention_ores = ore_csl_to_list("");
    }
    echo "<table border=1 cellpadding=0 cellspacing=0 align=center width=50%>";
    // invention name
    echo "  <tr class=wb><th colspan=2>" . $invention['name'] . "</th></tr>";
    // Plaatje plus ADS etc
    echo "  <tr>";
    echo "    <td align=center valign=top bgcolor=black>";
    echo "              <table border=0 cellpadding=0 cellspacing=0>";
    echo "                <tr>";
    echo "                   <td >";
    echo "                    <table align=left border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "                      <tr><td width=100><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/inventions/" . $invention['image'] . ".jpg\" width=150 height=150></td></tr>";
    echo "                    </table>";
    echo "                 </td>";
    echo "               </tr>";
    echo "             </table>";
    echo "    </td>";
    echo "    <td align=left valign=top bgcolor=black>";
    $class = 't';
    echo "             <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Function</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . item_get_type($invention['id']) . "&nbsp;</td>";
    echo "                </tr>";
    echo "                <tr><td colspan=3><hr></td></tr>\n";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Maximum Stock</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . $invention['max'] . " pcs&nbsp;</td>";
    echo "                </tr>";
    echo "                <tr><td colspan=3><hr></td></tr>\n";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Attack</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . $invention['attack'] . " pts&nbsp;</td>";
    echo "                </tr>";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Defense</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . $invention['defense'] . " pts&nbsp;</td>";
    echo "                </tr>";
    echo "              </table>";
    echo "    </td>";
    echo "  </tr>";
    if ($build_option) {
        // Costs + ores  (initial / upkeep)
        echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
        echo "  <tr bgcolor=black><td>";
        $cannot_build = smt_initial_ores($cannot_build, $invention_id, $user_id, $planet_ores);
        echo "  </td><td>";
        $cannot_build = smt_upkeep_ores($cannot_build, $invention_id, $user_id, $planet_ores);
        echo "  </td></tr>";
        echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
    } else {
        echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
        echo "  <tr bgcolor=black><td>";
        smt_initial_ores(0, $invention_id, $user_id, $planet_ores);
        echo "  </td><td>";
        smt_upkeep_ores(0, $invention_id, $user_id, $planet_ores);
        echo "  </td></tr>";
        echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
    }
    // Print rule and description
    if ($invention['rule'] != "") {
        echo "<tr bgcolor=black><td colspan=2><table border=0 cellspacing=5><tr><td>Effect: " . $invention['rule'] . "</td></tr></table></td></tr>";
    }
    if ($invention['description'] != "") {
        echo "<tr bgcolor=black><td colspan=2 ><table border=0 cellspacing=5><tr><td>" . $invention['description'] . "</td></tr></table></td></tr>";
    }
    // Print building possibility
    if ($build_option) {
        if ($cannot_build == false) {
            echo "<tr bgcolor=black><th colspan=2><a href=manufacture.php?cmd=" . encrypt_get_vars("manufacture") . "&iid=" . encrypt_get_vars($invention['id']) . "&aid=" . encrypt_get_vars($planet['id']) . ">BUILD IT</a></th></tr>";
        } else {
            echo "<tr bgcolor=black><th colspan=2>CANNOT BUILD</th></tr>";
        }
    }
    echo "</table>\n";
    echo "<br><br>\n";
}
function obsolete_show_invention_table($invention, $planet, $user, $stock_ores)
{
    assert(!empty($invention));
    assert(!empty($planet));
    assert(!empty($user));
    assert(!empty($stock_ores));
    global $_GALAXY;
    $cannot_build = false;
    $invention_ores = ore_csl_to_list($invention['initial_ores']);
    $planet_ores = $stock_ores;
    echo "<table border=1 cellpadding=0 cellspacing=0 align=center width=50%>";
    // invention name
    echo "  <tr><th colspan=2>" . $invention['name'] . "</th></tr>";
    // Plaatje plus ADS etc
    echo "  <tr>";
    echo "    <td align=center valign=top bgcolor=black>";
    echo "              <table border=0 cellpadding=0 cellspacing=0>";
    echo "                <tr>";
    echo "                   <td >";
    echo "                    <table align=left border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "                      <tr><td width=100><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/inventions/" . $invention['image'] . ".jpg\" width=150 height=150></td></tr>";
    echo "                    </table>";
    echo "                 </td>";
    echo "               </tr>";
    echo "             </table>";
    echo "    </td>";
    echo "    <td align=left valign=top bgcolor=black>";
    $class = 't';
    echo "             <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Function</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . item_get_type($invention['type']) . "&nbsp;</td>";
    echo "                </tr>";
    echo "                <tr><td colspan=3><hr></td></tr>\n";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Maximum</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . $invention['max'] . "&nbsp;</td>";
    echo "                </tr>";
    echo "                <tr><td colspan=3><hr></td></tr>\n";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Attack</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . $invention['attack'] . "&nbsp;</td>";
    echo "                </tr>";
    echo "                <tr>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>Defense</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;<strong>:</strong>&nbsp;</td>";
    echo "                  <td class=" . $class . ">&nbsp;" . $invention['defense'] . "&nbsp;</td>";
    echo "                </tr>";
    echo "              </table>";
    echo "    </td>";
    echo "  </tr>";
    // Costs + ores  (initial / upkeep)
    echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
    echo "  <tr bgcolor=black><td>";
    $cannot_build = smt_initial_ores($cannot_build, $invention, $user, $planet_ores);
    echo "  </td><td>";
    $cannot_build = smt_upkeep_ores($cannot_build, $invention, $user, $planet_ores);
    echo "  </td></tr>";
    echo "  <tr bgcolor=black><td colspan=2>&nbsp;</td></tr>\n";
    // Print rule and description
    if ($invention['rule'] != "") {
        echo "<tr><td colspan=2><table border=0 cellspacing=5><tr><td>Effect: " . $invention['rule'] . "</td></tr></table></td></tr>";
    }
    if ($invention['description'] != "") {
        echo "<tr><td colspan=2><table border=0 cellspacing=5><tr><td>" . $invention['description'] . "</td></tr></table></td></tr>";
    }
    // Print building possibility
    if ($cannot_build == false) {
        echo "<tr><th colspan=2><a href=manufacture.php?cmd=" . encrypt_get_vars("manufacture") . "&iid=" . encrypt_get_vars($invention['id']) . "&aid=" . encrypt_get_vars($planet['id']) . ">BUILD IT</a></th></tr>";
    } else {
        echo "<tr><th colspan=2>CANNOT BUILD</th></tr>";
    }
    echo "</table>\n";
    echo "<br><br>\n";
}