What about pulling the bolded code out and putting it in its own function? Then you can either call that function from elsewhere in your code, or you could have a controller function (a 3rd function) that would call the bolded code function, store it as a Javascript variable (or as a hidden form field, as Joe/interrupt suggested), and then pass the bolded code as a parameter to your existing function.
With respect to Joe's suggestion, you could do the same thing more efficiently by simply defining a var inside a Javascript block (outside of a function declaration) and setting that var to the generated HTML. Your var would then be accessible to all Javascript functions by name. By using a hidden form field, accessibility would require looking up the data off of the form, and also complicating your DOM with unneccessary form fields. Both ways would work perfectly though :).
Jon Emerson
http://www.jonemerson.net/