static function ToJavascript($string, $htmlEncode = true)
        {    
            if ($htmlEncode)
            {
                $string = self::ToHtml($string);
            }
            return '\'' . addcslashes($string, "'\r\n\\") . '\'';
        }