function _FORM_ITEM_SHOP($SA, $RealmID, $DBUser, $DBPassword, $GUID, $ItemID, $MinPrice, $PriceX, $DisplayPrice, $ITEM_DISCOUNT_MODE, $DISCOUNT_CONF, $REALSON = "")
{
    global $L, $AccountDBHost, $AccountDB, $PageListRecordsAmmount;
    echo "\n        <fieldset>\n            <div class = 'text-center'>" . $REALSON . "\n                <h2>" . $L[82] . "</h2>";
    _FORM_CHAR_BLOCK($SA, null, true);
    echo "</fieldset>";
    $connection = _MySQLConnect(_HostDBSwitch($RealmID), $DBUser, $DBPassword, _WorldDBSwitch($RealmID));
    // -----------------------------------------------------------------
    if (isset($ItemID)) {
        $query = mysql_query("\n                SELECT\n                  `entry` AS `id`,\n                  `class`,\n                  `subclass`,\n                  `ItemLevel`,\n                  `RequiredLevel`,\n                  `Quality`,\n                  `name`\n                FROM `item_template`\n            WHERE `entry` = " . $ItemID . ";", $connection) or die(mysql_error());
        $QueryResult = mysql_fetch_array($query);
        if (!empty($QueryResult['id'])) {
            $PRICE = _CalculatePrise($QueryResult, $MinPrice, $PriceX);
            $DISCOUNT = null;
            if ($PRICE > 1 && $ITEM_DISCOUNT_MODE) {
                $DISCOUNT = round($PRICE - $PRICE * $DISCOUNT_CONF);
            }
            $_SESSION['TCA']['SItemPrice'] = isset($DISCOUNT) ? $DISCOUNT : $PRICE;
            $_SESSION['TCA']['SItemName'] = $QueryResult['name'];
            echo "\n                <fieldset class = 'text-center'>\n                <div style = 'width: 800px;' class = 'alert service alert-success'>\n                    <div class = 'service_icon'></div>\n                    <h4><a href = 'http://old.wowhead.com/item=" . $QueryResult['id'] . "' target = '_blank'></a></h4>\n                    <div class = 'service_desc'>" . _PRICE_STR($PRICE, true, isset($DISCOUNT) && $PRICE > $DISCOUNT ? $DISCOUNT : null) . "</div>\n                </div>\n                </fieldset></br>";
        }
    }
    // -----------------------------------------------------------------
    $ITEM_CLASS = _refleshSessionValue(isset($_SESSION['TCA']['ItemClass']) ? $_SESSION['TCA']['ItemClass'] : null, isset($_GET['C']) ? (int) $_GET['C'] : null, 2);
    if (!isset($_SESSION['TCA']['ItemClass']) || $_SESSION['TCA']['ItemClass'] != $ITEM_CLASS) {
        unset($_GET['page']);
        unset($_SESSION['TCA']['P']);
    }
    $_SESSION['TCA']['ItemClass'] = $ITEM_CLASS;
    $PAGE_INDEX = _refleshSessionValue(isset($_SESSION['TCA']['P']) ? $_SESSION['TCA']['P'] : null, isset($_GET['page']) ? (int) $_GET['page'] : null, 1);
    $PAGE_INDEX = $PAGE_INDEX < 1 ? 1 : $PAGE_INDEX;
    $_SESSION['TCA']['P'] = $PAGE_INDEX;
    if (isset($ITEM_CLASS) && $ITEM_CLASS === 7) {
        $ITEM_CLASS_Q_STR = isset($ITEM_CLASS) ? "WHERE `class` IN (5, 6, 7) ORDER BY `class`,`itemlevel`" : null;
    } else {
        $ITEM_CLASS_Q_STR = isset($ITEM_CLASS) ? "WHERE `class` = " . $ITEM_CLASS . " ORDER BY `itemlevel`" : null;
    }
    $query = mysql_query("\n            SELECT\n              `entry` AS `id`,\n              `class`,\n              `subclass`,\n              `ItemLevel`,\n              `RequiredLevel`,\n              `Quality`,\n              `name`\n            FROM `item_template` " . $ITEM_CLASS_Q_STR . "\n        DESC LIMIT " . ($PAGE_INDEX * $PageListRecordsAmmount - $PageListRecordsAmmount) . ", " . $PageListRecordsAmmount . ";", $connection) or die(mysql_error());
    mysql_close($connection);
    echo "\n            <fieldset class = 'text-center'>\n            <form action = " . $_SERVER['PHP_SELF'] . " method = 'POST'>\n            <div class = 'clearfix'>";
    if (isset($ItemID)) {
        echo "     \n                <input name = 'itemID' type = 'text' placeholder = '" . $L[19] . "'>\n            </div>\n            <p>\n                <button class = 'btn btn-primary' type = 'submit'>" . _getPriceButtonSTR(11) . "</button>\n            </p>\n            <input type = 'hidden' name = 'isItemSame' value = '" . $ItemID . "'/>";
    } else {
        echo "\n                <input name = 'itemID' type = 'text' placeholder = '" . $L[49] . "'>\n            </div>\n            <p>\n                <button class = 'btn btn-primary' type = 'submit'>" . $L[48] . "</button>\n            </p>";
    }
    echo "\n            </form>\n            </fieldset>\n            <ul class = 'nav nav-tabs'>\n                <li" . _getBISelector(2, $ITEM_CLASS) . "><a href = '?C=2'>" . $L[282] . "</a></li> <!-- Weapon -->\n                <li" . _getBISelector(4, $ITEM_CLASS) . "><a href = '?C=4'>" . $L[284] . "</a></li> <!-- Armor -->\n                <li" . _getBISelector(16, $ITEM_CLASS) . "><a href = '?C=16'>" . $L[296] . "</a></li> <!-- Glyph -->\n                <li" . _getBISelector(3, $ITEM_CLASS) . "><a href = '?C=3'>" . $L[283] . "</a></li> <!-- Gem -->\n                <li" . _getBISelector(9, $ITEM_CLASS) . "><a href = '?C=9'>" . $L[289] . "</a></li> <!-- Recipe -->\n\n                <li" . _getBISelector(0, $ITEM_CLASS) . "><a href = '?C=0'>" . $L[280] . "</a></li> <!-- Consumable -->\n                <li" . _getBISelector(1, $ITEM_CLASS) . "><a href = '?C=1'>" . $L[281] . "</a></li> <!-- Container --> \n                <li" . _getBISelector(7, $ITEM_CLASS, "title = '" . $L[285] . ", " . $L[286] . ", " . $L[287] . "' ") . "><a href = '?C=7'>" . $L[287] . "</a></li> <!-- Trade Goods -->\n                <li" . _getBISelector(12, $ITEM_CLASS) . "><a href = '?C=12'>" . $L[292] . "</a></li> <!-- Quest -->\n                <li" . _getBISelector(13, $ITEM_CLASS) . "><a href = '?C=13'>" . $L[293] . "</a></li> <!-- Key -->\n                <li" . _getBISelector(15, $ITEM_CLASS) . "><a href = '?C=15'>" . $L[295] . "</a></li> <!-- Miscellaneous -->\n            </ul>\n            " . _pushPageNav($PAGE_INDEX) . "\n            <table class = 'table table-condensed'>\n                <tr class = 'menuBar'>\n                    <td>" . $L[275] . "</td>\n                    <td>" . $L[64] . "</td>\n                    <td></td>\n                </tr>";
    while ($QueryResult = mysql_fetch_array($query)) {
        $PRICE = _CalculatePrise($QueryResult, $MinPrice, $PriceX);
        $DISCOUNT = null;
        if ($PRICE > 1 && $ITEM_DISCOUNT_MODE) {
            $DISCOUNT = round($PRICE - $PRICE * 0.1);
        }
        $class = isset($DISCOUNT) && $PRICE > $DISCOUNT ? "success" : "info";
        echo "\n                <tr class = '" . $class . "'>\n                <td><a href = 'http://" . _getWHLanguage() . "wowhead.com/item=" . $QueryResult['id'] . "' target = '_blank'></a></td>";
        if (isset($DISCOUNT) && $PRICE > $DISCOUNT) {
            echo "<td>" . _PRICE_STR($PRICE, true, $DISCOUNT) . "</td>";
        } else {
            echo "\n                <td>" . _PRICE_STR($PRICE, true) . "</td>";
        }
        echo "<td><a href = '" . _AddGETAtributeToURL("itemID", $QueryResult['id']) . "'>" . $L[299] . "</a></td>\n            </tr>";
    }
    echo "\n            </table>" . _pushPageNav($PAGE_INDEX);
}
function _FORM_QUEST_COMPLETE($SA, $RealmID, $AccountDBHost, $AccountDB, $DBUser, $DBPassword, $GUID, $PRICE, $REALSON = "")
{
    global $L;
    $QueryString = "";
    $connection = _MySQLConnect(_HostDBSwitch($RealmID), $DBUser, $DBPassword, _CharacterDBSwitch($RealmID));
    $query = mysql_query("SELECT `quest` FROM `character_queststatus` WHERE `status` = 3 AND `guid` = " . (int) $GUID . ";", $connection) or die(mysql_error());
    while ($result = mysql_fetch_array($query)) {
        $QueryString .= $result['quest'] . ", ";
    }
    $QueryString = substr($QueryString, 0, -2);
    mysql_close($connection) or die(mysql_error());
    if ($QueryString != "") {
        $connection = _MySQLConnect(_HostDBSwitch($RealmID), $DBUser, $DBPassword, _WorldDBSwitch($RealmID));
        $query = mysql_query("SELECT \n                `Id` AS `id`,\n                `RewardChoiceItemId1` AS `I1`,\n                `RewardChoiceItemId2` AS `I2`,\n                `RewardChoiceItemId3` AS `I3`,\n                `RewardChoiceItemId4` AS `I4`,\n                `RewardChoiceItemId5` AS `I5`,\n                `RewardChoiceItemId6` AS `I6`\n            FROM\n                `quest_template` WHERE `Id` IN (" . $QueryString . ");", $connection) or die(mysql_error());
        while ($result = mysql_fetch_array($query)) {
            if ($result['I1'] < 1 && $result['I2'] < 1 && $result['I3'] < 1 && $result['I4'] < 1 && $result['I5'] < 1 && $result['I6'] < 1) {
                $SA['qList'][$result['id']] = true;
            } else {
                $ID = $result['id'];
                $i = 1;
                foreach ($result as $ITEM) {
                    if ($ITEM === $ID) {
                        continue;
                    }
                    if ($ITEM < 1) {
                        continue;
                    }
                    if (isset($SA['qList'][$ID]) && in_array($ITEM, $SA['qList'][$ID])) {
                        continue;
                    }
                    $SA['qList'][$ID][$i] = $ITEM;
                    $i++;
                }
            }
        }
        mysql_close($connection) or die(mysql_error());
    } else {
        die("EXCEPTION QUESTLIST-CREATE");
    }
    $_SESSION['TCA'] = $SA;
    echo "\n        <fieldset>\n        <form action = " . $_SERVER['PHP_SELF'] . " method = 'POST'>\n            <div class = 'text-center'>" . $REALSON . "\n                <h2>" . $L[89] . "</h2>\n                <fieldset>";
    _FORM_CHAR_BLOCK($SA, null, true);
    echo "\n                <div class = 'charBoxClean'>";
    $STEP = null;
    $BN = null;
    if (isset($_SESSION['pQuest']) && isset($SA['qList'][$_SESSION['pQuest']]) && $SA['qList'][$_SESSION['pQuest']] != true) {
        $STEP = 2;
        $BN = $L[291];
        $Q = $_SESSION['pQuest'];
        echo "\n                    <ul class = 'nav nav-pills'>\n                        <li class = 'dropdown'>\n                            <a id = 'QuestSelector" . $STEP . "' class = 'dropdown-toggle' role = 'button' data-toggle = 'dropdown' href = '#'>" . $L[71] . ":<b class = 'caret'></b></a>\n                            <ul id = 'QuestSelectorList" . $STEP . "' class = 'dropdown-menu' role = 'menu'>";
        foreach ($SA['qList'][$Q] as $ItemID) {
            if ($ItemID < 2) {
                continue;
            }
            echo "<li><a tabindex = '-1' href= '#' onclick = 'QuestJS(\$(this).html());'>" . $ItemID . "</a></li>";
        }
        echo "</ul>\n                        </li>\n                    </ul>";
    } else {
        $STEP = 1;
        $BN = $L[290];
        $DN = isset($_SESSION['pQuest']) ? $L[288] . $_SESSION['pQuest'] : $L[70];
        echo "\n                    <ul class = 'nav nav-pills'>\n                        <li class = 'dropdown'>\n                            <a id = 'QuestSelector" . $STEP . "' class = 'dropdown-toggle' role = 'button' data-toggle = 'dropdown' href = '#'>" . $DN . ":<b class = 'caret'></b></a>\n                            <ul id = 'QuestSelectorList" . $STEP . "' class = 'dropdown-menu' role = 'menu'>";
        foreach ($SA['qList'] as $QuestID => $ENABLED) {
            echo "<li><a tabindex = '-1' href= '# ' onclick = 'QuestJS(\$(this).html());'>" . $QuestID . "</a></li>";
        }
        echo "</ul>\n                        </li>\n                    </ul>";
    }
    echo "\n                </div>\n                </fieldset>\n                <br/>";
    if (isset($_SESSION['pQuest'])) {
        echo _BDiv(_PRICE_STR($PRICE));
        echo "<input type = 'hidden' name = 'QuestList" . $STEP . "' value = '" . $_SESSION['pQuest'] . "'/>";
    } else {
        $BN = $L[146];
        echo "<input type = 'hidden' name = 'QuestList" . $STEP . "' value = ''/>";
    }
    echo "<button class = 'btn btn-info' type = 'submit'>" . $BN . "</button>\n            </div>\n        </form>\n        </fieldset>\n    <script>\n        \$('#QuestSelector" . $STEP . "').click(function() {\n            \$('#QuestSelectorList" . $STEP . "').toggle();\n        })\n        function QuestJS(html) {\n            \$('#QuestSelectorList" . $STEP . "').hide();\n            \$('#QuestSelector" . $STEP . "').html(html);\n            \$('input[name = \"QuestList" . $STEP . "\"]').val(\$('#QuestSelector" . $STEP . "').text());\n        }\n    </script>";
}