Are you just adding the entire <script> to a Smarty template such as welcome.tpl?
If so, you will probably need to add {literal} tags, so you can escape the "{" and "}" characters when added to a Smarty template.
See this Smarty reference page for more details:
http://www.smarty.net/manual/en/language.function.literal.php
If you haven't already done so, you might want to try putting the entire <script> in an external Javascript file and reference it on the pages you want the bookmark feature to be available.
Also, test it out in different web browsers to see if you are having the same success/failure in each of the main browsers.
Robert