function GetIcon($Type, $DisplayIconId)
{
    if ($Type == "item") {
        $Table = "dbc_itemdisplayinfo";
    } else {
        //$Type == "spell"
        $Table = "dbc_spellicon";
    }
    if ($icon = GetNameFromDB($DisplayIconId, $Table)) {
        return "images/icons/64x64/" . $icon . ".png";
    } else {
        return "images/icons/64x64/404.png";
    }
}
        echo "<td class=\"\"><q><strong>", guild_tooltip($guildid), "</strong></q></td>";
        if ($cdata["played_season"]) {
            $win_percent = round($cdata["wons_season"] / $cdata["played_season"] * 100);
        } else {
            $win_percent = 0;
        }
        ?>
<td align="center"><img class="ci" onmouseout="hideTip()" onMouseOver="showTip('<?php 
        echo GetNameFromDB($cdata["race"], "dbc_chrraces");
        ?>
')" src="images/icons/race/<?php 
        echo $cdata["race"], "-", $cdata["gender"];
        ?>
.gif"><img src="shared/wow-com/images/layout/pixel.gif" width="2">
<img class="ci" onmouseout="hideTip()" onMouseOver="showTip('<?php 
        echo GetNameFromDB($cdata["class"], "dbc_chrclasses");
        ?>
')" src="images/icons/class/<?php 
        echo $cdata["class"];
        ?>
.gif"></td>
<td align="center"><q><i><span class="veryplain"><?php 
        echo $cdata["played_season"];
        ?>
</span></i></q></td>
<td align="center"><q><i><span class="g"><?php 
        echo $cdata["wons_season"];
        ?>
</span></i></q></td>
<td align="center"><q><i><span class="r"><?php 
        echo $cdata["played_season"] - $cdata["wons_season"];
<?php

