function os_poker_shop_page($tab, $category = NULL, $target_type = NULL, $target_id = NULL, $subtarget_id = NULL)
{
    $content = "";
    if ($tab == NULL || $tab == "shop") {
        require_once drupal_get_path('module', 'os_poker') . "/user.class.php";
        require_once drupal_get_path('module', 'os_poker') . "/shop.class.php";
        require_once drupal_get_path('module', 'os_poker') . "/poker.class.php";
        $subtarget = NULL;
        $buddies = NULL;
        $cats = CShop::ListCategories();
        if ($target_type == NULL) {
            $target_type = "self";
        }
        if ($category == NULL) {
            $vcats = array_keys($cats);
            if (count($vcats) > 0) {
                $category = $vcats[0];
            }
        }
        $prods = CShop::ListItems($category);
        if (isset($_GET["list"]) && $_GET["list"] == "items" && !empty($_GET["ajax"])) {
            return print theme('os_poker_item_list', $prods);
        }
        $current_user = CUserManager::instance()->CurrentUser();
        $buddies = array_filter($current_user->Buddies(TRUE), "_os_poker_user_accepts_gifts");
        switch ($target_type) {
            case "table":
                $target = array_filter(CPoker::UsersAtTable($target_id, TRUE), "_os_poker_user_accepts_gifts");
                if ($subtarget_id) {
                    $subtarget = CUserManager::instance()->User($subtarget_id);
                }
                $merge = array_merge(array(), $target, $buddies);
                $special = array();
                foreach ($merge as $u) {
                    $special[$u->uid] = $u->uid;
                }
                $special = array_unique(array_keys($special));
                break;
            case "buddy":
                $target = $buddies;
                $subtarget = CUserManager::instance()->User($target_id);
                break;
            case "self":
                $target = $buddies;
                $subtarget = $current_user;
                break;
        }
        if (!empty($_POST["shop_action"]) && !empty($_POST["shop_item"])) {
            $action = $_POST["shop_action"];
            $success = TRUE;
            switch ($action) {
                case "subtarget":
                    if ($subtarget->uid == $current_user->uid) {
                        $success = CShop::BuyItem($_POST["shop_item"], empty($_POST["shop_item_activate"]) ? FALSE : !!$_POST["shop_item_activate"]);
                        watchdog('os_poker', ' buy: ' . $success);
                    } else {
                        $success = CShop::GiveItem($_POST["shop_item"], array($subtarget));
                        watchdog('os_poker', ' giveItem: ' . $success);
                    }
                    break;
                case "target":
                    $success = CShop::GiveItem($_POST["shop_item"], $target);
                    watchdog('os_poker', ' target: ' . $success);
                    break;
                case "special":
                    $success = CShop::GiveItem($_POST["shop_item"], $special);
                    watchdog('os_poker', ' spezial: ' . $success);
                    break;
            }
            if ($success == FALSE) {
                $error = theme('poker_error_message', "<h1>" . t("Sorry !") . "</h1>" . t("You don't have enough Chips."));
            } else {
                if ($target_type == 'table') {
                    watchdog('os_poker', ' goto');
                    drupal_goto('poker/closebox');
                }
            }
        }
        $params = array("categories" => $cats, "current_category" => $category, "items" => $prods, "current_user" => $current_user, "target_type" => $target_type, "target" => $target, "subtarget" => $subtarget, "target_id" => $target_id, "subtarget_id" => $subtarget_id, "buddies" => $buddies, "special" => $special, "error" => $error);
        $content = theme('os_poker_shop', $params);
    } else {
        if ($tab == "get_chips") {
            $content = theme('os_poker_shop_get_chips', drupal_get_form('chips_paypal_form'), $params);
        }
    }
    return theme('os_poker_shop_tabs', $tab, $content);
}