public function cidReplace($text, $callback, $charset = 'UTF-8')
    {
        $dom = ($text instanceof Horde_Domhtml)
            ? $text
            : new Horde_Domhtml($text, $charset);

        foreach ($dom as $node) {
            if ($node instanceof DOMElement) {
                switch (Horde_String::lower($node->tagName)) {
                case 'body':
                case 'td':
                    $this->_cidReplace($node, 'background', $callback);
                    break;

                case 'img':
                    $this->_cidReplace($node, 'src', $callback);
                    break;
                }
            }
        }

        return $dom;
    }