if (!defined("Armory")) {
    header("Location: ../error.php");
    exit;
}
$faction_ihl = array(1118 => "classic", 469 => "alliance", 891 => "allianceforces", 1037 => "classic", 67 => "horde", 892 => "hordeforces", 1052 => "classic", 936 => "shattrathcity", 1117 => "classic", 169 => "steamwheedlecartel", 980 => "outland", 1097 => "classic", 0 => "zother");
$reputation_rank_length = array(36000, 3000, 3000, 3000, 6000, 12000, 21000, 999);
$reputation_cap = 42999;
$reputation_bottom = -42000;
$MIN_REPUTATION_RANK = 0;
$MAX_REPUTATION_RANK = 8;
$temp_out = array();
foreach ($faction_ihl as $key => $value) {
    $temp_out[$key] = array("<div class=\"inner-cont\">\r\n<table class=\"iht\">\r\n<tr>\r\n<td class=\"ihl\"><span class=\"faction-" . $value . "\">\r\n<p>" . GetNameFromDB($key, "dbc_faction") . "</p>\r\n</span></td><td class=\"ihrc\"></td>\r\n</tr>\r\n</table>\r\n<table>\r\n<tr>\r\n<td class=\"il\"></td><td class=\"ibg\">\r\n<div class=\"profile-wrapper\">", 0);
}
?>
<div class="parch-profile-banner" id="banner" style="margin-top: -7px!important;">
<h1><?php 
echo $lang["reputation"];
?>
</h1>
</div>
<?php 
switchConnection("characters", REALM_NAME);
$return_char_reputations = execute_query("SELECT `faction`, `standing` FROM `character_reputation` WHERE `guid` =" . $stat["guid"] . " AND (`flags` & 1 = 1)");
while ($factions = mysql_fetch_assoc($return_char_reputations)) {
    $standing = $factions["standing"];
    switchConnection("armory", REALM_NAME);
    $faction_info = mysql_fetch_assoc(execute_query("SELECT * FROM `dbc_faction` WHERE `id` =" . $factions["faction"] . " LIMIT 1"));
    // From base reputation
	var textGuildRank = "<?php 
    echo $lang["guild_rank"];
    ?>
";
	var theArray = new Array();
<?php 
    $i = 0;
    while ($cdata = mysql_fetch_assoc($mlquery)) {
        $_char_data = explode(" ", $cdata["data"]);
        $cdata["level"] = $_char_data[$defines["LEVEL"][CLIENT]];
        $_char_gender = dechex($_char_data[$defines["GENDER"][CLIENT]]);
        unset($_char_data);
        $_char_gender = str_pad($_char_gender, 8, 0, STR_PAD_LEFT);
        $cdata["gender"] = $_char_gender[3];
        $i = $i + 1;
        echo "theArray[", $i, " - 1] = [[\"&character=", $cdata["name"], "&realm=", REALM_NAME, "\"], [\"", $cdata["name"], "\"], [", $cdata["level"], "], [\"", $cdata["race"], "\", \"", $cdata["gender"], "\", \"", GetNameFromDB($cdata["race"], "dbc_chrraces"), "\"], [\"", $cdata["class"], "\", \"", GetNameFromDB($cdata["class"], "dbc_chrclasses"), "\"], [\"", $cdata["rank"], "\"]]; \n";
    }
    ?>
	var gHighestRank = 0;
	for (var x = 0; x < theArray.length; x++) {
		if (gHighestRank < theArray[x][5][0])
			gHighestRank = theArray[x][5][0];
	}
	replaceString = '<select  class="bankselect" style="width: 100px;" id = "selectRank" onChange = "gFrank = this.value; filterArray();" name = "optionRank"><option value = "-1"><?php 
    echo $lang["all_ranks"];
    ?>
</option>';
	replaceString += '<option value = "0"><?php 
    echo $lang["guild_master"];
    ?>
</option>';
function outputTooltip($itemid, $itemguid = 0, $itemlist = array())
{
    global $inventorytype, $ItemFlags, $config, $defines, $lang;
    /* Item Tooltip Output Function */
    /* Get Item Info */
    switchConnection("mangos", REALM_NAME);
    $tooltipText = "";
    $itemtable = "";
    if ($config["locales"]) {
        $itemdata = mysql_fetch_assoc(execute_query("SELECT * FROM `item_template` LEFT JOIN `locales_item` ON `item_template`.`entry` = `locales_item`.`entry` where `item_template`.`entry` = " . $itemid . " LIMIT 1"));
        $nameloc = "name_loc" . $config["locales"];
        $descriptionloc = "description_loc" . $config["locales"];
        if ($itemdata[$nameloc]) {
            $itemdata["name"] = $itemdata[$nameloc];
        }
        if ($itemdata[$descriptionloc]) {
            $itemdata["description"] = $itemdata[$descriptionloc];
        }
    } else {
        $itemdata = mysql_fetch_assoc(execute_query("SELECT * FROM `item_template` WHERE `entry` = " . $itemid . " LIMIT 1"));
    }
    $tooltipText .= "<table class=\"item-tooltip-table\" cellpadding=\"0\">";
    $itemtable .= "<div class=\"myTable\">";
    /* get character item specific information */
    if ($itemguid) {
        switchConnection("characters", REALM_NAME);
        $enchantmentsData = explode(" ", mysql_result(execute_query("SELECT `data` FROM `item_instance` WHERE `guid` = " . $itemguid . " LIMIT 1"), 0));
    }
    /* Random Enchantment PART 1*/
    $ItemRandomName = "";
    if ($itemguid && ($itemdata["RandomProperty"] || $itemdata["RandomSuffix"])) {
        $FirstEnchant = $defines["RANDOM_1"][CLIENT];
        if ($itemdata["RandomProperty"]) {
            $FirstEnchant += 6;
            $RandomEnchantTable = "dbc_itemrandomproperties";
        } else {
            // if($itemdata["RandomSuffix"])
            $RandomEnchantTable = "dbc_itemrandomsuffix";
        }
        switchConnection("armory", REALM_NAME);
        $ItemRandomData = mysql_fetch_assoc(execute_query("SELECT * FROM `" . $RandomEnchantTable . "`\r\n\t\t\tWHERE `ref_spellitemenchantment_1` = " . $enchantmentsData[$FirstEnchant] . " AND `ref_spellitemenchantment_2` = " . $enchantmentsData[$FirstEnchant + 3] . " AND `ref_spellitemenchantment_3` = " . $enchantmentsData[$FirstEnchant + 6] . " LIMIT 1"));
        $ItemRandomName = $ItemRandomData["name"];
    }
    /* Item Quality */
    switch ($itemdata["Quality"]) {
        case 0:
            $itemQuality = "gray";
            break;
        case 1:
            $itemQuality = "white";
            break;
        case 2:
            $itemQuality = "green";
            break;
        case 3:
            $itemQuality = "blue";
            break;
        case 4:
            $itemQuality = "purple";
            break;
        case 5:
            $itemQuality = "orange";
            break;
        case 6:
            $itemQuality = "gold";
            break;
            /* 7 */
        /* 7 */
        default:
            $itemQuality = "red";
    }
    $tooltipText .= tooltip_addsinglerow("<span class=\"item-quality-" . $itemQuality . "\">" . $itemdata["name"] . " " . $ItemRandomName . "</span>", "item-text-name");
    $itemtable .= "<span class=\"my" . ucfirst($itemQuality) . " myBold myItemName\"><span class=\"\">" . $itemdata["name"] . "</span><span class=\"\"> </span></span>";
    /* Item Binding */
    switch ($itemdata["bonding"]) {
        case 1:
            $itemBinding = $lang["binds_when_pickup"];
            break;
        case 2:
            $itemBinding = $lang["binds_when_equipped"];
            break;
        case 3:
            $itemBinding = $lang["binds_when_used"];
            break;
        case 4:
            $itemBinding = $lang["quest_item"];
            break;
        default:
            $itemBinding = "";
    }
    if ($itemBinding) {
        $tooltipText .= tooltip_addsinglerow($itemBinding);
        $itemtable .= "<br />" . $itemBinding;
    }
    /* Unique Status */
    if ($itemdata["Flags"]) {
        $count = 0;
        $UniqueString = "";
        foreach ($ItemFlags as $key => $value) {
            if ($itemdata["Flags"] & $key) {
                $count = 1;
                if ($value) {
                    $UniqueString = $value;
                }
            }
        }
        if ($UniqueString && $count) {
            $tooltipText .= tooltip_addsinglerow($UniqueString);
            $itemtable .= "<br />" . $UniqueString;
        } else {
            if ($config["ShowError"] && !$count) {
                $tooltipText .= tooltip_addsinglerow("<span class=\"error\">" . $lang["error"] . ": " . $lang["unknown"] . " Flags " . $itemdata["Flags"] . ", " . $lang["report_to_gm"] . "</span>");
                $itemtable .= "<br /><span class=\"error\">" . $lang["error"] . ": " . $lang["unknown"] . " Flags " . $itemdata["Flags"] . ", " . $lang["report_to_gm"] . "</span>";
            }
        }
    }
    $greenStats = array();
    /* Item Type */
    if ($itemdata["InventoryType"]) {
        switchConnection("armory", REALM_NAME);
        $itemClassRight = mysql_result(execute_query("SELECT `name` FROM `dbc_itemsubclass` WHERE `ref_itemclass` = " . $itemdata["class"] . " AND `id` = " . $itemdata["subclass"]), 0);
        if ($itemdata["InventoryType"] == 18) {
            $itemClassLeft = $itemdata["ContainerSlots"] . " " . $lang["slot"] . " " . $itemClassRight;
            $tooltipText .= tooltip_addsinglerow($itemClassLeft);
            $itemtable .= "<br />" . $itemClassLeft;
        } else {
            $itemClassLeft = $inventorytype[$itemdata["InventoryType"]];
            $tooltipText .= tooltip_adddoublerow($itemClassLeft, $itemClassRight);
            $itemtable .= "<br /><span class=\"tooltipRight\">" . $itemClassRight . "</span>" . $itemClassLeft;
        }
        /* Damage */
        $itemIsWeapon = 0;
        $minDamage = 0;
        $totalMinDamage = 0;
        $maxDamage = 0;
        $totalMaxDamage = 0;
        /* Loop through item data to check if any of the dmg_min and dmg_max fields are set and handle output as such */
        $dmg_max_index = CLIENT >= 2 ? 2 : 5;
        for ($i = 1; $i <= $dmg_max_index; $i++) {
            if ($itemdata["dmg_min" . $i]) {
                $itemIsWeapon = 1;
                $thisDelay = round($itemdata["delay"] / 1000, 2);
                $minDamage = $itemdata["dmg_min" . $i];
                $totalMinDamage += $minDamage;
                $maxDamage = $itemdata["dmg_max" . $i];
                $totalMaxDamage += $maxDamage;
                $itemDamageType = "&nbsp;";
                switch ($itemdata["dmg_type" . $i]) {
                    case 0:
                        $itemDamageType = "";
                        break;
                    case 1:
                        $itemDamageType .= $lang["holy"];
                        break;
                    case 2:
                        $itemDamageType .= $lang["fire"];
                        break;
                    case 3:
                        $itemDamageType .= $lang["nature"];
                        break;
                    case 4:
                        $itemDamageType .= $lang["frost"];
                        break;
                    case 5:
                        $itemDamageType .= $lang["shadow"];
                        break;
                    case 6:
                        $itemDamageType .= $lang["arcane"];
                        break;
                    default:
                        $itemDamageType .= $lang["unknown"] . ": " . $itemdata["dmg_type" . $i];
                }
                $itemDamageType .= "&nbsp;";
                if ($i == 1) {
                    $tooltipText .= tooltip_addsinglerow($minDamage . "-" . $maxDamage . $itemDamageType . $lang["dmg"]);
                    $itemtable .= "<br /><span class=\"\">" . $minDamage . "-" . $maxDamage . "</span><span class=\"\">" . $itemDamageType . "</span><span class=\"\">" . $lang["dmg"] . "</span>";
                } else {
                    $tooltipText .= tooltip_addsinglerow("+" . $minDamage . "-" . $maxDamage . $itemDamageType . $lang["damage"]);
                    $itemtable .= "<br /><span class=\"\">+" . $minDamage . "-" . $maxDamage . "</span><span class=\"\">" . $itemDamageType . "</span><span class=\"\">" . $lang["damage"] . "</span>";
                }
            }
        }
        if ($itemIsWeapon) {
            /* Convert delay to string to get .0 if it's not there */
            $thisDelayString = explode(".", $thisDelay);
            if (count($thisDelayString) == 1) {
                $thisDelay = $thisDelayString[0] . ".00";
            } else {
                if (count($thisDelayString) == 2 and strlen($thisDelayString[1]) == 1) {
                    $thisDelay . "0";
                }
            }
            /* Calculate DPS */
            $itemAverageDamage = ($totalMinDamage + $totalMaxDamage) / 2;
            $itemDamagePerSecond = round($itemAverageDamage / $thisDelay, 1);
            /* Convert to string to get .0 if it's not there */
            $itemDPSString = explode(".", $itemDamagePerSecond);
            if (count($itemDPSString) == 1) {
                $itemDamagePerSecond .= ".0";
            }
            $tooltipText .= tooltip_adddoublerow("(" . $itemDamagePerSecond . " " . $lang["damage_per_sec"] . ")", $lang["speed"] . " " . $thisDelay);
            $itemtable .= "<br /><span class=\"tooltipRight\">" . $lang["speed"] . " " . $thisDelay . "</span>(<span class=\"\">" . $itemDamagePerSecond . "&nbsp;</span><span class=\"\">" . $lang["damage_per_sec"] . "</span>)";
        }
        /* Armor Value */
        if ($itemdata["armor"]) {
            $tooltipText .= tooltip_addsinglerow($itemdata["armor"] . " " . $lang["armor"]);
            $itemtable .= "<br /><span class=\"\"><span class=\"\">" . $itemdata["armor"] . "</span><span class=\"\"> " . $lang["armor"] . "</span></span>";
        }
        /* Shield Block */
        if ($itemdata["block"]) {
            $tooltipText .= tooltip_addsinglerow($itemdata["block"] . " " . $lang["block"]);
            $itemtable .= "<br /><span class=\"\"><span class=\"\">" . $itemdata["block"] . "</span><span class=\"\"> " . $lang["block"] . "</span></span>";
        }
        /* Statistics */
        $isGreenStat = 0;
        for ($i = 1; $i <= 10; $i++) {
            if ($itemdata["stat_type" . $i]) {
                /* Confirmed stat */
                $statType = $itemdata["stat_type" . $i];
                $statVal = $itemdata["stat_value" . $i];
                $isGreenStat = 0;
                $statInfo = getStatType($statType, $statVal);
                if (strstr($statInfo, "[GREEN]")) {
                    $isGreenStat = 1;
                    $greenStats[] = str_replace("[GREEN]", "", $statInfo);
                } else {
                    $tooltipText .= tooltip_addsinglerow($statInfo);
                    $itemtable .= "<br /><span class=\"\"><span class=\"\">" . $statInfo . "&nbsp;</span></span>";
                }
            } else {
                break;
            }
        }
        /* More on $greenStats after Required Level line */
        /* Resistances */
        $resistances = array("arcane", "fire", "nature", "frost", "shadow");
        foreach ($resistances as $resistance) {
            if ($itemdata[$resistance . "_res"]) {
                $tooltipText .= tooltip_addsinglerow("+" . $itemdata[$resistance . "_res"] . " " . ucfirst($resistance) . " " . $lang["resistance"]);
                $itemtable .= "<br /><span class=\"\"><span class=\"\">+" . $itemdata[$resistance . "_res"] . " " . ucfirst($resistance) . " " . $lang["resistance"] . "</span></span>";
            }
        }
        /* Enchantment */
        if ($itemguid) {
            if ($enchantmentsData[$defines["PERMANENT"][CLIENT]]) {
                $tooltipText .= tooltip_addsinglerow("<span class=\"item-greenstat\">" . GetNameFromDB($enchantmentsData[$defines["PERMANENT"][CLIENT]], "dbc_spellitemenchantment") . "</span>");
            }
        }
        /* Random Enchantment PART 2 */
        if ($itemdata["RandomProperty"] || $itemdata["RandomSuffix"]) {
            if ($itemguid) {
                $RandomEnchantment = "";
                $enchvalueindex = 0;
                for ($i = $FirstEnchant; $i <= $FirstEnchant + 2 * 3; $i += 3) {
                    $enchvalueindex++;
                    if ($enchantmentsData[$i]) {
                        $RandomEnchantment = GetNameFromDB($enchantmentsData[$i], "dbc_spellitemenchantment");
                        if ($itemdata["RandomSuffix"]) {
                            $suffixFactor = GenerateEnchSuffixFactor($itemdata["ItemLevel"], $itemdata["InventoryType"], $itemdata["Quality"]);
                            $enchantvalue = round($suffixFactor * ($ItemRandomData["enchvalue_" . $enchvalueindex] / 10000));
                            $RandomEnchantment = str_replace("\$i", $enchantvalue, $RandomEnchantment);
                        }
                        $tooltipText .= tooltip_addsinglerow($RandomEnchantment);
                    }
                }
            } else {
                $tooltipText .= tooltip_addsinglerow("<span class=\"item-greenstat\">&lt;" . $lang["random_enchantment"] . "&gt;</span>");
            }
            $itemtable .= "<br /><span class=\"bonusGreen\">&lt;" . $lang["random_enchantment"] . "&gt;</span>";
        }
        /* Sockets */
        $prismatic_already = 0;
        for ($i = 1; $i <= 3; $i++) {
            $socketexist = 0;
            if ($itemdata["socketColor_" . $i]) {
                switch ($itemdata["socketColor_" . $i]) {
                    case 1:
                        $sockcol = "Meta";
                        $sockname = $lang["meta"];
                        break;
                    case 2:
                        $sockcol = "Red";
                        $sockname = $lang["red"];
                        break;
                    case 4:
                        $sockcol = "Yellow";
                        $sockname = $lang["yellow"];
                        break;
                    case 8:
                        $sockcol = "Blue";
                        $sockname = $lang["blue"];
                        break;
                    default:
                        $sockcol = "Unk";
                        $sockname = $lang["unk"];
                }
                $socketexist = 1;
            } else {
                if (!$prismatic_already && $itemguid && CLIENT && $enchantmentsData[$defines["PRISMATIC_SOCKET"][CLIENT]]) {
                    //prismatic socket
                    $sockcol = "Prismatic";
                    $sockname = $lang["prismatic"];
                    $prismatic_already = 1;
                    $socketexist = 1;
                }
            }
            if ($socketexist) {
                $socketName = $sockname . " " . $lang["socket"];
                $socketIcon = "shared/global/tooltip/images/icons/Socket_" . $sockcol . ".png";
                $socketColor = "setItemGray";
                if ($itemguid) {
                    $socket_offset = $defines["SOCKET_1"][CLIENT] + ($i - 1) * 3;
                    if ($enchantmentsData[$socket_offset]) {
                        switchConnection("armory", REALM_NAME);
                        $GemInfo = mysql_fetch_assoc(execute_query("SELECT `name`, `gemid` FROM `dbc_spellitemenchantment` WHERE `id` = " . $enchantmentsData[$socket_offset] . " LIMIT 1"));
                        $socketName = $GemInfo["name"];
                        switchConnection("mangos", REALM_NAME);
                        $socketIcon = GetIcon("item", mysql_result(execute_query("SELECT `displayid` FROM `item_template` WHERE `entry` = " . $GemInfo["gemid"] . " LIMIT 1"), 0));
                        $socketColor = "setItemYellow";
                    }
                }
                $tooltipText .= tooltip_addsinglerow("<img class=\"socketImg\" src=\"" . $socketIcon . "\">" . $socketName, $socketColor);
                $itemtable .= "<br /><span class=\"" . $socketColor . "\"><img class=\"socketImg\" src=\"" . $socketIcon . "\">" . $socketName . "</span>";
            }
        }
        //socket Bonus
        if ($itemdata["socketBonus"]) {
            if (!($SocketBonus = GetNameFromDB($itemdata["socketBonus"], "dbc_spellitemenchantment")) && $config["ShowError"]) {
                $tooltipText .= tooltip_addsinglerow("<span class=\"error\">" . $lang["error"] . ": " . $lang["unknown"] . " socketBonus " . $itemdata["socketBonus"] . ", " . $lang["report_to_gm"] . "</span>");
                $itemtable .= "<br /><span class=\"error\">" . $lang["error"] . ": " . $lang["unknown"] . " socketBonus " . $itemdata["socketBonus"] . ", " . $lang["report_to_gm"] . "</span>";
            } else {
                $socketBonusColor = "setItemGray";
                if ($itemguid) {
                    if ($enchantmentsData[$defines["SOCKET_BONUS"][CLIENT]]) {
                        $socketBonusColor = "setItemYellow";
                    }
                }
                $tooltipText .= tooltip_addsinglerow($lang["socket_bonus"] . ":&nbsp;" . $SocketBonus, $socketBonusColor);
                $itemtable .= "<br /><span class=\"" . $socketBonusColor . "\">" . $lang["socket_bonus"] . ":&nbsp;" . $SocketBonus . "</span>";
            }
        }
        /* Durability */
        if ($itemdata["MaxDurability"]) {
            if ($itemguid) {
                $tooltipText .= tooltip_addsinglerow($lang["durability"] . ":&nbsp;" . $enchantmentsData[$defines["DURABILITY"][CLIENT]] . "&nbsp;/&nbsp;" . $enchantmentsData[$defines["MAX_DURABILITY"][CLIENT]]);
            } else {
                $tooltipText .= tooltip_addsinglerow($lang["durability"] . ":&nbsp;" . $itemdata["MaxDurability"] . "&nbsp;/&nbsp;" . $itemdata["MaxDurability"]);
            }
            $itemtable .= "<br />" . $lang["durability"] . ":&nbsp;" . $itemdata["MaxDurability"] . "&nbsp;/&nbsp;" . $itemdata["MaxDurability"];
        }
    }
    //Requires Class
    $allowclass = $itemdata["AllowableClass"];
    if ($allowclass != -1 && ($allowclass & 1535) != 1535) {
        $ClassesString = ShowAllowable($allowclass, "dbc_chrclasses");
        if ($ClassesString) {
            $tooltipText .= tooltip_addsinglerow($lang["classes"] . ":" . $ClassesString);
            $itemtable .= "<br />" . $lang["classes"] . ":" . $ClassesString;
        } else {
            if ($config["ShowError"]) {
                $tooltipText .= tooltip_addsinglerow("<span class=\"error\">" . $lang["error"] . ": " . $lang["unknown"] . " AllowableClass " . $itemdata["AllowableClass"] . ", " . $lang["report_to_gm"] . "</span>");
                $itemtable .= "<br /><span class=\"error\">" . $lang["error"] . ": " . $lang["unknown"] . " AllowableClass " . $itemdata["AllowableClass"] . ", " . $lang["report_to_gm"] . "</span>";
            }
        }
    }
    //Requires Race
    $allowrace = $itemdata["AllowableRace"];
    if ($allowrace != -1 && ($allowrace & 1791) != 1791) {
        $RacesString = ShowAllowable($allowrace, "dbc_chrraces");
        if ($RacesString) {
            $tooltipText .= tooltip_addsinglerow($lang["races"] . ":" . $RacesString);
            $itemtable .= "<br />" . $lang["races"] . ":" . $RacesString;
        } else {
            if ($config["ShowError"]) {
                $tooltipText .= tooltip_addsinglerow("<span class=\"error\">>" . $lang["error"] . ": " . $lang["unknown"] . " AllowableRace " . $itemdata["AllowableRace"] . ", " . $lang["report_to_gm"] . "</span>");
                $itemtable .= "<br /><span class=\"error\">>" . $lang["error"] . ": " . $lang["unknown"] . " AllowableRace " . $itemdata["AllowableRace"] . ", " . $lang["report_to_gm"] . "</span>";
            }
        }
    }
    // Requires Level
    if ($itemdata["RequiredLevel"]) {
        $tooltipText .= tooltip_addsinglerow($lang["requires_level"] . "&nbsp;" . $itemdata["RequiredLevel"]);
        $itemtable .= "<br />" . $lang["requires_level"] . "&nbsp;" . $itemdata["RequiredLevel"];
    }
    /* Required Skill (riding, blacksmithing..) */
    if ($itemdata["RequiredSkill"]) {
        $requiredSkill = GetNameFromDB($itemdata["RequiredSkill"], "dbc_skillline");
        if ($requiredSkill) {
            $tooltipText .= tooltip_addsinglerow($lang["requires"] . "&nbsp;" . $requiredSkill . " " . $itemdata["RequiredSkillRank"]);
            $itemtable .= "<br /><span class=\"\">" . $lang["requires"] . "&nbsp;</span><span class=\"\">" . $requiredSkill . "&nbsp;</span><span class=\"\"></span><span class=\"\">" . $itemdata["RequiredSkillRank"] . "</span><span class=\"\"></span>";
        } else {
            if ($config["ShowError"]) {
                $tooltipText .= tooltip_addsinglerow("<span class=\"error\">" . $lang["error"] . ": " . $lang["unknown"] . " RequiredSkill " . $itemdata["RequiredSkill"] . ", " . $lang["report_to_gm"] . "</span>");
                $itemtable .= "<br /><span class=\"error\">" . $lang["error"] . ": " . $lang["unknown"] . " RequiredSkill " . $itemdata["RequiredSkill"] . ", " . $lang["report_to_gm"] . "</span>";
            }
        }
    }
    // Required Spell
    if ($itemdata["requiredspell"]) {
        $requiredSpell = GetNameFromDB($itemdata["requiredspell"], "dbc_spell");
        if ($requiredSpell) {
            $tooltipText .= tooltip_addsinglerow($lang["requires"] . "&nbsp;" . $requiredSpell);
            $itemtable .= "<br /><span class=\"\">" . $lang["requires"] . "&nbsp;</span><span class=\"\">" . $requiredSpell . "</span><span class=\"\"></span>";
        } else {
            if ($config["ShowError"]) {
                $tooltipText .= tooltip_addsinglerow("<span class=\"error\">" . $lang["error"] . ": " . $lang["unknown"] . " requiredspell " . $itemdata["requiredspell"] . ", " . $lang["report_to_gm"] . "</span>");
                $itemtable .= "<br /><span class=\"error\">" . $lang["error"] . ": " . $lang["unknown"] . " requiredspell " . $itemdata["requiredspell"] . ", " . $lang["report_to_gm"] . "</span>";
            }
        }
    }
    // Green Statistics
    if (count($greenStats)) {
        foreach ($greenStats as $key => $val) {
            $tooltipText .= tooltip_addsinglerow("<span class=\"item-greenstat\">" . $val . "</span>");
            $itemtable .= "<br /><span class=\"bonusGreen\">" . $val . "</span>";
        }
    }
    // Spell Data
    $showspelldata = 1;
    for ($i = 1; $i <= 5; $i++) {
        if ($itemdata["spelltrigger_" . $i] == 6) {
            $showspelldata = 0;
        }
    }
    if ($showspelldata) {
        for ($i = 1; $i <= 5; $i++) {
            if ($itemdata["spellid_" . $i]) {
                switch ($itemdata["spelltrigger_" . $i]) {
                    case 0:
                        $spellTrigger = $lang["use"];
                        break;
                    case 1:
                        $spellTrigger = $lang["equip"];
                        break;
                    case 2:
                        $spellTrigger = $lang["hit_chance"];
                        break;
                    default:
                        $spellTrigger = $lang["unknown_trigger"] . " " . $itemdata["spelltrigger_" . $i];
                }
                switchConnection("armory", REALM_NAME);
                $spellDescription = spell_parsedata(mysql_fetch_assoc(execute_query("SELECT * FROM `dbc_spell` WHERE `id` = " . $itemdata["spellid_" . $i] . " LIMIT 1")));
                if ($spellDescription) {
                    $tooltipText .= tooltip_addsinglerow("<span class=\"item-greenstat\">" . $spellTrigger . ": " . $spellDescription . "</span>");
                    $itemtable .= "<br /><span class=\"bonusGreen\">" . $spellTrigger . ": " . $spellDescription . "</span>";
                }
            }
        }
    }
    /* Item Set Data */
    if ($itemdata["itemset"]) {
        /* Get Set Name */
        switchConnection("armory", REALM_NAME);
        $setData = mysql_fetch_assoc(execute_query("SELECT * FROM `dbc_itemset` WHERE `id` = " . $itemdata["itemset"] . " LIMIT 1"));
        $setName = $setData["name"];
        for ($i = 1; $i <= 8; $i++) {
            $setItemsIds[] = $setData["item_" . $i];
        }
        /* Get Items in set */
        switchConnection("mangos", REALM_NAME);
        $setItemsQuery = "SELECT `entry`, `name` FROM `item_template` WHERE ";
        $nameloc = "name_loc" . $config["locales"];
        if ($config["locales"]) {
            $setItemsQuery = "SELECT item_template.`entry`, `name`, `" . $nameloc . "` FROM `item_template` LEFT JOIN `locales_item` ON `item_template`.`entry` = `locales_item`.`entry` WHERE ";
        } else {
            $setItemsQuery = "SELECT `entry`, `name` FROM `item_template` WHERE ";
        }
        if (in_array($itemid, $setItemsIds)) {
            $setItemsQuery .= "`item_template`.`entry` IN (";
            foreach ($setItemsIds as $value) {
                $setItemsQuery .= $value . ",";
            }
            $setItemsQuery .= "0)";
        } else {
            // Hack for gladiator sets
            $setItemsQuery .= "`itemset` = " . $itemdata["itemset"] . " AND `ItemLevel` = " . $itemdata["ItemLevel"] . " AND `Quality` = " . $itemdata["Quality"];
        }
        $setItemsQueryexecute = execute_query($setItemsQuery);
        $owned_count = 0;
        while ($setItemData = mysql_fetch_assoc($setItemsQueryexecute)) {
            if (!empty($setItemData[$nameloc])) {
                $setItemData["name"] = $setItemData[$nameloc];
            }
            $setItems[$setItemData["entry"]] = $setItemData["name"];
            if (in_array($setItemData["entry"], $itemlist)) {
                $owned_count++;
            }
        }
        $tooltipText .= tooltip_addsinglerow("<br />" . $setName . " (" . $owned_count . "/" . count($setItems) . ")", "item-set-name");
        $itemtable .= "<br /><br /><span class=\"setNameYellow\">" . $setName . " (" . $owned_count . "/" . count($setItems) . ")</span><div class=\"setItemIndent\">";
        /* Output items in set */
        foreach ($setItems as $itemID => $itemName) {
            if (in_array($itemID, $itemlist)) {
                $tooltipText .= tooltip_addsinglerow($itemName, "item-set-item-acquired");
            } else {
                $tooltipText .= tooltip_addsinglerow($itemName, "item-set-item-unacquired");
            }
            // Player does not have this item
            $itemtable .= "<br /><span class=\"setItemGray\">" . $itemName . "</span>";
        }
        $tooltipText .= tooltip_addsinglerow("<br />");
        $itemtable .= "</div><br />";
        for ($i = 1; $i <= 8; $i++) {
            if ($setData["bonus_" . $i]) {
                //How many pieces do we need?
                $requiredSetPieces = $setData["pieces_" . $i];
                //SET BONUSES
                switchConnection("armory", REALM_NAME);
                $setBonus = spell_parsedata(mysql_fetch_assoc(execute_query("SELECT * FROM `dbc_spell` WHERE `id` = " . $setData["bonus_" . $i] . " LIMIT 1")));
                if ($owned_count >= $requiredSetPieces) {
                    $tooltipText .= tooltip_addsinglerow("(" . $requiredSetPieces . ") " . $lang["set"] . ": " . $setBonus, "item-set-item-acquired");
                } else {
                    $tooltipText .= tooltip_addsinglerow("(" . $requiredSetPieces . ") " . $lang["set"] . ": " . $setBonus, "item-set-item-unacquired");
                }
                $itemtable .= "<br /><span class=\"setItemGray\">(" . $requiredSetPieces . ") " . $lang["set"] . ": " . $setBonus . "</span>";
            }
        }
    }
    /* Flavour Text */
    if ($itemdata["description"] != NULL) {
        $tooltipText .= tooltip_addsinglerow("<span class=\"myYellow\">&quot;" . $itemdata["description"] . "&quot;</span>");
        $itemtable .= "<br /><span class=\"myYellow\">&quot;" . $itemdata["description"] . "&quot;</span>";
    }
    /* Item Source */
    if ($config["ShowSource"]) {
        switchConnection("armory", REALM_NAME);
        $SourceQuery = execute_query("SELECT `item_source` FROM `cache_item_search` WHERE `item_id` = " . $itemid . " LIMIT 1");
        if ($row = mysql_fetch_assoc($SourceQuery)) {
            $ItemSource = $row["item_source"];
        } else {
            $item_search_cache = cache_item_search($itemid);
            $ItemSource = $item_search_cache["item_source"];
        }
        $tooltipText .= "<tr><td colspan=\"2\"><br /><span class=\"myYellow\">" . $lang["source"] . ":&nbsp;</span><span class=\"\">" . $ItemSource . "</span></td></tr>";
        $itemtable .= "<br /><br /><span class=\"myYellow\">" . $lang["source"] . ":&nbsp;</span><span class=\"\">" . $ItemSource . "</span>";
    }
    $tooltipText .= "</table>";
    $itemtable .= "</div>";
    return $itemguid ? $tooltipText : array($tooltipText, $itemtable);
}
<td align="center"><q><i><span class="veryplain"><?php 
    echo $char["level"];
    ?>
</span></i></q></td>
<td align="right"><q><img src="images/icons/race/<?php 
    echo $char["race"], "-", $char["gender"];
    ?>
.gif" onmouseover="showTip('<?php 
    echo GetNameFromDB($char["race"], "dbc_chrraces");
    ?>
')" onmouseout="hideTip()"></q></td>
<td align="left"><q><img src="images/icons/class/<?php 
    echo $char["class"];
    ?>
.gif" onmouseover="showTip('<?php 
    echo GetNameFromDB($char["class"], "dbc_chrclasses");
    ?>
')" onmouseout="hideTip()"></q></td>
<td align="center"><q><img width="20" height="20" src="images/icon-<?php 
    echo $char["faction"];
    ?>
.gif" onMouseOver="showTip('<?php 
    echo $lang[$char["faction"]];
    ?>
')" onmouseout="hideTip()"></q></td>
<td><q><?php 
    echo guild_tooltip($char["guildid"]);
    ?>
</q></td>
<td align="center"><q><i><span class="veryplain"><?php 
    echo $char["kills"];
    }
}
if ($error) {
    ?>
<div class="parchment-top">
<div class="parchment-content">
<?php 
    showerror("character", $error);
} else {
    require "configuration/statisticshandler.php";
    $stat = assign_stats($data);
    switchConnection("characters", REALM_NAME);
    $guildid = mysql_fetch_assoc(execute_query("SELECT `guildid` FROM `guild_member` WHERE `guid` = " . $stat["guid"] . " LIMIT 1"));
    $stat["guild"] = $guildid ? $guildid["guildid"] : 0;
    $race = GetNameFromDB($stat["race"], "dbc_chrraces");
    $class = GetNameFromDB($stat["class"], "dbc_chrclasses");
    $PagesCharArray = array("sheet" => "character-sheet.php", "reputation" => "character-reputation.php", "skills" => "character-skills.php", "arenateams" => "character-arenateams.php", "achievements" => "character-achievements.php");
    if (isset($_GET["charPage"]) && isset($PagesCharArray[$_GET["charPage"]])) {
        $requested_char_action = $_GET["charPage"];
    } else {
        $requested_char_action = "sheet";
    }
    ?>
<script type="text/javascript">

var theClassId = <?php 
    echo $stat["class"];
    ?>
;
var theRaceId = <?php 
    echo $stat["race"];