function JoinNotEmpty($separator, $array)
    {
        if (!is_array($array)) {
            return '';
        }

        $rv = trim(array_shift($array));

        foreach ($array as $item) {
            $item = $this->Escape(trim($item));
            if ($rv != '' and $item != '') {
                $rv .= $separator;
            }
            $rv .= $item ;
        }
        return $rv;
    }