if ($dep = $sqlm->fetch_assoc($sqlm->query('
		SELECT field_1, field_2, field_3, field_' . ($tab['field_16'] + 1) . ', field_13,field_16' . ($tab['field_16'] < 4 ? ', field_' . ($tab['field_16'] + 2) . '' : '') . '
		FROM dbc_talent
		WHERE id = ' . $tab['field_13'] . ' and field_' . ($tab['field_16'] + 1) . ' != 0
		LIMIT 1'))) {
        if (empty($tabs[$dep['field_1']][$dep['field_2']][$dep['field_3']])) {
            $tabs[$dep['field_1']][$dep['field_2']][$dep['field_3']] = array($dep['field_' . ($tab['field_16'] + 1) . ''], '' . ($tab['field_16'] + 1) . '', $tab['field_16'] < 4 ? $dep['field_' . ($tab['field_16'] + 2) . ''] ? '2' : '5' : '5');
            $i += $tab['field_16'] + 1;
            if ($dep['field_13']) {
                talent_dependencies($tabs, $dep, $i, $sqlm);
            }
        }
    }
}
//########################################################################################################################
// MAIN
//########################################################################################################################
// action variable reserved for future use
//$action = (isset($_GET['action'])) ? $_GET['action'] : NULL;
$lang_char = lang_char();
$output .= '
<div class="top">
	<h1>' . $lang_char['character'] . '</h1>
</div>';
// we getting links to realm database and character database left behind by header
// header does not need them anymore, might as well reuse the link
char_talent($sqlr, $sqlc);
//unset($action);
unset($action_permission);
unset($lang_char);
require_once 'footer.php';
}
// this_is_junk: Because we use it for filenames, we can't use the one in the language kit.
function get_class_name($class_id)
{
    $class_names = array(1 => "Warrior", 2 => "Paladin", 3 => "Hunter", 4 => "Rogue", 5 => "Priest", 6 => "DeathKnight", 7 => "Shaman", 8 => "Mage", 9 => "Warlock", 11 => "Druid");
    return $class_names[$class_id];
}
function talent_dependencies(&$tabs, &$tab, &$i)
{
    global $sql;
    $query = "SELECT TalentTab, Row, Col, Spell" . ($tab["TalentCount1"] + 1) . ", Talent1, TalentCount1" . ($tab["TalentCount1"] < 4 ? ", Spell" . ($tab["TalentCount1"] + 2) : "") . " FROM talent WHERE id='" . $tab["Talent1"] . "' AND Spell" . ($tab["TalentCount1"] + 1) . " != 0 LIMIT 1";
    if ($dep = $sql["dbc"]->fetch_assoc($sql["dbc"]->query($query))) {
        if (empty($tabs[$dep["TalentTab"]][$dep["Row"]][$dep["Col"]])) {
            $tabs[$dep["TalentTab"]][$dep["Row"]][$dep["Col"]] = array($dep["Spell" . ($tab["TalentCount1"] + 1)], $tab["TalentCount1"] + 1, $tab["TalentCount1"] < 4 ? $dep["Spell" . ($tab["TalentCount1"] + 2)] ? "2" : "5" : "5");
            $i += $tab["TalentCount1"] + 1;
            if ($dep["Talent1"]) {
                talent_dependencies($tabs, $dep, $i);
            }
        }
    }
}
//########################################################################################################################
// MAIN
//########################################################################################################################
// action variable reserved for future use
//$action = (isset($_GET["action"])) ? $_GET["action"] : NULL;
$output .= '
      <div class="bubble">';
char_talent();
unset($action_permission);
require_once "footer.php";