public static function updateQS($key, $value, $reverseorder = false, $qs = '')
    {

        if (empty($qs)) {
            $qs = $_SERVER['QUERY_STRING'];
        }
        if ($reverseorder) {
            if (preg_match("/ascdesc=ASC/", $qs)) {
                $qs = self::updateQS('ascdesc', 'DESC', 0, $qs);
            } else {
                $qs = self::updateQS('ascdesc', 'ASC', 0, $qs);
            }
        }
        if (!$qs) {
            if ($value) {
                return "$key=$value";
            } else {
                return "";
            }
        }
        if (preg_match("/$key=/", $qs)) {
            if ($value) {
                return preg_replace("/$key=[^&]+/", "$key=$value", $qs);
            } else {
                return preg_replace("/$key=[^&]?/", "", $qs);
            }
        } else {
            if ($value) {
                return $qs . "&$key=$value";
            } else {
                return $qs;
            }
        }
    }